earthlcd / ezLCD-5x

Public Repository for ezLCD-5035-RT release files system, firmware and issue reporting
https://earthlcd.com/products/ezlcd-5x?_pos=1&_sid=0927d2260&_ss=r
0 stars 1 forks source link

ez.BoxFill one off on the x (maybe y too) #76

Open JacobChrist opened 1 year ago

JacobChrist commented 1 year ago

Describe the bug When using a ez.BoxFill the box (at least in the x-axis) doesn't go to the extents specified (maybe by design but if so its not clear in the manual.

The following image erases the trace with a box fill but the last pixel on the right is not erased. image

A clear and concise description of what the bug is.

To Reproduce Here is the code that generates the issue:

unction renderOscope(audio, gain)
    local result

    local x_min = 11
    local x_max = ez.Width-x_min
    local y_min = 10
    local y_max = 156
    local y_mid = (y_max - y_min) / 2 + y_min
    local y_max = 156
    local peak_to_peak = y_max - y_min
    local peak = peak_to_peak / 2

    -- erase previous scope
    ez.BoxFill(x_min, y_min, x_max, y_max, ez.RGB(0, 0, 40)) -- X1, Y1, X2, Y2, Color

    local index = 1
    for x = x_min, x_max, 1 do
        local left = ez.audio_getLeft(a, index) + .0
        index = index + 1
        left = left / gain * (peak)
        if(left > peak) then left = peak end
        if(left < -peak) then left = -peak end
        ez.Plot( x, math.floor(left + y_mid), ez.RGB(0, 0xff, 0) )
    end
end

Note: this bug was found in unreleased I2S firmware, so the ez.audio_getLeft() will need to be replaced with something equivalent if firmware is unavailable.