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.
toaster-oven-bluepill/Core/Src/Gui/screen_manual.c

79 lines
2.0 KiB

2 years ago
//
// Created by MightyPork on 2023/04/09.
//
#include <stddef.h>
#include <stdbool.h>
#include "app_gui.h"
#include "gui_event.h"
#include "screen_menu.h"
#include "app_heater.h"
#include "ufb/fb_7seg.h"
#include "FreeRTOS.h"
2 years ago
#include "ufb/fb_text.h"
2 years ago
void screen_manual(GuiEvent event)
{
bool temp_changed = false;
if (event == GUI_EVENT_SCREEN_INIT) {
2 years ago
app_heater_manual_override_clear();
app_heater_enable(false);
2 years ago
return;
}
// menu is activated by long push
if (push_time() >= pdMS_TO_TICKS(500)) {
switch_screen(screen_manual_menu, true);
return;
}
switch (event) {
case GUI_EVENT_PAINT:
2 years ago
fb_7seg_number(FBW/2 - ((12+2) * 3 - 2)/2, 36,
12, 20, 2, 2,
2 years ago
1,
s_app.set_temp, 3, 0
);
2 years ago
fb_text(FBW/2, 25, "Teplota °C", TEXT_CENTER, 1);
fb_text(FBW/2, 64, s_app.heater_enabled ? "ZAPNUTO" : "Vypnuto", TEXT_CENTER, 1);
SPRINTF(stmp, "%.1f", s_app.oven_temp);
fb_text(FBW/2, 80, stmp, TEXT_CENTER | FONT_DOUBLE, 1);
fb_text(2, FBH - 8 * 3, "←→Nastav", 0, 1);
fb_text(2, FBH - 8 * 2, "> Zap/Vyp", 0, 1);
fb_text(2, FBH - 8 * 1, "» Menu", 0, 1);
2 years ago
break;
case GUI_EVENT_KNOB_RELEASE:
input_sound_effect();
s_app.heater_enabled ^= 1;
app_heater_enable(s_app.heater_enabled);
request_paint();
break;
case GUI_EVENT_KNOB_PLUS:
if (s_app.set_temp <= MAX_TEMP - 5) {
s_app.set_temp += 5;
temp_changed = true;
}
break;
case GUI_EVENT_KNOB_MINUS:
if (s_app.set_temp >= 5) {
s_app.set_temp -= 5;
temp_changed = true;
}
break;
}
if (temp_changed) {
input_sound_effect();
app_heater_set_target((float) s_app.set_temp);
request_paint();
}
}