#include #include #include #include "knob.h" #include "gui.h" const int pushPin = 5; const int wheelPin1 = 18; const int wheelPin2 = 23; static void handle_pushbtn(void *arg); static void handle_wheel(void *arg); void knob_init() { printf("Knob init\n"); gpio_config_t output = { .pin_bit_mask = (1<> wheelPin2) & 1) << 1) | ((inputs >> wheelPin1) & 1); if (wheelState == S_ILLEGAL) { if (ab != 0b11) { return; } } uint8_t next = switch_table[wheelState*4 + ab]; const bool forward = next & SW_FWD; const bool backward = next & SW_BCK; next &= ~(SW_FWD | SW_BCK); wheelState = next; if (forward || backward) { BaseType_t higherWoken = 0; xTaskNotifyFromISR(hGuiThread, forward | (backward << 1), eSetValueWithOverwrite, &higherWoken); if (higherWoken) { portYIELD_FROM_ISR(); } } } static void handle_pushbtn(void *arg) { const uint32_t inputs = gpio_input_get(); if ((inputs & (1 << pushPin)) == 0) { BaseType_t higherWoken = 0; xTaskNotifyFromISR(hGuiThread, 0b100, eSetValueWithOverwrite, &higherWoken); if (higherWoken) { portYIELD_FROM_ISR(); } } }