ui improvements

calib-gui
Ondřej Hruška 1 year ago
parent ccce0ff72f
commit 18655e437f
  1. 10
      Core/Src/Gui/app_gui.c
  2. 8
      Core/Src/Gui/app_gui.h
  3. 43
      Core/Src/Gui/screen_manual.c
  4. 35
      Core/Src/Gui/screen_manual_menu.c
  5. 2
      Lib/ufb/Inc/ufb/fb_text.h
  6. 17
      Lib/ufb/Src/fb_text.c
  7. 5
      Lib/ufb/Src/font_57.inc.c
  8. 9
      Lib/ufb/Src/fontedit_57.c
  9. 1
      Makefile

@ -14,6 +14,8 @@
#include "ufb/fb_text.h"
#include "app_safety.h"
struct State s_app = {};
/** Get push time (while held) */
uint32_t push_time() {
return s_app.pushed ? (xTaskGetTickCount() - s_app.push_time) : 0;
@ -28,7 +30,7 @@ void request_paint() {
/** Draw the common overlay / HUD (with temperatures and heater status) */
static void draw_common_overlay();
static char tmp[100];
char stmp[100];
/** Main loop */
void app_task_gui(void *argument) {
@ -132,11 +134,11 @@ void switch_screen(screen_t pScreen, bool init) {
/** Draw GUI common to all screens */
static void draw_common_overlay() {
SPRINTF(tmp, "%3.1f°C →%3d°C", s_app.oven_temp, s_app.set_temp);
fb_text(3, 3, tmp, FONT_3X5, 1);
SPRINTF(stmp, "%5.1f°C →%3d°C", s_app.oven_temp, s_app.set_temp);
fb_text(3, 3, stmp, FONT_3X5, 1);
if (s_app.heater_enabled) {
fb_frame(0, 0, FBW, 11, 2, 1);
fb_frame(0, 0, FBW, 11, 1, 1);
}
}

@ -9,6 +9,8 @@
#include <stdbool.h>
#include "gui_event.h"
extern char stmp[100];
void app_task_gui(void *argument);
@ -40,7 +42,7 @@ void screen_home(GuiEvent event);
void screen_manual(GuiEvent event);
void screen_manual_menu(GuiEvent event);
static struct State {
struct State {
/// Latest oven temp readout
float oven_temp;
//float soc_temp;
@ -89,6 +91,8 @@ static struct State {
uint8_t tick_counter;
} menu;
} page;
} s_app = {};
};
extern struct State s_app;
#endif //BLUEPILLTROUBA_APP_GUI_H

@ -10,6 +10,7 @@
#include "app_heater.h"
#include "ufb/fb_7seg.h"
#include "FreeRTOS.h"
#include "ufb/fb_text.h"
void screen_manual(GuiEvent event)
@ -27,10 +28,22 @@ void screen_manual(GuiEvent event)
switch (event) {
case GUI_EVENT_PAINT:
fb_7seg_number(4, 40, 12, 20, 2, 2,
fb_7seg_number(FBW/2 - ((12+2) * 3 - 2)/2, 36,
12, 20, 2, 2,
1,
s_app.set_temp, 3, 0
);
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);
break;
case GUI_EVENT_KNOB_RELEASE:
@ -61,31 +74,3 @@ void screen_manual(GuiEvent event)
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);
}

@ -0,0 +1,35 @@
//
// Created by MightyPork on 2023/04/09.
//
#include <stddef.h>
#include "app_gui.h"
#include "app_heater.h"
#include "screen_menu.h"
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);
}

@ -20,6 +20,8 @@
/// Print characters 2x wider and taller
#define FONT_DOUBLE (FONT_DOUBLEW | FONT_DOUBLEH)
#define TEXT_CENTER 32
/// Print text stored in flash
void fb_text_P(fbpos_t x, fbpos_t y, const char *text, uint8_t flags, fbcolor_t color);

@ -27,6 +27,21 @@ void fb_text_P_or_RAM(fbpos_t x, fbpos_t y, const char *text, uint8_t flags, fbc
symh = 7;
}
const uint8_t pxw = (flags & FONT_DOUBLEW) ? 2 : 1;
const uint8_t pxh = (flags & FONT_DOUBLEH) ? 2 : 1;
if (flags & TEXT_CENTER) {
size_t len = utf8_strlen(text);
if (len == 0) {
return;
}
uint8_t charw = (symw + 1 + ((flags & FONT_BOLD) ? 1 : 0)) * pxw;
len *= charw;
len -= pxw;
x -= (fbpos_t) (len / 2);
}
while ((uchar = Utf8Iterator_Next(&iter)).uint) {
const uint8_t *data;
if (flags & FONT_4X5) {
@ -64,8 +79,6 @@ void fb_text_P_or_RAM(fbpos_t x, fbpos_t y, const char *text, uint8_t flags, fbc
}
} else {
// slow, pixel-by-pixel drawing
const uint8_t pxw = (flags & FONT_DOUBLEW) ? 2 : 1;
const uint8_t pxh = (flags & FONT_DOUBLEH) ? 2 : 1;
for(fbpos_t xx = 0; xx < symw; xx++) {
uint8_t column = pgm_read_byte(&data[xx]);
for(fbpos_t yy = 0; yy < symh; yy++) {

@ -103,18 +103,19 @@ static const struct utf_glyph5x PROGMEM font57_extra[] = {
{.utf={.symbol=""}, {{0x08, 0x10, 0x3e, 0x10, 0x08}}},
{.utf={.symbol=""}, {{0x08, 0x1c, 0x2a, 0x08, 0x08}}},
{.utf={.symbol=""}, {{0x08, 0x08, 0x2a, 0x1c, 0x08}}},
{.utf={.symbol=""}, {{0x1c, 0x22, 0x2e, 0x2a, 0x1c}}},
{.utf={.symbol=""}, {{0x1c, 0x22, 0x2e, 0x2a, 0x1c}}},
{.utf={.symbol=""}, {{0x63, 0x55, 0x4d, 0x55, 0x63}}},
{.utf={.symbol=""}, {{0x1c, 0x22, 0x2a, 0x22, 0x1c}}},
{.utf={.symbol=""}, {{0x10, 0x38, 0x54, 0x10, 0x1e}}},
{.utf={.symbol="🌡"}, {{0x20, 0x7e, 0x79, 0x7e, 0x2a}}},
{.utf={.symbol="°"}, {{0x00, 0x07, 0x05, 0x07, 0x00}}},
{.utf={.symbol="μ"}, {{0x7c, 0x20, 0x20, 0x10, 0x3c}}},
{.utf={.symbol="🔙"}, {{0x04, 0x4e, 0x55, 0x44, 0x38}}},
{.utf={.symbol=""}, {{0x04, 0x4e, 0x55, 0x44, 0x38}}},
{.utf={.symbol=""}, {{0x7f, 0x3e, 0x1c, 0x08, 0x00}}},
{.utf={.symbol=""}, {{0x00, 0x08, 0x1c, 0x3e, 0x7f}}},
{.utf={.symbol="č"}, {{0x38, 0x45, 0x46, 0x45, 0x20}}},
{.utf={.symbol="š"}, {{0x48, 0x55, 0x56, 0x55, 0x20}}},
{.utf={.symbol="í"}, {{0x00, 0x44, 0x7d, 0x41, 0x00}}},
{.utf={.symbol="ž"}, {{0x44, 0x65, 0x56, 0x4d, 0x44}}},
{.utf={.symbol="»"}, {{0x22, 0x14, 0x2a, 0x14, 0x08}}},
};

@ -927,6 +927,14 @@ const char *font_extras[] = {
" # ",
" # ",
"#####",
// »
" ",
"x x ",
" x x ",
" x x",
" x x ",
"x x ",
" ",
};
const char *font_extras_utf[] = {
@ -950,6 +958,7 @@ const char *font_extras_utf[] = {
"š",
"í",
"ž",
"»",
};
#include "fontedit_render.inc.c"

@ -51,6 +51,7 @@ Core/Src/Gui/app_gui.c \
Core/Src/Gui/screen_menu.c \
Core/Src/Gui/screen_home.c \
Core/Src/Gui/screen_manual.c \
Core/Src/Gui/screen_manual_menu.c \
Core/Src/app_temp.c \
Core/Src/app_knob.c \
Core/Src/app_buzzer.c \

Loading…
Cancel
Save