mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-11 23:38:11 -07:00
Merge branch 'dev' of https://github.com/Flipper-XFW/Xtreme-Firmware into dev
This commit is contained in:
@@ -39,25 +39,26 @@
|
||||
static const GpioPin led_pin = {.port = GPIOA, .pin = LL_GPIO_PIN_8};
|
||||
static uint8_t led_buffer[SK6805_LED_COUNT][3];
|
||||
|
||||
void SK6805_init(void) {
|
||||
void SK6805_init() {
|
||||
DEBUG_INIT();
|
||||
furi_hal_gpio_write(SK6805_LED_PIN, false);
|
||||
furi_hal_gpio_init(SK6805_LED_PIN, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
|
||||
}
|
||||
|
||||
uint8_t SK6805_get_led_count(void) {
|
||||
uint8_t SK6805_get_led_count() {
|
||||
return (const uint8_t)SK6805_LED_COUNT;
|
||||
}
|
||||
void SK6805_set_led_color(uint8_t led_index, uint8_t r, uint8_t g, uint8_t b) {
|
||||
FURI_LOG_T(TAG, "led: %d, r: %d, g: %d, b: %d", led_index, r, g, b);
|
||||
furi_check(led_index < SK6805_LED_COUNT);
|
||||
|
||||
led_buffer[led_index][0] = g;
|
||||
led_buffer[led_index][1] = r;
|
||||
led_buffer[led_index][2] = b;
|
||||
FURI_LOG_T(TAG, "led: %d, r: %d, g: %d, b: %d", led_index, r, g, b);
|
||||
}
|
||||
|
||||
void SK6805_update(void) {
|
||||
void SK6805_update() {
|
||||
FURI_LOG_T(TAG, "update");
|
||||
SK6805_init();
|
||||
furi_kernel_lock();
|
||||
uint32_t end;
|
||||
|
||||
@@ -26,14 +26,14 @@
|
||||
/**
|
||||
* @brief Инициализация линии управления подсветкой
|
||||
*/
|
||||
void SK6805_init(void);
|
||||
void SK6805_init();
|
||||
|
||||
/**
|
||||
* @brief Получить количество светодиодов в подсветке
|
||||
*
|
||||
* @return Количество светодиодов
|
||||
*/
|
||||
uint8_t SK6805_get_led_count(void);
|
||||
uint8_t SK6805_get_led_count();
|
||||
|
||||
/**
|
||||
* @brief Установить цвет свечения светодиода
|
||||
@@ -48,6 +48,6 @@ void SK6805_set_led_color(uint8_t led_index, uint8_t r, uint8_t g, uint8_t b);
|
||||
/**
|
||||
* @brief Обновление состояния подсветки дисплея
|
||||
*/
|
||||
void SK6805_update(void);
|
||||
void SK6805_update();
|
||||
|
||||
#endif /* SK6805_H_ */
|
||||
|
||||
+112
-87
@@ -47,58 +47,27 @@ static struct {
|
||||
|
||||
static struct {
|
||||
bool settings_loaded;
|
||||
FuriMutex* mutex;
|
||||
bool enabled;
|
||||
bool last_rainbow;
|
||||
uint8_t last_brightness;
|
||||
RgbColor last_colors[SK6805_LED_COUNT];
|
||||
FuriTimer* rainbow_timer;
|
||||
HsvColor rainbow_hsv;
|
||||
} rgb_state = {
|
||||
.settings_loaded = false,
|
||||
.mutex = NULL,
|
||||
.enabled = false,
|
||||
.last_rainbow = true,
|
||||
.last_brightness = 0,
|
||||
.last_colors =
|
||||
{
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, 0, 0},
|
||||
},
|
||||
.rainbow_timer = NULL,
|
||||
.rainbow_hsv = {0, 255, 255},
|
||||
};
|
||||
|
||||
static void rainbow_timer(void* ctx) {
|
||||
UNUSED(ctx);
|
||||
rgb_backlight_update(rgb_state.last_brightness, true);
|
||||
}
|
||||
|
||||
void rgb_backlight_reconfigure(bool enabled) {
|
||||
if(enabled && !rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
}
|
||||
void rgb_backlight_load_settings(bool enabled) {
|
||||
if(rgb_state.settings_loaded) return;
|
||||
rgb_state.enabled = enabled;
|
||||
rgb_state.mutex = furi_mutex_alloc(FuriMutexTypeRecursive);
|
||||
|
||||
if(rgb_state.enabled && rgb_settings.rainbow_mode != RGBBacklightRainbowModeOff) {
|
||||
if(rgb_state.rainbow_timer == NULL) {
|
||||
rgb_state.rainbow_timer = furi_timer_alloc(rainbow_timer, FuriTimerTypePeriodic, NULL);
|
||||
} else {
|
||||
furi_timer_stop(rgb_state.rainbow_timer);
|
||||
}
|
||||
furi_timer_start(rgb_state.rainbow_timer, rgb_settings.rainbow_interval);
|
||||
} else if(rgb_state.rainbow_timer != NULL) {
|
||||
furi_timer_stop(rgb_state.rainbow_timer);
|
||||
furi_timer_free(rgb_state.rainbow_timer);
|
||||
rgb_state.rainbow_timer = NULL;
|
||||
}
|
||||
rgb_state.rainbow_hsv.s = rgb_settings.rainbow_saturation;
|
||||
|
||||
rgb_backlight_update(rgb_state.last_brightness, false);
|
||||
}
|
||||
|
||||
void rgb_backlight_load_settings(void) {
|
||||
// Do not load data from internal memory when booting in DFU mode
|
||||
if(!furi_hal_is_normal_boot() || rgb_state.settings_loaded) {
|
||||
if(!furi_hal_is_normal_boot()) {
|
||||
rgb_state.settings_loaded = true;
|
||||
return;
|
||||
}
|
||||
@@ -114,108 +83,166 @@ void rgb_backlight_load_settings(void) {
|
||||
rgb_backlight_reconfigure(rgb_state.enabled);
|
||||
}
|
||||
|
||||
void rgb_backlight_save_settings(void) {
|
||||
void rgb_backlight_save_settings() {
|
||||
if(!rgb_state.settings_loaded) return;
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
saved_struct_save(
|
||||
RGB_BACKLIGHT_SETTINGS_PATH,
|
||||
&rgb_settings,
|
||||
sizeof(rgb_settings),
|
||||
RGB_BACKLIGHT_SETTINGS_MAGIC,
|
||||
RGB_BACKLIGHT_SETTINGS_VERSION);
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void rgb_backlight_set_color(uint8_t index, RgbColor color) {
|
||||
if(index >= COUNT_OF(rgb_settings.colors)) return;
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
}
|
||||
|
||||
if(!rgb_state.settings_loaded) return;
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
rgb_settings.colors[index] = color;
|
||||
rgb_backlight_reconfigure(rgb_state.enabled);
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
RgbColor rgb_backlight_get_color(uint8_t index) {
|
||||
if(index >= COUNT_OF(rgb_settings.colors)) return (RgbColor){0, 0, 0};
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
}
|
||||
return rgb_settings.colors[index];
|
||||
|
||||
if(!rgb_state.settings_loaded) return (RgbColor){0, 0, 0};
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
RgbColor color = rgb_settings.colors[index];
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
return color;
|
||||
}
|
||||
|
||||
void rgb_backlight_set_rainbow_mode(RGBBacklightRainbowMode rainbow_mode) {
|
||||
if(rainbow_mode >= RGBBacklightRainbowModeCount) return;
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
}
|
||||
|
||||
if(!rgb_state.settings_loaded) return;
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
rgb_settings.rainbow_mode = rainbow_mode;
|
||||
rgb_backlight_reconfigure(rgb_state.enabled);
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
RGBBacklightRainbowMode rgb_backlight_get_rainbow_mode() {
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
}
|
||||
return rgb_settings.rainbow_mode;
|
||||
if(!rgb_state.settings_loaded) return 0;
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
RGBBacklightRainbowMode rainbow_mode = rgb_settings.rainbow_mode;
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
return rainbow_mode;
|
||||
}
|
||||
|
||||
void rgb_backlight_set_rainbow_speed(uint8_t rainbow_speed) {
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
}
|
||||
if(!rgb_state.settings_loaded) return;
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
rgb_settings.rainbow_speed = rainbow_speed;
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
uint8_t rgb_backlight_get_rainbow_speed() {
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
}
|
||||
return rgb_settings.rainbow_speed;
|
||||
if(!rgb_state.settings_loaded) return 0;
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
uint8_t rainbow_speed = rgb_settings.rainbow_speed;
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
return rainbow_speed;
|
||||
}
|
||||
|
||||
void rgb_backlight_set_rainbow_interval(uint32_t rainbow_interval) {
|
||||
if(rainbow_interval < 100) return;
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
}
|
||||
|
||||
if(!rgb_state.settings_loaded) return;
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
rgb_settings.rainbow_interval = rainbow_interval;
|
||||
rgb_backlight_reconfigure(rgb_state.enabled);
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
uint32_t rgb_backlight_get_rainbow_interval() {
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
}
|
||||
return rgb_settings.rainbow_interval;
|
||||
if(!rgb_state.settings_loaded) return 0;
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
uint32_t rainbow_interval = rgb_settings.rainbow_interval;
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
return rainbow_interval;
|
||||
}
|
||||
|
||||
void rgb_backlight_set_rainbow_saturation(uint8_t rainbow_saturation) {
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
}
|
||||
if(!rgb_state.settings_loaded) return;
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
rgb_settings.rainbow_saturation = rainbow_saturation;
|
||||
rgb_backlight_reconfigure(rgb_state.enabled);
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
uint8_t rgb_backlight_get_rainbow_saturation() {
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
if(!rgb_state.settings_loaded) return 0;
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
uint8_t rainbow_saturation = rgb_settings.rainbow_saturation;
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
return rainbow_saturation;
|
||||
}
|
||||
|
||||
static void rainbow_timer(void* ctx) {
|
||||
UNUSED(ctx);
|
||||
rgb_backlight_update(rgb_state.last_brightness, true);
|
||||
}
|
||||
|
||||
void rgb_backlight_reconfigure(bool enabled) {
|
||||
if(!rgb_state.settings_loaded) return;
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
rgb_state.enabled = enabled;
|
||||
if(rgb_state.enabled && rgb_settings.rainbow_mode != RGBBacklightRainbowModeOff) {
|
||||
if(rgb_state.rainbow_timer == NULL) {
|
||||
rgb_state.rainbow_timer = furi_timer_alloc(rainbow_timer, FuriTimerTypePeriodic, NULL);
|
||||
} else {
|
||||
furi_timer_stop(rgb_state.rainbow_timer);
|
||||
}
|
||||
furi_timer_start(rgb_state.rainbow_timer, rgb_settings.rainbow_interval);
|
||||
} else if(rgb_state.rainbow_timer != NULL) {
|
||||
furi_timer_stop(rgb_state.rainbow_timer);
|
||||
furi_timer_free(rgb_state.rainbow_timer);
|
||||
rgb_state.rainbow_timer = NULL;
|
||||
}
|
||||
return rgb_settings.rainbow_saturation;
|
||||
rgb_state.rainbow_hsv.s = rgb_settings.rainbow_saturation;
|
||||
rgb_backlight_update(rgb_state.last_brightness, false);
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void rgb_backlight_update(uint8_t brightness, bool tick) {
|
||||
if(!rgb_state.enabled) return;
|
||||
if(!rgb_state.settings_loaded) {
|
||||
rgb_backlight_load_settings();
|
||||
if(!rgb_state.settings_loaded) return;
|
||||
furi_check(furi_mutex_acquire(rgb_state.mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
if(!rgb_state.enabled) {
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
return;
|
||||
}
|
||||
|
||||
switch(rgb_settings.rainbow_mode) {
|
||||
case RGBBacklightRainbowModeOff: {
|
||||
if(!rgb_state.last_rainbow && rgb_state.last_brightness == brightness &&
|
||||
memcmp(rgb_state.last_colors, rgb_settings.colors, sizeof(rgb_settings.colors)) == 0) {
|
||||
return;
|
||||
}
|
||||
rgb_state.last_rainbow = false;
|
||||
memcpy(rgb_state.last_colors, rgb_settings.colors, sizeof(rgb_settings.colors));
|
||||
|
||||
float bright = brightness / 255.0f;
|
||||
for(uint8_t i = 0; i < SK6805_get_led_count(); i++) {
|
||||
SK6805_set_led_color(
|
||||
@@ -229,14 +256,9 @@ void rgb_backlight_update(uint8_t brightness, bool tick) {
|
||||
|
||||
case RGBBacklightRainbowModeWave:
|
||||
case RGBBacklightRainbowModeSolid: {
|
||||
rgb_state.last_rainbow = true;
|
||||
|
||||
if(tick && brightness) {
|
||||
rgb_state.rainbow_hsv.h += rgb_settings.rainbow_speed;
|
||||
} else {
|
||||
if(rgb_state.last_brightness == brightness && rgb_state.last_rainbow) {
|
||||
return;
|
||||
}
|
||||
rgb_state.rainbow_hsv.v = brightness;
|
||||
}
|
||||
|
||||
@@ -254,9 +276,12 @@ void rgb_backlight_update(uint8_t brightness, bool tick) {
|
||||
}
|
||||
|
||||
default:
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
return;
|
||||
}
|
||||
|
||||
rgb_state.last_brightness = brightness;
|
||||
SK6805_update();
|
||||
|
||||
furi_check(furi_mutex_release(rgb_state.mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
@@ -33,16 +33,11 @@ typedef enum {
|
||||
} RGBBacklightRainbowMode;
|
||||
|
||||
/**
|
||||
* @brief Reconfigure rgb backlight with new settings
|
||||
* @brief Load backlight settings from SD card. Needs to be run at boot
|
||||
*
|
||||
* @param enabled Whether the rgb backlight is enabled
|
||||
*/
|
||||
void rgb_backlight_reconfigure(bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Load backlight settings from SD card
|
||||
*/
|
||||
void rgb_backlight_load_settings();
|
||||
void rgb_backlight_load_settings(bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Save Current RGB Lighting Settings
|
||||
@@ -95,6 +90,13 @@ void rgb_backlight_set_rainbow_saturation(uint8_t rainbow_saturation);
|
||||
|
||||
uint8_t rgb_backlight_get_rainbow_saturation();
|
||||
|
||||
/**
|
||||
* @brief Reconfigure rgb backlight with new settings
|
||||
*
|
||||
* @param enabled Whether the rgb backlight is enabled
|
||||
*/
|
||||
void rgb_backlight_reconfigure(bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Apply current RGB lighting settings
|
||||
*
|
||||
|
||||
+1
-1
Submodule lib/libusb_stm32 updated: 9168e2a31d...6ca2857519
@@ -64,7 +64,6 @@ sources += [
|
||||
"stm32wb_copro/wpan/ble/core/auto/ble_l2cap_aci.c",
|
||||
"stm32wb_copro/wpan/ble/core/template/osal.c",
|
||||
"stm32wb_copro/wpan/utilities/dbg_trace.c",
|
||||
"stm32wb_copro/wpan/utilities/otp.c",
|
||||
"stm32wb_copro/wpan/utilities/stm_list.c",
|
||||
]
|
||||
|
||||
|
||||
+1
-1
Submodule lib/stm32wb_copro updated: 6c9c54f056...bbccbefae2
@@ -688,7 +688,7 @@ static void subghz_protocol_nice_flor_s_remote_controller(
|
||||
if(subghz_custom_btn_get_original() == 0) {
|
||||
subghz_custom_btn_set_original(instance->btn);
|
||||
}
|
||||
subghz_custom_btn_set_max(3);
|
||||
subghz_custom_btn_set_max(4);
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_decoder_nice_flor_s_get_hash_data(void* context) {
|
||||
@@ -774,6 +774,9 @@ static uint8_t subghz_protocol_nice_flor_s_get_btn_code() {
|
||||
case 0x8:
|
||||
btn = 0x1;
|
||||
break;
|
||||
case 0x3:
|
||||
btn = 0x1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -792,6 +795,9 @@ static uint8_t subghz_protocol_nice_flor_s_get_btn_code() {
|
||||
case 0x8:
|
||||
btn = 0x4;
|
||||
break;
|
||||
case 0x3:
|
||||
btn = 0x4;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -810,6 +816,30 @@ static uint8_t subghz_protocol_nice_flor_s_get_btn_code() {
|
||||
case 0x8:
|
||||
btn = 0x2;
|
||||
break;
|
||||
case 0x3:
|
||||
btn = 0x8;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(custom_btn_id == SUBGHZ_CUSTOM_BTN_RIGHT) {
|
||||
switch(original_btn_code) {
|
||||
case 0x1:
|
||||
btn = 0x3;
|
||||
break;
|
||||
case 0x2:
|
||||
btn = 0x3;
|
||||
break;
|
||||
case 0x4:
|
||||
btn = 0x3;
|
||||
break;
|
||||
case 0x8:
|
||||
btn = 0x3;
|
||||
break;
|
||||
case 0x3:
|
||||
btn = 0x2;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -196,7 +196,7 @@ void XTREME_SETTINGS_LOAD() {
|
||||
flipper_format_free(file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
rgb_backlight_reconfigure(x->rgb_backlight);
|
||||
rgb_backlight_load_settings(x->rgb_backlight);
|
||||
}
|
||||
|
||||
void XTREME_SETTINGS_SAVE() {
|
||||
|
||||
Reference in New Issue
Block a user