Announcement

Collapse
No announcement yet.

Modified LEDDigitsDisplay Routine

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

  • Modified LEDDigitsDisplay Routine

    Just wanted to share this modified display routine. If you have several fast counters, or somewhat stable values that are being updated constantly, this modified LEDDigitsdisplay routine will only write those digits which have changed since the last time the routine was called. This can result in a significant speed up as writing the images to the display is much longer than checking if the digit has changed.

    In a 4 digit test from 0000 to 9999, the unmodified routine takes approx 1 min 27 seconds to complete. The modified routine completes in about 27 seconds. This routine as is will only handle a single custom digit control, but it would be trivial to add support for multiple controls......

    For applications where the majority of digits change for each call to update the control, noticeably less improvement can be expected....

    Code:
    func ledDigitsDisplay2(var newval, var index, var left, var Digits, var MinDigits, var WidthDigit, var LeadingBlanks, var FastMode) ;
        var private digitstate[6];
        var i, k, l, lb ;
        l := 1 ;
        for (i := 1; i < Digits; i++)
            l *= 10 ;
        next
        lb := LeadingBlanks ;
        for (i := 0; i < Digits; i++)
            k := newval / l ;
            newval -= k * l ;
            if ( lb && (i < Digits - MinDigits) )
                if (k == 0)
                    k := -1 ;
                else
                    lb := 0 ;
                endif
            endif
            l /= 10 ;
            if(FastMode)
                if(digitstate[i] != k)
                    img_SetWord(hndl, index, IMAGE_INDEX, k);
                    img_SetWord(hndl, index, IMAGE_XPOS, left+i*WidthDigit) ;
                    img_Show(hndl, index);
                endif
            else
                img_SetWord(hndl, index, IMAGE_INDEX, k);
                img_SetWord(hndl, index, IMAGE_XPOS, left+i*WidthDigit) ;
                img_Show(hndl, index);
            endif
            digitstate[i] := k;
        next
    endfunc
    _______________
    Best Regards,
    Howard
Working...
X