PSE unit edit screen + switched to 12pt font
This commit is contained in:
parent
30d3f5c351
commit
db11ea6c46
15
Core/Inc/PSE_unit_edit_screen.h
Normal file
15
Core/Inc/PSE_unit_edit_screen.h
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* PSE_unit_edit_screen.h
|
||||
*
|
||||
* Created on: Aug 10, 2023
|
||||
* Author: leo
|
||||
*/
|
||||
|
||||
#ifndef INC_PSE_EDIT_SCREEN_H_
|
||||
#define INC_PSE_EDIT_SCREEN_H_
|
||||
|
||||
#include "PSE_unit.h"
|
||||
|
||||
void PSE_unit_edit_screen_Gen(lv_obj_t* parent, pse_unit* unit);
|
||||
|
||||
#endif /* INC_PSE_EDIT_SCREEN_H_ */
|
@ -13,7 +13,7 @@ void load_units(pse_unit* units, uint8_t unit_num){
|
||||
units[i] = (pse_unit){
|
||||
.enabled = i%2,
|
||||
.port = i,
|
||||
.flow = 1500,
|
||||
.flow = 1500*i,
|
||||
.volume = 0,
|
||||
.set_volume = 0,
|
||||
};
|
||||
|
83
Core/Src/PSE_unit_edit_screen.c
Normal file
83
Core/Src/PSE_unit_edit_screen.c
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* home_screen.c
|
||||
*
|
||||
* Created on: Aug 7, 2023
|
||||
* Author: leo
|
||||
*/
|
||||
|
||||
#include <src/core/lv_disp.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "PSE_unit_edit_screen.h"
|
||||
|
||||
#include "PSE_unit.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
static lv_obj_t* parent_screen;
|
||||
|
||||
static void back_button_handler(lv_event_t * e){
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
// Save
|
||||
lv_scr_load_anim(parent_screen, LV_SCR_LOAD_ANIM_FADE_ON, 100, 100, true);
|
||||
}
|
||||
}
|
||||
|
||||
static lv_coord_t widg_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
static lv_coord_t widg_row_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
static lv_obj_t* flow_widget(lv_obj_t* parent, pse_unit* unit){
|
||||
// The main container
|
||||
lv_obj_t* cont = lv_obj_create(parent);
|
||||
lv_obj_set_size(cont, lv_pct(24), lv_pct(100));
|
||||
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_COLUMN);
|
||||
// lv_obj_add_event_cb(cont, unit_widget_clicked_handler, LV_EVENT_ALL, pse_unit);
|
||||
|
||||
// flow setting
|
||||
lv_obj_t* flow = lv_label_create(cont);
|
||||
lv_obj_set_width(flow, lv_pct(100));
|
||||
lv_obj_set_flex_grow(flow, 1);
|
||||
lv_label_set_text_fmt(flow, "Debit : \n%d.%d\nmL/mn", unit->flow / 1000, unit->flow % 1000);
|
||||
return cont;
|
||||
}
|
||||
|
||||
void PSE_unit_edit_screen_Gen(lv_obj_t* parent, pse_unit* unit){
|
||||
parent_screen = parent;
|
||||
// Create a new screen
|
||||
lv_obj_t* scr = lv_obj_create(NULL);
|
||||
|
||||
// create the top menu on the top 20%
|
||||
lv_obj_t* top_menu = lv_obj_create(scr);
|
||||
lv_obj_set_align(top_menu, LV_ALIGN_TOP_LEFT);
|
||||
lv_obj_set_size(top_menu, lv_pct(100), lv_pct(20));
|
||||
lv_obj_set_style_pad_all(top_menu, 5, 0);
|
||||
|
||||
// add a back button
|
||||
lv_obj_t* back_button = lv_btn_create(top_menu);
|
||||
lv_obj_set_size(back_button, lv_pct(10), lv_pct(100));
|
||||
lv_obj_set_align(back_button, LV_ALIGN_TOP_LEFT);
|
||||
lv_obj_add_event_cb(back_button, back_button_handler, LV_EVENT_ALL, NULL);
|
||||
|
||||
// add the back label
|
||||
lv_obj_t* back_label = lv_label_create(back_button);
|
||||
lv_label_set_text(back_label, LV_SYMBOL_LEFT);
|
||||
lv_obj_center(back_label);
|
||||
|
||||
// grid layout for the widgets
|
||||
lv_obj_t* units_grid = lv_obj_create(scr);
|
||||
lv_obj_align_to(units_grid, top_menu, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
||||
lv_obj_set_size(units_grid, lv_pct(100), lv_pct(80));
|
||||
lv_obj_set_style_pad_all(units_grid, 5, 0);
|
||||
lv_obj_set_layout(units_grid, LV_LAYOUT_GRID);
|
||||
|
||||
lv_obj_set_grid_dsc_array(units_grid, widg_col_dsc, widg_row_dsc);
|
||||
|
||||
// Flow widget
|
||||
lv_obj_t* obj = flow_widget(units_grid, unit);
|
||||
lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
|
||||
// fade in the new screen
|
||||
lv_scr_load_anim(scr, LV_SCR_LOAD_ANIM_FADE_ON, 100, 100, false);
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
#include "lvgl.h"
|
||||
|
||||
#include "PSE_unit.h"
|
||||
#include "PSE_unit_edit_screen.h"
|
||||
|
||||
static void run_handler(lv_event_t * e){
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
@ -31,6 +32,7 @@ static void run_handler(lv_event_t * e){
|
||||
static lv_coord_t units_col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
static lv_coord_t units_row_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
static lv_obj_t* screen;
|
||||
|
||||
static void unit_widget_enabled_handler(lv_event_t * e){
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
@ -48,17 +50,27 @@ static void unit_widget_enabled_handler(lv_event_t * e){
|
||||
}
|
||||
}
|
||||
|
||||
static void unit_widget_clicked_handler(lv_event_t* e){
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
|
||||
if(code == LV_EVENT_CLICKED) {
|
||||
pse_unit* unit = lv_event_get_user_data(e);
|
||||
PSE_unit_edit_screen_Gen(screen, unit);
|
||||
}
|
||||
}
|
||||
|
||||
static lv_obj_t* PSE_unit_widget(lv_obj_t* parent, pse_unit* pse_unit){
|
||||
// The main container
|
||||
lv_obj_t* cont = lv_obj_create(parent);
|
||||
lv_obj_set_size(cont, lv_pct(24), lv_pct(100));
|
||||
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_add_event_cb(cont, unit_widget_clicked_handler, LV_EVENT_ALL, pse_unit);
|
||||
|
||||
// flow setting
|
||||
lv_obj_t* flow = lv_label_create(cont);
|
||||
lv_obj_set_width(flow, lv_pct(100));
|
||||
lv_obj_set_flex_grow(flow, 1);
|
||||
lv_label_set_text_fmt(flow, "%d.%d\nmL/mn", pse_unit->flow / 1000, pse_unit->flow % 1000);
|
||||
lv_label_set_text_fmt(flow, "%02d.%03d\nmL/mn", pse_unit->flow / 1000, pse_unit->flow % 1000);
|
||||
|
||||
// volume delivered readout
|
||||
lv_obj_t* vol = lv_label_create(cont);
|
||||
@ -92,6 +104,7 @@ static lv_obj_t* PSE_unit_widget(lv_obj_t* parent, pse_unit* pse_unit){
|
||||
void Home_Screen_Gen(pse_unit* pse_units, uint8_t pse_unit_num){
|
||||
// Create a new screen
|
||||
lv_obj_t* scr = lv_obj_create(NULL);
|
||||
screen = scr;
|
||||
|
||||
// create the top menu on the top 20%
|
||||
lv_obj_t* top_menu = lv_obj_create(scr);
|
||||
|
@ -49,7 +49,7 @@
|
||||
#define LV_MEM_CUSTOM 0
|
||||
#if LV_MEM_CUSTOM == 0
|
||||
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
|
||||
#define LV_MEM_SIZE (16U * 1024U) /*[bytes]*/
|
||||
#define LV_MEM_SIZE (32U * 1024U) /*[bytes]*/
|
||||
|
||||
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
|
||||
#define LV_MEM_ADR 0 /*0: unused*/
|
||||
@ -327,8 +327,8 @@
|
||||
*https://fonts.google.com/specimen/Montserrat*/
|
||||
#define LV_FONT_MONTSERRAT_8 0
|
||||
#define LV_FONT_MONTSERRAT_10 0
|
||||
#define LV_FONT_MONTSERRAT_12 0
|
||||
#define LV_FONT_MONTSERRAT_14 1
|
||||
#define LV_FONT_MONTSERRAT_12 1
|
||||
#define LV_FONT_MONTSERRAT_14 0
|
||||
#define LV_FONT_MONTSERRAT_16 0
|
||||
#define LV_FONT_MONTSERRAT_18 0
|
||||
#define LV_FONT_MONTSERRAT_20 0
|
||||
@ -363,7 +363,7 @@
|
||||
#define LV_FONT_CUSTOM_DECLARE
|
||||
|
||||
/*Always set a default font*/
|
||||
#define LV_FONT_DEFAULT &lv_font_montserrat_14
|
||||
#define LV_FONT_DEFAULT &lv_font_montserrat_12
|
||||
|
||||
/*Enable handling large font and/or fonts with a lot of characters.
|
||||
*The limit depends on the font size, font face and bpp.
|
||||
@ -538,7 +538,7 @@
|
||||
#if LV_USE_THEME_DEFAULT
|
||||
|
||||
/*0: Light mode; 1: Dark mode*/
|
||||
#define LV_THEME_DEFAULT_DARK 1
|
||||
#define LV_THEME_DEFAULT_DARK 0
|
||||
|
||||
/*1: Enable grow on press*/
|
||||
#define LV_THEME_DEFAULT_GROW 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user