Make Horus widgets 'shadow' effect an option (#5203)
[opentx.git] / radio / sdcard / horus / WIDGETS / Counter / main.lua
blob49c89962ece7a0b3aba1dba98f67ad0cebe4540b
1 ---- #########################################################################
2 ---- # #
3 ---- # Copyright (C) OpenTX #
4 -----# #
5 ---- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html #
6 ---- # #
7 ---- # This program is free software; you can redistribute it and/or modify #
8 ---- # it under the terms of the GNU General Public License version 2 as #
9 ---- # published by the Free Software Foundation. #
10 ---- # #
11 ---- # This program is distributed in the hope that it will be useful #
12 ---- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 ---- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 ---- # GNU General Public License for more details. #
15 ---- # #
16 ---- #########################################################################
17 local options = {
18 { "Option1", SOURCE, 1 },
19 { "Option2", VALUE, 1000 },
20 { "Option3", COLOR, RED },
21 { "Shadow", BOOL, 0 }
24 local function create(zone, options)
25 local pie = { zone=zone, options=options, counter=0 }
26 print(options.Option2)
27 return pie
28 end
30 local function update(pie, options)
31 pie.options = options
32 end
34 local function background(pie)
35 pie.counter = pie.counter + 1
36 end
38 function refresh(pie)
39 pie.counter = pie.counter + 1
40 if pie.options.Shadow == 1 then
41 lcd.drawNumber(pie.zone.x, pie.zone.y, pie.counter, LEFT + DBLSIZE + TEXT_COLOR);
42 else
43 lcd.drawNumber(pie.zone.x, pie.zone.y, pie.counter, LEFT + DBLSIZE + TEXT_COLOR + SHADOWED);
44 end
45 end
47 return { name="Counter", options=options, create=create, update=update, refresh=refresh, background=background }