Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buttons & lights & relays providers refactoring #2414

Merged
merged 80 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
687028b
libs: renormalize line endings
mcspr Dec 27, 2020
7c3610f
wip relay providers
mcspr Dec 30, 2020
7604d43
drive lights and rfb through custom callbacks
mcspr Dec 30, 2020
9631f1d
schedule cfg too
mcspr Dec 30, 2020
b24c17a
tuya refactoring
mcspr Dec 31, 2020
39e5c94
Merge remote-tracking branch 'origin' into todo/lights-relays
mcspr Dec 31, 2020
fdd3658
tuya wip v2. drop states, use providers directly for both lights and …
mcspr Jan 2, 2021
985c98d
fix gpio locking checks
mcspr Jan 2, 2021
ec65393
check how leds behave
mcspr Jan 2, 2021
a53506b
fix webui
mcspr Jan 2, 2021
c58d21c
use gpio locked check for cli
mcspr Jan 2, 2021
9177b4e
remove tuya state cache from tests
mcspr Jan 2, 2021
0b27e46
unique dp, init lights before relays
mcspr Jan 3, 2021
073cb41
try to handle step as well
mcspr Jan 3, 2021
cd4a739
ensure relay0 is global light toggle, fix typos
mcspr Jan 3, 2021
ebe4431
sync switch state, ignore channel values le 0x10
mcspr Jan 3, 2021
9432a5d
fix syncing wrong relayid
mcspr Jan 3, 2021
5396999
already showing product
mcspr Jan 3, 2021
69a8444
fix dataframe copy & move
mcspr Jan 3, 2021
664654f
transitions defaults
mcspr Jan 3, 2021
6610008
oops
mcspr Jan 3, 2021
42529fd
try to workaround gcc 4.8.2 issue with noexcept = default
mcspr Jan 3, 2021
55c0af4
filter off by default
mcspr Jan 3, 2021
01b59a9
fixup! try to workaround gcc 4.8.2 issue with noexcept = default
mcspr Jan 3, 2021
f6d3805
experiment with hiding the channel switch
mcspr Jan 3, 2021
2d8a474
blobs
mcspr Jan 3, 2021
c690a50
depend on lights when using lightState
mcspr Jan 3, 2021
ceebb41
fix tuya-generic-dimmer flags
mcspr Jan 3, 2021
430860f
fixup! fix tuya-generic-dimmer flags
mcspr Jan 3, 2021
dc9dfc4
fix rfb referencing old implementation
mcspr Jan 3, 2021
db53cb2
fix more invalid preprocessor light_provider checks
mcspr Jan 3, 2021
4a4e8c6
fix old get/release lock references
mcspr Jan 3, 2021
80754ee
gpio cleanup
mcspr Jan 3, 2021
041340c
Merge remote-tracking branch 'origin/dev' into todo/lights-relays
mcspr Jan 4, 2021
675fa97
fix gcc4.8
mcspr Jan 4, 2021
19d1529
fix my92xx referencing old func
mcspr Jan 4, 2021
f85aa93
fix my92xx referencing old func
mcspr Jan 4, 2021
b2ec30e
fix gpio.h interface
mcspr Jan 4, 2021
dab2c97
add locking for debug serial
mcspr Jan 4, 2021
1dc58cf
update relay cmd, print prov
mcspr Jan 4, 2021
b5d3907
use ctx out
mcspr Jan 4, 2021
003c904
fixup basepin interface once more, cleanup button providers as well
mcspr Jan 5, 2021
9451031
more cleanup, manage dual & stm through relay
mcspr Jan 5, 2021
0b76993
add missing debounceevent changes
mcspr Jan 5, 2021
7bed368
tests
mcspr Jan 5, 2021
49301f4
fix referencing moved-out-of object
mcspr Jan 5, 2021
f6ce51d
manually setting pins as hw past 8
mcspr Jan 5, 2021
97a696b
fix hw configs
mcspr Jan 5, 2021
b986105
dont use relay when what we want is to use the switch
mcspr Jan 5, 2021
3fea207
ui fixes
mcspr Jan 5, 2021
a9bbb82
fix parser log
mcspr Jan 6, 2021
31d7cca
to confirm that 100% brightness is caused by the switch ON
mcspr Jan 6, 2021
254aa54
try to to map dp<->id before doing relayAdd or lightAdd
mcspr Jan 6, 2021
40649ef
show light state id
mcspr Jan 6, 2021
dca61b5
fixup invalid frame data storage iterators, completely separate view …
mcspr Jan 6, 2021
c1d1964
make sure dataframeview(frame.serialized()) works correctly
mcspr Jan 6, 2021
f46982c
fix channel dp<->id mixup, mcu should receive int now
mcspr Jan 7, 2021
38a52f3
ignore discovery when configured through settings
mcspr Jan 7, 2021
d164f7d
cleanup, correct transport tests
mcspr Jan 7, 2021
d75dfed
format
mcspr Jan 7, 2021
6141cc2
common prefix for log settings
mcspr Jan 7, 2021
c8543d6
nicer names
mcspr Jan 7, 2021
69f72a4
configDone should be set only once
mcspr Jan 7, 2021
ca099ca
ensure there are some channels before doing the lightupdate()
mcspr Jan 8, 2021
8cfe703
update lightTime -> ltTime
mcspr Jan 8, 2021
35e8693
lt prefix for webui
mcspr Jan 8, 2021
3fa5ee0
automatically filter incoming state data when channel state is set
mcspr Jan 9, 2021
49e2cc9
rework transitions, disable dependency on transition step when disabled
mcspr Jan 10, 2021
2487095
TEST push heartbeat earlier
mcspr Jan 10, 2021
c56e46e
customize transition step & time through the class, rework comms masking
mcspr Jan 11, 2021
97c1a53
ensure we receive hb echo before running setup() funcs
mcspr Jan 11, 2021
f8f4bdd
cleanup
mcspr Jan 11, 2021
4604b50
cfg opts, better names
mcspr Jan 11, 2021
91942d6
settings & defaults
mcspr Jan 11, 2021
c75f262
make sure relay boots only once
mcspr Jan 12, 2021
37ee1f2
defaults for domoticz
mcspr Jan 12, 2021
0d94a13
cleanup
mcspr Jan 12, 2021
56e40d2
fix typo, recover api transition
mcspr Jan 12, 2021
f16ab6c
make use of non-integer transition
mcspr Jan 12, 2021
2b2fb4f
fix serialize warning (todo for the next time)
mcspr Jan 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions code/espurna/DebounceEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,27 @@
#include <functional>
#include <memory>

#include "compat.h"
#include "libs/DebounceEvent.h"

namespace debounce_event {

EventEmitter::EventEmitter(types::Pin pin, types::EventHandler callback, const types::Config& config, unsigned long debounce_delay, unsigned long repeat) :
_pin(pin),
EventEmitter::EventEmitter(BasePinPtr&& pin, types::EventHandler callback, const types::Config& config, unsigned long debounce_delay, unsigned long repeat) :
_pin(std::move(pin)),
_callback(callback),
_config(config),
_is_switch(config.mode == types::Mode::Switch),
_delay(debounce_delay),
_repeat(repeat)
{
if (!pin) return;
if (!_pin) return;

switch (_config.pin_mode) {
case types::PinMode::InputPullup:
_pin->pinMode(INPUT_PULLUP);
break;
case types::PinMode::InputPulldown:
// ESP8266 does not have INPUT_PULLDOWN definition, and instead
// has a GPIO16-specific INPUT_PULLDOWN_16:
// - https://github.com/esp8266/Arduino/issues/478
// - https://github.com/esp8266/Arduino/commit/1b3581d55ebf0f8c91e081f9af4cf7433d492ec9
#ifdef ESP8266
if (_pin->pin == 16) {
_pin->pinMode(INPUT_PULLDOWN_16);
} else {
_pin->pinMode(INPUT);
}
#else
_pin->pinMode(INPUT_PULLDOWN);
#endif
break;
case types::PinMode::Input:
_pin->pinMode(INPUT);
Expand All @@ -83,19 +72,19 @@ EventEmitter::EventEmitter(types::Pin pin, types::EventHandler callback, const t
_value = _default_value;
}

EventEmitter::EventEmitter(types::Pin pin, const types::Config& config, unsigned long delay, unsigned long repeat) :
EventEmitter(pin, nullptr, config, delay, repeat)
EventEmitter::EventEmitter(BasePinPtr&& pin, const types::Config& config, unsigned long delay, unsigned long repeat) :
EventEmitter(std::move(pin), nullptr, config, delay, repeat)
{}

bool EventEmitter::isPressed() {
return (_value != _default_value);
}

const types::Pin EventEmitter::getPin() const {
const BasePinPtr& EventEmitter::pin() const {
return _pin;
}

const types::Config EventEmitter::getConfig() const {
const types::Config& EventEmitter::config() const {
return _config;
}

Expand Down
12 changes: 5 additions & 7 deletions code/espurna/alexa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ void _alexaBrokerCallback(const String& topic, unsigned char id, unsigned int va
}

if (topic.equals(MQTT_TOPIC_RELAY)) {
#if RELAY_PROVIDER == RELAY_PROVIDER_LIGHT
if (id > 0) return;
#endif
if (id > 0) return;
_alexa.setState(id, value, value > 0 ? 255 : 0);
}

Expand All @@ -97,13 +95,13 @@ void alexaLoop() {
alexa_queue_element_t element = _alexa_queue.front();
DEBUG_MSG_P(PSTR("[ALEXA] Device #%u state: %s value: %d\n"), element.device_id, element.state ? "ON" : "OFF", element.value);

#if RELAY_PROVIDER == RELAY_PROVIDER_LIGHT
#if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE
if (0 == element.device_id) {
relayStatus(0, element.state);
lightState(element.state);
} else {
lightState(element.device_id - 1, element.state);
lightChannel(element.device_id - 1, element.value);
lightUpdate(true, true);
lightUpdate();
}
#else
relayStatus(element.device_id, element.state);
Expand All @@ -130,7 +128,7 @@ void alexaSetup() {
}

// Lights
#if RELAY_PROVIDER == RELAY_PROVIDER_LIGHT
#if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE

// Global switch
_alexa.addDevice(hostname.c_str());
Expand Down
Loading