EP7 – How to Program Arduino – New Menu with Class and I2C LCD

preview_player
Показать описание
In this episode, I revisit my menu design, and greatly simplify the code, all with the help of a custom button class (which I will show you how to make). Additionally, I am using a larger Liquid Crystal display, controlled via an I2C interface board, just to add some spice.

This is the seventh episode in a series where I will be providing some practical lessons on how to write programs using Arduino. These lessons are intended to be useful information that you can use in your own code immediately, but I also hope it serves as a general lesson to get you thinking about how to write code better.
Рекомендации по теме
Комментарии
Автор

Attention ESP32 users. Please check my community post with things you should be aware of when implementing this project on a ESP32.

ForOurGood
Автор

What an amazing video. This is definately something I can use as a template for future projects. Thanks for taking the time to make it.

Pete-ppkt
Автор

Can you please share the code you use in your videos? It's very difficult to write it all from the video!

andreagori
Автор

This is a useful lesson - is it possible to change the setting values if you only have 4 buttons. If I create a Menü then I have only two or three button. So I use the combinations of pressing two buttons the same time. I like the LCD with 80 chars.

viktorhugo
Автор

I have successfully implemented it, but there is a small issue that I haven't been able to resolve yet. When the plus or minus button is pressed, the value increases or decreases by 2 instead of 1, as it should. For example, when the value is at 1 and I press the plus button once, the displayed value jumps to 3, and I notice that the number 2 is briefly shown for a very short moment. Could you explain what is happening and how to fix it? Thank you

ahmatzainulm
Автор

I was wondering what program you are using to write the code? It appears to be far superior to Arduino IDE. Can you post a link, so I can check it out. Thanks Pete

Pete-ppkt
Автор

hi can you help me? i follow your code and if i wanted to make the menu scroll in single/one row what do i change?

RNDHVAC
Автор

I ported your menu system to an ESP32.
Everything works wonderfully, but I wasn't able to achieve values up to 10, 000 in the settings.
Can you help me with this problem?
Thank you

KM-ywjy
Автор

Your video is very good
I ported your menu system to an ESP32.
When it's done, everything is done. Check the LCD and the values in setting #2, 3, 4, 6 are flashing continuously, it seems like the previous value overlaps the next value (ex: setting #2 59 overlaps 60)., and the plus and minus buttons are not working properly, the code is exactly the same as in the video because I have checked it many times.
Can you help me with this problem?
Thank you !!!

hoangminhhienle
Автор

Hi. Im trying to do a menu in the LCD but I have a problem, my code compiles and everything but the problems is in the LCD, when I set the cursor in the option that I want to select ( the cursor is an ">") but the submenu or the suboptions inside of the option where the cursor is, The suboptions appear beneath the option without even selecting them, I think the problems is the LCD, becuase it sparkles and doesnt even show some words; besides, Ive bee checking the code severla times and It does not seem to be the problem. What would you recommend me to do? Btw, great video, love the large videos when you put the whole code from the beginning instead of just showing it

edfriedrich.
Автор

How do I get Platform IO. Every thing I try will not work.

snakezdewiggle
Автор

I would like to use your code to control how far a stepper motor movers. Specifically, modify test # 2 of the code so than I can adjust it in 0.01 increments rather than whole numbers. From what I have read, I need to use a float rather than an interger. Can you show me how to modify the code, or direct me to some reference material so I can do it.

I think these are the correct line numbers for your code.

Line 68) void adjustUint8_t(uint8_t *v, uint8_t min, uint8_t max);
Line 83) uint8_t Test2_Num = 60;
Line 507) if (menuItemPrintable(1, 2)){lcd.print(F("Setting #2 = "));}
Line 520) if (menuItemPrintable(14, 2)){printUint32_tAtWidth(settings.Test2_Num, 3, ' ', false);}
Line 549) case 2: adjustUint8_t(&settings.Test2_Num, 0, 255); break;
Line 635) void adjustUint8_t (uint8_t *v, uint8_t min, uint8_t max){
Line 637) if (btnPlus.RepeatCnt == 0 && btnMinus.Repeated()){if (*v > min){*v = *v - 1; updateItemValue = true;}}
Line 639) if (btnMinus.RepeatCnt == 0 && btnPlus.Repeated()){if (*v < max){*v = *v + 1; updateItemValue = true;}}
Line 640) }

Thanks Pete

Pete-ppkt
Автор

Hello sir, i really do appriciate ur work and really understand why u never choose to share your code and i really made a functional menu with your lession and i can prove i do learn and implimented just knowledge provided on ur videos but now m stuck on a place as m using tft-espi library and on my menu system their is a pointer arrow and also white box around my menu item to show pointer but now m stuck i cant figure it out scrolling vertically as shown on this video also i wanna implement if my menu item text is bigger than box m m using to show point then i want my text to scoll horizontally but as off now on my understand i did make that printmenufunction and i do impliment a logic like if its bigger than box then scroll the text else just print inside box also before this logis i do provide condition as u mentioned comparing value with subpos but issue is as i hv to call that print function as many times as how many items i want so if in middle one menu item text is bigger that scrolling function takes time and hold subsequent function to execute now wht to do and also i really cant understand logic behind verticle scrolling can you help me please

riteshpradhan
Автор

DO YOU THİNK THİS PROGRAM WİTH ENCODER ?

agahgokdag
Автор

Sir super but ples code on oled menu sir

anandprasad
Автор

Could you show all the finished code at once? because I watched the entire video and you went back and forth many times and modified many things and I missed a lot😃

giovannivannella
Автор

Wow. You talk really fast. I was exhausted in five minutes. I guess I'm just not cut out for learning in this way. Thanks anyway. Good information I'm sure.

KW-eipi
Автор

@ForOurGood Please, like all YouTubers are doing, create audio and multiple languages for your video. YouTube has this configuration. I speak Portuguese, I love the subject, but it is not possible to understand English.

makeryourself