volume delivered reset button
This commit is contained in:
parent
cfa69448cc
commit
e0781317a2
@ -5,7 +5,6 @@
|
|||||||
* Author: leo
|
* Author: leo
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <src/core/lv_disp.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@ -95,7 +94,8 @@ lv_obj_t* volume_widget_label;
|
|||||||
static void update_volume(keypad_data* data){
|
static void update_volume(keypad_data* data){
|
||||||
pse_unit* unit = data->user_data;
|
pse_unit* unit = data->user_data;
|
||||||
unit->set_volume = data->value;
|
unit->set_volume = data->value;
|
||||||
lv_label_set_text_fmt(volume_widget_label, "Volume : \n%lu.%lu\nmL", unit->set_volume / 1000, unit->set_volume % 1000);
|
lv_label_set_text_fmt(volume_widget_label, "Volume : \n%u.%03u/\n%u.%03u\nmL", unit->volume / 1000, unit->volume % 1000, unit->set_volume / 1000, unit->set_volume % 1000);
|
||||||
|
// lv_label_set_text_fmt(volume_widget_label, "Volume : \n%lu.%lu\nmL", unit->set_volume / 1000, unit->set_volume % 1000);
|
||||||
}
|
}
|
||||||
static void volume_edit_handler(lv_event_t* e){
|
static void volume_edit_handler(lv_event_t* e){
|
||||||
lv_event_code_t code = lv_event_get_code(e);
|
lv_event_code_t code = lv_event_get_code(e);
|
||||||
@ -110,6 +110,16 @@ static void volume_edit_handler(lv_event_t* e){
|
|||||||
Keypad_screen_launch(&kp_data);
|
Keypad_screen_launch(&kp_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static void volume_readout_reset_handler(lv_event_t* e){
|
||||||
|
lv_event_code_t code = lv_event_get_code(e);
|
||||||
|
|
||||||
|
if(code == LV_EVENT_CLICKED){
|
||||||
|
c_pse_unit->start_pos = c_pse_unit->stepper_status->steps_counter;
|
||||||
|
pse_unit_compute_volume_delivered(c_pse_unit);
|
||||||
|
lv_label_set_text_fmt(volume_widget_label, "Volume : \n%u.%03u/\n%u.%03u\nmL", c_pse_unit->volume / 1000, c_pse_unit->volume % 1000, c_pse_unit->set_volume / 1000, c_pse_unit->set_volume % 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static lv_obj_t* volume_widget(lv_obj_t* parent, pse_unit* unit){
|
static lv_obj_t* volume_widget(lv_obj_t* parent, pse_unit* unit){
|
||||||
// The main container
|
// The main container
|
||||||
lv_obj_t* cont = lv_obj_create(parent);
|
lv_obj_t* cont = lv_obj_create(parent);
|
||||||
@ -120,9 +130,20 @@ static lv_obj_t* volume_widget(lv_obj_t* parent, pse_unit* unit){
|
|||||||
// volume setting
|
// volume setting
|
||||||
lv_obj_t* vol = lv_label_create(cont);
|
lv_obj_t* vol = lv_label_create(cont);
|
||||||
lv_obj_set_width(vol, lv_pct(100));
|
lv_obj_set_width(vol, lv_pct(100));
|
||||||
lv_obj_set_flex_grow(vol, 1);
|
lv_obj_set_flex_grow(vol, 2);
|
||||||
lv_label_set_text_fmt(vol, "Volume : \n%lu.%lu\nmL", unit->set_volume / 1000, unit->set_volume % 1000);
|
lv_label_set_text_fmt(vol, "Volume : \n%u.%03u/\n%u.%03u\nmL", unit->volume / 1000, unit->volume % 1000, unit->set_volume / 1000, unit->set_volume % 1000);
|
||||||
volume_widget_label = vol;
|
volume_widget_label = vol;
|
||||||
|
|
||||||
|
// volume delivered reset button
|
||||||
|
lv_obj_t* vol_reset = lv_btn_create(cont);
|
||||||
|
lv_obj_set_width(vol_reset, lv_pct(100));
|
||||||
|
lv_obj_add_event_cb(vol_reset, volume_readout_reset_handler, LV_EVENT_ALL, NULL);
|
||||||
|
lv_obj_set_flex_grow(vol_reset, 1);
|
||||||
|
|
||||||
|
lv_obj_t* vol_reset_label = lv_label_create(vol_reset);
|
||||||
|
lv_obj_center(vol_reset_label);
|
||||||
|
lv_label_set_text(vol_reset_label, LV_SYMBOL_REFRESH);
|
||||||
|
|
||||||
return cont;
|
return cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user