Automatically detect FlySky digital hall sticks on X10-class radios without necessity of build-time CMake option FLYSKY_HALL_STICKS.

Added special UART4 init to sample if FlySky sticks are present or not.
Added boolean globalData.flyskygimbals to save the detection result.
Removed FLYSKY_HALL_STICKS and FLYSKY_HALL_STICKS_REVERSE CMake build options.

Tested on two RM TX16S radios, one with FlySky digital hall sticks and second with stock analog sticks.
This commit is contained in:
rotorman
2021-11-19 21:33:03 +01:00
committed by Risto
parent 1002fddd12
commit 80a51837c1
24 changed files with 248 additions and 217 deletions
+39 -33
View File
@@ -27,7 +27,7 @@
#include "imu_lsm6ds33.h"
#endif
#if defined (FLYSKY_HALL_STICKS) || defined (FLYSKY_HALL_STICKS_REVERSE)
#if defined(RADIO_FAMILY_T16) || defined(PCBNV14)
#include "../../targets/horus/flyskyHallStick_driver.h"
#endif
@@ -48,49 +48,55 @@ class RadioAnalogsDiagsWindow: public Window {
void paint(BitmapBuffer * dc) override
{
#if !defined(SIMU) && (defined (FLYSKY_HALL_STICKS) || defined (FLYSKY_HALL_STICKS_REVERSE))
for (uint8_t i = 0; i < FLYSKY_HALL_CHANNEL_COUNT; i++) {
#if !defined(SIMU) && (defined(RADIO_FAMILY_T16) || defined(PCBNV14))
if (globalData.flyskygimbals)
{
for (uint8_t i = 0; i < FLYSKY_HALL_CHANNEL_COUNT; i++) {
#if LCD_W > LCD_H
coord_t y = 1 + (i / 2) * FH;
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
coord_t y = 1 + (i / 2) * FH;
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
#else
coord_t y = 1 + i * FH;
uint8_t x = 10;
coord_t y = 1 + i * FH;
uint8_t x = 10;
#endif
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
dc->drawNumber(x + 3 * 15 - 1, y, hall_raw_values[i], LEFT | COLOR_THEME_PRIMARY1);
dc->drawNumber(x + ANA_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
}
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
dc->drawNumber(x + 3 * 15 - 1, y, hall_raw_values[i], LEFT | COLOR_THEME_PRIMARY1);
dc->drawNumber(x + ANA_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
}
for (uint8_t i = FLYSKY_HALL_CHANNEL_COUNT; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
for (uint8_t i = FLYSKY_HALL_CHANNEL_COUNT; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
#if LCD_W > LCD_H
coord_t y = 1 + (i / 2) * FH;
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
coord_t y = 1 + (i / 2) * FH;
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
#else
coord_t y = 1 + i * FH;
uint8_t x = 10;
coord_t y = 1 + i * FH;
uint8_t x = 10;
#endif
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
dc->drawNumber(x + 3 * 15 -1, y, anaIn(i), LEFT | COLOR_THEME_PRIMARY1);
dc->drawNumber(x + ANA_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
dc->drawNumber(x + 3 * 15 -1, y, anaIn(i), LEFT | COLOR_THEME_PRIMARY1);
dc->drawNumber(x + ANA_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
}
}
#else
for (uint8_t i = 0; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
#endif
if (!globalData.flyskygimbals) // Also Simulator
{
for (uint8_t i = 0; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
#if LCD_W > LCD_H
coord_t y = 1 + (i / 2) * FH;
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
coord_t y = 1 + (i / 2) * FH;
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
#else
coord_t y = 1 + i * FH;
uint8_t x = 10;
#endif
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
dc->drawNumber(x + 3 * 15 -1, y, anaIn(i), LEFT | COLOR_THEME_PRIMARY1);
dc->drawNumber(x + ANA_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
}
coord_t y = 1 + i * FH;
uint8_t x = 10;
#endif
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
dc->drawNumber(x + 3 * 15 -1, y, anaIn(i), LEFT | COLOR_THEME_PRIMARY1);
dc->drawNumber(x + ANA_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
}
}
#if !defined(SIMU) && defined(IMU_LSM6DS33)
coord_t yimu = MENU_CONTENT_TOP + 3 * FH;