Add TXRSSI and TXLQI sensors to FrSky D8/D16/LBT when using MULTI (#7128)
[opentx.git] / radio / util / lua / lua_event_test.lua
blob3a883b7cbb322e03ece61930d911bf7e7a0bf980
1 local toolName = "TNS|LUA event tests|TNE"
2 ---- #########################################################################
3 ---- # #
4 ---- # Copyright (C) OpenTX #
5 -----# #
6 ---- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html #
7 ---- # #
8 ---- # This program is free software; you can redistribute it and/or modify #
9 ---- # it under the terms of the GNU General Public License version 2 as #
10 ---- # published by the Free Software Foundation. #
11 ---- # #
12 ---- # This program is distributed in the hope that it will be useful #
13 ---- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 ---- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 ---- # GNU General Public License for more details. #
16 ---- # #
17 ---- #########################################################################
19 local virtual_next = 0
20 local virtual_prev = 0
21 local virtual_inc = 0
22 local virtual_dec = 0
23 local virtual_next_rept = 0
24 local virtual_prev_rept = 0
25 local virtual_page_next = 0
26 local virtual_page_prev = 0
27 local virtual_enter = 0
28 local virtual_enter_long = 0
29 local virtual_menu = 0
30 local virtual_menu_long = 0
32 -- Init
33 local function init()
35 end
37 -- Main
38 local function run(event)
39 if event == nil then
40 error("Cannot be run as a model script!")
41 return 2
42 end
43 if event == EVT_VIRTUAL_EXIT then
44 return 2
45 end
46 if event == EVT_VIRTUAL_NEXT then
47 virtual_next = virtual_next + 1
48 end
49 if event == EVT_VIRTUAL_PREV then
50 virtual_prev = virtual_prev + 1
51 end
52 if event == EVT_VIRTUAL_INC then
53 virtual_inc = virtual_inc + 1
54 end
55 if event == EVT_VIRTUAL_DEC then
56 virtual_dec = virtual_dec + 1
57 end
58 if event == EVT_VIRTUAL_NEXT_REPT then
59 virtual_next_rept = virtual_next_rept + 1
60 end
61 if event == EVT_VIRTUAL_PREV_REPT then
62 virtual_prev_rept = virtual_prev_rept + 1
63 end
64 if event == EVT_VIRTUAL_NEXT_PAGE then
65 virtual_page_next = virtual_page_next +1
66 end
67 if event == EVT_VIRTUAL_PREV_PAGE then
68 virtual_page_prev = virtual_page_prev + 1
69 killEvents(event);
70 end
71 if event == EVT_VIRTUAL_ENTER then
72 virtual_enter = virtual_enter + 1
73 end
74 if event == EVT_VIRTUAL_MENU then
75 virtual_menu = virtual_menu + 1
76 end
78 lcd.clear()
79 lcd.drawScreenTitle("LUA EVENT TEST", 0, 0)
80 lcd.drawText(1, 10, "PREV:"..virtual_prev)
81 lcd.drawText(LCD_W/2, 10, "NEXT: "..virtual_next)
82 lcd.drawText(1, 20, "DEC:"..virtual_dec)
83 lcd.drawText(LCD_W/2, 20, "INC:"..virtual_inc)
84 lcd.drawText(1, 30, "NXT PAGE: "..virtual_page_next)
85 lcd.drawText(LCD_W/2, 30, "PRV PAGE: "..virtual_page_prev)
86 lcd.drawText(1, 50, "ENTER: "..virtual_enter)
87 lcd.drawText(LCD_W/2, 50, "MENU: "..virtual_menu)
88 return 0
89 end
91 return { init=init, run=run }