switch case kind menu in Espruino? #5044
Replies: 1 comment
-
Posted at 2015-09-29 by DrAzzy I did a menu on an LCD - there's an old version of the code in this thread over here, though I haven't updated the code there to the latest version I'm using, and I don't have it in github for some stupid reason: https://www.hackster.io/azzy/adjustable-color-temperature-desk-lamp (there's also a thread here on it but the code on hackster is newer, I think) It's sort of ugly though. I avoid switch-case whenever possible - my track record with writing switch/case statements and not screwing them up is miserable. Posted at 2015-09-30 by @gfwilliams I actually had a menu library I'd fiddled with myself. I'll see if I can dig it out. Personally, I stored the whole menu as structure where the values were functions that got executed when selected, something like:
It made it relatively simple and easy to read. The menu code then just iterates over the object's fields and draws them, then when selected it runs the function. Posted at 2015-09-30 by @gfwilliams Ok, just dug it out:
Anyone think this would be worth turning into a 'proper' module? Posted at 2015-09-30 by @gfwilliams Note: LCD is set up as in this tutorial Posted at 2015-10-02 by bigplik Thanks Gordon, I'll check it later on today, will try to use it under SSD1306, hope I can manage Posted at 2015-10-02 by @gfwilliams Great! it should be fine with that - the default font is quite small. Let me know if you've got any thoughts - I'd love to get this into a module as soon as possible really. Posted at 2015-10-12 by bigplik hi, still fighting with it ;) could you tell me how to change font size ;)
Posted at 2015-10-12 by @gfwilliams Great! :) Actually if you want some fonts that look a bit better, you can load in Bitmap fonts as well: http://www.espruino.com/Fonts |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-09-29 by bigplik
I Wonder how to make simple menu for LCD or OLED ssd1306, I know how to create it in arduino programming style using switch case function, are here any samples about that?
Beta Was this translation helpful? Give feedback.
All reactions