Page 1 of 1

Lua Widget, SHADOWED and BLINK not working

Posted: Sun Aug 11, 2019 7:44 am
by Erazotropa
Hi all,

I am struggling with the SHADOWED and BLINK flags in my widget.
They dont function.

This my code to test it.

Code: Select all

local options = {
	{ "Color", COLOR, WHITE },	
	{ "Shadow", BOOL, 0} 
}

function create(zone, options)
	local Context = { zone=zone, options=options }
	return Context
end

-- This function allow updates when you change widgets settings
local function update(Context, options)
  Context.options = options
end



function ScreenUpdate(Context)

	lcd.drawText(Context.zone.x, Context.zone.y - 8, "Hello" , CUSTOM_COLOR + DBLSIZE + shadowed + BLINK)
	
end




function update(Context, options)
	Context.options = options
	Context.back = nil
end

function refresh(Context)
	
	lcd.setColor(CUSTOM_COLOR, Context.options.Color)
	
	if Context.options.Shadow == 1 then
		shadowed = SHADOWED
	else
		shadowed = 0
	end	
	
	ScreenUpdate(Context)
	
end

return { name="ShadowTest", options=options, create=create, update=update, refresh=refresh }


Re: Lua Widget, SHADOWED and BLINK not working

Posted: Mon Aug 12, 2019 8:22 am
by tonnie78
For what type of transmittor are you creating the script.

I think these functions do not work on transmitters with color display

Re: Lua Widget, SHADOWED and BLINK not working

Posted: Mon Aug 12, 2019 11:22 am
by Erazotropa
Hi, I am using a Horus, (as mentioned on MBF too) Both do work fine in other scripts.. but in my simple script both dont work..

Re: Lua Widget, SHADOWED and BLINK not working

Posted: Wed Aug 14, 2019 7:38 pm
by Ivanstein
From what I have suffered through and according to the OpenTX Lua programming guide, you need to set up variables used in several functions in the create function to initialize them.

Something like:
function create(zone, options)

local context = {zone=zone, options=options, parameters=parameters}
local parameters ={}
parameters.shadowed=0

return context