Skip to content

Creating a counter with decimals #2499

Closed Answered by olikraus
Claponi asked this question in Q&A
Discussion options

You must be logged in to vote

Unfortunately it is a little bit more complicated, because you need to consider some edge cases like 100.0 --> 0.0 rollover.

I created a full example here: https://github.com/olikraus/u8g2/blob/master/sys/arduino/u8g2_page_buffer/MUIFractionSimpleRotary/MUIFractionSimpleRotary.ino

The increment case for example is here:

case MUIF_MSG_EVENT_NEXT: // for mud mode
if ( ui->is_mud == 0 ) {
return_value = mui_u8g2_u8_min_max_wm_mud_pi(ui, msg); // none mud state
}
else if ( decimal == 9 ) { // 46.9 --> 47.0
pre_decimal++;
return_value = mui…

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
8 replies
@Claponi
Comment options

@olikraus
Comment options

@olikraus
Comment options

Answer selected by Claponi
@Claponi
Comment options

@Claponi
Comment options

@olikraus
Comment options

@olikraus
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants