mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-24 11:14:26 +03:00
ibutton app, only read mode
This commit is contained in:
parent
a8fdbc6376
commit
799eefd754
@ -24,6 +24,7 @@ BUILD_VIBRO_DEMO = 1
|
||||
BUILD_SD_TEST = 1
|
||||
BUILD_GPIO_DEMO = 1
|
||||
BUILD_MUSIC_PLAYER = 1
|
||||
BUILD_IBUTTON = 1
|
||||
endif
|
||||
|
||||
APP_NFC ?= 0
|
||||
@ -258,6 +259,17 @@ CFLAGS += -DBUILD_MUSIC_PLAYER
|
||||
C_SOURCES += $(wildcard $(APP_DIR)/music-player/*.c)
|
||||
endif
|
||||
|
||||
APP_IBUTTON ?= 0
|
||||
ifeq ($(APP_IBUTTON), 1)
|
||||
CFLAGS += -DAPP_IBUTTON
|
||||
BUILD_IBUTTON = 1
|
||||
endif
|
||||
BUILD_IBUTTON ?= 0
|
||||
ifeq ($(BUILD_IBUTTON), 1)
|
||||
CFLAGS += -DBUILD_IBUTTON
|
||||
CPP_SOURCES += $(wildcard $(APP_DIR)/ibutton/ibutton.cpp)
|
||||
endif
|
||||
|
||||
# device drivers
|
||||
|
||||
APP_GUI ?= 0
|
||||
|
@ -4,8 +4,12 @@
|
||||
|
||||
// start app
|
||||
void AppiButton::run() {
|
||||
acquire_state();
|
||||
mode[0] = new AppiButtonModeDallasRead(this);
|
||||
mode[1] = new AppiButtonModeDallasEmulate(this);
|
||||
release_state();
|
||||
|
||||
switch_to_mode(0);
|
||||
|
||||
// create pin
|
||||
GpioPin red_led = led_gpio[0];
|
||||
@ -94,6 +98,14 @@ void AppiButton::decrease_mode() {
|
||||
release_state();
|
||||
}
|
||||
|
||||
void AppiButton::switch_to_mode(uint8_t mode_index) {
|
||||
acquire_state();
|
||||
mode[state.mode_index]->release();
|
||||
state.mode_index = mode_index;
|
||||
mode[state.mode_index]->acquire();
|
||||
release_state();
|
||||
}
|
||||
|
||||
// app enter function
|
||||
extern "C" void app_ibutton(void* p) {
|
||||
AppiButton* app = new AppiButton();
|
||||
|
@ -8,7 +8,8 @@ typedef uint8_t event_t;
|
||||
class AppiButtonState {
|
||||
public:
|
||||
// state data
|
||||
uint8_t dallas_address[8] = {0x01, 0xFD, 0x0E, 0x84, 0x01, 0x00, 0x00, 0xDB};
|
||||
// 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
|
||||
@ -51,4 +52,5 @@ public:
|
||||
|
||||
void increase_mode();
|
||||
void decrease_mode();
|
||||
void switch_to_mode(uint8_t mode_index);
|
||||
};
|
@ -25,19 +25,19 @@ public:
|
||||
|
||||
void AppiButtonModeDallasEmulate::event(AppiButtonEvent* event, AppiButtonState* state) {
|
||||
if(event->type == AppiButtonEvent::EventTypeTick) {
|
||||
acquire();
|
||||
if(onewire_slave->emulate(state->dallas_address, 8)) {
|
||||
app->blink_red();
|
||||
/*if(onewire_slave->emulate(state->dallas_address, 8)) {
|
||||
app->blink_green();
|
||||
} else {
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
void AppiButtonModeDallasEmulate::render(CanvasApi* canvas, AppiButtonState* state) {
|
||||
canvas->set_font(canvas, FontSecondary);
|
||||
canvas->draw_str(canvas, 2, 25, "< dallas emulate");
|
||||
canvas->draw_str(canvas, 2, 37, "give me domophone");
|
||||
canvas->draw_str(canvas, 2, 37, "unimplemented");
|
||||
{
|
||||
char buf[24];
|
||||
sprintf(
|
||||
|
@ -129,8 +129,7 @@ bool OneWireGpioSlave::receiveBit(void) {
|
||||
// wait while bus is HIGH
|
||||
OneWiteTimeType time = OneWireEmulateTiming::SLOT_MAX[overdrive_mode];
|
||||
time = wait_while_gpio(time, true);
|
||||
if (time == 0)
|
||||
{
|
||||
if(time == 0) {
|
||||
printf("RESET_IN_PROGRESS\n");
|
||||
return false;
|
||||
}
|
||||
@ -144,8 +143,7 @@ bool OneWireGpioSlave::receiveBit(void) {
|
||||
// wait while bus is LOW
|
||||
time = OneWireEmulateTiming::MSG_HIGH_TIMEOUT;
|
||||
time = wait_while_gpio(time, false);
|
||||
if (time == 0)
|
||||
{
|
||||
if(time == 0) {
|
||||
printf("TIMEOUT_HIGH\n");
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user