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.
 
 
 
zavlaha-kzk/src/screens/screen_moisture_calib.c

53 lines
1.6 KiB

#include <stdio.h>
#include "app_gui.h"
#include "gui_event.h"
#include "app_io.h"
#include "app_config.h"
static int phase = 0;
static uint16_t sample_dry = 0;
void screen_moisture_calib(GuiEvent event)
{
switch (event) {
case GUI_EVENT_SCREEN_INIT:
phase = 0;
// pass through
case GUI_EVENT_SCREEN_TICK_100MS:
gui_read_moisture();
request_paint(); // will read new measurement
break;
case GUI_EVENT_PAINT:
if (phase == 0) {
LcdBuffer_Write(&lcd, 0, 0, "Dej čidlo do vyschlé");
LcdBuffer_Write(&lcd, 1, 0, "půdy (vlhkost 0%)");
} else {
LcdBuffer_Write(&lcd, 0, 0, "Dej čidlo do mokré");
LcdBuffer_Write(&lcd, 1, 0, "půdy (vlhkost 100%)");
}
snprintf(sbuf, sbuf_len, "Vlhkost %4d/4095", s_app.moisture_raw);
LcdBuffer_Write(&lcd, 2, 0, sbuf);
LcdBuffer_Write(&lcd, 3, 0, "🅳Zrušit 🅰Potvrdit");
break;
case GUI_EVENT_KEY_A: // Confirm
if (phase == 0) {
sample_dry = s_app.moisture_raw;
phase++;
LcdBuffer_Clear(&lcd); // make sure there isnt overlap with previous step
} else {
settings_scratch.moisture_dry = sample_dry;
settings_scratch.moisture_wet = s_app.moisture_raw;
switch_screen(screen_settings, false);
}
break;
case GUI_EVENT_KEY_D: // CANCEL
switch_screen(screen_settings, false);
break;
}
}