mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-22 10:43:11 +00:00
a96f23af9b
* fix multithread logic * more buffer for dallas id string * update apps to use new logic * delay_us small speedup * add consant qualifier to gpio records and some core api * fix some apps to use simpler method of getting gpio record * fix ibutton app, stupid stack problem
56 lines
No EOL
1.2 KiB
C++
56 lines
No EOL
1.2 KiB
C++
#pragma once
|
|
#include "app-template.h"
|
|
#include "ibutton_mode_template.h"
|
|
|
|
// event enumeration type
|
|
typedef uint8_t event_t;
|
|
|
|
class AppiButtonState {
|
|
public:
|
|
// state data
|
|
// test key = {0x01, 0xFD, 0x0E, 0x84, 0x01, 0x00, 0x00, 0xDB};
|
|
uint8_t dallas_address[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
uint8_t mode_index;
|
|
|
|
// state initializer
|
|
AppiButtonState() {
|
|
mode_index = 0;
|
|
}
|
|
};
|
|
|
|
// events class
|
|
class AppiButtonEvent {
|
|
public:
|
|
// events enum
|
|
static const event_t EventTypeTick = 0;
|
|
static const event_t EventTypeKey = 1;
|
|
|
|
// payload
|
|
union {
|
|
InputEvent input;
|
|
} value;
|
|
|
|
// event type
|
|
event_t type;
|
|
};
|
|
|
|
// our app derived from base AppTemplate class
|
|
// with template variables <state, events>
|
|
class AppiButton : public AppTemplate<AppiButtonState, AppiButtonEvent> {
|
|
public:
|
|
const GpioPin* red_led_record;
|
|
const GpioPin* green_led_record;
|
|
|
|
static const uint8_t modes_count = 2;
|
|
AppTemplateMode<AppiButtonState, AppiButtonEvent>* mode[modes_count];
|
|
|
|
void run();
|
|
void render(CanvasApi* canvas);
|
|
|
|
void blink_red();
|
|
void blink_green();
|
|
|
|
void increase_mode();
|
|
void decrease_mode();
|
|
void switch_to_mode(uint8_t mode_index);
|
|
}; |