Browse Source

btn: store actions as uint8_t instead of uint16_t

mcspr-patch-1
Maxim Prokhorov 4 years ago
committed by Max Prokhorov
parent
commit
032f921fc4
2 changed files with 10 additions and 8 deletions
  1. +9
    -7
      code/espurna/button.h
  2. +1
    -1
      code/espurna/button.ino

+ 9
- 7
code/espurna/button.h View File

@ -16,6 +16,8 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
constexpr size_t ButtonsPresetMax = 8; constexpr size_t ButtonsPresetMax = 8;
constexpr size_t ButtonsMax = 32; constexpr size_t ButtonsMax = 32;
using button_action_t = uint8_t;
enum class button_event_t { enum class button_event_t {
None = 0, None = 0,
Pressed = 1, Pressed = 1,
@ -27,12 +29,12 @@ enum class button_event_t {
}; };
struct button_actions_t { struct button_actions_t {
uint16_t pressed;
uint16_t click;
uint16_t dblclick;
uint16_t lngclick;
uint16_t lnglngclick;
uint16_t trplclick;
button_action_t pressed;
button_action_t click;
button_action_t dblclick;
button_action_t lngclick;
button_action_t lnglngclick;
button_action_t trplclick;
}; };
struct button_event_delays_t { struct button_event_delays_t {
@ -64,7 +66,7 @@ struct button_t {
}; };
bool buttonState(unsigned char id); bool buttonState(unsigned char id);
uint16_t buttonAction(unsigned char id, const button_event_t event);
button_action_t buttonAction(unsigned char id, const button_event_t event);
void buttonMQTT(unsigned char id, button_event_t event); void buttonMQTT(unsigned char id, button_event_t event);
void buttonEvent(unsigned char id, button_event_t event); void buttonEvent(unsigned char id, button_event_t event);


+ 1
- 1
code/espurna/button.ino View File

@ -330,7 +330,7 @@ bool buttonState(unsigned char id) {
return _buttons[id].state(); return _buttons[id].state();
} }
uint16_t buttonAction(unsigned char id, const button_event_t event) {
button_action_t buttonAction(unsigned char id, const button_event_t event) {
if (id >= _buttons.size()) return 0; if (id >= _buttons.size()) return 0;
return _buttonDecodeEventAction(_buttons[id].actions, event); return _buttonDecodeEventAction(_buttons[id].actions, event);
} }


Loading…
Cancel
Save