Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use and edit 16 bit numbers in MUI menu system. #2529

Open
czorgormez opened this issue Nov 5, 2024 · 4 comments
Open

use and edit 16 bit numbers in MUI menu system. #2529

czorgormez opened this issue Nov 5, 2024 · 4 comments

Comments

@czorgormez
Copy link

is it possible to use and edit 16 bit numbers in mui menu system ?

@olikraus
Copy link
Owner

olikraus commented Nov 5, 2024

I think a 16 bit var doesn't make much sense. How shell the user enter 10000? The user needs to click 10000 times to reach that value. I think it is better to break down the number into 5 variables, each from 0 to 9 (first var from 0 to 5). Then you can calculate the 16 bit value with a10000+b1000+c100d*10+e (a..e are the five variables).

There is a similar example here:
https://github.com/olikraus/u8g2/blob/master/sys/arduino/u8g2_page_buffer/MUIFractionSimpleRotary/MUIFractionSimpleRotary.ino

The above example also updates the next higher value based on the overflow of the lower number however this is not really required.

@czorgormez
Copy link
Author

agree, it is not practical to edit numbers larger than 100.

however we used to edit this type of variables with cursor select system thousandth, hundredth, tenth, oneth one by one and user can select the digit and edit by up-down buttons.

also there is another old method called as typematic. a single click adds or subtracts one but if user keeps pressing the button variable starts to increment tenth every second, after several sec. it starts to increment by hundreds every sec etc.

@olikraus
Copy link
Owner

olikraus commented Nov 5, 2024

true, but this could be simply implemented by yourself: Just create a new muif, which displays your 16 bit variable:

uint8_t muif_draw_16_bit_variable(mui_t *ui, uint8_t msg) {
  if ( msg == MUIF_MSG_DRAW ) {
      u8g2.setCursor(mui_get_x(ui), mui_get_y(ui));
      u8g2.print(my_16bit_var);
  }
  return 0;
}

Register this muif in the muif table (for example with MUIF_RO("VV", muif_draw_16_bit_variable) ) and refer the same inside FDS with MUI_XY("VV",x,y).

Then, if the form with this number is visible (by checking the FDS form id with https://github.com/olikraus/u8g2/wiki/muiref#getcurrentformid) , just apply your up / down updates and do a redraw of the menu.

@czorgormez
Copy link
Author

Thanks, i will use this method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants