Skip to content

Commit

Permalink
feat: preliminary HelloRadioSky V14 and V12 radio support (#5494)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardclli authored Sep 11, 2024
1 parent 6e706c4 commit b78da34
Show file tree
Hide file tree
Showing 13 changed files with 375 additions and 46 deletions.
2 changes: 2 additions & 0 deletions fw.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
["FrSky X9 Lite S", "x9lites-"],
["FrSky X-Lite", "xlite-"],
["FrSky X-Lite S", "xlites-"],
["HelloRadioSky V12", "v12-"],
["HelloRadioSky V14", "v14-"],
["HelloRadioSky V16", "v16-"],
["iFlight Commando 8", "commando8-"],
["Jumper T12", "t12-"],
Expand Down
33 changes: 33 additions & 0 deletions radio/src/targets/taranis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,39 @@ elseif(PCB STREQUAL X7)
set(BLUETOOTH YES)
set(ROTARY_ENCODER YES)
add_definitions(-DMANUFACTURER_FRSKY)
elseif(PCBREV STREQUAL V12)
set(DEFAULT_INTERNAL_MODULE CROSSFIRE CACHE STRING "Default internal module")
set(INTERNAL_MODULE_SERIAL YES)
set(MODULE_SIZE_STD YES)
set(FLAVOUR v12)
set(NAVIGATION_TYPE x7)
set(CPU_TYPE_FULL STM32F407xG)
set(ROTARY_ENCODER YES)
set(USB_CHARGER YES)
add_definitions(-DRADIO_V12)
add_definitions(-DSTM32_SUPPORT_32BIT_TIMERS)
set(PXX2 ON)
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
if (NOT BLUETOOTH)
set(AUX_SERIAL ON)
endif()
elseif(PCBREV STREQUAL V14)
set(DEFAULT_INTERNAL_MODULE CROSSFIRE CACHE STRING "Default internal module")
set(INTERNAL_MODULE_SERIAL YES)
set(MODULE_SIZE_STD YES)
set(FLAVOUR v14)
set(NAVIGATION_TYPE x7)
set(CPU_TYPE_FULL STM32F407xG)
set(ROTARY_ENCODER YES)
set(USB_CHARGER YES)
add_definitions(-DRADIO_V14)
add_definitions(-DSTM32_SUPPORT_32BIT_TIMERS)
set(PXX2 ON)
set(ENABLE_SERIAL_PASSTHROUGH ON CACHE BOOL "Enable serial passthrough")
set(FLYSKY_GIMBAL ON)
if (NOT BLUETOOTH)
set(AUX_SERIAL ON)
endif()
else()
set(DEFAULT_INTERNAL_MODULE XJT_PXX1 CACHE STRING "Default internal module")
set(FLAVOUR x7)
Expand Down
44 changes: 42 additions & 2 deletions radio/src/targets/taranis/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,54 @@

HardwareOptions hardwareOptions;

#if defined(LED_STRIP_GPIO)
extern const stm32_pulse_timer_t _led_timer;
#endif

#if !defined(BOOT)

#if defined(FUNCTION_SWITCHES)
#include "storage/storage.h"
#endif

#if defined(SIXPOS_SWITCH_INDEX)
uint8_t lastADCState = 0;
uint8_t sixPosState = 0;
bool dirty = true;
uint16_t getSixPosAnalogValue(uint16_t adcValue)
{
uint8_t currentADCState = 0;
if (adcValue > 3800)
currentADCState = 6;
else if (adcValue > 3100)
currentADCState = 5;
else if (adcValue > 2300)
currentADCState = 4;
else if (adcValue > 1500)
currentADCState = 3;
else if (adcValue > 1000)
currentADCState = 2;
else if (adcValue > 400)
currentADCState = 1;
if (lastADCState != currentADCState) {
lastADCState = currentADCState;
} else if (lastADCState != 0 && lastADCState - 1 != sixPosState) {
sixPosState = lastADCState - 1;
dirty = true;
}
if (dirty) {
for (uint8_t i = 0; i < 6; i++) {
if (i == sixPosState)
ws2812_set_color(i, SIXPOS_LED_RED, SIXPOS_LED_GREEN, SIXPOS_LED_BLUE);
else
ws2812_set_color(i, 0, 0, 0);
}
ws2812_update(&_led_timer);
}
return (4096/5)*(sixPosState);
}
#endif

void boardInit()
{
LL_APB1_GRP1_EnableClock(AUDIO_RCC_APB1Periph);
Expand Down Expand Up @@ -182,8 +224,6 @@ void boardInit()
usbInit();

#if defined(LED_STRIP_GPIO)
extern const stm32_pulse_timer_t _led_timer;

ws2812_init(&_led_timer, LED_STRIP_LENGTH, WS2812_GRB);
for (uint8_t i = 0; i < LED_STRIP_LENGTH; i++) {
ws2812_set_color(i, 0, 0, 50);
Expand Down
4 changes: 4 additions & 0 deletions radio/src/targets/taranis/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ void usbChargerInit();
bool usbChargerLed();
#endif

#if defined(RADIO_V14) || defined(RADIO_V12)
uint16_t getSixPosAnalogValue(uint16_t adcValue);
#endif

// LED driver
void ledInit();
void ledOff();
Expand Down
Loading

0 comments on commit b78da34

Please sign in to comment.