Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7914cfa
create Dockerfile to build espurna with docker
copyrights Jun 2, 2019
682d09a
write README.md
copyrights Jun 2, 2019
a956190
fix typo
copyrights Jun 2, 2019
9084848
change Dockerfile to fix automated code review
copyrights Jun 2, 2019
a35ddad
add version pinning
copyrights Jun 2, 2019
6541c29
redice version pinning; remove apt-get clean
copyrights Jun 3, 2019
8610164
use COPY instead of git clone
copyrights Jun 3, 2019
a064789
fix typo
copyrights Jun 4, 2019
246b4ca
make UID and GID configurable
copyrights Jun 4, 2019
9c11160
add .dockerignore
copyrights Jun 4, 2019
83a49b1
Merge remote-tracking branch 'origin-copyrights/docker-build' into de…
wyattearp Nov 5, 2020
6cb9648
patching up docker and readme
wyattearp Nov 5, 2020
69500e7
typo correction
wyattearp Nov 13, 2020
b24b0a2
pio: fix git builds & bump current platform
mcspr Nov 15, 2020
a62d1cd
pio: -latest-base -> -base for envs
mcspr Nov 16, 2020
f497312
btn: option to read default value on initialization
mcspr Oct 15, 2020
99cb8e0
hw: restore sonoff-mini switch actions defaults
mcspr Nov 15, 2020
12ae9d1
sns/hlw8012: default ratios at compile time
mcspr Nov 15, 2020
850db61
pio: filter single-source files by absolute path
mcspr Nov 16, 2020
ac6f0b7
docs: mention exception decoder in the bug report
mcspr Nov 28, 2020
3717db7
create Dockerfile to build espurna with docker
copyrights Jun 2, 2019
ef254c0
write README.md
copyrights Jun 2, 2019
8c46382
fix typo
copyrights Jun 2, 2019
0688029
change Dockerfile to fix automated code review
copyrights Jun 2, 2019
458e904
add version pinning
copyrights Jun 2, 2019
d5cf379
redice version pinning; remove apt-get clean
copyrights Jun 3, 2019
df497b2
use COPY instead of git clone
copyrights Jun 3, 2019
f143b3e
fix typo
copyrights Jun 4, 2019
01583b8
make UID and GID configurable
copyrights Jun 4, 2019
9aeb0f0
add .dockerignore
copyrights Jun 4, 2019
21df1ac
patching up docker and readme
wyattearp Nov 5, 2020
f334283
typo correction
wyattearp Nov 13, 2020
9a58e40
updating items based on feedback
wyattearp Dec 27, 2020
631e815
merging in
wyattearp Dec 27, 2020
7208101
why didn't you show me that was wrong???
wyattearp Dec 28, 2020
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
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.s#?
*.b#?
.modgit
firmware*
*.gch
.pio*
.clang_complete
.gcc-flags.json
.sconsign.dblite
.python
.env
.DS_Store
.vscode
21 changes: 20 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ assignees: ''

*Fulfilling this template will help developers and contributors to address the issue. Try to be as specific and extensive as possible. If the information provided is not enough the issue will likely be closed.*

*You can now remove this line and the above ones. Text in italic is meant to be replaced by your own words. If any of the sections below are not relevant to the issue (for instance, the screenshots) then you can delete them.*
*You can now remove this line and the above ones. Text in italic is meant to be replaced by your own words. If any of the sections below are not relevant to the issue (for instance, the screenshots or crash report) then you can delete them.*

**Bug description**
*A clear and concise description of what the bug is.*
Expand All @@ -38,6 +38,25 @@ assignees: ''
* *Flash mode*
* *Device brand, model and version*

**Crash report**
*Save the crash postmortem message, which may look something like:*
> Exception (28):
> epc1=0x4021e698 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
>
> ctx: sys
> sp: 3ffffc90 end: 3fffffb0 offset: 01a0
> \>\>\>stack\>\>\>
> ...
> \<\<\<stack\<\<\<
>

*And, use one of the following tools to decode it:*
- *https://github.com/mcspr/EspArduinoExceptionDecoder*
- *https://github.com/me-no-dev/EspExceptionDecoder (when using Arduino IDE)*

*When using PlatformIO, it is also possible to use a built-in exception decoder when device's serial connection is available:*
- `pio device monitor --echo -e $environment -f esp8266_exception_decoder`

**Tools used**
* *Desktop operating system*
* *Browser & version*
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ jobs:
- stage: Test Host
- stage: Test WebUI
- stage: Test PlatformIO Build
env: TEST_ENV=esp8266-4m-base
- env: >-
env: >-
TEST_ENV=esp8266-4m-latest-base TEST_EXTRA_ARGS="-a
test/build/extra/secure_client.h"
- stage: Release
Expand Down
51 changes: 31 additions & 20 deletions code/espurna/DebounceEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,48 @@ EventEmitter::EventEmitter(types::Pin pin, types::EventHandler callback, const t
_callback(callback),
_config(config),
_is_switch(config.mode == types::Mode::Switch),
_default_value(config.default_value == types::PinValue::High),
_delay(debounce_delay),
_repeat(repeat),
_value(_default_value),
_ready(false),
_reset_count(true),
_event_start(0),
_event_length(0),
_event_count(0)
_repeat(repeat)
{
if (!pin) return;

if (_config.pin_mode == types::PinMode::InputPullup) {
switch (_config.pin_mode) {
case types::PinMode::InputPullup:
_pin->pinMode(INPUT_PULLUP);
} else if (_config.pin_mode == types::PinMode::InputPulldown) {
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(_default_value ? INPUT : INPUT_PULLDOWN_16);
} else {
_pin->pinMode(INPUT);
}
#else
_pin->pinMode(INPUT_PULLDOWN);
#endif
} else {
#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);
break;
}

switch (config.default_value) {
case types::PinValue::Low:
_default_value = false;
break;
case types::PinValue::High:
_default_value = true;
break;
case types::PinValue::Initial:
_default_value = ((HIGH) == _pin->digitalRead());
break;
}

_value = _default_value;
}

EventEmitter::EventEmitter(types::Pin pin, const types::Config& config, unsigned long delay, unsigned long repeat) :
Expand Down
23 changes: 14 additions & 9 deletions code/espurna/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ String serialize(const debounce_event::types::Mode& value) {
template<>
debounce_event::types::PinValue convert(const String& value) {
switch (value.toInt()) {
case 0:
return debounce_event::types::PinValue::Low;
case 1:
default:
return debounce_event::types::PinValue::High;
case 2:
return debounce_event::types::PinValue::Initial;
default:
case 0:
return debounce_event::types::PinValue::Low;
}
}

Expand All @@ -81,9 +83,11 @@ String serialize(const debounce_event::types::PinValue& value) {
result = "0";
break;
case debounce_event::types::PinValue::High:
default:
result = "1";
break;
case debounce_event::types::PinValue::Initial:
result = "2";
break;
}
return result;
}
Expand Down Expand Up @@ -124,21 +128,22 @@ String serialize(const debounce_event::types::PinMode& mode) {

// -----------------------------------------------------------------------------

constexpr const debounce_event::types::Config _buttonDecodeConfigBitmask(const unsigned char bitmask) {
constexpr debounce_event::types::Config _buttonDecodeConfigBitmask(int bitmask) {
return {
((bitmask & ButtonMask::Pushbutton)
? debounce_event::types::Mode::Pushbutton
: debounce_event::types::Mode::Switch),
((bitmask & ButtonMask::DefaultHigh)
? debounce_event::types::PinValue::High
((bitmask & ButtonMask::DefaultLow) ? debounce_event::types::PinValue::Low
: (bitmask & ButtonMask::DefaultHigh) ? debounce_event::types::PinValue::High
: (bitmask & ButtonMask::DefaultBoot) ? debounce_event::types::PinValue::Initial
: debounce_event::types::PinValue::Low),
((bitmask & ButtonMask::SetPullup) ? debounce_event::types::PinMode::InputPullup
: (bitmask & ButtonMask::SetPulldown) ? debounce_event::types::PinMode::InputPulldown
: debounce_event::types::PinMode::Input)
};
}

constexpr const button_action_t _buttonDecodeEventAction(const button_actions_t& actions, button_event_t event) {
constexpr button_action_t _buttonDecodeEventAction(const button_actions_t& actions, button_event_t event) {
return (
(event == button_event_t::Pressed) ? actions.pressed :
(event == button_event_t::Released) ? actions.released :
Expand All @@ -150,7 +155,7 @@ constexpr const button_action_t _buttonDecodeEventAction(const button_actions_t&
);
}

constexpr const button_event_t _buttonMapReleased(uint8_t count, unsigned long length, unsigned long lngclick_delay, unsigned long lnglngclick_delay) {
constexpr button_event_t _buttonMapReleased(uint8_t count, unsigned long length, unsigned long lngclick_delay, unsigned long lnglngclick_delay) {
return (
(0 == count) ? button_event_t::Released :
(1 == count) ? (
Expand Down
54 changes: 27 additions & 27 deletions code/espurna/button_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ BUTTON MODULE

namespace ButtonMask {

enum {
Pushbutton = 1 << 0,
Switch = 1 << 1,
DefaultHigh = 1 << 2,
SetPullup = 1 << 3,
SetPulldown = 1 << 4
};
constexpr int Pushbutton { 1 << 0 };
constexpr int Switch { 1 << 1 };
constexpr int DefaultLow { 1 << 2 };
constexpr int DefaultHigh { 1 << 3 };
constexpr int DefaultBoot { 1 << 4 };
constexpr int SetPullup { 1 << 5 };
constexpr int SetPulldown { 1 << 6 };

} // namespace ButtonMask

constexpr const unsigned char _buttonPin(unsigned char index) {
constexpr unsigned char _buttonPin(unsigned char index) {
return (
(index == 0) ? BUTTON1_PIN :
(index == 1) ? BUTTON2_PIN :
Expand All @@ -33,7 +33,7 @@ constexpr const unsigned char _buttonPin(unsigned char index) {
);
}

constexpr const unsigned char _buttonConfigBitmask(unsigned char index) {
constexpr int _buttonConfigBitmask(unsigned char index) {
return (
(index == 0) ? (BUTTON1_CONFIG) :
(index == 1) ? (BUTTON2_CONFIG) :
Expand All @@ -46,7 +46,7 @@ constexpr const unsigned char _buttonConfigBitmask(unsigned char index) {
);
}

constexpr const unsigned char _buttonRelease(unsigned char index) {
constexpr unsigned char _buttonRelease(unsigned char index) {
return (
(index == 0) ? BUTTON1_RELEASE :
(index == 1) ? BUTTON2_RELEASE :
Expand All @@ -59,7 +59,7 @@ constexpr const unsigned char _buttonRelease(unsigned char index) {
);
}

constexpr const unsigned char _buttonPress(unsigned char index) {
constexpr unsigned char _buttonPress(unsigned char index) {
return (
(index == 0) ? BUTTON1_PRESS :
(index == 1) ? BUTTON2_PRESS :
Expand All @@ -72,7 +72,7 @@ constexpr const unsigned char _buttonPress(unsigned char index) {
);
}

constexpr const unsigned char _buttonClick(unsigned char index) {
constexpr unsigned char _buttonClick(unsigned char index) {
return (
(index == 0) ? BUTTON1_CLICK :
(index == 1) ? BUTTON2_CLICK :
Expand All @@ -85,7 +85,7 @@ constexpr const unsigned char _buttonClick(unsigned char index) {
);
}

constexpr const unsigned char _buttonDoubleClick(unsigned char index) {
constexpr unsigned char _buttonDoubleClick(unsigned char index) {
return (
(index == 0) ? BUTTON1_DBLCLICK :
(index == 1) ? BUTTON2_DBLCLICK :
Expand All @@ -98,7 +98,7 @@ constexpr const unsigned char _buttonDoubleClick(unsigned char index) {
);
}

constexpr const unsigned char _buttonTripleClick(unsigned char index) {
constexpr unsigned char _buttonTripleClick(unsigned char index) {
return (
(index == 0) ? BUTTON1_TRIPLECLICK :
(index == 1) ? BUTTON2_TRIPLECLICK :
Expand All @@ -111,7 +111,7 @@ constexpr const unsigned char _buttonTripleClick(unsigned char index) {
);
}

constexpr const unsigned char _buttonLongClick(unsigned char index) {
constexpr unsigned char _buttonLongClick(unsigned char index) {
return (
(index == 0) ? BUTTON1_LNGCLICK :
(index == 1) ? BUTTON2_LNGCLICK :
Expand All @@ -124,7 +124,7 @@ constexpr const unsigned char _buttonLongClick(unsigned char index) {
);
}

constexpr const unsigned char _buttonLongLongClick(unsigned char index) {
constexpr unsigned char _buttonLongLongClick(unsigned char index) {
return (
(index == 0) ? BUTTON1_LNGLNGCLICK :
(index == 1) ? BUTTON2_LNGLNGCLICK :
Expand All @@ -137,7 +137,7 @@ constexpr const unsigned char _buttonLongLongClick(unsigned char index) {
);
}

constexpr const unsigned char _buttonRelay(unsigned char index) {
constexpr unsigned char _buttonRelay(unsigned char index) {
return (
(index == 0) ? (BUTTON1_RELAY - 1) :
(index == 1) ? (BUTTON2_RELAY - 1) :
Expand All @@ -150,11 +150,11 @@ constexpr const unsigned char _buttonRelay(unsigned char index) {
);
}

constexpr const unsigned long _buttonDebounceDelay() {
constexpr unsigned long _buttonDebounceDelay() {
return BUTTON_DEBOUNCE_DELAY;
}

constexpr const unsigned long _buttonDebounceDelay(unsigned char index) {
constexpr unsigned long _buttonDebounceDelay(unsigned char index) {
return (
(index == 0) ? BUTTON1_DEBOUNCE_DELAY :
(index == 1) ? BUTTON2_DEBOUNCE_DELAY :
Expand All @@ -167,11 +167,11 @@ constexpr const unsigned long _buttonDebounceDelay(unsigned char index) {
);
}

constexpr const unsigned long _buttonRepeatDelay() {
constexpr unsigned long _buttonRepeatDelay() {
return BUTTON_REPEAT_DELAY;
}

constexpr const unsigned long _buttonRepeatDelay(unsigned char index) {
constexpr unsigned long _buttonRepeatDelay(unsigned char index) {
return (
(index == 0) ? BUTTON1_REPEAT_DELAY :
(index == 1) ? BUTTON2_REPEAT_DELAY :
Expand All @@ -184,11 +184,11 @@ constexpr const unsigned long _buttonRepeatDelay(unsigned char index) {
);
}

constexpr const unsigned long _buttonLongClickDelay() {
constexpr unsigned long _buttonLongClickDelay() {
return BUTTON_LNGCLICK_DELAY;
}

constexpr const unsigned long _buttonLongClickDelay(unsigned char index) {
constexpr unsigned long _buttonLongClickDelay(unsigned char index) {
return (
(index == 0) ? BUTTON1_LNGCLICK_DELAY :
(index == 1) ? BUTTON2_LNGCLICK_DELAY :
Expand All @@ -201,11 +201,11 @@ constexpr const unsigned long _buttonLongClickDelay(unsigned char index) {
);
}

constexpr const unsigned long _buttonLongLongClickDelay() {
constexpr unsigned long _buttonLongLongClickDelay() {
return BUTTON_LNGLNGCLICK_DELAY;
}

constexpr const unsigned long _buttonLongLongClickDelay(unsigned char index) {
constexpr unsigned long _buttonLongLongClickDelay(unsigned char index) {
return (
(index == 0) ? BUTTON1_LNGLNGCLICK_DELAY :
(index == 1) ? BUTTON2_LNGLNGCLICK_DELAY :
Expand All @@ -218,7 +218,7 @@ constexpr const unsigned long _buttonLongLongClickDelay(unsigned char index) {
);
}

constexpr const bool _buttonMqttSendAllEvents(unsigned char index) {
constexpr bool _buttonMqttSendAllEvents(unsigned char index) {
return (
(index == 0) ? (1 == BUTTON1_MQTT_SEND_ALL_EVENTS) :
(index == 1) ? (1 == BUTTON2_MQTT_SEND_ALL_EVENTS) :
Expand All @@ -231,7 +231,7 @@ constexpr const bool _buttonMqttSendAllEvents(unsigned char index) {
);
}

constexpr const bool _buttonMqttRetain(unsigned char index) {
constexpr bool _buttonMqttRetain(unsigned char index) {
return (
(index == 0) ? (1 == BUTTON1_MQTT_RETAIN) :
(index == 1) ? (1 == BUTTON2_MQTT_RETAIN) :
Expand Down
3 changes: 3 additions & 0 deletions code/espurna/config/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,12 @@
#define BUTTON1_PIN 0
#define BUTTON1_CONFIG BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1

#define BUTTON2_PIN 4
#define BUTTON2_CONFIG BUTTON_SWITCH | BUTTON_SET_PULLUP | BUTTON_DEFAULT_HIGH
#define BUTTON2_RELAY 1
#define BUTTON2_PRESS BUTTON_ACTION_ON
#define BUTTON2_RELEASE BUTTON_ACTION_OFF

// Relays
#define RELAY1_PIN 12
Expand Down
2 changes: 2 additions & 0 deletions code/espurna/config/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
// compat definitions for DebounceEvent
#define BUTTON_PUSHBUTTON ButtonMask::Pushbutton
#define BUTTON_SWITCH ButtonMask::Switch
#define BUTTON_DEFAULT_LOW ButtonMask::DefaultLow
#define BUTTON_DEFAULT_HIGH ButtonMask::DefaultHigh
#define BUTTON_DEFAULT_BOOT ButtonMask::DefaultBoot
#define BUTTON_SET_PULLUP ButtonMask::SetPullup
#define BUTTON_SET_PULLDOWN ButtonMask::SetPulldown

Expand Down
Loading