[Horus] Add RTC Battery voltage in RADIO / HARDWARE

This commit is contained in:
Bertrand Songis
2019-08-21 16:29:15 +02:00
parent 363ab00d81
commit 2dd8cb5d76
2 changed files with 129 additions and 121 deletions
+38 -8
View File
@@ -52,6 +52,8 @@ enum MenuRadioHardwareItems {
ITEM_RADIO_HARDWARE_SH,
ITEM_RADIO_HARDWARE_SI, // Gimbal switch left
ITEM_RADIO_HARDWARE_SJ, // Gimbal switch right
ITEM_RADIO_HARDWARE_BATTERY_CALIB,
ITEM_RADIO_HARDWARE_RTC_BATTERY,
ITEM_RADIO_HARDWARE_SERIAL_BAUDRATE,
ITEM_RADIO_HARDWARE_BLUETOOTH_MODE,
ITEM_RADIO_HARDWARE_BLUETOOTH_PAIRING_CODE,
@@ -60,7 +62,6 @@ enum MenuRadioHardwareItems {
ITEM_RADIO_HARDWARE_AUX_SERIAL_MODE,
#endif
ITEM_RADIO_HARDWARE_JITTER_FILTER,
ITEM_RADIO_HARDWARE_BAT_CAL,
ITEM_RADIO_HARDWARE_MAX
};
@@ -77,7 +78,31 @@ enum MenuRadioHardwareItems {
bool menuRadioHardware(event_t event)
{
MENU(STR_HARDWARE, RADIO_ICONS, menuTabGeneral, MENU_RADIO_HARDWARE, ITEM_RADIO_HARDWARE_MAX, { 0, LABEL(Sticks), 0, 0, 0, 0, LABEL(Pots), POTS_ROWS, LABEL(Switches), SWITCHES_ROWS, 0, BLUETOOTH_ROWS, 0, 0, 0 });
MENU(STR_HARDWARE, RADIO_ICONS, menuTabGeneral, MENU_RADIO_HARDWARE, ITEM_RADIO_HARDWARE_MAX, {
0 /* calibration button */,
LABEL(Sticks),
0 /* stick 1 */,
0 /* stick 2 */,
0 /* stick 3 */,
0 /* stick 4 */,
LABEL(Pots),
POTS_ROWS,
LABEL(Switches),
SWITCHES_ROWS,
0, /* battery */
READONLY_ROW, /* RTC */
0, /* max baudrate */
BLUETOOTH_ROWS,
0, /* aux serial mode */
0, /* ADC filter */
});
uint8_t sub = menuVerticalPosition;
@@ -182,6 +207,17 @@ bool menuRadioHardware(event_t event)
break;
}
case ITEM_RADIO_HARDWARE_BATTERY_CALIB:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BATT_CALIB);
lcdDrawNumber(HW_SETTINGS_COLUMN+50, y, getBatteryVoltage(), attr|PREC2, 0, NULL, "V");
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.txVoltageCalibration, -127, 127);
break;
case ITEM_RADIO_HARDWARE_RTC_BATTERY:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_RTC_BATT);
lcdDrawNumber(HW_SETTINGS_COLUMN+50, y, getRTCBatteryVoltage(), attr|PREC2, 0, NULL, "V");
break;
case ITEM_RADIO_HARDWARE_SERIAL_BAUDRATE:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MAXBAUDRATE);
lcdDrawNumber(HW_SETTINGS_COLUMN+50, y, CROSSFIRE_BAUDRATES[g_eeGeneral.telemetryBaudrate], attr|LEFT);
@@ -232,12 +268,6 @@ bool menuRadioHardware(event_t event)
g_eeGeneral.jitterFilter = 1 - editCheckBox(b, HW_SETTINGS_COLUMN+50, y, attr, event);
break;
}
case ITEM_RADIO_HARDWARE_BAT_CAL:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BATT_CALIB);
lcdDrawNumber(HW_SETTINGS_COLUMN+50, y, getBatteryVoltage(), attr|LEFT|PREC2, 0, NULL, "V");
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.txVoltageCalibration, -127, 127);
break;
}
}
+91 -113
View File
@@ -21,13 +21,54 @@ BOARD_SKY9X = 2
BOARD_TARANIS = 3
BOARD_HORUS = 4
# Board families
BOARD_FAMILY_ARM = 1
def build_target(target, path, cmake_options):
srcdir = os.path.dirname(os.path.realpath(__file__)) + "/../.."
outpath = path + ".out"
errpath = path + ".err"
# Launch CMake
cmd = ["cmake"]
for option, value in cmake_options.items():
cmd.append("-D%s=%s" % (option, value))
if "OPENTX_VERSION_SUFFIX" in os.environ:
suffix = os.environ["OPENTX_VERSION_SUFFIX"]
cmd.append('-DVERSION_SUFFIX="%s"' % suffix)
if suffix.startswith("N"):
cmd.append('-DNIGHTLY_BUILD_WARNING=YES')
cmd.append(srcdir)
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = proc.communicate()
if proc.returncode == 0:
open(outpath, "a").write("\n".join(cmd) + output.decode("utf-8") + error.decode("utf-8"))
else:
open(errpath, "w").write(output.decode("utf-8") + error.decode("utf-8"))
return COMPILATION_ERROR
# Launch make
cmd = ["make", "-j2", target]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = proc.communicate()
if proc.returncode == 0:
open(outpath, "a").write(output.decode("utf-8") + error.decode("utf-8"))
else:
open(errpath, "w").write(output.decode("utf-8") + error.decode("utf-8"))
return COMPILATION_ERROR
if target == "firmware":
# Check binary size
size = os.stat(target).st_size
if size > maxsize:
return FIRMWARE_SIZE_TOO_BIG
# Copy binary to the binaries directory
shutil.move(target, path)
if len(sys.argv) != 3:
exit(INVALID_FIRMWARE)
what = sys.argv[1]
target = sys.argv[1]
directory, filename = os.path.split(sys.argv[2])
root, ext = os.path.splitext(filename)
options = root.split("-")
@@ -36,119 +77,102 @@ if len(options) < 2 or options[0] != "opentx":
exit(INVALID_FIRMWARE)
optcount = 1
command_options = {}
cmake_options = {}
if options[optcount] == "sky9x":
command_options["PCB"] = "SKY9X"
cmake_options["PCB"] = "SKY9X"
firmware_options = options_sky9x
maxsize = 65536 * 4
board = BOARD_SKY9X
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "9xrpro":
command_options["PCB"] = "9XRPRO"
command_options["SDCARD"] = "YES"
cmake_options["PCB"] = "9XRPRO"
cmake_options["SDCARD"] = "YES"
firmware_options = options_sky9x
maxsize = 65536 * 4
board = BOARD_SKY9X
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "ar9x":
command_options["PCB"] = "AR9X"
command_options["SDCARD"] = "YES"
cmake_options["PCB"] = "AR9X"
cmake_options["SDCARD"] = "YES"
firmware_options = options_ar9x
maxsize = 65536 * 4
board = BOARD_SKY9X
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "x9lite":
command_options["PCB"] = "X9LITE"
command_options["MULTI_SPORT"] = "ON"
cmake_options["PCB"] = "X9LITE"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9lite
maxsize = 65536 * 8
board = BOARD_TARANIS
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "x7":
command_options["PCB"] = "X7"
command_options["MULTI_SPORT"] = "ON"
cmake_options["PCB"] = "X7"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9dp
maxsize = 65536 * 8
board = BOARD_TARANIS
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "xlite":
command_options["PCB"] = "XLITE"
command_options["MULTI_SPORT"] = "ON"
cmake_options["PCB"] = "XLITE"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_xlite
maxsize = 65536 * 8
board = BOARD_TARANIS
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "xlites":
command_options["PCB"] = "XLITES"
command_options["MULTI_SPORT"] = "ON"
cmake_options["PCB"] = "XLITES"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_xlites
maxsize = 65536 * 8
board = BOARD_TARANIS
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "x9d":
command_options["PCB"] = "X9D"
command_options["MULTI_SPORT"] = "ON"
cmake_options["PCB"] = "X9D"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9d
maxsize = 65536 * 8
board = BOARD_TARANIS
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "x9d+":
command_options["PCB"] = "X9D+"
command_options["MULTI_SPORT"] = "ON"
cmake_options["PCB"] = "X9D+"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9dp
maxsize = 65536 * 8
board = BOARD_TARANIS
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "x9d+2019":
command_options["PCB"] = "X9D+"
command_options["PCBREV"] = "2019"
command_options["MULTI_SPORT"] = "ON"
cmake_options["PCB"] = "X9D+"
cmake_options["PCBREV"] = "2019"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9dp
maxsize = 65536 * 8
board = BOARD_TARANIS
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "x9e":
command_options["PCB"] = "X9E"
command_options["MULTI_SPORT"] = "ON"
cmake_options["PCB"] = "X9E"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9e
maxsize = 65536 * 8
board = BOARD_TARANIS
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "x10":
command_options["PCB"] = "X10"
command_options["MULTI_SPORT"] = "ON"
cmake_options["PCB"] = "X10"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_horus_x10
maxsize = 2 * 1024 * 1024
board = BOARD_HORUS
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "x12s":
command_options["PCB"] = "X12S"
command_options["MULTI_SPORT"] = "ON"
cmake_options["PCB"] = "X12S"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_horus_x12s
maxsize = 2 * 1024 * 1024
board = BOARD_HORUS
board_family = BOARD_FAMILY_ARM
elif options[optcount] == "t12":
command_options["PCB"] = "X7"
command_options["PCBREV"] = "T12"
command_options["MULTI_SPORT"] = "ON"
cmake_options["PCB"] = "X7"
cmake_options["PCBREV"] = "T12"
cmake_options["MULTI_SPORT"] = "ON"
firmware_options = options_taranis_x9dp
maxsize = 65536 * 8
board = BOARD_TARANIS
board_family = BOARD_FAMILY_ARM
else:
exit(INVALID_BOARD)
if what == "firmware":
if board_family == BOARD_FAMILY_ARM:
ext = ".bin"
else:
ext = ".hex"
if target == "firmware":
ext = ".bin"
target = "firmware" + ext
filename = "opentx"
elif what == "libsimulator":
elif target == "libsimulator":
ext = ".so"
target = "libopentx-" + options[optcount] + "-simulator.so"
filename = "libopentx"
@@ -159,21 +183,25 @@ filename += "-" + options[optcount]
optcount += 1
# The firmware options
for opt, value in firmware_options.items():
for opt, values in firmware_options.items():
found = False
for i in range(optcount, len(options)):
if options[i] == opt:
found = True
break
if found:
optvalue = value[1]
filename += "-" + opt
else:
optvalue = value[2]
if not isinstance(values, list):
values = [values]
if optvalue is not None:
command_options[value[0]] = optvalue
for name, value1, value2 in values:
if found:
value = value1
filename += "-" + opt
else:
value = value2
if value is not None:
cmake_options[name] = value
# The firmware display language
language = ""
@@ -182,62 +210,12 @@ for key in languages:
language = key
if not language:
exit(INVALID_LANGUAGE)
command_options["TRANSLATIONS"] = language.upper()
cmake_options["TRANSLATIONS"] = language.upper()
filename += "-" + language + ext
path = os.path.join(directory, filename)
errpath = path + ".err"
def build_firmware(path):
srcdir = os.path.dirname(os.path.realpath(__file__)) + "/../.."
outpath = path + ".out"
# cmake 3.7.2 cannot work from / so we need to go into a subdir
os.mkdir("/build")
os.chdir("/build")
# Launch CMake
cmd = ["cmake"]
for opt, value in command_options.items():
cmd.append("-D%s=%s" % (opt, value))
if "OPENTX_VERSION_SUFFIX" in os.environ:
suffix = os.environ["OPENTX_VERSION_SUFFIX"]
cmd.append('-DVERSION_SUFFIX="%s"' % suffix)
if suffix.startswith("N"):
cmd.append('-DNIGHTLY_BUILD_WARNING=YES')
cmd.append(srcdir)
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = proc.communicate()
if proc.returncode == 0:
file(outpath, "a").write("\n".join(cmd) + output + error)
else:
file(errpath, "w").write(output + error)
print(filename)
exit(COMPILATION_ERROR)
# Launch make
cmd = ["make", "-j2", what]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = proc.communicate()
if proc.returncode == 0:
open(outpath, "a").write(output + error)
else:
open(errpath, "w").write(output + error)
print(filename)
exit(COMPILATION_ERROR)
if what == "firmware":
# Check binary size
if board_family == BOARD_FAMILY_ARM:
size = os.stat(target).st_size
if size > maxsize:
exit(FIRMWARE_SIZE_TOO_BIG)
# Copy binary to the binaries directory
shutil.move(target, path)
if os.path.isfile(errpath):
print(filename)
exit(COMPILATION_ERROR)
@@ -251,7 +229,7 @@ lock = filelock.FileLock(lockpath)
try:
with lock.acquire(timeout = 60*60):
if not os.path.isfile(path):
build_firmware(path)
build_target(target, path)
except filelock.Timeout:
print(filename)
exit(COMPILATION_ERROR)