olikraus / m2tklib

Automatically exported from code.google.com/p/m2tklib
Other
49 stars 11 forks source link

Last element of LIST with u8g doesn't display #148

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use u8g
2. Create a list of buttons
3. Select the last button
4. Do some custom drawing when that button is selected (m2.clear() + state 
change in callback)

What is the expected output? What do you see instead?
Nothing is shown, u8g functions have no effect, even drawPixel.
This only happens when the last element of the list is a button and that button 
is selected. Others buttons are not affected.

What version of the product are you using? On what operating system?
u8glib 1.17 with m2tklib 1.11 on Teensy 3.1

Original issue reported on code.google.com by ant.ber...@gmail.com on 1 Mar 2015 at 7:05

GoogleCodeExporter commented 9 years ago
can you post code where i can see the problem? Thanks

Original comment by olikr...@gmail.com on 3 Mar 2015 at 4:50

hcgraf commented 8 years ago

I'm experiencing the same problem, however it was not present in earlier revisions of my project. Going to bisect now…

As a workaround, it's possible to add a read-only, zero-size button to the end of the M2_LIST: M2_BUTTON(el_dummy, "h0w0r1", "", NULL);

hcgraf commented 8 years ago

OK, I found the proper solution. Always set the u8g color index by using u8g_SetColorIndex(&u8g,1) in your custom drawing routine.

It seems that m2tk always leaves the color index at 1 except when you click on the last button of a menu. That makes sense, because the last thing drawn by m2tk was the inverted (highlighted) button.

It would be possible to add a call to u8g_SetColorIndex in the end of m2_Draw, that would leave u8g in a consistent state and save other users from this apparently strange and quite hard to debug issue…