mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-25 17:25:10 +03:00
Added generation of Lua fields documentation file: lua_fields.txt
This commit is contained in:
parent
4d84ba4c19
commit
b5c63e339f
3 changed files with 251 additions and 10 deletions
|
@ -1280,7 +1280,8 @@ lua_exports.cpp: myeeprom.h ../util/luaexport.py
|
|||
@echo "Generating a list of Lua exported constants in lua_exports.txt"
|
||||
@$(CPP) -DPCBTARANIS -DCPUARM -DLUA -DEXPORT myeeprom.h | grep LEXP > lua_exports.txt
|
||||
@echo "Parsing and generating C Lua exports in lua_exports.cpp"
|
||||
@python ../util/luaexport.py lua_exports.txt lua_exports.cpp
|
||||
@python ../util/luaexport.py $(VERSION) lua_exports.txt lua_exports.cpp lua_fields.txt
|
||||
@rm lua_exports.txt
|
||||
|
||||
# Eye candy.
|
||||
# AVR Studio 3.x does not check make's exit code but relies on
|
||||
|
@ -1419,7 +1420,7 @@ clean_list :
|
|||
$(REMOVE) stamp-opentx.h
|
||||
$(REMOVE) bitmaps/*.lbm
|
||||
$(REMOVE) fonts/*/*.lbm
|
||||
$(REMOVE) lua_exports.txt lua_exports.cpp
|
||||
$(REMOVE) lua_exports.txt lua_exports.cpp lua_fields.txt
|
||||
$(MAKE) -C bootloader clean
|
||||
|
||||
#### Install
|
||||
|
|
205
radio/src/lua_fields.txt
Normal file
205
radio/src/lua_fields.txt
Normal file
|
@ -0,0 +1,205 @@
|
|||
Alphabetical list of Lua fields for OpenTX version 2.1.0
|
||||
|
||||
|
||||
Field name Field description
|
||||
----------------------------------------------
|
||||
a1 A1 analogue value [units as configured]
|
||||
a1-min A1 analogue value minimum [units as configured]
|
||||
a2 A2 analogue value [units as configured]
|
||||
a2-min A2 analogue value minimum [units as configured]
|
||||
a3 A3 analogue value [units as configured]
|
||||
a3-min A3 analogue value minimum [units as configured]
|
||||
a4 A4 analogue value [units as configured]
|
||||
a4-min A4 analogue value minimum [units as configured]
|
||||
accx G sensor - acceleration in X axis [g]
|
||||
accy G sensor - acceleration in Y axis [g]
|
||||
accz G sensor - acceleration in Z axis [g]
|
||||
ail Aileron
|
||||
air-speed Air speed [knots]
|
||||
air-speed-max Highest air speed [knots]
|
||||
altitude Variometer altitude [meters]
|
||||
altitude-max Highest altitude [meters]
|
||||
altitude-min Lowest altitude [meters]
|
||||
cell-min LiPo sensor - lowest current cell voltage [volts]
|
||||
cell-min-min LiPo sensor - all time lowest cell voltage [volts]
|
||||
cell-sum LiPo sensor - current summ of all cell voltages [volts]
|
||||
cell-sum-min LiPo sensor - all time lowest summ of all cell voltages [volts]
|
||||
ch0 Channel CH0
|
||||
ch1 Channel CH1
|
||||
ch2 Channel CH2
|
||||
ch3 Channel CH3
|
||||
ch4 Channel CH4
|
||||
ch5 Channel CH5
|
||||
ch6 Channel CH6
|
||||
ch7 Channel CH7
|
||||
ch8 Channel CH8
|
||||
ch9 Channel CH9
|
||||
ch10 Channel CH10
|
||||
ch11 Channel CH11
|
||||
ch12 Channel CH12
|
||||
ch13 Channel CH13
|
||||
ch14 Channel CH14
|
||||
ch15 Channel CH15
|
||||
ch16 Channel CH16
|
||||
ch17 Channel CH17
|
||||
ch18 Channel CH18
|
||||
ch19 Channel CH19
|
||||
ch20 Channel CH20
|
||||
ch21 Channel CH21
|
||||
ch22 Channel CH22
|
||||
ch23 Channel CH23
|
||||
ch24 Channel CH24
|
||||
ch25 Channel CH25
|
||||
ch26 Channel CH26
|
||||
ch27 Channel CH27
|
||||
ch28 Channel CH28
|
||||
ch29 Channel CH29
|
||||
ch30 Channel CH30
|
||||
ch31 Channel CH31
|
||||
clock RTC clock [minutes from midnight]
|
||||
consumption Current sensor - consumption [mili amper hours]
|
||||
current Current sensor - current [ampers]
|
||||
current-max Current sensor - highest current [ampers]
|
||||
cyc1 Cyclic 1
|
||||
cyc2 Cyclic 2
|
||||
cyc3 Cyclic 3
|
||||
distance GPS distance [meters]
|
||||
distance-max Biggest GPS distance [meters]
|
||||
dte Total energy [???]
|
||||
ele Elevator
|
||||
flight-mode Current flight mode number [number]
|
||||
fuel Fuel level [percent]
|
||||
gps-altitude GPS altitude [meters]
|
||||
gps-clock GPS clock [seconds from midnight]
|
||||
gps-speed GPS speed [knots]
|
||||
gps-speed-max Highest GPS speed [knots]
|
||||
gvar0 Global variable 0
|
||||
gvar1 Global variable 1
|
||||
gvar2 Global variable 2
|
||||
gvar3 Global variable 3
|
||||
gvar4 Global variable 4
|
||||
gvar5 Global variable 5
|
||||
gvar6 Global variable 6
|
||||
gvar7 Global variable 7
|
||||
gvar8 Global variable 8
|
||||
heading GPS heading [degrees]
|
||||
input0 Input [I0]
|
||||
input1 Input [I1]
|
||||
input2 Input [I2]
|
||||
input3 Input [I3]
|
||||
input4 Input [I4]
|
||||
input5 Input [I5]
|
||||
input6 Input [I6]
|
||||
input7 Input [I7]
|
||||
input8 Input [I8]
|
||||
input9 Input [I9]
|
||||
input10 Input [I10]
|
||||
input11 Input [I11]
|
||||
input12 Input [I12]
|
||||
input13 Input [I13]
|
||||
input14 Input [I14]
|
||||
input15 Input [I15]
|
||||
input16 Input [I16]
|
||||
input17 Input [I17]
|
||||
input18 Input [I18]
|
||||
input19 Input [I19]
|
||||
input20 Input [I20]
|
||||
input21 Input [I21]
|
||||
input22 Input [I22]
|
||||
input23 Input [I23]
|
||||
input24 Input [I24]
|
||||
input25 Input [I25]
|
||||
input26 Input [I26]
|
||||
input27 Input [I27]
|
||||
input28 Input [I28]
|
||||
input29 Input [I29]
|
||||
input30 Input [I30]
|
||||
input31 Input [I31]
|
||||
latitude GPS latitude [degrees, North is positive]
|
||||
longitude GPS longitude [degrees, East is positive]
|
||||
ls Left slider
|
||||
ls0 Logical switch L0
|
||||
ls1 Logical switch L1
|
||||
ls2 Logical switch L2
|
||||
ls3 Logical switch L3
|
||||
ls4 Logical switch L4
|
||||
ls5 Logical switch L5
|
||||
ls6 Logical switch L6
|
||||
ls7 Logical switch L7
|
||||
ls8 Logical switch L8
|
||||
ls9 Logical switch L9
|
||||
ls10 Logical switch L10
|
||||
ls11 Logical switch L11
|
||||
ls12 Logical switch L12
|
||||
ls13 Logical switch L13
|
||||
ls14 Logical switch L14
|
||||
ls15 Logical switch L15
|
||||
ls16 Logical switch L16
|
||||
ls17 Logical switch L17
|
||||
ls18 Logical switch L18
|
||||
ls19 Logical switch L19
|
||||
ls20 Logical switch L20
|
||||
ls21 Logical switch L21
|
||||
ls22 Logical switch L22
|
||||
ls23 Logical switch L23
|
||||
ls24 Logical switch L24
|
||||
ls25 Logical switch L25
|
||||
ls26 Logical switch L26
|
||||
ls27 Logical switch L27
|
||||
ls28 Logical switch L28
|
||||
ls29 Logical switch L29
|
||||
ls30 Logical switch L30
|
||||
ls31 Logical switch L31
|
||||
pilot-latitude Latitude of frist GPS position [degrees, North is positive]
|
||||
pilot-longitude Longitude of frist GPS position [degrees, East is positive]
|
||||
power Current sensor - power [wats]
|
||||
power-max Current sensor - highest power [wats]
|
||||
rpm Rotational speed [revolutions per minute]
|
||||
rpm-max Highest rotational speed [revolutions per minute] [meters]
|
||||
rs Right slider
|
||||
rssi RSSI [more is better]
|
||||
rud Rudder
|
||||
s1 Potentiometer 1
|
||||
s2 Potentiometer 2
|
||||
s3 Potentiometer 3
|
||||
sa Switch A
|
||||
sb Switch B
|
||||
sc Switch C
|
||||
sd Switch D
|
||||
se Switch E
|
||||
sf Switch F
|
||||
sg Switch G
|
||||
sh Switch H
|
||||
swr Transmitter antenna quality [less is better]
|
||||
temp1 Temperature 1 [degrees celsius]
|
||||
temp1-max Highest temperature 1 [degrees celsius]
|
||||
temp2 Temperature 2 [degrees celsius]
|
||||
temp2-max Highest temperature 2 [degrees celsius]
|
||||
thr Throttle
|
||||
timer1 Timer 1 value [seconds]
|
||||
timer2 Timer 2 value [seconds]
|
||||
timer3 Timer 3 value [seconds]
|
||||
trim-ail Aileron trim
|
||||
trim-ele Elevator trim
|
||||
trim-rud Rudder trim
|
||||
trim-thr Throttle trim
|
||||
trn0 Trainer input 0
|
||||
trn1 Trainer input 1
|
||||
trn2 Trainer input 2
|
||||
trn3 Trainer input 3
|
||||
trn4 Trainer input 4
|
||||
trn5 Trainer input 5
|
||||
trn6 Trainer input 6
|
||||
trn7 Trainer input 7
|
||||
trn8 Trainer input 8
|
||||
trn9 Trainer input 9
|
||||
trn10 Trainer input 10
|
||||
trn11 Trainer input 11
|
||||
trn12 Trainer input 12
|
||||
trn13 Trainer input 13
|
||||
trn14 Trainer input 14
|
||||
trn15 Trainer input 15
|
||||
tx-voltage Transmitter battery voltage [volts]
|
||||
vertical-speed Variometer vertical speed [m/s]
|
||||
vfas Current sensor - voltage [volts]
|
||||
vfas-min Current sensor - lowest voltage [volts]
|
|
@ -6,6 +6,7 @@ import sys
|
|||
import os
|
||||
import traceback
|
||||
import time
|
||||
import re
|
||||
|
||||
PREC1 = 10
|
||||
PREC2 = 100
|
||||
|
@ -57,11 +58,22 @@ def LEXP_EXTRA(name, description, value, condition = "true"):
|
|||
# extra also added to normal items to enable searching
|
||||
exports.append( (CONSTANT_VALUE, name, description) )
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
print "Error: not enough arguments!"
|
||||
print "Usage:"
|
||||
print " luaexport.py <version> <input txt> <output cpp> [<doc output>]"
|
||||
|
||||
inputFile = sys.argv[1]
|
||||
outputFile = sys.argv[2]
|
||||
version = sys.argv[1]
|
||||
inputFile = sys.argv[2]
|
||||
outputFile = sys.argv[3]
|
||||
docFile = None
|
||||
if len(sys.argv) >= 4:
|
||||
docFile = sys.argv[4]
|
||||
print "Version %s" % version
|
||||
print "Input file %s" % inputFile
|
||||
print "Output file %s" % outputFile
|
||||
if docFile:
|
||||
print "Documentation file %s" % docFile
|
||||
|
||||
inp = open(inputFile, "r")
|
||||
|
||||
|
@ -102,7 +114,8 @@ inp.close()
|
|||
|
||||
out = open(outputFile, "w")
|
||||
|
||||
out.write("//This file was generated by luaexport.py script on %s\n\n\n" % time.asctime())
|
||||
out.write("//This file was generated by luaexport.py script on %s for OpenTX version %s\n\n\n"
|
||||
% ( time.asctime(), version))
|
||||
|
||||
header = """
|
||||
struct LuaSingleField {
|
||||
|
@ -153,8 +166,8 @@ case_body = "\n".join(case_clauses)
|
|||
func_body = """
|
||||
extern lua_State *L;
|
||||
|
||||
// The handling of extra Lua fileds that are not
|
||||
// accesible by the getValue()
|
||||
// The handling of extra Lua fields that are not
|
||||
// accessible by the getValue()
|
||||
static int luaGetExtraValue(int src)
|
||||
{
|
||||
switch (src) {
|
||||
|
@ -165,11 +178,33 @@ static int luaGetExtraValue(int src)
|
|||
|
||||
""" % case_body
|
||||
out.write(func_body)
|
||||
print "Generated %d condtions in luaGetExtraValue()" % len(exports_extra)
|
||||
|
||||
|
||||
print "Generated %d conditions in luaGetExtraValue()" % len(exports_extra)
|
||||
out.close()
|
||||
|
||||
if docFile:
|
||||
#prepare fields
|
||||
all_exports = [(name, desc) for (id, name, desc) in exports]
|
||||
for (id, nameFormat, descriptionFormat, valuesCount) in exports_multiple:
|
||||
for v in range(valuesCount):
|
||||
name = nameFormat + str(v)
|
||||
desc = descriptionFormat % v
|
||||
all_exports.append( (name, desc) )
|
||||
#natural sort by field name
|
||||
convert = lambda text: int(text) if text.isdigit() else text
|
||||
alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key[0]) ]
|
||||
all_exports.sort(key = alphanum_key)
|
||||
|
||||
out = open(docFile, "w")
|
||||
out.write("Alphabetical list of Lua fields for OpenTX version %s\n\n\n" % version)
|
||||
FIELD_NAME_WIDTH = 25
|
||||
out.write("Field name%sField description\n" % (' '*(FIELD_NAME_WIDTH-len('Field name'))))
|
||||
out.write("----------------------------------------------\n")
|
||||
data = ["%s%s%s" % (name, ' '*(FIELD_NAME_WIDTH-len(name)) , desc) for (name, desc) in all_exports]
|
||||
out.write("\n".join(data))
|
||||
out.write("\n")
|
||||
|
||||
out.close()
|
||||
|
||||
if warning:
|
||||
sys.exit(1)
|
||||
elif error:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue