Commit Graph

3306 Commits

Author SHA1 Message Date
Maxim Prokhorov
2f0b8e47bc ws: localize info access 2021-12-14 17:43:53 +03:00
m-kozlowski
21a8c2678f ntp: use milliseconds in sntp_*_delay functions (#2490) 2021-12-12 12:25:05 +03:00
Maxim Prokhorov
26d28db0ef relay: fixup stm relay change delay 2021-12-09 03:16:13 +03:00
Maxim Prokhorov
1b27fa5316 relay: preliminary support for internal duration types
Not as clean as other modules, but at least prepare for the further changes.
Implement settings for float duration conversion, and test it out with pulse
and flood window time values.

More safe-guards for an externally-defined pulse time, make sure it is
not either inf or nan and is an actual finite number

Also use EnumerableConfig for the WebUI output, and make sure to use
internal _relays.size() instead of doing a function call
2021-12-09 03:07:57 +03:00
Maxim Prokhorov
67d4463652 ota: last remaining un-typed deferredReset 2021-12-09 01:57:03 +03:00
Maxim Prokhorov
f881b83ea8 hass: flash-strings for json keys
Saves ~100bytes in RAM
2021-12-09 01:24:17 +03:00
Maxim Prokhorov
de35f9bfe1 light: use internal duration type(s)
Get rid of 'assumed' units and use strong types instead
Also update HomeAssistant conversion code as float -> uint durations
2021-12-09 01:15:11 +03:00
Maxim Prokhorov
ac9806c9e5 system: use internal duration types with nice_delay 2021-12-09 01:15:11 +03:00
Maxim Prokhorov
f44aab5fdb system: simple deferred reset function
No need for specific delay for each instance, just use a shared one
2021-12-09 01:15:11 +03:00
Maxim Prokhorov
f9ad9d44e1 webui: find all span elements, not just one 2021-12-09 01:15:11 +03:00
Maxim Prokhorov
2f580a37a2 terminal: context is a temporary
Make sure it could be moved further along, and the values inside of it
can be safely moved as well.

Also fixup commands that were missing ctx in OK / Error.
2021-12-08 18:05:25 +03:00
Maxim Prokhorov
a0e090489b terminal: get rid of ctx.argc
No need to duplicate argv::size()
2021-12-08 17:42:12 +03:00
Maxim Prokhorov
f2a7dcffe1 ntp: fix terminal ntp.settime and implement ntp.sync
Use internal duration types, store time in seconds and propogate as
uint32_t when it is necessary. Update tick values as well.

Instead of generic `toInt(), overload between `strtol` and `strtoll`.
Current implementation of `settimeofday` rejects `struct tz` pointer,
make sure it's nullptr.

Sync is a simple enough routine... But, expect an already synced system
before triggering the sntp restart.
2021-12-08 17:31:29 +03:00
Maxim Prokhorov
a8cf30832e wifi: use internal types for timeouts
For this, keep things as milliseconds (at least for now)

Make sure to use __builtin_strlen in constexpr context
Remove `has*()` functions that are no longer used

Update WebUI callback to use EnumerableConfig
2021-12-08 13:48:44 +03:00
Maxim Prokhorov
baac061d27 telnet: destroy the specific client when disconnecting 2021-12-08 13:48:44 +03:00
Maxim Prokhorov
a684348b17 system: instruct the compiler to crash instead of invoking undefined behaviour 2021-12-08 13:48:44 +03:00
Maxim Prokhorov
b05dcf6540 config: update comments, mention time units 2021-12-08 13:48:44 +03:00
Maxim Prokhorov
135c7b80ac ws: use internal types for timeouts 2021-12-08 13:48:44 +03:00
Maxim Prokhorov
5dc0908d8c ws: format with the actual type of the time_t
Don't assume the size <-> type, utilize type matching in the template
specialization to retrieve the actual type <-> format pair that we need
2021-12-08 13:48:44 +03:00
Maxim Prokhorov
0f34261fab web: use internal millis() call 2021-12-08 13:48:44 +03:00
Maxim Prokhorov
16960067d8 system: some refactoring
There's no need to move a temporary which is already an rvalue

Clean-up some redundant attributes and function in settings.
Make sure C types are proxied to fixed-sized ones, not the other way around.

Clean-up webprint implementation
- use typed duration for the backlog
- don't duplicate members and types for config, just re-use the struct as-is
- don't go over-the-top with const members, just proxy through a method
2021-12-08 13:48:40 +03:00
Maxim Prokhorov
4d04125eb6 pio: bump toolchain-xtensa for git environments
ref. https://github.com/esp8266/Arduino/pull/8393
2021-12-07 02:11:46 +03:00
Maxim Prokhorov
c33d9960b4 ir: bump IRremoteESP8266 to 2.8.0 2021-12-07 01:08:44 +03:00
Maxim Prokhorov
8312f27e4b pio: even shorter suffix for .ipp files
remove .cpp from the resulting suffix, since .ipp already implies it is c++
update comments once again
2021-12-07 01:06:18 +03:00
Maxim Prokhorov
4e4d75af63 rfbridge: fix efm8bb1 provider send & receive
(possibly) noticed in the gitter
https://gitter.im/tinkerman-cat/espurna?at=61abba5a76e37917551e4a2f

refactoring causality, as there's no longer an explicit Serial.begin
for RFB_PROVIDER_EFM8BB1 in the hardware setup in the system.cpp
(also, from not including wip serial changes that did serial port setup :/)
2021-12-06 18:55:11 +03:00
Maxim Prokhorov
c0c3dcdc1d ir: include typos 2021-11-30 03:20:13 +03:00
Maxim Prokhorov
d40322d98f ci: fix quoting for the test_build -include
amends 79321b6707
otherwise, env.ParseFlags never understands it
2021-11-30 03:17:33 +03:00
Maxim Prokhorov
d094283df2 pio: formatting 2021-11-30 01:28:09 +03:00
Maxim Prokhorov
a7a9c5045f pio: generate .cpp.ipp instead of .cpp.inc
fixes #2479
2021-11-30 00:15:52 +03:00
Maxim Prokhorov
c738b91b6a pio: simplify single-source builder
Generate resulting .cpp in the $BUILD_DIR, no need for atexit
Register middleware only once, there's no need to manually walk the
project directory since fnmatch.fnmatch(...) supports globs

Provide a SCons Action instead of simple function, so there's a way to
generate things on demand via command line
```
$ pio run -e $env -t .pio/build/$env/espurna_single_source/src/main.cpp
```
2021-11-30 00:06:24 +03:00
Maxim Prokhorov
ebc479f145 pio: fix indirect dependency on the build-and-copy .bin 2021-11-29 23:06:25 +03:00
Maxim Prokhorov
79321b6707 ci: directly use the test build headers
- just pass `-include ${cfg}` to the compiler instead of a
  temporary custom.h. also do `-DDEVICE=...` and `-DMANUFACTURER=...`
- rework test_build to print using `logging` module
- report leftover configurations, after the failed one exits
- prettify the output and highlight relevant info instead of the whole lines
2021-11-29 23:06:03 +03:00
Maxim Prokhorov
adfa4968b7 system: docs and notice about overflows in micros / millis 2021-11-26 01:33:18 +03:00
Maxim Prokhorov
61f160e08d sensor: time_point is not a duration 2021-11-26 00:24:47 +03:00
Maxim Prokhorov
c54b2eff2a system: clean-up 2021-11-26 00:24:47 +03:00
Maxim Prokhorov
802394f527 system: revert interval search not taking zero into an account 2021-11-26 00:24:47 +03:00
Maxim Prokhorov
e40d22be38 mqtt: fix reading settings twice when getting user name 2021-11-26 00:24:47 +03:00
Maxim Prokhorov
1ca98880d6 system: refactoring & delays clean-up
- BREAKING replace loadavg and system check from millis to seconds
- implement all available system clocks, make sure it is correctly
  scaled with the origin type
- fix duration::{millis(),ccount(),seconds()} and return a respective
  clock's time_point instead of duration. just like led sources, make
  sure every module stores timestamps as time_point and intervals as
  duration
- no need to track millis overflow on top of existing overflow counter
  of the micros64 in getUptime
- remove class overhead in led static delays conversion, just try to
  inline the required calculations and use NAME as unique id

also fix some non-apparent issues with heartbeat
- allow zero interval when it is also Mode::Once
- iterating runners to find the interval might return zero
2021-11-26 00:24:47 +03:00
Maxim Prokhorov
2fe5fc6c34 system: internal delays as duration 2021-11-26 00:24:47 +03:00
Maxim Prokhorov
d19bd45d57 pzem004t: check before accessing the port pointer 2021-11-26 00:24:47 +03:00
Melanie Thielker
03442608da hardware: add support for Yagusmart 1, 2 add 3 gang switches (#2488)
* Add support for Yagusmart 1, 2 ad 3 gang switches

https://www.amazon.co.uk/gp/product/B086MV5MC8

These don't come with an esp8266 anymore, but can be trivially converted
as the new chip is pin compatible. Note, GPIO15 needs to be connected to
GND on 1 and 2 gang switches in order to enable the ESP to boot.

* Update code/platformio.ini

Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>

* Adjust build flags and name to be conformant to project culture and conventions

* changelog

* sorting

Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
2021-11-25 05:52:14 +03:00
Maxim Prokhorov
f9cb5ebea0 sns: remember real time setting for exported values 2021-11-23 03:05:34 +03:00
Maxim Prokhorov
62944f7dce sns: another single-source fix
RFM69 has intentional `null` (0) defined in the public header
cc0e354cbb/RFM69.h (L161)
2021-11-23 02:36:28 +03:00
Maxim Prokhorov
0fdad17635 pzem004: fix single-source build
```
In file included from espurna\espurna_single_source.cpp:62:
espurna\wifi.cpp:282:38: error: specialization of 'T settings::internal::convert(const String&) [with T = IPAddress]' after instantiation
  282 | IPAddress convert(const String& value) {
      |                                      ^
```
2021-11-23 02:36:28 +03:00
Maxim Prokhorov
9db679f93a sns: attachInterruptArg() instead of storing pin info in iram
simplify isr code, since esp{8266,32} Cores allow to pass void* argument to the isr
also allows to seamlessly lock the gpio (but, outside does not yet check it's result)
2021-11-23 02:36:28 +03:00
Maxim Prokhorov
b7259441f6 hlw8012: fix typo and single-source builds with defaults 2021-11-23 02:36:28 +03:00
Maxim Prokhorov
1ef22e16f1 sns: deprecate global delta settings 2021-11-23 02:36:28 +03:00
Maxim Prokhorov
a734a9e1d9 i2c: fix missing include 2021-11-23 02:36:28 +03:00
Maxim Prokhorov
56caa18d22 wifi: fix fallback triggering ap without checking the setting first 2021-11-23 02:36:28 +03:00
Maxim Prokhorov
8f7f1c968f sns: unify settings & settings page actions
- remove 'local' index and replace sensor code depending on it with the
  existing 'slot' aka 'magnitude index' used in value() and type()
- common method to store and retrieve ratios for voltage, current,
  active power and energy. default implementation is no-op, sensor
  should implement ratio adjustment & calculations to use 'slot' indexes
- re-implement 'expected' values ui. display the actual ratio values,
  and have a separate page for updating them in a more apparent way
- remove legacy settings that were adjusting expected values
- remove legacy settings that were resetting ratios and analog calibration
- generic webui action caller, add ratios and analog calibration resets

all of 'emon' sensors were updated to utilize the new approach to the
ratio handling. pulsemeter is somewhat an outlier, but it is unclear
whether removing the energy ratio is justified

terminal part was also updated
- implement `expected` command that hooks into the new ratioFromValue
  (and what webui uses to calculate ratios)
- implement `energy` command to list only MAGNITUDE_ENERGY
- remove old pzem004t commands doing ratio reset and total energy count

another global update is related to espurna::duration
- rework module-local heartbeat and led durations into a global
  espurna::duration
- update sensor internals to use specific units instead of multiplying things
  on line-by-line basis. export count() to the api
2021-11-23 02:36:28 +03:00