Hey folks,
Here is the situation, PC is sending numbers between 0 to 100 to arduino ever 200ms. Arduino is taking these values and drawing a status bar.
So far so good. Problem is the number that comes to Arduino jumps around a lot and that caused very jittery status bar. What I need to to is something like this:
->Take the first value that arrives and store it. Wait for the second value
->When the second value arrives; run a loop that goes thru every integer between first and second. At every number draw to TFT screen. ie:
//Pseudo code
while (first_val < second val)
{
first_var++;
lcd.Text1.SetValue(first_val)//Text1 is the important part here. It's not static.
}
//Obviously there has to be another function for the cases where the first_val is bigger than the second
->When the third number arrives, overrides first_val with second_val and second_val with third_val
->Return to beginning
Doing this is no problem for a single value. I used a temporary value to store the last value and got it working. Problem is, there are around 10 values that needs to use this function. Creating an additional temporary value for each by hand is tedious. Also impacts performance pretty hard.
So the solution is obviously creating a Class. Problem is, I need to pass the TFT object to that Class too. The screen I'm using is Nextion, It has it's own library and I have no idea how to pass an object created by some library to another class.
Not to mention, I'm pretty fuzzy about Arduino and classes. I've seen some examples of OOP in arduino, but I'm not even sure if they are native arduino codes or C++.
Can anyone give me a hand?
EDIT1:
Here is the video showing the problem.
The first one is the G15's screen. If you look at the CPU load bars, they are updating very fluidly(Possibly with more than 30+ hz). The second one is mine, and it looks pretty bad.
EDIT2: Here is the github page if you want to see the entirety of Arduino code.