fix multithread logic in template app, update gpio HAL (#250)

* 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
This commit is contained in:
DrZlo13
2020-11-19 15:25:32 +03:00
committed by GitHub
parent ccd40497eb
commit a96f23af9b
24 changed files with 137 additions and 88 deletions

View File

@@ -4,25 +4,21 @@
// 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];
GpioPin green_led = led_gpio[1];
// TODO open record
red_led_record = &red_led;
green_led_record = &green_led;
red_led_record = &led_gpio[0];
green_led_record = &led_gpio[1];
// configure pin
gpio_init(red_led_record, GpioModeOutputOpenDrain);
gpio_init(green_led_record, GpioModeOutputOpenDrain);
app_ready();
AppiButtonEvent event;
while(1) {
if(get_event(&event, 100)) {
@@ -61,9 +57,7 @@ void AppiButton::render(CanvasApi* canvas) {
canvas->set_font(canvas, FontPrimary);
canvas->draw_str(canvas, 2, 12, "iButton");
if(mode[state.mode_index] != NULL) {
mode[state.mode_index]->render(canvas, &state);
}
mode[state.mode_index]->render(canvas, &state);
}
void AppiButton::blink_red() {