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.
93 lines
2.2 KiB
93 lines
2.2 KiB
/**
|
|
* TODO file description
|
|
*/
|
|
|
|
#include <stdbool.h>
|
|
#include "app_gui.h"
|
|
#include "app_heater.h"
|
|
#include "app_buzzer.h"
|
|
#include "app_temp.h"
|
|
#include "FreeRTOS.h"
|
|
#include "task.h"
|
|
#include "queue.h"
|
|
#include "ufb/framebuffer.h"
|
|
#include "ufb/fb_text.h"
|
|
|
|
#define MAX_TEMP 400
|
|
|
|
static struct State {
|
|
float oven_temp;
|
|
float soc_temp;
|
|
int set_temp;
|
|
int set_temp_wheel;
|
|
bool heater_enabled;
|
|
} s_app = {};
|
|
|
|
static void calc_set_temp() {
|
|
int clamped = s_app.set_temp_wheel;
|
|
if (clamped < 0) {
|
|
clamped = 0;
|
|
}
|
|
s_app.set_temp = (clamped / 2) * 5;
|
|
if (s_app.set_temp > MAX_TEMP) {
|
|
s_app.set_temp = MAX_TEMP;
|
|
}
|
|
|
|
app_heater_set_target((float) s_app.set_temp);
|
|
}
|
|
|
|
void app_task_gui(void *argument) {
|
|
// Wait until inited
|
|
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
|
PUTS("GUI task starts\r\n");
|
|
|
|
char tmp[100];
|
|
|
|
while (1) {
|
|
s_app.oven_temp = app_temp_read_oven();
|
|
s_app.soc_temp = app_temp_read_soc();
|
|
|
|
uint32_t message = GUI_EVENT_NONE;
|
|
osMessageQueueGet(guiEventQueHandle, &message, NULL, pdMS_TO_TICKS(1000));
|
|
|
|
switch (message) {
|
|
case GUI_NOTIFY_KNOB_PLUS:
|
|
s_app.set_temp_wheel++;
|
|
calc_set_temp();
|
|
break;
|
|
case GUI_NOTIFY_KNOB_MINUS:
|
|
s_app.set_temp_wheel--;
|
|
calc_set_temp();
|
|
break;
|
|
case GUI_NOTIFY_KNOB_PRESS:
|
|
break;
|
|
case GUI_NOTIFY_KNOB_RELEASE:
|
|
s_app.heater_enabled ^= 1;
|
|
app_heater_enable(s_app.heater_enabled);
|
|
app_buzzer_beep();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
fb_clear();
|
|
|
|
SPRINTF(tmp, "T=%.1f°C", s_app.oven_temp);
|
|
fb_text(3, 3, tmp, FONT_5X7, 1);
|
|
|
|
SPRINTF(tmp, "Cil=%d°C", s_app.set_temp);
|
|
fb_text(3, 11, tmp, FONT_5X7, 1);
|
|
|
|
SPRINTF(tmp, "Stav=%s", s_app.heater_enabled ? "ZAP" : "VYP");
|
|
fb_text(3, 19, tmp, FONT_5X7, 1);
|
|
|
|
SPRINTF(tmp, "Tsoc=%.1f°C", s_app.soc_temp);
|
|
fb_text(3, 27, tmp, FONT_5X7, 1);
|
|
|
|
if (s_app.heater_enabled) {
|
|
fb_frame(0, 0, FBW, FBH, 2, 1);
|
|
}
|
|
|
|
fb_blit();
|
|
}
|
|
}
|
|
|