Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions radio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@ if(PCB STREQUAL X7 AND PCBREV STREQUAL LR3PRO)
else()
option(POWER_LED_BLUE "Override Power LED to be normally Blue" OFF)
endif()
option(POWER_LED_GREEN "Override Power LED to be normally Green" OFF)
option(POWER_LED_CYAN "Override Power LED to be normally Cyan" OFF)
option(POWER_LED_YELLOW "Override Power LED to be normally Yellow" OFF)
option(POWER_LED_MAGENTA "Override Power LED to be normally Magenta" OFF)
option(POWER_LED_WHITE "Override Power LED to be normally White" OFF)

set(POWER_LED_OPTIONS
POWER_LED_BLUE
POWER_LED_GREEN
POWER_LED_CYAN
POWER_LED_YELLOW
POWER_LED_MAGENTA
POWER_LED_WHITE
)
set(POWER_LED_OPTION_COUNT 0)
foreach(POWER_LED_OPTION ${POWER_LED_OPTIONS})
if(${POWER_LED_OPTION})
math(EXPR POWER_LED_OPTION_COUNT "${POWER_LED_OPTION_COUNT} + 1")
endif()
endforeach()
if(POWER_LED_OPTION_COUNT GREATER 1)
message(FATAL_ERROR "Only one POWER_LED_* color option can be enabled")
endif()

# since we reset all default CMAKE compiler flags for firmware builds, provide an alternate way for user to specify additional flags.
set(FIRMWARE_C_FLAGS "" CACHE STRING "Additional flags for firmware target c compiler (note: all CMAKE_C_FLAGS[_*] are ignored for firmware/bootloader).")
Expand Down Expand Up @@ -524,9 +547,11 @@ if(USBJ_EX)
)
endif()

if(POWER_LED_BLUE)
add_definitions(-DPOWER_LED_BLUE)
endif()
foreach(POWER_LED_OPTION ${POWER_LED_OPTIONS})
if(${POWER_LED_OPTION})
add_definitions(-D${POWER_LED_OPTION})
endif()
endforeach()

foreach(FILE ${TARGET_SRC})
set(SRC targets/${TARGET_DIR}/${FILE} ${SRC})
Expand Down
45 changes: 35 additions & 10 deletions radio/src/boards/generic_stm32/led_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,28 +108,53 @@ __weak void ledOff()
#endif
}

__weak void ledRed()
static void ledRgb(bool red, bool green, bool blue)
{
ledOff();
#if defined(LED_RED_GPIO)
GPIO_LED_GPIO_ON(LED_RED_GPIO);
if (red) GPIO_LED_GPIO_ON(LED_RED_GPIO);
#endif
#if defined(LED_GREEN_GPIO)
if (green) GPIO_LED_GPIO_ON(LED_GREEN_GPIO);
#endif
#if defined(LED_BLUE_GPIO)
if (blue) GPIO_LED_GPIO_ON(LED_BLUE_GPIO);
#endif
}

__weak void ledRed()
{
ledRgb(true, false, false);
}

__weak void ledGreen()
{
ledOff();
#if defined(LED_GREEN_GPIO)
GPIO_LED_GPIO_ON(LED_GREEN_GPIO);
#endif
ledRgb(false, true, false);
}

__weak void ledBlue()
{
ledOff();
#if defined(LED_BLUE_GPIO)
GPIO_LED_GPIO_ON(LED_BLUE_GPIO);
#endif
ledRgb(false, false, true);
}

__weak void ledYellow()
{
ledRgb(true, true, false);
}

__weak void ledMagenta()
{
ledRgb(true, false, true);
}

__weak void ledCyan()
{
ledRgb(false, true, true);
}

__weak void ledWhite()
{
ledRgb(true, true, true);
}

#if defined(FUNCTION_SWITCHES_RGB_LEDS)
Expand Down
14 changes: 11 additions & 3 deletions radio/src/boards/jumper-h750/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,18 @@ void boardInit()
delaysInit();
timersInit();

#if !defined(POWER_LED_BLUE)
ledBlue();
#else
#if defined(POWER_LED_WHITE)
ledWhite();
#elif defined(POWER_LED_MAGENTA)
ledMagenta();
#elif defined(POWER_LED_YELLOW)
ledYellow();
#elif defined(POWER_LED_CYAN)
ledCyan();
#elif defined(POWER_LED_GREEN)
ledGreen();
#else
ledBlue();
#endif

ExtFLASH_InitRuntime();
Expand Down
4 changes: 4 additions & 0 deletions radio/src/boards/jumper-h750/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ void ledOff();
void ledRed();
void ledBlue();
void ledGreen();
void ledYellow();
void ledMagenta();
void ledCyan();
void ledWhite();

// LCD driver
void lcdSetInitalFrameBuffer(void* fbAddress);
Expand Down
14 changes: 11 additions & 3 deletions radio/src/boards/rm-h750/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,18 @@ void boardInit()
timersInit();

usbChargerInit();
#if !defined(POWER_LED_BLUE)
ledBlue();
#else
#if defined(POWER_LED_WHITE)
ledWhite();
#elif defined(POWER_LED_MAGENTA)
ledMagenta();
#elif defined(POWER_LED_YELLOW)
ledYellow();
#elif defined(POWER_LED_CYAN)
ledCyan();
#elif defined(POWER_LED_GREEN)
ledGreen();
#else
ledBlue();
#endif

ExtFLASH_InitRuntime();
Expand Down
4 changes: 4 additions & 0 deletions radio/src/boards/rm-h750/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ void ledOff();
void ledRed();
void ledBlue();
void ledGreen();
void ledYellow();
void ledMagenta();
void ledCyan();
void ledWhite();

// LCD driver
void lcdSetInitalFrameBuffer(void* fbAddress);
Expand Down
27 changes: 22 additions & 5 deletions radio/src/edgetx.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,13 +570,30 @@ constexpr uint8_t OPENTX_START_NO_CHECKS = 0x04;

#if defined(STATUS_LEDS)
#define LED_ERROR_BEGIN() ledRed()
// Green "ready to use" if available, unless overridden by user or mfg preference
#if !defined(POWER_LED_BLUE) && (defined(LED_GREEN_GPIO) || defined(LED_STRIP_GPIO))
#define LED_ERROR_END() ledGreen()
#define LED_BIND() ledBlue()
#if (defined(PCBT15) || defined(PCBTX15) || defined(PCBTX16SMK3)) && defined(POWER_LED_WHITE)
#define LED_ERROR_END() ledWhite()
#define LED_BIND() ledBlue()
#elif (defined(PCBT15) || defined(PCBTX15) || defined(PCBTX16SMK3)) && defined(POWER_LED_MAGENTA)
#define LED_ERROR_END() ledMagenta()
#define LED_BIND() ledBlue()
#elif (defined(PCBT15) || defined(PCBTX15) || defined(PCBTX16SMK3)) && defined(POWER_LED_YELLOW)
#define LED_ERROR_END() ledYellow()
#define LED_BIND() ledBlue()
#elif (defined(PCBT15) || defined(PCBTX15) || defined(PCBTX16SMK3)) && defined(POWER_LED_CYAN)
#define LED_ERROR_END() ledCyan()
#define LED_BIND() ledBlue()
#elif (defined(PCBT15) || defined(PCBTX15) || defined(PCBTX16SMK3)) && defined(POWER_LED_GREEN)
#define LED_ERROR_END() ledGreen()
#define LED_BIND() ledBlue()
#else
// Green "ready to use" if available, unless overridden by user or mfg preference
#if !defined(POWER_LED_BLUE) && (defined(LED_GREEN_GPIO) || defined(LED_STRIP_GPIO))
#define LED_ERROR_END() ledGreen()
#define LED_BIND() ledBlue()
#else
// Either green is not an option, or blue is preferred "ready to use" color
#define LED_ERROR_END() ledBlue()
#define LED_ERROR_END() ledBlue()
#endif
#endif
#else
#define LED_ERROR_BEGIN()
Expand Down
15 changes: 15 additions & 0 deletions radio/src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ static const char * const options[] = {
#endif
#if defined(POWER_LED_BLUE)
"power_led_blue",
#endif
#if defined(POWER_LED_GREEN)
"power_led_green",
#endif
#if defined(POWER_LED_CYAN)
"power_led_cyan",
#endif
#if defined(POWER_LED_YELLOW)
"power_led_yellow",
#endif
#if defined(POWER_LED_MAGENTA)
"power_led_magenta",
#endif
#if defined(POWER_LED_WHITE)
"power_led_white",
#endif
nullptr //sentinel
};