esp32 firmware for a toaster reflow oven WIP!!!!!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
reflower/main/gui.c

71 lines
1.5 KiB

5 years ago
#include "gui.h"
#include "nokia.h"
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
static void gui_thread(void *arg);
TaskHandle_t hGuiThread = NULL;
void gui_init() {
printf("GUI init\n");
LCD_setup();
LCD_clearDisplay(0);
LCD_setStr("Hello World", 0, 0, 1);
LCD_updateDisplay();
int rv = xTaskCreate(gui_thread, "gui", 4096, NULL, 3, &hGuiThread);
assert (rv == pdPASS);
}
static void __attribute__((noreturn)) gui_thread(void *arg) {
uint32_t pos = 20;
#define NMAX 60
while (1) {
uint32_t value;
xTaskNotifyWait(0, ULONG_MAX, &value, portMAX_DELAY);
printf("Knob event 0x%02x ", value);
5 years ago
if (value & 0b1000) {
printf("PUSH ");
}
if (value & 0b100) {
5 years ago
printf("RELS ");
}
if ((value & 0b11) == 0b11) {
printf("BNCE ");
} else {
if (value & 0b01) {
printf("FWD ");
if (pos == NMAX) {
pos = 0;
}
else {
pos += 1;
}
5 years ago
}
if (value & 0b10) {
printf("BACK ");
if (pos == 0) {
pos = NMAX;
}
else {
pos--;
}
5 years ago
}
5 years ago
}
5 years ago
printf(">");
5 years ago
for (int i=0; i<pos; i++) {
printf(" ");
}
5 years ago
printf("#");
for (int i=pos; i<NMAX; i++) {
printf(" ");
}
printf("<\n");
5 years ago
}
}