Announcement

Collapse
No announcement yet.

Trying to update Cool Gauge in IF statement - ridiculously slow!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Vince_4D
    replied
    Greetings VooMan,

    I'm glad that the code somehow achieved what you are planning on your project.
    If you need any further assistance, don't hesitate to inform us.

    Best regards,

    Leave a comment:


  • VooMan
    replied
    Hi Vince_4D

    I tried that code you sent. Works really nicely! I haven't had a chance to finish playing around with it but at the moment it looks like it might do the job very well.

    Leave a comment:


  • Vince_4D
    replied
    Hi VooMan,

    This is the output that you must expect in implementing the files that I sent you in my previous post, click videolink.

    Since you’re not using the Software Serial, were you able to comment out the “Serial.print” codes?
    Those instructions will send data to the display, hence, may cause a delay in updating the gauge value. Moreover, the display will not understand these data.

    Also, kindly check if the FFC is still placed properly. Misalignment of the conductors may cause data loss.

    About the difference between hardware and software UART on Arduino, the links below might give you useful information.
    Hope this will help.

    Best regards,

    Leave a comment:


  • VooMan
    replied
    Hi. Thanks. I tried the files. I had to change genieBegin(COMMS) to genieBegin(Serial) to get the Arduino to communicate with my display. The resulting gauge was super jumpy, jumping from one side of the gauge to the other, with no transition. I've uploaded a video of it.

    I wonder if it has something to do with using genie(Serial), instead of genieBegin(COMMS)? What's the difference?
    Attached Files
    Last edited by VooMan; 13th June 2018, 09:07 AM.

    Leave a comment:


  • Vince_4D
    replied
    Greetings VooMan,

    I created a code that you might want to check. It is an implementation of a gauge widget that more or less responds just like an analog gauge.

    Attached are the files needed for the implementation.

    Hope this will help.


    Best regards,
    Attached Files

    Leave a comment:


  • VooMan
    replied
    Nice one thank you. Thought it would be simple!

    When I say "move like an analogue gauge" I just mean that it needs to move more smoothly and not jump from one side of the dial to the other, which is the best I can manage so far!

    Leave a comment:


  • ESPsupport
    replied
    Ahh, but why do you really want to have it move like an analogue gauge? You can't even see how an analogue gauge moves, as your eye can't discern much more than 25fps (which is the main reason why movies are 25fps, or 30fps in some locales). Even at 15 fps many people will struggle to see transition.

    Plus Analogue gauges are not smooth, they have lag at the start, the accelerate quickly and have overshoot at the end. They are also notoriously inaccurate, maybe by even 10-20%.

    So how you update the gauge is up to you, but there is absolutely no need to send every incremental value, it is just a waste of time any effort.


    As for your second question, just compare the current value to the new one before sending, if they are the same, don't send

    Leave a comment:


  • VooMan
    replied
    Hi, Mark. Having the transitions in gauge movement is crucial because I want it to move like an analogue gauge.

    Thanks for the advicea advice. I'll have to make sure the Arduino only sends discernable values to the gauge.

    How do I make sure it doesn't rewrite the same values? Probably simple, but I can't think of a way!

    Leave a comment:


  • ESPsupport
    replied
    You shouldn't be drawing every image between boost current and boost target, otherwise it will take a long time.

    Why not just draw the target?

    There are other things you could do, if you are looking for some 'apparent' transition.

    The time it takes to draw each images is based on the read time from uSD, for the Picaso processor this is about 650,000 pixels per second. For Diablo it is 2,100,000 pixels per second.

    So it's important not to waste time drawing every point between current and target, just as it is important not to keep rewriting the same value, or to have values in your gauge that have no discernable difference to adjacent values

    Leave a comment:


  • VooMan
    replied
    I just tried the If-Else If statement. Still goes at the same speed. It seems at the moment that this is the maximum speed that the screen can handle.

    Leave a comment:


  • Eran
    replied
    Hi Vooman,

    I have sent you a video of the first version of the code that I suggested in my previous email. Can you check if the behavior of your gauges is the same as the one that I just sent you?

    About the above post, can you try changing your two if statements into a single "if-else if" statement?


    Code:
    if(BoostCurrent < BoostTarget)  //if gauge needle is below actual boost level...
        {
          BoostCurrent++;  //increase gauge needle
        }
       
     else if(BoostCurrent > BoostTarget)  //if gauge needle is above actual boost level
        {
          BoostCurrent--;  //decrease gauge
        }

    This is just an initial assessment based on the part of the code that you have posted, I'd still need to have a deeper look into the entirety of your code and get back to you.

    Best Regards,

    Leave a comment:


  • VooMan
    replied
    Hi. Thanks for responding to my email. Very much appreciated. Thanks as well for the link. some of it went over my head so I'll have to read again a few times!

    I see what you mean; making the gauges smaller does make them respond a lot quicker ( although it does completely scupper the aim of my project!)

    I also significantly sped up the gauge movement by simply putting the ADC-to-gauge conversion at the beginning, so now "BoostCurrent" only counts up to a maximum of 30 instead of 1023!

    Code:
     BoostTarget = map(analogRead(MAPSensorPin), 0, 1023, 0, 30);  //get actual boost pressure
        if(BoostCurrent < BoostTarget)  //if gauge needle is below actual boost level...
        {
          BoostCurrent++;  //increase gauge needle
        }
        
        if(BoostCurrent > BoostTarget)  //if gauge needle is above actual boost level
        {
          BoostCurrent--;  //decrease gauge
        } 
        //BoostVal = map(BoostCurrent, 0, 1023, 0, 20);  // Convert ADC value to gauge numbers
        BoostVal = BoostCurrent;
     
       
        AFRVal = 0;
        OilPressVal = 0; 
        OilTempVal = 0; 
    
        //This would be used to change the colour of the gauges but is unused here
        if(digitalRead(NightPin) == LOW)
        { 
          WriteObject(BoostDayColour, BoostVal);
    ETC...

    One thing I still don't get is why doing the IF statements as above is still massively slower than immediately updating the the gauge like this:

    Code:
     {
       BoostVal = map(analogRead(MAPSensorPin), 0, 1023, 0, 30);
        AFRVal = 0;
        OilPressVal = 0;
        OilTempVal = 0; 
    
        if(digitalRead(NightPin) == LOW)
        { 
          WriteObject(BoostDayColour, BoostVal);
    Are you able to explain why this is?
    Is there anything else I can do to decrease the time it takes for the gauge needle to move?

    Leave a comment:


  • Eran
    replied

    Hi Vooman,

    I’ve tried the project file that you sent me and it’s working the way it should be on my side. Still, I want to comment few things.

    The reason behind the slow update is because of their size. Large images introduce a long ACK response, and it is normal. You can read more about this issue in this thread:
    https://forum.4dsystems.com.au/forum...0146#post60146

    To show that it actually is the reason, I sent you back two modified versions of your code. It’s apparent from the two versions that the smaller the size is, the faster the gauge updates; and the more the objects that need an update, the slower the update rate is.

    Can you try the two versions that I sent you and compare it to your original project? A feedback about the difference between the two modified versions and your original version would be great.

    Best Regards,

    Leave a comment:


  • Eran
    replied
    Hi Vooman,

    I received your email and will see what I can do to help you.

    Best Regards,

    Leave a comment:


  • VooMan
    replied
    Hi. I've just emailed you. Many thanks

    Leave a comment:

Working...
X