3866 Commits

Author SHA1 Message Date
Maxim Prokhorov
2365d08b88 pwm: also handle older Core versions
when target duty is either zero or at the driver limit, forcibly
stop the waveform / pwm driver via a sort-of private function call

resolve #2532
2022-08-19 19:07:30 +03:00
Maxim Prokhorov
16d61d5fc2 gpio: register access commands 2022-08-19 17:39:39 +03:00
Maxim Prokhorov
091c87ea45 gpio: fix not using provided mode in gpio16 case 2022-08-19 17:36:25 +03:00
Maxim Prokhorov
2868e0a481 pwm: arduino needs an explicit stop 2022-08-19 14:53:11 +03:00
Maxim Prokhorov
1cb841125f pwm: adjust for float precision loss 2022-08-19 13:27:52 +03:00
Maxim Prokhorov
08a31fcbf5 pwm: fix arduino pin init 2022-08-19 13:10:40 +03:00
Maxim Prokhorov
844f20003d pzem004tv30: convert to watt seconds just once 2022-08-18 22:09:59 +03:00
Maxim Prokhorov
49b616afbc emon: rollover happens on kwh limit 2022-08-18 22:09:59 +03:00
Maxim Prokhorov
c86b4c3778 pzem004tv30: actually ignore initial energy request
amend 037be9aa99
2022-08-18 17:03:20 +03:00
Maxim Prokhorov
fb511ef891 pzem004tv30: sensor string 2022-08-18 16:58:53 +03:00
Maxim Prokhorov
7adb804464 pzem004tv30: try to calculate energy delta
- store latest pzem reading and compare with the latest one each reading
- fix `Energy::Energy(double)` scale, it should be kWh and not Wh
- move watt-second accumulator to constructor, allow object addition
2022-08-18 16:47:24 +03:00
Maxim Prokhorov
037be9aa99 emon: separate initial and reset energy api
ignore energy reset on boot with pzem004t(v30), ref. #2530
(and continue to use its own internal energy persistance)
2022-08-18 14:48:30 +03:00
Maxim Prokhorov
7095cfffd7 pwm: missing header
missed when moving new-pwm includes
fix accidentally including sdk header
2022-08-16 13:01:11 +03:00
Maxim Prokhorov
2d38efcd6b pzem004tv30: fix debug 2022-08-15 16:44:31 +03:00
Maxim Prokhorov
c07310c974 pzem004tv30: correct magnitude index for energy reset 2022-08-15 16:25:21 +03:00
Maxim Prokhorov
7f15da59ee sns: fix swdt reset when parsing MQTT payload
This *must* use views, but that's something for another day
Tweak terminal command, also allow to view the energy value
2022-08-15 16:25:21 +03:00
Maxim Prokhorov
1e655cc921 system: fix Core flash API usage when assessing latest crash
amends 8fb1a49881

Core accepts address, not sector
Compare with partial data, not just one byte
2022-08-15 16:25:01 +03:00
Maxim Prokhorov
c9a3a6ed54 lib: fix fs_math include 2022-08-15 12:01:50 +03:00
Maxim Prokhorov
b0da3e8c7f light: external pwm support
- allow both new-pwm and analogWrite (Core) implementations
- rework new-pwm initialization, a bit more sane type for pin config
- remove pin setup from lights, everything is handled by provider already
Core prepares and initializes pins when updating duty, new-pwm does this
when pwm_init is called
- rework internals related to value scaling, allow percentage as pwm duty
and value limit (instead of absolute limit set by lights previously)
2022-08-15 12:01:20 +03:00
Maxim Prokhorov
5929ae9f16 pzem004tv30: typo in pin default 2022-08-11 22:58:06 +03:00
Maxim Prokhorov
2f5ea5d06b emon: fix energy ratio accessor and notify when any ratio changes
in case some hardware needs it, like ina219 calibration register
that is used by both sensor implementation and hw itself
2022-08-11 11:11:33 +03:00
Maxim Prokhorov
396f8a7770 pzem004tv3: init serial port
fix a bug introduced in e4b068ec7d
resolve #2528
2022-08-11 10:18:55 +03:00
Maxim Prokhorov
e9de3d4435 emon: typo in energy counter 2022-07-22 23:52:14 +03:00
Maxim Prokhorov
34f83c9c90 rfm69: re-apply ad8e30fcda 2022-07-21 15:56:31 +03:00
Maxim Prokhorov
aaefbfbc4a emon: api changes 2022-07-21 15:29:28 +03:00
Maxim Prokhorov
58d4a98553 webui: version bump terser 4.8.1
dependabot woes
2022-07-21 15:11:22 +03:00
Maxim Prokhorov
1b49326e12 ntc: scale based on input voltage
resolves #2500
resolves #2523

- fixing default config values, make sure we take inputs into
  an account and not assume we stay in the 0.0...1.0 range
- use shelly values from tasmota analog sensor impl
- handle edgecase when both resistances are zeroed
- clearer description of available connection schemes

in theory, there is also an option of having *both* up and down
resistors at the same time; right now we simply deduce NTC position by
making it an opposite of resistance. ldrsensor implementation currently
allows to explicitly set sensor position
2022-07-20 20:32:55 +03:00
Maxim Prokhorov
b366d77a5e sns: namespace, fix init function(s)
One namespace for sensor functions and types.
Fix discrepancy between topic and indexed topic funcs.
Energy types fixes, make sure we use known ratios.

Sensor fixes, moving certain pin settings and defaults into the sensor
classes, using those in the actual sensor init code.
Energy is still within the sensor module, pending version bump before moving.
2022-07-20 20:32:55 +03:00
Maxim Prokhorov
91eb010fea ina219: fix invalid shift 2022-07-15 04:43:16 +03:00
Maxim Prokhorov
ad8e30fcda rfm69: clean-up *after* max ID, not before
fixes #2507
2022-06-13 14:29:49 +03:00
Maxim Prokhorov
fb31449ed9 ntc: formatting & actually return the value
fixup 4d4b8461dd
(if only the compiler warned about an empty branch...)
2022-06-13 02:14:40 +03:00
Maxim Prokhorov
a461d2c18a board: fix 2.7.4 build 2022-06-13 00:12:36 +03:00
Maxim Prokhorov
65db8e6112 board: spi_flash_read size is in bytes 2022-06-12 23:55:29 +03:00
Maxim Prokhorov
01047c3b80 sns: type prefixes should be in flash 2022-06-12 22:18:53 +03:00
Maxim Prokhorov
4d4b8461dd ntc: make sure we handle adc value of 0
plus, move reading into pre()
2022-06-12 22:04:24 +03:00
Maxim Prokhorov
84017214d2 webui: detect when sensor unit changes
also split energy info into a separate payload & handler
2022-06-12 20:36:01 +03:00
Maxim Prokhorov
68374bba9e sns: refactoring
make sure we have access to magnitude formatters early in the file
more namespacing, where possible
2022-06-12 20:36:01 +03:00
Maxim Prokhorov
e3a2294ef0 sns: handle basic metric units conversion
proper support for both conversion directions
ratio object stores the scaling, no need to deduce it through the enum
name anymore

we still don't really enforce incompatible units, though,
but it is unclear at what stage the error should come in
2022-06-12 20:36:01 +03:00
Maxim Prokhorov
7dfb10905c sns: handle both directions when converting temperature unit
when types are the same, handle things directly in the class base
plus, reduce the amount of explicit comparisons
2022-06-12 20:36:01 +03:00
Maxim Prokhorov
c937b10d86 analog: raw and advanced scaling in the base class 2022-06-12 20:36:01 +03:00
Maxim Prokhorov
425027223c sns: sensor ratio helpers 2022-06-11 23:43:10 +03:00
Maxim Prokhorov
09c0750c69 sns: change magnitude filter 2022-06-11 23:04:35 +03:00
Maxim Prokhorov
c58b37c173 ina219: correctly scale raw values
fix gain multipliers, last two scaled down instead of up
bus voltage is in mV, using datasheet value of lsb (4mV)
2022-06-11 23:04:35 +03:00
Maxim Prokhorov
8059f1a4ca ina219: invalid max expected current is a config error 2022-06-09 23:52:17 +03:00
Maxim Prokhorov
4572dd3d6c ina219: we already know the type 2022-06-09 23:51:09 +03:00
Maxim Prokhorov
15f6446479 ina219: shunt resistance and expected current
address #2516, implement through ratio setting
2022-06-09 23:49:58 +03:00
Maxim Prokhorov
a52f0b0ce4 ws: fix multiple clients 2022-06-01 22:27:11 +03:00
Maxim Prokhorov
567b9d7769 web: also check for ap state 2022-06-01 22:20:25 +03:00
Maxim Prokhorov
2c728074f9 web: image length is a compile time constant 2022-06-01 21:52:18 +03:00
Maxim Prokhorov
81e4d423e2 board: type of webui image 2022-06-01 21:50:10 +03:00