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 @@ -549,9 +572,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
48 changes: 37 additions & 11 deletions radio/src/boards/generic_stm32/led_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,31 +115,57 @@ __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_RED2_GPIO)
GPIO_LED_GPIO_ON(LED_RED2_GPIO);
if (red) GPIO_LED_GPIO_ON(LED_RED2_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
6 changes: 3 additions & 3 deletions radio/src/boards/jumper-h750/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#include "stm32_adc.h"
#include "stm32_gpio.h"
#include "stm32_i2c_driver.h"
Expand Down Expand Up @@ -198,7 +198,7 @@ void boardOff()
// RTC->BKP0R = SHUTDOWN_REQUEST;
pwrOff();

// We reach here only in forced power situations, such as hw-debugging with external power
// We reach here only in forced power situations, such as hw-debugging with external power
// Enter STM32 stop mode / deep-sleep
// Code snippet from ST Nucleo PWR_EnterStopMode example
#define PDMode 0x00000000U
Expand All @@ -212,7 +212,7 @@ void boardOff()

/* Set SLEEPDEEP bit of Cortex System Control Register */
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));

// To avoid HardFault at return address, end in an endless loop
while (1) {

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
7 changes: 4 additions & 3 deletions radio/src/boards/rm-h750/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#include "stm32_adc.h"
#include "stm32_gpio.h"
#include "stm32_i2c_driver.h"
Expand Down Expand Up @@ -167,6 +167,7 @@ void boardInit()
timersInit();

usbChargerInit();

#if !defined(POWER_LED_BLUE)
ledBlue();
#else
Expand Down Expand Up @@ -227,7 +228,7 @@ void boardOff()

pwrOff();

// We reach here only in forced power situations, such as hw-debugging with external power
// We reach here only in forced power situations, such as hw-debugging with external power
// Enter STM32 stop mode / deep-sleep
// Code snippet from ST Nucleo PWR_EnterStopMode example
#define PDMode 0x00000000U
Expand All @@ -241,7 +242,7 @@ void boardOff()

/* Set SLEEPDEEP bit of Cortex System Control Register */
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));

// To avoid HardFault at return address, end in an endless loop
while (1) {

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
57 changes: 51 additions & 6 deletions radio/src/edgetx.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,15 +570,60 @@ constexpr uint8_t OPENTX_START_NO_CHECKS = 0x04;

#if 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()

// Check discrete GPIO capability. STATUS_LED_STRIP means a board's
// led_driver.cpp drives the status LED through an RGB strip and can
// produce any color, so it satisfies every check below.
#define LED_HAS_RED (defined(LED_RED_GPIO) || defined(LED_RED2_GPIO) || defined(STATUS_LED_STRIP))
#define LED_HAS_GREEN (defined(LED_GREEN_GPIO) || defined(STATUS_LED_STRIP))
#define LED_HAS_BLUE (defined(LED_BLUE_GPIO) || defined(STATUS_LED_STRIP))

#define LED_HAS_YELLOW (LED_HAS_RED && LED_HAS_GREEN)
#define LED_HAS_MAGENTA (LED_HAS_RED && LED_HAS_BLUE)
#define LED_HAS_CYAN (LED_HAS_GREEN && LED_HAS_BLUE)
#define LED_HAS_WHITE (LED_HAS_RED && LED_HAS_GREEN && LED_HAS_BLUE)

#if defined(POWER_LED_WHITE) && !LED_HAS_WHITE
#error "POWER_LED_WHITE requires red, green and blue status LED GPIOs (or a strip-driven status LED)"
#elif defined(POWER_LED_MAGENTA) && !LED_HAS_MAGENTA
#error "POWER_LED_MAGENTA requires red and blue status LED GPIOs (or a strip-driven status LED)"
#elif defined(POWER_LED_YELLOW) && !LED_HAS_YELLOW
#error "POWER_LED_YELLOW requires red and green status LED GPIOs (or a strip-driven status LED)"
#elif defined(POWER_LED_CYAN) && !LED_HAS_CYAN
#error "POWER_LED_CYAN requires green and blue status LED GPIOs (or a strip-driven status LED)"
#elif defined(POWER_LED_GREEN) && !LED_HAS_GREEN
#error "POWER_LED_GREEN requires a green status LED GPIO (or a strip-driven status LED)"
#endif
Comment thread
pfeerick marked this conversation as resolved.

#if defined(POWER_LED_WHITE) && LED_HAS_WHITE
#define LED_ERROR_END() ledWhite()
#define LED_BIND() ledBlue()
#elif defined(POWER_LED_MAGENTA) && LED_HAS_MAGENTA
#define LED_ERROR_END() ledMagenta()
#define LED_BIND() ledBlue()
#elif defined(POWER_LED_YELLOW) && LED_HAS_YELLOW
#define LED_ERROR_END() ledYellow()
#define LED_BIND() ledBlue()
#elif defined(POWER_LED_CYAN) && LED_HAS_CYAN
#define LED_ERROR_END() ledCyan()
#define LED_BIND() ledBlue()
#elif defined(POWER_LED_GREEN) && LED_HAS_GREEN
#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()
// No POWER_LED_* override set - default to green if available, else blue.
#if !defined(POWER_LED_BLUE) && LED_HAS_GREEN
#define LED_ERROR_END() ledGreen()
#define LED_BIND() ledBlue()
#else
#define LED_ERROR_END() ledBlue()
#endif
Comment thread
pfeerick marked this conversation as resolved.
#endif
#else
#if defined(POWER_LED_BLUE) || defined(POWER_LED_GREEN) || defined(POWER_LED_CYAN) || \
defined(POWER_LED_YELLOW) || defined(POWER_LED_MAGENTA) || defined(POWER_LED_WHITE)
#error "POWER_LED_* requires a board with a status LED (STATUS_LEDS)"
#endif
#define LED_ERROR_BEGIN()
#define LED_ERROR_END()
#endif
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
};
8 changes: 5 additions & 3 deletions radio/src/targets/horus/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ void ledInit();
void ledOff();
void ledRed();
void ledBlue();
#if defined(LED_GREEN_GPIO)
void ledGreen();
#endif
void ledGreen();
void ledYellow();
void ledMagenta();
void ledCyan();
void ledWhite();

// LCD driver

Expand Down
1 change: 1 addition & 0 deletions radio/src/targets/pa01/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ set(SIZE_TARGET_MEM_DEFINE "MEM_SIZE_SDRAM1=8192")
set(FIRMWARE_STRIP_BOOTLOADER YES)

add_definitions(-DPCBPA01 -DPCBHORUS -DPCBFLYSKY)
add_definitions(-DSTATUS_LED_STRIP)
add_definitions(-DBATTERY_CHARGE)
add_definitions(-DSTM32_SUPPORT_32BIT_TIMERS)
add_definitions(-DFIRMWARE_QSPI)
Expand Down
Loading