I am an owner of arduino uno. I have written a code for monitoring voltage changes. It is all displayed on the TFT screen with a graphic style. What i need is also to include a current monitoring, the hardware isnt the problem. What i cannot think how to codea menu for the display to show the voltage diagram. I want to make a two way scrolling menu, forward and backwards, when a button is pressed to display lets say the voltage graph, when pressed the forward button the current when pressed forward again another function.
Thank you for reading, looking forward to reading your replies.
You can make a simple menu with case statements. just make sure you only run the things you need to per screen otherwise it will slow down your processing time.
If you need to monitor both diagrams with real time values, you can make your variables volatile, but again it may slow things down if you have too many things running.
Hi HazardsMind, the way my graphic works is that for every sensor value it prints a line with a mapped value height, as far as i know i think that "case" menu wont work cuz everytime the code checks if the button is pressed or not it'll restart the whole function a.k.a. graphic so i wont get the graphic to be displayed or im wrong and i dont fully understand the switch function xD. Thank you for your reply.
Why are you constantly redrawing the lines? Only when you get a new value should the line change.
When you use the case statement, your "graphs" should be within a while loop, this way only the things related to that graph should be running and not everything. You could also use an Interrupt on the button to change the case.
On second thought, how many screens are you switching between, you might not even need case statement, just an IF/ELSE statement.
The line is constantly drawn cuz i want to compare the changes with the time, so if the voltage is constant i want to see it constant if theres a minor change i want to see the minor change. Its just 2 screens now, voltage and current readings, and hmm seems i have no idea how to code that switch thing and make a loop within.
And the code u asked about, is to refresh the screen when the line reaches the end of the screen i think x)
Where is the button that you want to use the switch the screens?
For the button I would use an interrupt routine that looks for the button state as either "rising" or "falling" (depending on how the button is wired). Then in the interrupt function, you would increment a counter.
For the switch statements, you could have: ( you might not need the while loop)
switch( counter % 2 )
{
case 0:
/* Voltage stuff */
break;
I would like to use a push button, so i could read a high and low i guess instead rising and lowering... hmm thats a nice idea ill look more into it, thank you very much.
Rising is the transition from low to high, and falling is high to low. AttachInterrupt Look that the pins used for the interrupts, because there are only so many per board type, and the pins a very specific.
Hah thats very interesting function, even though i dont get it ill struggle more around it! Thank you very much i really appreciate your help kind sir! ill try to solve the problem eventually
Oh and i have an Uno so its only pins 2 and 3