some work on screens

master
Ondřej Hruška 1 year ago
parent 149a116ef7
commit 2eefdf6325
  1. 5
      CMakeLists.txt
  2. 21
      src/app_config.c
  3. 33
      src/app_config.h
  4. 202
      src/lcd/cgram.c
  5. 3
      src/screens/app_gui.h
  6. 37
      src/screens/screen_cyklus.c
  7. 32
      src/screens/screen_home.c

@ -21,7 +21,10 @@ add_executable(zavlaha
src/lcd/cgrom.c
src/lcd/lcdbuf.c
src/screens/app_gui.c
src/screens/screen_home.c src/app_io.c)
src/screens/screen_home.c
src/app_io.c
src/app_config.c
src/screens/screen_cyklus.c)
# Add pico_stdlib library which aggregates commonly used features
target_link_libraries(zavlaha pico_stdlib hardware_i2c hardware_adc hardware_irq)

@ -0,0 +1,21 @@
/**
* TODO file description
*/
#include "app_config.h"
// TODO sensible defaults, loading and saving to/from EE
struct AppConfig app_config = {
.circuit_base_time_s = 10, // for a test
.circuit_time_percent = {30, 60, 90, 100}, // for a test
.schedules = {
{6, 45},
{255, 0},
{255, 0},
{255, 0}
},
.moisture_enable = true,
.moisture_dry = 2800,
.moisture_wet = 1600,
.moisture_threshold_percent = 70,
};

@ -0,0 +1,33 @@
/**
* TODO file description
*/
#ifndef ZAVLAHA_APP_CONFIG_H
#define ZAVLAHA_APP_CONFIG_H
#include <stdint.h>
#include <stdbool.h>
#define CIRCUIT_COUNT 4
#define SCHEDULE_COUNT 4
#define UNUSED_SCHEDULE_HOUR 0xFF
struct ScheduleTime {
uint8_t h;
uint8_t m;
};
struct AppConfig {
uint16_t circuit_base_time_s;
uint8_t circuit_time_percent[CIRCUIT_COUNT]; // 0% can be used to disable a branch
struct ScheduleTime schedules[SCHEDULE_COUNT]; // 0xFF hour is used to disable the slot
bool moisture_enable;
uint16_t moisture_dry;
uint16_t moisture_wet;
uint8_t moisture_threshold_percent;
};
extern struct AppConfig app_config;
#endif //ZAVLAHA_APP_CONFIG_H

@ -372,6 +372,208 @@ const struct LcdBuf_CGRAM_Symbol CGRAM_CZ[] = {
},
},
// GUI symbols
{
.symbol = "🌢", // Humidity
.fallback = 'H',
.data = {
0b00100,
0b01110,
0b01110,
0b11111,
0b10111,
0b11111,
0b01110,
},
},
// Some useful glyphs for GUI with a keypad
{
.symbol = "🅰",
.fallback = 'A',
.data = {
0b11111,
0b11011,
0b10101,
0b10001,
0b10101,
0b10101,
0b11111,
},
},
{
.symbol = "🅱",
.fallback = 'B',
.data = {
0b11111,
0b10011,
0b10101,
0b10011,
0b10101,
0b10011,
0b11111,
},
},
{
.symbol = "🅲",
.fallback = 'C',
.data = {
0b11111,
0b11011,
0b10101,
0b10111,
0b10101,
0b11011,
0b11111,
},
},
{
.symbol = "🅳",
.fallback = 'D',
.data = {
0b11111,
0b10011,
0b10101,
0b10101,
0b10101,
0b10011,
0b11111,
},
},
{
.symbol = "",
.fallback = '1',
.data = {
0b11111,
0b11011,
0b10011,
0b11011,
0b11011,
0b10001,
0b11111,
},
},
{
.symbol = "",
.fallback = '2',
.data = {
0b11111,
0b11001,
0b10101,
0b11101,
0b11011,
0b10001,
0b11111,
},
},
{
.symbol = "",
.fallback = '3',
.data = {
0b11111,
0b10011,
0b11101,
0b10011,
0b11101,
0b10011,
0b11111,
},
},
{
.symbol = "",
.fallback = '4',
.data = {
0b11111,
0b10101,
0b10101,
0b10001,
0b11101,
0b11101,
0b11111,
},
},
{
.symbol = "",
.fallback = '*',
.data = {
0b11111,
0b01010,
0b10001,
0b00000,
0b10001,
0b01010,
0b11111,
},
},
{
.symbol = "¤",
.fallback = '#',
.data = {
0b11111,
0b10101,
0b00000,
0b10101,
0b00000,
0b10101,
0b11111,
},
},
{
.symbol = "",
.fallback = ' ',
.data = {
0b11100,
0b11100,
0b11100,
0b11100,
0b11100,
0b11100,
0b11100,
0b11100,
},
},
{
.symbol = "",
.fallback = '^',
.data = {
0b00100,
0b01110,
0b10101,
0b00100,
0b00100,
0b00100,
0b00100,
},
},
{
.symbol = "",
.fallback = 'v',
.data = {
0b00100,
0b00100,
0b00100,
0b00100,
0b10101,
0b01110,
0b00100,
},
},
{
.symbol = "",
.fallback = 0xE8,
.data = {
0b00000,
0b00000,
0b00001,
0b10011,
0b11110,
0b01100,
0b00000,
},
},
{}, /* end mark */
};

@ -11,6 +11,8 @@
#include "gui_event.h"
#include "lcd/lcdbuf.h"
// 🌢🅰🅱🅲🅳❶❷❸❹⊛¤▌↑↓✔
/// Temporary scratch buffer
extern char stmp[100];
@ -46,6 +48,7 @@ void request_paint();
// prototypes for screen handlers
void screen_home(GuiEvent event);
void screen_cyklus(GuiEvent event);
// XXX other prototypes
struct State {

@ -0,0 +1,37 @@
/**
* Zavlahovy cuklus
*/
//
// 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"
void screen_cyklus(GuiEvent event)
{
uint32_t now = timestamp();
switch (event) {
case GUI_EVENT_SCREEN_INIT:
case GUI_EVENT_SCREEN_TICK:
//
break;
case GUI_EVENT_PAINT:
LcdBuffer_Write(&lcd, 0, 0, "==ZÁVLAHOVÝ CYKLUS==");
LcdBuffer_Write(&lcd, 1, 0, "Okruh 2/4 30/200s");
LcdBuffer_Write(&lcd, 2, 0, "█████████▌");
LcdBuffer_Write(&lcd, 3, 0, "🅳 Přerušit");
break;
case GUI_EVENT_KEY_D:
switch_screen(screen_home, true);
return;
}
}

@ -37,14 +37,36 @@ void screen_home(GuiEvent event)
}
break;
case GUI_EVENT_PAINT:;
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);
uint32_t moisture_pt = ((uint32_t)(moisture > 2800 ? 0 : (2800 - moisture)) * 100) / (2800 - 1600);
sprintf(stmp, "Vlhkost: %4d", moisture);
LcdBuffer_Write(&lcd, 2, 0, stmp);
sprintf(stmp, " %2d:%02d:%02d %3d%% 🌢 ", rtc_time.hour, rtc_time.minute, rtc_time.second, moisture_pt);
LcdBuffer_Write(&lcd, 0, 0, stmp);
LcdBuffer_Write(&lcd, 1, 0, "Plán. závlaha 7:15");
LcdBuffer_Write(&lcd, 2, 0, "❶Spustit ❷Přeskočit");
LcdBuffer_Write(&lcd, 3, 0, "🅰Nastavení");
// LcdBuffer_Write(&lcd, 1, 0, "❶ Spustit cyklus");
// LcdBuffer_Write(&lcd, 2, 0, "❷ Ruční řízení");
// LcdBuffer_Write(&lcd, 3, 0, "🅰 Nastavení");
// LcdBuffer_Write(&lcd, 1, 0, "🅰Program 🅱Poměry");
// LcdBuffer_Write(&lcd, 2, 0, "🅲Vlhkoměr 🅳Čas");
break;
case GUI_EVENT_KEY_1:
switch_screen(screen_cyklus, true);
break;
case GUI_EVENT_KEY_2:
// TODO
break;
case GUI_EVENT_KEY_A:
// TODO
break;
default:

Loading…
Cancel
Save