diff --git a/Core/Inc/lcdio.h b/Core/Inc/lcdio.h index 78cfc33..fd830cc 100644 --- a/Core/Inc/lcdio.h +++ b/Core/Inc/lcdio.h @@ -7,6 +7,8 @@ #include +#include "stm32f1xx_hal.h" + #ifndef INC_LCDIO_H_ #define INC_LCDIO_H_ diff --git a/Core/Src/PSE_unit.c b/Core/Src/PSE_unit.c index 8147fe5..5450d8e 100644 --- a/Core/Src/PSE_unit.c +++ b/Core/Src/PSE_unit.c @@ -44,11 +44,10 @@ void load_units(pse_unit* units, pse_syringe* syringes, pse_stepper_conf* steppe // Open save file FIL saveFile; - char* filename; - if(asprintf(&filename, "PSEsave%d", ws_ind) == -1){ + char filename[16]; + if(snprintf(filename, 16, "PSEsave%d", ws_ind) == -1){ lv_obj_t * mbox1 = lv_msgbox_create(NULL, "Error", "Could not load configuration from SD card (filename gen error)", NULL, true); lv_obj_center(mbox1); - free(filename); return; } @@ -56,10 +55,8 @@ void load_units(pse_unit* units, pse_syringe* syringes, pse_stepper_conf* steppe lv_obj_t * mbox1 = lv_msgbox_create(NULL, "Error", "Could not load configuration from SD card", NULL, true); lv_obj_center(mbox1); generate_default_units(units, syringes, stepper_confs, stepper_status, home_displays, unit_num); - free(filename); return; } - free(filename); // read configuration sequentially for(int i = 0; i < unit_num; i++){ @@ -112,11 +109,10 @@ void save_units(pse_unit* units, uint8_t unit_num, uint16_t ws_ind){ // Open save file FIL saveFile; - char* filename; - if(asprintf(&filename, "PSEsave%d", ws_ind) == -1){ + char filename[16]; + if(snprintf(filename, 16, "PSEsave%u", ws_ind) == -1){ lv_obj_t * mbox1 = lv_msgbox_create(NULL, "Error", "Could not save configuration to SD card (filename gen error)", NULL, true); lv_obj_center(mbox1); - free(filename); return; } @@ -126,7 +122,6 @@ void save_units(pse_unit* units, uint8_t unit_num, uint16_t ws_ind){ lv_obj_t* text = lv_msgbox_get_text(mbox1); lv_label_set_text_fmt(text, "Could not save configuration to SD card (file open failed %d <%s>)", res, filename); lv_obj_center(mbox1); - free(filename); return; } @@ -143,7 +138,6 @@ 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){ diff --git a/Core/Src/PSE_unit_edit_screen.c b/Core/Src/PSE_unit_edit_screen.c index 29aa8cb..f665f63 100644 --- a/Core/Src/PSE_unit_edit_screen.c +++ b/Core/Src/PSE_unit_edit_screen.c @@ -44,7 +44,6 @@ static void back_button_handler(lv_event_t * e){ } else c_pse_unit->stepper_status->stop_at_limit = 0; - printf("dksfghjsdgf %d %d %d\n", c_pse_unit->stepper_status->stop_steps, c_pse_unit->stepper_status->steps_counter, c_pse_unit->start_pos); // go back to the main menu Home_Screen_Gen(c_pse_units, c_pse_units_num, true); @@ -96,7 +95,7 @@ lv_obj_t* volume_widget_label; static void update_volume(keypad_data* data){ pse_unit* unit = data->user_data; unit->set_volume = data->value; - 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%ld.%03lu/\n%ld.%03lu\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){ @@ -118,7 +117,7 @@ static void volume_readout_reset_handler(lv_event_t* 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); + lv_label_set_text_fmt(volume_widget_label, "Volume : \n%ld.%03lu/\n%ld.%03lu\nmL", c_pse_unit->volume / 1000, c_pse_unit->volume % 1000, c_pse_unit->set_volume / 1000, c_pse_unit->set_volume % 1000); } } @@ -133,7 +132,7 @@ static lv_obj_t* volume_widget(lv_obj_t* parent, pse_unit* unit){ lv_obj_t* vol = lv_label_create(cont); lv_obj_set_width(vol, lv_pct(100)); lv_obj_set_flex_grow(vol, 2); - 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); + lv_label_set_text_fmt(vol, "Volume : \n%ld.%03lu/\n%lu.%03lu\nmL", unit->volume / 1000, unit->volume % 1000, unit->set_volume / 1000, unit->set_volume % 1000); volume_widget_label = vol; // volume delivered reset button diff --git a/Core/Src/home_screen.c b/Core/Src/home_screen.c index 2dae9e7..cd0c637 100644 --- a/Core/Src/home_screen.c +++ b/Core/Src/home_screen.c @@ -37,7 +37,7 @@ void volume_readout_update(lv_timer_t* timer){ 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); + lv_label_set_text_fmt(disp->volume, "%ld.%.3d\nmL", volume / 1000, abs(volume) % 1000); } } } @@ -131,7 +131,7 @@ 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, "%u.%03u\nmL/mn", pse_unit->flow / 1000, pse_unit->flow % 1000); + lv_label_set_text_fmt(pse_unit->home_display->flow, "%lu.%03lu\nmL/mn", pse_unit->flow / 1000, pse_unit->flow % 1000); volume_readout_update(NULL); lv_obj_t* enabled = pse_unit->home_display->enabled; @@ -183,7 +183,7 @@ static lv_obj_t* PSE_unit_widget(lv_obj_t* parent, pse_unit* pse_unit){ lv_obj_set_width(flow, lv_pct(100)); lv_obj_set_flex_grow(flow, 1); lv_label_set_long_mode(flow, LV_LABEL_LONG_CLIP); - lv_label_set_text_fmt(flow, "%02u.%03u\nmL/mn", pse_unit->flow / 1000, pse_unit->flow % 1000); + lv_label_set_text_fmt(flow, "%02lu.%03lu\nmL/mn", pse_unit->flow / 1000, pse_unit->flow % 1000); pse_unit->home_display->flow = flow; // volume delivered readout @@ -191,7 +191,7 @@ static lv_obj_t* PSE_unit_widget(lv_obj_t* parent, pse_unit* pse_unit){ lv_obj_set_width(vol, lv_pct(100)); lv_obj_set_flex_grow(vol, 1); lv_label_set_long_mode(vol, LV_LABEL_LONG_CLIP); - lv_label_set_text_fmt(vol, "%d.%03u\nmL", pse_unit->volume / 1000, abs(pse_unit->volume) % 1000); + lv_label_set_text_fmt(vol, "%ld.%03d\nmL", pse_unit->volume / 1000, abs(pse_unit->volume) % 1000); pse_unit->home_display->volume = vol; // home button diff --git a/Core/Src/keypad_screen.c b/Core/Src/keypad_screen.c index d40767b..2ac81ed 100644 --- a/Core/Src/keypad_screen.c +++ b/Core/Src/keypad_screen.c @@ -56,7 +56,7 @@ static void keypress_handler(lv_event_t * e){ else if(txt[0] == 'X') value = 0; else value /= 10; - lv_label_set_text_fmt(value_readout, "%02d.%03d", value/1000, value%1000); + lv_label_set_text_fmt(value_readout, "%02ld.%03ld", value/1000, value%1000); } } @@ -84,10 +84,10 @@ void Keypad_screen_launch(keypad_data* data){ lv_label_set_text(back_label, LV_SYMBOL_LEFT); lv_obj_center(back_label); - // add a readout of the set value - value_readout = lv_label_create(top_menu); - lv_label_set_text_fmt(value_readout, "%02d.%03d", value/1000, value%1000); - lv_obj_center(value_readout); + // add a readout of the set value + value_readout = lv_label_create(top_menu); + lv_label_set_text_fmt(value_readout, "%02lu.%03lu", value/1000, value%1000); + lv_obj_center(value_readout); // add a validation button lv_obj_t* ok_button = lv_btn_create(top_menu); @@ -100,11 +100,11 @@ void Keypad_screen_launch(keypad_data* data){ lv_label_set_text(ok_label, LV_SYMBOL_OK); lv_obj_center(ok_label); - lv_obj_t * btnm1 = lv_btnmatrix_create(scr); - lv_btnmatrix_set_map(btnm1, btnm_map); + lv_obj_t * btnm1 = lv_btnmatrix_create(scr); + lv_btnmatrix_set_map(btnm1, btnm_map); lv_obj_align_to(btnm1, top_menu, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); lv_obj_set_size(btnm1, lv_pct(100), lv_pct(80)); - lv_obj_add_event_cb(btnm1, keypress_handler, LV_EVENT_ALL, NULL); + lv_obj_add_event_cb(btnm1, keypress_handler, LV_EVENT_ALL, NULL); - lv_scr_load(scr); + lv_scr_load(scr); } diff --git a/Core/Src/lcdio.c b/Core/Src/lcdio.c index a41f1d7..04a1f3b 100644 --- a/Core/Src/lcdio.c +++ b/Core/Src/lcdio.c @@ -39,6 +39,6 @@ void LCD_IO_WriteData(uint16_t RegValue) { *LCD_RAM = RegValue; } -uint16_t* LCD_IO_getDataPt(void){ +volatile uint16_t* LCD_IO_getDataPt(void){ return LCD_RAM; } diff --git a/Core/Src/main.c b/Core/Src/main.c index e7d52ec..ce996d8 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -141,10 +141,10 @@ static void MX_GPIO_Init(void); static void MX_DMA_Init(void); static void MX_FSMC_Init(void); static void MX_USART1_UART_Init(void); +static void MX_TIM4_Init(void); static void MX_SDIO_SD_Init(void); static void MX_TIM2_Init(void); static void MX_TIM3_Init(void); -static void MX_TIM4_Init(void); static void MX_TIM5_Init(void); /* USER CODE BEGIN PFP */ #ifdef __GNUC__ diff --git a/Core/Src/pse_stepper_planer.c b/Core/Src/pse_stepper_planer.c index 1c553f1..a84e972 100644 --- a/Core/Src/pse_stepper_planer.c +++ b/Core/Src/pse_stepper_planer.c @@ -70,11 +70,10 @@ void pse_stepper_planer_compute_sps(pse_unit* unit){ uint64_t res = numerator / denominator; uint64_t min_scale = PSE_STEPPER_TIMER_CLOCK * 1000 / (2 * PSE_STEPPER_WARN_MAX_KSPS); - printf("min scale %lu\n", min_scale); if(res < min_scale){ lv_obj_t * mbox1 = lv_msgbox_create(NULL, "WARNING", "aaa", NULL, true); lv_obj_t* text = lv_msgbox_get_text(mbox1); - lv_label_set_text_fmt(text, "Fast movement selected, this may lead to undefined behavior (%lu ksps)", PSE_STEPPER_TIMER_CLOCK * 1000 / res); + lv_label_set_text_fmt(text, "Fast movement selected, this may lead to undefined behavior (%llu ksps)", PSE_STEPPER_TIMER_CLOCK * 1000 / res); lv_obj_center(mbox1); return; } diff --git a/PSE.ioc b/PSE.ioc index d92679e..a690409 100644 --- a/PSE.ioc +++ b/PSE.ioc @@ -338,4 +338,4 @@ VP_TIM4_VS_ClockSourceINT.Signal=TIM4_VS_ClockSourceINT VP_TIM5_VS_ClockSourceINT.Mode=Internal VP_TIM5_VS_ClockSourceINT.Signal=TIM5_VS_ClockSourceINT board=custom -isbadioc=true +isbadioc=false