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.
91 lines
2.0 KiB
91 lines
2.0 KiB
//
|
|
// 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"
|
|
|
|
|
|
void screen_manual(GuiEvent event)
|
|
{
|
|
bool temp_changed = false;
|
|
if (event == GUI_EVENT_SCREEN_INIT) {
|
|
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:
|
|
fb_7seg_number(4, 40, 12, 20, 2, 2,
|
|
1,
|
|
s_app.set_temp, 3, 0
|
|
);
|
|
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();
|
|
}
|
|
}
|
|
|
|
// ---------------------------
|
|
|
|
static const char* manual_menu_opts[] = {
|
|
"Zrušit",
|
|
"Hlavní menu",
|
|
NULL
|
|
};
|
|
|
|
static void manual_menu_cb(int opt) {
|
|
switch (opt) {
|
|
case 0:
|
|
// Close menu
|
|
switch_screen(screen_manual, false);
|
|
break;
|
|
|
|
case 1:
|
|
s_app.heater_enabled = false;
|
|
app_heater_enable(false);
|
|
switch_screen(screen_home, true);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void screen_manual_menu(GuiEvent event)
|
|
{
|
|
screen_menu(event, manual_menu_opts, manual_menu_cb);
|
|
}
|
|
|