flipperzero-firmware/applications/ibutton/ibutton.h
2020-11-16 21:21:58 +10:00

54 lines
1.1 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
uint8_t dallas_address[8] = {0x01, 0xFD, 0x0E, 0x84, 0x01, 0x00, 0x00, 0xDB};
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:
GpioPin* red_led_record;
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();
};