1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 03:20:00 +03:00

LED Dimmer (#13776)

* LED Dimmer

Build with EXTRA_FLAGS=-DUSE_LED_STRIP

Tested on SpeedyBeeF7V3

Added adjrange to update the ledstrip_brightness variable. This allows for easy changing of LEDs without having to connect to the configurator.

* Added Unit Tests, Space to Tab

Added unit tests into rx_controls_unittest.cc. The LED brightness is returned as 50 for testing purposes.

Changed tabs in ledstrip.c & .h and rc_adjustments.c to 4 spaces for coding standards.

* Update src/main/fc/rc_adjustments.h

Missed a tab in rc_adjustments.h

Co-authored-by: nerdCopter <56646290+nerdCopter@users.noreply.github.com>

* Update src/main/fc/rc_adjustments.c

Removal of empty line

Co-authored-by: nerdCopter <56646290+nerdCopter@users.noreply.github.com>

* Update rc_adjustments.c

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>

* Update src/main/io/ledstrip.c

* Update src/main/io/ledstrip.h

* Update src/test/unit/rc_controls_unittest.cc

---------

Co-authored-by: nerdCopter <56646290+nerdCopter@users.noreply.github.com>
Co-authored-by: Jay Blackman <blckmn@users.noreply.github.com>
Co-authored-by: Petr Ledvina <ledvinap@gmail.com>
Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
This commit is contained in:
jpmreece 2024-12-23 20:28:43 +00:00 committed by GitHub
parent 00bcbdd897
commit d22d8405c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 30 additions and 0 deletions

View file

@ -226,6 +226,10 @@ static const adjustmentConfig_t defaultAdjustmentConfigs[ADJUSTMENT_FUNCTION_COU
.adjustmentFunction = ADJUSTMENT_LED_PROFILE,
.mode = ADJUSTMENT_MODE_SELECT,
.data = { .switchPositions = 3 }
}, {
.adjustmentFunction = ADJUSTMENT_LED_DIMMER,
.mode = ADJUSTMENT_MODE_SELECT,
.data = { .switchPositions = 100 }
}
};
@ -264,6 +268,8 @@ static const char * const adjustmentLabels[] = {
"ROLL F",
"YAW F",
"OSD PROFILE",
"LED PROFILE",
"LED DIMMER",
};
static int adjustmentRangeNameIndex = 0;
@ -641,6 +647,13 @@ static uint8_t applySelectAdjustment(adjustmentFunction_e adjustmentFunction, ui
if (getLedProfile() != position) {
setLedProfile(position);
}
#endif
break;
case ADJUSTMENT_LED_DIMMER:
#ifdef USE_LED_STRIP
if (getLedBrightness() != position) {
setLedBrightness(position);
}
#endif
break;

View file

@ -62,6 +62,7 @@ typedef enum {
ADJUSTMENT_YAW_F,
ADJUSTMENT_OSD_PROFILE,
ADJUSTMENT_LED_PROFILE,
ADJUSTMENT_LED_DIMMER,
ADJUSTMENT_FUNCTION_COUNT
} adjustmentFunction_e;

View file

@ -1588,4 +1588,16 @@ void setLedProfile(uint8_t profile)
ledStripConfigMutable()->ledstrip_profile = profile;
}
}
uint8_t getLedBrightness(void)
{
return ledStripConfig()->ledstrip_brightness;
}
void setLedBrightness(uint8_t brightness)
{
if ( brightness <= 100 ) {
ledStripConfigMutable()->ledstrip_brightness = brightness;
}
}
#endif

View file

@ -239,3 +239,5 @@ void updateRequiredOverlay(void);
uint8_t getLedProfile(void);
void setLedProfile(uint8_t profile);
uint8_t getLedBrightness(void);
void setLedBrightness(uint8_t brightness);

View file

@ -654,6 +654,8 @@ bool isTryingToArm(void) { return false; }
void resetTryingToArm(void) {}
void setLedProfile(uint8_t profile) { UNUSED(profile); }
uint8_t getLedProfile(void) { return 0; }
uint8_t getLedBrightness(void) { return 50; }
void setLedBrightness(uint8_t brightness) { UNUSED(brightness); }
void compassStartCalibration(void) {}
void pinioBoxTaskControl(void) {}
void schedulerIgnoreTaskExecTime(void) {}