4365 Commits

Author SHA1 Message Date
Maxim Prokhorov
7b4af9ad95 thingspeak: rework request generation
Get rid of variable-length array in favour of a single allocation,
and also do everything through String concat.
2021-09-03 11:05:09 +03:00
Maxim Prokhorov
4bb0c3386a light: more refactoring
Reading clang-tidy reports... Make sure to explicitly handle instances
of float -> (unsigned) long  silently removing the fractional part.
Also, small adjustments to the way these values are parsed.

Specifically:
- calculating step & time in the transition function
- rgb channels temperature adjustment from kelvins

Get rid of input & target as bool param. Replace it with more
specific functions, named accordingly, returning the Rgb struct.
(also fixes `rgb` command not returning what the rest of the API returns)

As a side-effect, make RGB payload conversion use a more paranoid parsing & serialization methods.
2021-09-03 11:03:53 +03:00
Maxim Prokhorov
d527351364 light: trigger an update on brightness function change
So it's no longer required to change any values or the state

Slightly changed the inputValue -> value transformation classes,
actually using the recursive template to apply things in order.
Still a bit quirky, but nothing better comes to mind for this.
2021-08-31 06:07:53 +03:00
Maxim Prokhorov
32aae70374 light: more refactoring related input & value stages
Fixes color+(white or cct) brightness function factor calculation
to actually do what the comment says it does.

No more unsigned char for value, consistent integer math and
explicit clamping of the input & output values.

As a follow-up for the a55cf0b, reworks brightness functions:
- value input and application implemented as part of the channel class
- track value changes externally, no need for OnceFlag
- simple all, only-rgb, color+white and color+cct are distinct
  functions, where brightness classes implement the actual math
- avoid accidentally doing an actual function call through
  `lightChannels()` by not accessing channels elements & size directly
  through the vector (yay c++ strictness regarding *public* symbols)
2021-08-30 14:34:30 +03:00
Maxim Prokhorov
dd4426b77f webui: fix small screen menu toggle
no need to apply 'active' class to anything other than 'layout'
fix #2469
2021-08-30 14:34:30 +03:00
Maxim Prokhorov
1ae7f27253 debug: fix build warning with serial disabled
resolve #2468
2021-08-30 14:34:30 +03:00
Maxim Prokhorov
a55cf0b847 light: stop the update request from running twice
In case the rgb+white(cct) brightness function was selected by the
configuration, internal calculations will always result in 'changed' being 'true'
and as a result it will continiously re-create the transition object.

fix #2467 (at least for now, the brightness function should be actually fixed)
2021-08-27 23:28:10 +03:00
Maxim Prokhorov
188414b431 webui: typo the password pattern
fix #2465
2021-08-27 04:11:53 +03:00
Maxim Prokhorov
ef8e7fa0dd webui: rebuild once again
amends 03573b783e
2021-08-27 04:09:45 +03:00
Maxim Prokhorov
fd913f15a1 thermostat: typo 2021-08-22 06:54:25 +03:00
Maxim Prokhorov
03573b783e webui: apply modules-... style globally
Otherwise, some things are still hidden
(or, depend on the order of incoming messages)

Make thermostat code use those as well, instead of injecting
thermostatVisible in every json payload
2021-08-22 06:42:16 +03:00
Maxim Prokhorov
5b5f104db3 ha: const-correct normalization
And init directly in the members list
2021-08-21 02:50:46 +03:00
Maxim Prokhorov
6087becf86 mqtt: remove unnecessary const_cast of the topic 2021-08-21 02:48:27 +03:00
Maxim Prokhorov
e6a0e505b3 mqtt: payload is not const
Even if std::function compiles with the wrong (but compatible) signature
2021-08-21 02:48:27 +03:00
Maxim Prokhorov
31688f1bf0 ota: missing space in the outgoing http request
fix #2465
2021-08-21 02:42:25 +03:00
Maxim Prokhorov
bdd821db86 pio: check returncode of the git process
Since the Popen instance won't do that by itself. Handles the case
where there is `git` command present, but it's not a git repo underneath.
2021-08-17 14:35:20 +03:00
Maxim Prokhorov
459591b0df webui: slightly reduce wsRegister() overhead
Since there are no dynamic callbacks registered at setup(),
use simple function pointers as the input type.

Internal type is still std::func, though
(and not yet sure how to get rid of it correctly)
2021-08-17 04:11:01 +03:00
Maxim Prokhorov
3e835cbc33 debug: Timestamp is constexpr struct 2021-08-17 01:12:26 +03:00
Maxim Prokhorov
efcb863ca2 debug: fix off-by-one error when formatting to allocated buffer 2021-08-17 01:11:56 +03:00
Maxim Prokhorov
d9662bd66a debug: don't show timestamps for terminal outputs
Previous version used add_timestamp=false for outputs, this one
accidentally used const char*, size_t overload in place of const char*, boolean

Make sure this can't happen by using a stronger constexpr boolean
specifically for the timestamp conversion.

Also, naming clean-up and making sure raw bytes sender does not enable
already disabled debugging output.
2021-08-16 17:46:56 +03:00
Maxim Prokhorov
1ca8d5e7a0 pio: update platform_latest
Build with Core 3.0.2 release
2021-08-16 17:00:57 +03:00
Maxim Prokhorov
5aa43d4bf1 all: suppress -Wunused-function for serialization helpers 2021-08-16 07:31:00 +03:00
Maxim Prokhorov
ba69eba460 all: suppress BasePin copies and moves
ref. https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-copy-virtual
2021-08-16 04:31:37 +03:00
Maxim Prokhorov
8bcac5f6ec gpio: clean-up
Clarify vtable anchoring, move the comment to the .cpp (near the anchor itself)
Use constexpr instead of preprocessor for GPIO_NONE
2021-08-16 04:31:37 +03:00
Maxim Prokhorov
aa5e0d46b1 led: refactor module to use namespace(s)
As well as previous commits, remove ..._config.h header in favour of .cpp

Refactor loop to only use the `Led` instance, without needing to know
it's ID. Link relay<->led on demand instead of using a flat list.

Import LedPattern implementation into the .cpp, preserve existing .in
file to generate the constructor code (when needed).
Use accessor methods instead of plain members where possible, try to
hide the actual implementation details behind some common ones.

Introduce default settings query for `led` prefix. Setting function
reworked to use common string `prefix` checker instead of requiring the
consumer to provide a onKeyCheck-like lambda / standalone function.
2021-08-16 04:31:36 +03:00
Maxim Prokhorov
2ad187e529 mdns: do not use espurna.h include in the header 2021-08-16 04:31:36 +03:00
Maxim Prokhorov
d482baa725 light: refactor to use namespace(s)
Also clamp the value in setters / getters.
2021-08-16 04:31:36 +03:00
Maxim Prokhorov
ef9b95b68e button: refactor inline getSetting into functions 2021-08-16 04:17:13 +03:00
Maxim Prokhorov
1522087112 relay: refactor inline getSetting into functions 2021-08-16 04:16:30 +03:00
Maxim Prokhorov
7d7bbef2d1 wifi: clean-up
Value init Mac array, both compiler versions support this.
Named constants for conversion function lengths / sizes.
2021-08-12 17:26:48 +03:00
Maxim Prokhorov
921bf08483 settings: no need to test ::keys() 2021-08-12 10:49:09 +03:00
Maxim Prokhorov
85184db09c ota: fix invalid ::update args and tweak ns nesting 2021-08-12 10:48:25 +03:00
Maxim Prokhorov
1aa4e2fed4 rpn: simplify the handler of expiring runners 2021-08-11 18:50:34 +03:00
Maxim Prokhorov
144fbe9b89 settings: no need for vector in the base class 2021-08-11 18:50:34 +03:00
Maxim Prokhorov
11f06cf0a5 ota: fix the build without both flags 2021-08-11 18:50:34 +03:00
Maxim Prokhorov
85e70d8a07 relay: workaround for gcc4.8 single-source build
Resolve the code generation issue with vector methods being unable to
store the exception info string in the same elf section
(which apparently becomes duplicated, somehow, when building single .cpp)

Error messages look like something like this:
```
vector.tcc:405
error: __c causes a section type conflict with __c
    _M_check_len(size_type(1), __EXCSTR("vector::_M_emplace_back_aux"));

vector.tcc:71
note: '__c' was declared here
  __throw_length_error(__EXCSTR(__N("vector::reserve")));
```
2021-08-11 18:45:55 +03:00
Maxim Prokhorov
37b46a040f domoticz: update changelog and webui 2021-08-11 14:25:12 +03:00
Maxim Prokhorov
94f31241dc domoticz: refactoring
Common functions moved into namespace domoticz { ... }
Module functions moved into namespace { ... }

Remove templates and favour simple function for nvalue & svalue formatting,
and also use ArduinoJson for the JSON serialization.

Detach lights from the 1st relay, introduce `dczLightIdx`
Use named channel functions instead of counting channels manually.
Try to migrate the old settings.

Introduce stronger type for Idx to avoid entity id vs. domoticz idx confusion in function arguments,
since both are numeric and there's no distinction besides the name itself.
2021-08-11 14:11:20 +03:00
Maxim Prokhorov
b167d61615 debug: refactoring & remove special case for PROGMEM
Don't use variable length array and remove `debugSend_P`, directly give the format to `vsnprintf_P`.

Common functions moved into namespace debug { ... }
Module functions moved into namespace { ... }

Provide len argument to most outputs, so it's calculated exactly once.
Early checks for nullptr and zero length.

Fix include order once again, try not to depend on config in header and
only use it in the actual .cpp code.

Still involves strlen for flash strings, but that needs to be addressed by using a custom type like:
```
struct PstrWithLength {
    const char* const ptr;
    size_t size;
};
```
And define PSTR macro to return:
```
PstrWithLength{&__pstr__[0], sizeof(__pstr__)};`
```
(and, probably, for any `const char (&fixed)[Size]` arrays as well)
2021-08-11 13:58:24 +03:00
Maxim Prokhorov
d3551ed169 mqtt: limit received messages in log 2021-08-11 12:31:31 +03:00
Maxim Prokhorov
401b678ec6 ota: refactoring & remove deprecated secure client
Remove AXTLS mentions from asynctcp and httpupdate
More namespace MODULE and namespace { ... }
2021-08-10 17:01:27 +03:00
Maxim Prokhorov
c3c929ea34 rpn: refactoring & initialization clean-up
Use namespace instead of custom prefix everywhere.
Multiple init() funcs per namespace, instead of one large one for all
of available operators

Continue to apply namespace { ... }
2021-08-07 16:50:30 +03:00
Maxim Prokhorov
453157c5db all: more static symbols 2021-08-07 16:49:07 +03:00
Maxim Prokhorov
658648d270 core: naming cleanup
Set -> On, when the handler could be added multiple times
Remove unused functions from the headers, and add correct names for the used ones.
2021-08-06 18:45:14 +03:00
Maxim Prokhorov
7a77d23bc5 pio: upstream toolchain
More strict than the current platform-espressif8266 and also prefer this version to for the release tag.
2021-08-06 15:07:43 +03:00
Maxim Prokhorov
cfb58a3f52 alexa: fix unused warning for relay vs. lights functions 2021-08-06 15:03:16 +03:00
Maxim Prokhorov
cf79259189 ci: release workflow 2021-08-06 14:45:52 +03:00
Maxim Prokhorov
814a708fdc config: comments and default(s) 2021-08-06 13:40:31 +03:00
Maxim Prokhorov
c5f70286d1 wifi: allow to set bssid and channel from settings
For when scanning is disabled. Remove uniqueness requirement, since
settings may contain multiple SSID with different BSSID values.

wifi::Mac conversion helpers for both xxxxxxxxxx and xx:xx:xx:xx:xx:xx
2021-08-06 13:21:39 +03:00
Maxim Prokhorov
4be2d370af garland: fixed-size LED arrays
Shuffle std::vector usage, trying out std::array for static data and
std::unique_ptr where common use-case is reserve / resize + emplace

Also try to workaroud exception string issue with gcc4.8, which should
not be a problem with gcc10.3 coming with Core 3.0.0, but... one solution at a time
2021-08-06 12:53:19 +03:00