Commit Graph

3276 Commits

Author SHA1 Message Date
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
Maxim Prokhorov
a8389b3aa0 sns: apply emon ratios to ade7953 values
Clean-up the sensor code to have intermediate 'raw' representation of
every value read from the sensor.

Update energy code to include 'actual' value that can be read directly
from the chip. Adjust the 'expected' value that we were already calculating.
2021-11-23 02:36:28 +03:00
drc38
9d4ef1a386 SHT3X: add 0x44 address (#2484)
amend code to work with both i2c addresses as per datasheet https://dfimg.dfrobot.com/nobody/wiki/88b31350da4f54d00989c74c6fa392f7.pdf
2021-11-15 03:52:26 +03:00
Max Prokhorov
f8ecdaf14b garland: fix missing include 2021-11-15 03:10:29 +03:00
Maxim Prokhorov
c95ea71c18 core: clean-up const(expr) qualifiers 2021-10-24 15:30:04 +03:00
Maxim Prokhorov
aec829ae95 webui: rebuild static files 2021-10-24 14:22:32 +03:00
Maxim Prokhorov
5a8a4ea096 sns: actually allow more than one ads1x15 2021-10-24 14:22:32 +03:00
Maxim Prokhorov
f456d9622a webui: display switch pretty name for dcz and tspk 2021-10-24 14:22:32 +03:00
Maxim Prokhorov
eb59726b4f sns: report both used & supported units to the webui
Generic way to find out which units the magnitude type supports.
Clean-up UI related to temperature, energy and power units.
Resolves #2482

Also apply some refactoring to the 'schema'-generated
payloads by using the EnumerableConfig helper class.
Class received some new features:
- optional callback, verifying that index should be used at all
  specific use-case is magnitudes list that needs only 'counted' ones
- std::iota / ranges::iota_view -like helper object for sequences
  starting with something other than 0

Reordered payloads, prefer queueing over sending everything at once.
2021-10-24 14:22:08 +03:00
Maxim Prokhorov
a2c02a38e5 hardware: tweak core and core-webui targets
given that relay, button and led settings may be hardcoded,
explicitly remove from -core and -core-webui
restore telnet debugging though, since the terminal output needs it

for -core-webui, disables mdns and the generic webui server + webui blob
per 56f74cfe, make the resulting .bin even smaller
2021-10-20 13:26:12 +03:00
Maxim Prokhorov
0b64bd0229 core: minimize espurna.h use in headers 2021-10-20 13:07:34 +03:00
Maxim Prokhorov
4441345fce prometheus: enable by default 2021-10-20 13:07:34 +03:00
Maxim Prokhorov
050cbe79ba ota: also log internal updater error for arduino-ota 2021-10-20 11:38:36 +03:00
Maxim Prokhorov
6eaf88c69b utils: normalize hostname setting usage 2021-10-20 11:38:07 +03:00
Patrizio Bekerle
51133a69d9 mqtt: add mqtt.send terminal command (#2477) (#2478)
* Add SERIAL_SENSOR support

* Implement "MQTT.SEND" command, remove all other commands (#2477)

* Move command to mqtt.cpp and drop extra files

* Update CHANGELOG.md

Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
2021-10-12 18:03:28 +03:00
Maxim Prokhorov
509bbea77d ir: fix missing ctor arguments when using noop classes 2021-10-03 22:07:22 +03:00
Maxim Prokhorov
a69a705cdc pio: normalize .ini override file line-endings 2021-10-03 20:44:58 +03:00
Maxim Prokhorov
a4637aa19c ir: fix building with gcc-4.8 2021-10-03 20:44:58 +03:00
Maxim Prokhorov
b9db535950 light: fix out-of-bounds access when using GPIO16
As noticed in the #2472

Internal implemementation still lacks the support for the GPIO16,
as it needs to use 'special' IO16 registers (and due to the fact that the 'normal'
registers only fit in an u16[16], from 0 to 15, so internals need to change as well)
One possible way is to attach certain implementation funcs to the
struct handling the isr, avoiding a bunch of in-line checks for `pin == 16`

Another option is to just use Core's `analogWrite`, which hides the
implementation from us and should work pretty seamlessly.
(...but, currently has 2 different waveform generator types, and it is
not really clear which one is a better default, as it needs to be set at
build-time)
2021-10-03 20:44:58 +03:00
Maxim Prokhorov
6f132ef3c5 webui: debug SEND button should be type=submit
ref. #2476
2021-10-03 20:44:58 +03:00
Maxim Prokhorov
daa7c4d726 webui: schema payload helper
Instead of typing schema and the actual payload handler twice,
declare the 'key' and the associated function on the same line

ref. #2476
2021-10-03 20:44:58 +03:00
Maxim Prokhorov
de2d5f7350 led: pattern fixes and terminal command
Implement strongly-typed time units via std::chrono,
compile-time checks with static delays and limit possible values in the
pattern parser. Clamp 'repeats' as well, instead of relying on overflow

Rework internal loop & template runners, so there's no need to
proxy status and led struct all over. Instead, simply declare two
separate funcs that are supposed to be run during the pattern and at
it's end.

Instead of cloning the 'delays' array, implement a sequence iterator
that is tracking the currently used delay and it's repeats, and which
also jumps to the next entry in the list.
(but, this uses c++ iterators, and *may* be prone to errors)

Implement small terminal command 'led <ID> [<PATTERN STRING>]'.
Running without the 'PATTERN STRING' resets the LED to the values in settings.

Move re2c-generated parser back into a separate file, use .cpp.inc as
include and .re as the source

ref. #2476, fix 'finite' pattern handling
2021-10-03 20:44:58 +03:00
Maxim Prokhorov
ea525f2f69 ir: implement 'state' encode & decode
Another type of payload from the IRremoteESP8266, intended to be used
with HVAC devices. Also add a bunch of comments in regards to IRac.h

More tweaks to the internal StringView and ParseResult, make
sure the implementation closely follows the STL alternatives.

More configuration options for the:
- Transmitter, support INPUT_PULLUP
- Receiver, allow to set signal inversion and modulation.
  Correctly implement buffer size setting.
- MQTT topics, allow to override both in and out

Also fix the 'simple' parser HEX range, accepting 8byte payloads (16chars)
and allowing lowercase inputs.
2021-10-03 20:44:58 +03:00
Maxim Prokhorov
b36d65057f ir: declare rx and tx stuff closer to the top 2021-10-03 20:44:58 +03:00
Maxim Prokhorov
ddb9f67a5b ir: restructure and add more settings
Declare settings under it's own namespace, where previous version used
function prefix. Allow to have configurable timeout and buffer size for
rx; default series, repeats and delay values for tx.

Values are reloaded with the appropriate configure() function from the
namespace, unless they apply to the IR{send,recv} object itself.

Also, no need to define 'default' fields for either of the Payload
structures. After parsing is done, pass all of string views to the
function defined in the .cpp that will prepare the resulting value.
2021-10-03 20:44:58 +03:00
Maxim Prokhorov
6fd474694c ssdp: typos and concatenation instead of printf 2021-10-03 20:44:58 +03:00
Maxim Prokhorov
d9e37762b6 ir: bump IRremoteESP8266 to 2.7.20 2021-10-03 20:44:58 +03:00
Maxim Prokhorov
f427ea3c1e ir: formatting 2021-10-03 20:44:58 +03:00
Maxim Prokhorov
444fcec890 webui: fix relay and curtain config change detection
resolve #2470
2021-10-03 20:44:58 +03:00
Maxim Prokhorov
cf0315c231 scripts: formatting 2021-10-03 20:44:58 +03:00
Maxim Prokhorov
001ec79c8e ir: clean-up and refactoring of the existing module
- provide a queue for the outgoing messages, don't depend on the MQTT
  callback implementation details and always postpone the actual transfer.
- generate user input parsers using re2c, adds special PlatformIO build handlers
- add terminal command to show GPIO info and send a simple payload
- rework button<->action presets into value<->terminal command presets and custom ones
  through the use of `irCmd<VALUE>` settings, where the VALUE is taken from the simple payload
  (yet, it does not understand repeated codes, but that's something to add later *or* use rpnlib)
- add tx message integration for the relay module via `irRelayOn#` and `irRelayOff#`
- rework simple payload to include 'repeats' value for the 'IRsend::send()'
  also adds internal 'series', 'delay' and includes full 64bit 'value'
  (as uppercase HEX, instead of decimal)
- rework raw payload to use 'series' instead of 'repeats', and provide a
  clear distinction between the usec time and the options of the message
  by moving the required options to the front and separating them using ':'
  (just like the simple variant)
- make RX and TX pin a runtime setting, make RX and TX support a build flag
- small test framework to check whether internal string encode<->decode works

Also updates the hexEncode & hexDecode implementations to use
'iterators' instead of just pointer + index.
2021-10-03 20:44:58 +03:00