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.
60 lines
1.4 KiB
60 lines
1.4 KiB
2 years ago
|
/**
|
||
|
* TODO file description
|
||
|
*/
|
||
|
//
|
||
|
// Created by MightyPork on 2023/04/09.
|
||
|
//
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
#include "app_gui.h"
|
||
|
#include "gui_event.h"
|
||
|
#include "ds_rtc.h"
|
||
|
#include "app_io.h"
|
||
|
|
||
|
static uint32_t last_time = 0;
|
||
|
static struct rtc_time rtc_time = {};
|
||
|
static uint16_t moisture = 0;
|
||
|
|
||
|
static char showbuf[20];
|
||
|
static uint8_t showbuf_wp = 0;
|
||
|
|
||
|
void screen_home(GuiEvent event)
|
||
|
{
|
||
|
uint32_t now = timestamp();
|
||
|
uint32_t elapsed = now - last_time;
|
||
|
|
||
|
switch (event) {
|
||
|
case GUI_EVENT_SCREEN_INIT:
|
||
|
memset(showbuf, ' ', sizeof(showbuf));
|
||
|
// pass
|
||
|
case GUI_EVENT_SCREEN_TICK:
|
||
|
if (elapsed >= 100) {
|
||
|
last_time = now;
|
||
|
rtc_get_time(&rtc_time);
|
||
|
moisture = moisture_read();
|
||
|
request_paint();
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case GUI_EVENT_PAINT:;
|
||
|
LcdBuffer_Write(&lcd, 0, 0, showbuf);
|
||
|
|
||
|
sprintf(stmp, "Čas: %02d:%02d:%02d", rtc_time.hour, rtc_time.minute, rtc_time.second);
|
||
|
LcdBuffer_Write(&lcd, 1, 0, stmp);
|
||
|
|
||
|
sprintf(stmp, "Vlhkost: %4d", moisture);
|
||
|
LcdBuffer_Write(&lcd, 2, 0, stmp);
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
if (event >= 32) {
|
||
|
showbuf[showbuf_wp++] = event;
|
||
|
if (showbuf_wp == 20) {
|
||
|
showbuf_wp = 0;
|
||
|
}
|
||
|
request_paint();
|
||
|
}
|
||
|
}
|
||
|
}
|