dummy volume delired readout

This commit is contained in:
leo 2023-09-13 18:09:20 +02:00
parent 654ad8baad
commit 7bcb3a7afa
Signed by: leo
GPG Key ID: 0DD993BFB2B307DB
4 changed files with 38 additions and 5 deletions

View File

@ -49,11 +49,13 @@ typedef struct{
uint8_t enabled;
pse_ports port; // physical port on which this unit is connected
uint32_t flow; // flow (in µL.min-1)
uint32_t volume; // current volume dispensed (in µL)
int32_t volume; // current volume dispensed (in µL)
uint32_t set_volume; // volume to stop at (0 for no max)
pse_syringe* syringe; // associated syringe
pse_stepper_conf* stepper_conf; // hardware configuration for the associated stepper
pse_home_display* home_display; // Widgets for updating the home screen
int32_t start_pos; // movement start position for volume calculation
uint32_t nL_per_step; // pL delivered per step
} pse_unit;
@ -61,4 +63,6 @@ void load_units(pse_unit* units, pse_syringe* syringes, pse_stepper_conf* steppe
void load_units_short(pse_unit* units, uint8_t unit_num, uint16_t ws_ind);
void save_units(pse_unit* units, uint8_t unit_num, uint16_t ws_ind);
void pse_unit_compute_volume_delivered(pse_unit* unit);
void pse_unit_compute_volume_per_step(pse_unit* unit);
#endif

View File

@ -121,3 +121,11 @@ void save_units(pse_unit* units, uint8_t unit_num, uint16_t ws_ind){
f_close(&saveFile);
free(filename);
}
void pse_unit_compute_volume_delivered(pse_unit* unit){
unit->volume = (int64_t)1 * (unit->stepper_conf->steps_counter - unit->start_pos) * unit->nL_per_step / 1000;
}
void pse_unit_compute_volume_per_step(pse_unit* unit){
unit->nL_per_step = 10;
}

View File

@ -33,6 +33,9 @@ static void back_button_handler(lv_event_t * e){
// update stepper pwm generation
pse_stepper_planer_compute_sps(c_pse_unit);
// compute volume delivered per steps
pse_unit_compute_volume_per_step(c_pse_unit);
// go back to the main menu
Home_Screen_Gen(c_pse_units, c_pse_units_num, true);
}

View File

@ -7,6 +7,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "lvgl.h"
@ -20,6 +21,19 @@ static int units_num;
static uint16_t workspace_index = 0;
static lv_obj_t* ws_label;
static lv_timer_t* volume_readout_update_timer;
void volume_readout_update(lv_timer_t* timer){
for(int i = 0; i < units_num; i++){
if(units[i].enabled){
pse_home_display* disp = units[i].home_display;
pse_unit_compute_volume_delivered(&units[i]);
int32_t volume = units[i].volume;
lv_label_set_text_fmt(disp->volume, "%d.%.3lu\nmL", volume / 1000, abs(volume) % 1000);
}
}
}
static void run_handler(lv_event_t * e){
lv_event_code_t code = lv_event_get_code(e);
@ -31,10 +45,13 @@ static void run_handler(lv_event_t * e){
lv_label_set_text(label, LV_SYMBOL_PAUSE);
pse_sp_set_dir_all(units, units_num, 1);
pse_sp_start_all(units, units_num);
volume_readout_update_timer = lv_timer_create(volume_readout_update, 100, NULL);
}
else{
lv_label_set_text(label, LV_SYMBOL_PLAY);
pse_sp_stop_all(units, units_num);
lv_timer_del(volume_readout_update_timer);
}
}
}
@ -84,6 +101,7 @@ 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) {
if(volume_readout_update_timer != NULL) lv_timer_del(volume_readout_update_timer);
pse_unit* unit = lv_event_get_user_data(e);
PSE_unit_edit_screen_Gen(units, unit, units_num, workspace_index);
}
@ -92,8 +110,8 @@ static void unit_widget_clicked_handler(lv_event_t* e){
static void update_readouts_widgets(){
for(int i = 0; i < units_num; i++){
pse_unit* pse_unit = &units[i];
lv_label_set_text_fmt(pse_unit->home_display->flow, "%02lu.%03lu\nmL/mn", pse_unit->flow / 1000, pse_unit->flow % 1000);
lv_label_set_text_fmt(pse_unit->home_display->volume, "%lu.%lu\nmL", pse_unit->volume / 1000, pse_unit->volume % 1000);
lv_label_set_text_fmt(pse_unit->home_display->flow, "%u.%03u\nmL/mn", pse_unit->flow / 1000, pse_unit->flow % 1000);
// lv_label_set_text_fmt(pse_unit->home_display->volume, "%lu.%lu\nmL", pse_unit->volume / 1000, pse_unit->volume % 1000);
lv_obj_t* enabled = pse_unit->home_display->enabled;
lv_obj_t* enabled_label = lv_obj_get_child(enabled, 0);
@ -143,14 +161,14 @@ static lv_obj_t* PSE_unit_widget(lv_obj_t* parent, pse_unit* pse_unit){
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, "%02lu.%03lu\nmL/mn", pse_unit->flow / 1000, pse_unit->flow % 1000);
lv_label_set_text_fmt(flow, "%02u.%03u\nmL/mn", pse_unit->flow / 1000, pse_unit->flow % 1000);
pse_unit->home_display->flow = flow;
// volume delivered readout
lv_obj_t* vol = lv_label_create(cont);
lv_obj_set_width(vol, lv_pct(100));
lv_obj_set_flex_grow(vol, 1);
lv_label_set_text_fmt(vol, "%lu.%lu\nmL", pse_unit->volume / 1000, pse_unit->volume % 1000);
lv_label_set_text_fmt(vol, "%d.%03u\nmL", pse_unit->volume / 1000, abs(pse_unit->volume) % 1000);
pse_unit->home_display->volume = vol;
// home button