Lua Widget, SHADOWED and BLINK not working

openTx has introduced a range of new features, ideas and bling. It is fast becoming the firmware of choice for many users. openTx will run on ALL current hardware platforms, including the gruvin9x and sky9x boards. Work has already started to support the new FrSky X9D radio!
Post Reply
Erazotropa
Posts: 2
Joined: Sun Aug 11, 2019 7:10 am
Country: -

Lua Widget, SHADOWED and BLINK not working

Post by Erazotropa » Sun Aug 11, 2019 7:44 am

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 }

Last edited by Erazotropa on Mon Aug 12, 2019 11:23 am, edited 1 time in total.


tonnie78
Posts: 96
Joined: Mon Jan 12, 2015 9:33 am
Country: -

Re: Lua Widget, SHADOWED and BLINK not working

Post by tonnie78 » Mon Aug 12, 2019 8:22 am

For what type of transmittor are you creating the script.

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

Erazotropa
Posts: 2
Joined: Sun Aug 11, 2019 7:10 am
Country: -

Re: Lua Widget, SHADOWED and BLINK not working

Post by Erazotropa » Mon Aug 12, 2019 11:22 am

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..

Ivanstein
Posts: 2
Joined: Sat Jun 29, 2019 12:47 am
Country: -

Re: Lua Widget, SHADOWED and BLINK not working

Post by Ivanstein » Wed Aug 14, 2019 7:38 pm

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


Post Reply

Return to “openTx”