From 716d7ad30fdfe4c754748d81220ad82e2c774eb2 Mon Sep 17 00:00:00 2001 From: kraus Date: Mon, 20 Sep 2021 11:03:17 +0200 Subject: [PATCH] 2.31.2 --- README.md | 2 +- extras/ChangeLog | 3 ++ library.properties | 2 +- src/clib/mui.c | 5 +++ src/clib/mui_u8g2.c | 80 +++++++++++++++++++++++++++++++++++++++++---- src/clib/mui_u8g2.h | 7 ++-- 6 files changed, 89 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 771e6274..fd0629c0 100644 --- a/README.md +++ b/README.md @@ -8,5 +8,5 @@ Description: https://github.com/olikraus/u8g2/wiki Issue Tracker: https://github.com/olikraus/u8g2/issues -Download (2.31.1): https://github.com/olikraus/U8g2_Arduino/archive/master.zip +Download (2.31.2): https://github.com/olikraus/U8g2_Arduino/archive/master.zip diff --git a/extras/ChangeLog b/extras/ChangeLog index 48afc98b..6645f438 100644 --- a/extras/ChangeLog +++ b/extras/ChangeLog @@ -271,3 +271,6 @@ https://github.com/olikraus/u8g2 ChangeLog * Bugfix drawButtonUTF8 (added C++ code, issue 1577) 2021-09-19 v2.31.1 olikraus@gmail.com * Added icons from https://app.streamlinehq.com/icons/pixel (issue 1589) +2021-09-20 v2.31.2 olikraus@gmail.com + * Bugfix release for include error (issues 1592 and 1594) + diff --git a/library.properties b/library.properties index 5976f577..b1c9d286 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=U8g2 -version=2.31.1 +version=2.31.2 author=oliver maintainer=oliver sentence=Monochrome LCD, OLED and eInk Library. Display controller: SSD1305, SSD1306, SSD1309, SSD1316, SSD1320, SSD1322, SSD1325, SSD1327, SSD1329, SSD1606, SSD1607, SH1106, SH1107, SH1108, SH1122, T6963, RA8835, LC7981, PCD8544, PCF8812, HX1230, UC1601, UC1604, UC1608, UC1610, UC1611, UC1617, UC1638, UC1701, ST7511, ST7528, ST7565, ST7567, ST7571, ST7586, ST7588, ST75256, ST75320, NT7534, ST7920, IST3020, IST7920, LD7032, KS0108, KS0713, HD44102, T7932, SED1520, SBN1661, IL3820, MAX7219. Interfaces: I2C, SPI, Parallel. diff --git a/src/clib/mui.c b/src/clib/mui.c index 33fc0356..d147d50e 100644 --- a/src/clib/mui.c +++ b/src/clib/mui.c @@ -717,6 +717,11 @@ void mui_EnterForm(mui_t *ui, fds_t *fds, uint8_t initial_cursor_position) ui->touch_focus_fds = NULL; ui->cursor_focus_fds = NULL; + /* reset all the scoll values */ + ui->form_scroll_top = 0; + ui->form_scroll_visible = 0; + ui->form_scroll_total = 0; + /* assign the form, which should be entered */ ui->current_form_fds = fds; diff --git a/src/clib/mui_u8g2.c b/src/clib/mui_u8g2.c index 32d23475..17b59c91 100644 --- a/src/clib/mui_u8g2.c +++ b/src/clib/mui_u8g2.c @@ -782,7 +782,7 @@ uint8_t mui_u8g2_u8_opt_line_wa_mse_pi(mui_t *ui, uint8_t msg) { *value = 0; mui_fds_get_nth_token(ui, *value); - } + } mui_u8g2_draw_button_utf(ui, mui_u8g2_get_draw_button_pi_flags(ui), ui->arg, 1, MUI_U8G2_V_PADDING, ui->text); //u8g2_DrawButtonUTF8(u8g2, mui_get_x(ui), mui_get_y(ui), mui_u8g2_get_draw_button_pi_flags(ui), ui->arg, 1, MUI_U8G2_V_PADDING, ui->text); @@ -1042,13 +1042,14 @@ uint8_t mui_u8g2_u8_opt_child_mse_common(mui_t *ui, uint8_t msg) break; case MUIF_MSG_FORM_START: /* we can assume that the list starts at the top. It will be adjisted by cursor down events later */ - ui->form_scroll_top = 0; + /* ui->form_scroll_top = 0 and all other form_scroll values are set to 0 if a new form is entered in mui_EnterForm() */ if ( ui->form_scroll_visible <= arg ) ui->form_scroll_visible = arg+1; if ( ui->form_scroll_total == 0 ) ui->form_scroll_total = mui_GetSelectableFieldOptionCnt(ui, ui->last_form_id, ui->last_form_cursor_focus_position); + //printf("MUIF_MSG_FORM_START: arg=%d visible=%d top=%d total=%d\n", arg, ui->form_scroll_visible, ui->form_scroll_top, ui->form_scroll_total); break; - case MUIF_MSG_FORM_END: + case MUIF_MSG_FORM_END: break; case MUIF_MSG_CURSOR_ENTER: break; @@ -1063,7 +1064,7 @@ uint8_t mui_u8g2_u8_opt_child_mse_common(mui_t *ui, uint8_t msg) case MUIF_MSG_TOUCH_UP: break; case MUIF_MSG_EVENT_NEXT: - //printf("MUIF_MSG_EVENT_NEXT: arg=%d form_scroll_visible=%d\n", arg, ui->form_scroll_visible); + //printf("MUIF_MSG_EVENT_NEXT: arg=%d visible=%d top=%d total=%d\n", arg, ui->form_scroll_visible, ui->form_scroll_top, ui->form_scroll_total); if ( arg+1 == ui->form_scroll_visible ) { if ( ui->form_scroll_visible + ui->form_scroll_top < ui->form_scroll_total ) @@ -1096,7 +1097,7 @@ uint8_t mui_u8g2_u8_opt_child_mse_common(mui_t *ui, uint8_t msg) } -uint8_t mui_u8g2_u8_opt_child_wm_mse_pi(mui_t *ui, uint8_t msg) +uint8_t mui_u8g2_u8_opt_radio_child_wm_mse_pi(mui_t *ui, uint8_t msg) { u8g2_t *u8g2 = mui_get_U8g2(ui); uint8_t *value = (uint8_t *)muif_get_data(ui->uif); @@ -1141,7 +1142,7 @@ uint8_t mui_u8g2_u8_opt_child_wm_mse_pi(mui_t *ui, uint8_t msg) } -uint8_t mui_u8g2_u8_opt_child_w1_mse_pi(mui_t *ui, uint8_t msg) +uint8_t mui_u8g2_u8_opt_radio_child_w1_mse_pi(mui_t *ui, uint8_t msg) { u8g2_t *u8g2 = mui_get_U8g2(ui); uint8_t *value = (uint8_t *)muif_get_data(ui->uif); @@ -1186,6 +1187,45 @@ uint8_t mui_u8g2_u8_opt_child_w1_mse_pi(mui_t *ui, uint8_t msg) return 0; } + +uint8_t mui_u8g2_u8_opt_child_wm_mse_pi(mui_t *ui, uint8_t msg) +{ + u8g2_t *u8g2 = mui_get_U8g2(ui); + //uint8_t *value = (uint8_t *)muif_get_data(ui->uif); + uint8_t arg = ui->arg; // remember the arg value, because it might be overwritten + + switch(msg) + { + case MUIF_MSG_DRAW: + { + //u8g2_uint_t w = 0; + u8g2_uint_t x = mui_get_x(ui); // if mui_GetSelectableFieldTextOption is called, then field vars are overwritten, so get the value + u8g2_uint_t y = mui_get_y(ui); // if mui_GetSelectableFieldTextOption is called, then field vars are overwritten, so get the value + uint8_t flags = mui_u8g2_get_draw_button_pi_flags(ui); + //if ( mui_IsCursorFocus(ui) ) + //{ + // flags = U8G2_BTN_INV; + //} + + if ( ui->text[0] == '\0' ) + { + /* if the text is not provided, then try to get the text from the previous (saved) element, assuming that this contains the selection */ + /* this will overwrite all ui member functions, so we must not access any ui members (except ui->text) any more */ + mui_GetSelectableFieldTextOption(ui, ui->last_form_id, ui->last_form_cursor_focus_position, arg + ui->form_scroll_top); + } + if ( ui->text[0] != '\0' ) + { + u8g2_DrawButtonUTF8(u8g2, x, y, flags, 0, 1, MUI_U8G2_V_PADDING, ui->text); + } + } + break; + default: + return mui_u8g2_u8_opt_child_mse_common(ui, msg); + } + return 0; +} + + /* data: mui_u8g2_list_t * */ @@ -1424,3 +1464,31 @@ uint8_t mui_u8g2_u16_list_child_w1_mse_pi(mui_t *ui, uint8_t msg) } return 0; } + +uint8_t mui_u8g2_u16_list_goto_w1_mse_pi(mui_t *ui, uint8_t msg) +{ + u8g2_t *u8g2 = mui_get_U8g2(ui); + mui_u8g2_list_t *list = (mui_u8g2_list_t *)muif_get_data(ui->uif); + uint16_t *selection = mui_u8g2_list_get_selection_ptr(list); + void *data = mui_u8g2_list_get_data_ptr(list); + mui_u8g2_get_list_element_cb element_cb = mui_u8g2_list_get_element_cb(list); + //mui_u8g2_get_list_count_cb count_cb = mui_u8g2_list_get_count_cb(list); + + uint16_t pos = ui->arg; // remember the arg value, because it might be overwritten + pos += ui->form_scroll_top; + + switch(msg) + { + case MUIF_MSG_DRAW: + mui_u8g2_draw_button_utf(ui, mui_u8g2_get_draw_button_pi_flags(ui), u8g2_GetDisplayWidth(u8g2), 1, MUI_U8G2_V_PADDING, element_cb(data, pos)+1); + break; + case MUIF_MSG_CURSOR_SELECT: + if ( selection != NULL ) + *selection = pos; + mui_GotoForm(ui, (uint8_t)element_cb(data, pos)[0], 0); + break; + default: + return mui_u8g2_u16_list_child_mse_common(ui, msg); + } + return 0; +} diff --git a/src/clib/mui_u8g2.h b/src/clib/mui_u8g2.h index 0eb742c4..3f74ae78 100644 --- a/src/clib/mui_u8g2.h +++ b/src/clib/mui_u8g2.h @@ -38,7 +38,7 @@ #ifndef MUI_U8G2_H #define MUI_U8G2_H -#include +#include "mui.h" /*==========================================*/ /* C++ compatible */ @@ -130,8 +130,9 @@ uint8_t mui_u8g2_u8_opt_line_wa_mse_pi(mui_t *ui, uint8_t msg); uint8_t mui_u8g2_u8_opt_line_wa_mud_pi(mui_t *ui, uint8_t msg); uint8_t mui_u8g2_u8_opt_parent_wm_mse_pi(mui_t *ui, uint8_t msg); +uint8_t mui_u8g2_u8_opt_radio_child_wm_mse_pi(mui_t *ui, uint8_t msg); +uint8_t mui_u8g2_u8_opt_radio_child_w1_mse_pi(mui_t *ui, uint8_t msg); uint8_t mui_u8g2_u8_opt_child_wm_mse_pi(mui_t *ui, uint8_t msg); -uint8_t mui_u8g2_u8_opt_child_w1_mse_pi(mui_t *ui, uint8_t msg); uint8_t mui_u8g2_u8_chkbox_wm_pi(mui_t *ui, uint8_t msg); uint8_t mui_u8g2_u8_radio_wm_pi(mui_t *ui, uint8_t msg); @@ -165,6 +166,8 @@ uint8_t mui_u8g2_u16_list_line_wa_mud_pi(mui_t *ui, uint8_t msg); uint8_t mui_u8g2_u16_list_parent_wm_mse_pi(mui_t *ui, uint8_t msg); uint8_t mui_u8g2_u16_list_child_w1_mse_pi(mui_t *ui, uint8_t msg); +uint8_t mui_u8g2_u16_list_goto_w1_mse_pi(mui_t *ui, uint8_t msg); /* first char of the string denotes the target form */ + #ifdef __cplusplus }