Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ez.PutPictFile(x, y, file) sometimes draws image at the incorrect x location. #77

Open
JacobChrist opened this issue Apr 19, 2023 · 2 comments
Assignees
Labels
bug Something isn't working confirm-resolved Lua

Comments

@JacobChrist
Copy link
Member

JacobChrist commented Apr 19, 2023

Describe the bug
Sometimes when using the ez.PutPictFile(x, y, file) function the image is drawing at the wrong x location. At the time of the creation of this issue, issue #72 still exists and is unaddressed and is probably related.

Screenshots
image

To Reproduce
Steps to reproduce the behavior:

  1. Run the program and click on the different plants, a failure is emanate

Expected behavior
Image should always be rendered at the correct X,Y location.

MANDATORY: Attachments
Image files:
PlanetScale.zip

----------------------------------------------------------------------
-- ezLCD Planetary Scale application note example
--
-- Created  03/14/2023  -  Jacob Christ
----------------------------------------------------------------------

function printBox(x1, y1, x2, fg, bg, font_height, str) -- Show a title sequence for the program
	-- Erase Old Weight
	local y2 = y1 + font_height

	ez.BoxFill(x1,y1, x2,y2, bg) -- X, Y, Width, Height, Color

	-- Display Line
	ez.SetColor(fg)
	ez.SetFtFont(fn, font_height * 0.70) -- Font Number, Height, Width
	ez.SetXY(x1, y1)
	print(str)
end

function titleScreen(fn) -- Show a title sequence for the program
	local result
	ez.Cls(ez.RGB(0,0,0))

	ez.SetAlpha(255)
	ez.SetXY(0, 0)
	result = ez.PutPictFile(0, 0, "/PlanetScale/planet-menu-grid-onlineconverter.jpg")
	ez.SerialTx("result=".. tostring(result) .. "\r\n", 80, debug_port) -- doesn't work
end

debug_port = 0
-- Event Handelers
-- Serial Port Event
function DebugPortReceiveFunction(byte)
	ez.SerialTx(byte, 1, debug_port)
end

-- Define the Button Event Handler
function ProcessButtons(id, event)
	-- TODO: Insert your button processing code here

	if id >= 1 and id <= 9 and event == 2 then
		new_planet = true
		planet = id
	end

	ez.Button(id, event)
	str = "id=" .. tostring(id) ..  ", event=" .. tostring(event)
	ez.SerialTx(str .. "\r\n", 80, debug_port)
	printBox(400, 0, 800, ez.RGB(0xff, 0xff, 0xff), ez.RGB(0x00, 0x00, 0x80), font_height, str)

end 

function deviceData()
	ez.SerialTx("**********************************************************************\r\n", 80, debug_port)
	ez.SerialTx("* EarthLCD Planetary Scale\r\n", 80, debug_port)
	ez.SerialTx("**********************************************************************\r\n", 80, debug_port)
	ez.SerialTx(ez.FirmVer .. "\r\n", 80, debug_port)
	ez.SerialTx(ez.LuaVer .. "\r\n", 80, debug_port)
	ez.SerialTx("S/N: " .. ez.SerialNo .. "\r\n", 80, debug_port)
	ez.SerialTx(ez.Width .. "x" .. ez.Height .. "\r\n", 80, debug_port)

	str = ez.FirmVer
	printBox(400, 1 * font_height, 800, ez.RGB(0xff, 0xff, 0xff), ez.RGB(0x00, 0x00, 0x80), font_height, str)
	str = ez.LuaVer
	printBox(400, 2 * font_height, 800, ez.RGB(0xff, 0xff, 0xff), ez.RGB(0x00, 0x00, 0x80), font_height, str)
	str = "S/N: " .. ez.SerialNo 
	printBox(400, 3 * font_height, 800, ez.RGB(0xff, 0xff, 0xff), ez.RGB(0x00, 0x00, 0x80), font_height, str)
	str = ez.Width .. "x" .. ez.Height
	printBox(400, 4 * font_height, 800, ez.RGB(0xff, 0xff, 0xff), ez.RGB(0x00, 0x00, 0x80), font_height, str)
end

-----------------------------------------------------------------------------
-- Globals
-----------------------------------------------------------------------------
fn = 14
font_height = 240 / 8 -- = 30

new_planet = true
planet = 1

-----------------------------------------------------------------------------
-- Setup Button(2)
-----------------------------------------------------------------------------
-- ez.Button( id, ?, ?, ?, ?, X, Y, W, H)

ez.Button(0, 1, -1, -11, -1,   0,   0,  50,  50) -- 0 - Menu
ez.Button(1, 1, -1, -11, -1,   0, 320,  50, 280) -- 1 - Sun
ez.Button(2, 1, -1, -11, -1,  50, 320,  50, 280) -- 2 - Mercury
ez.Button(3, 1, -1, -11, -1, 100, 320,  75, 280) -- 3 - Venus
ez.Button(4, 1, -1, -11, -1, 175, 320,  55, 280) -- 4 - Earth
ez.Button(5, 1, -1, -11, -1, 230, 320,  60, 280) -- 5 - Mars
ez.Button(6, 1, -1, -11, -1, 290, 320, 160, 280) -- 6 - Jupiter
ez.Button(7, 1, -1, -11, -1, 450, 320, 150, 280) -- 7 - Saturn
ez.Button(8, 1, -1, -11, -1, 600, 320, 100, 280) -- 8 - Uranus
ez.Button(9, 1, -1, -11, -1, 700, 320, 100, 280) -- 9 - Neptune

-- Start to receive button events
ez.SetButtonEvent("ProcessButtons")

-----------------------------------------------------------------------------
-- Main
-----------------------------------------------------------------------------
-- open the RS-232 port
ez.SerialOpen("DebugPortReceiveFunction", debug_port)

titleScreen(fn)
deviceData()

while 1 do

	-- Test Loop
	if new_planet == true then
		-- ez.SetAlpha(255)
		local planet_x = 53 -- 50
		local planet_y = 21 -- 25
		ez.SetXY(planet_x, planet_y)
		if planet == 1 then ez.PutPictFile(planet_x, planet_y, "/PlanetScale/1-sun.jpg") end
		if planet == 2 then ez.PutPictFile(planet_x, planet_y, "/PlanetScale/2-mercury.jpg") end
		if planet == 3 then ez.PutPictFile(planet_x, planet_y, "/PlanetScale/3-venus.jpg") end
		if planet == 4 then ez.PutPictFile(planet_x, planet_y, "/PlanetScale/4-earth.jpg") end
		if planet == 5 then ez.PutPictFile(planet_x, planet_y, "/PlanetScale/5-mars.jpg") end
		if planet == 6 then ez.PutPictFile(planet_x, planet_y, "/PlanetScale/6-jupiter.jpg") end
		if planet == 7 then ez.PutPictFile(planet_x, planet_y, "/PlanetScale/7-saturn.jpg") end
		if planet == 8 then ez.PutPictFile(planet_x, planet_y, "/PlanetScale/8-uranus.jpg") end
		if planet == 9 then ez.PutPictFile(planet_x, planet_y, "/PlanetScale/9-neptune.jpg") end
		new_planet = false
	end

end

Note from Randy:
Product: PROD_EZLCD_105B (passed) or PROD_EZLCD_5104 (failed)

@JacobChrist JacobChrist added bug Something isn't working Lua labels Apr 19, 2023
@JacobChrist
Copy link
Member Author

The 10" display I have is in a case so its hard to debug so I tested on a 5035 and the issue doesn't manifest itself. I suspect that the global X,Y variables are being modified so I am testing firmware that fixes issue #72 bypasses the use of the Global X,Y variables when drawing an image. Issue addressed on commit https://github.com/earthlcd/EZLCD-5xxx-Master/commit/0c6bb4c5a6c868ccf953f51f8a468b71760b22dc but not released.

@JacobChrist
Copy link
Member Author

I think this issue is related to https://github.com/earthlcd/EZLCD-5xxx-Master/issues/69 and is resolved, but we should keep this open until the time when it can be tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirm-resolved Lua
Projects
None yet
Development

No branches or pull requests

2 participants