-
Hi! On M2TK lib I could do something like this: How to do something similar to this in MUI? I have a global variable holding my motor speed value and I would like to calculate a new PWM duty everytime a change occurs. Also, how to get which form is active as in m2_GetRoot()? Edit: typo |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I could just user variables to track these changes, but I think probably this isn't the best way to do this, but after reading the MUI help I didn't found it. Please, any help would be greatly appreciated 👍 |
Beta Was this translation helpful? Give feedback.
-
You could extend an existing MUIF. Lets take this list of functions: u8g2/sys/arduino/u8g2_page_buffer/MUICountDown/MUICountDown.ino Lines 347 to 359 in d987608 More specific, lets get change events from "mui_u8g2_u8_min_max_wm_mse_pi", which is defined here: Line 727 in d987608 In this case we will first call the original function and then listen and react on the events which modify the value. uint8_t my_mui_u8g2_u8_min_max_wm_mse_pi(mui_t *ui, uint8_t msg)
{
uint8_t result = mui_u8g2_u8_min_max_wm_mse_pi(ui, msg); // call original function
if ( msg == MUIF_MSG_CURSOR_SELECT || msg == MUIF_MSG_VALUE_INCREMENT || msg == MUIF_MSG_VALUE_DECREMENT )
{
... // value has changed, do something special
}
return result;
} Then of course, in the MUIF list you have to use your own function: muif_t muif_list[] = {
/* normal text style */
MUIF_U8G2_FONT_STYLE(0, u8g2_font_helvR08_tr),
/* Leave the menu system */
MUIF_VARIABLE("LV",&exit_code,mui_u8g2_btn_exit_wm_fi),
/* input for a number between 0 to 9 */
MUIF_U8G2_U8_MIN_MAX("IN", &number_input, 0, 9, my_mui_u8g2_u8_min_max_wm_mse_pi), // call modified function
/* MUI_LABEL is used to place fixed text on the screeen */
MUIF_LABEL(mui_u8g2_draw_text)
}; |
Beta Was this translation helpful? Give feedback.
You could extend an existing MUIF. Lets take this list of functions:
u8g2/sys/arduino/u8g2_page_buffer/MUICountDown/MUICountDown.ino
Lines 347 to 359 in d987608
More specific, lets get change events from "mui_u8g2_u8_min_max_wm_…