Merge branch 'dev' into xtruan/eurocorp_menu

This commit is contained in:
Struan Clark
2023-08-15 19:08:11 -06:00
23 changed files with 791 additions and 199 deletions

View File

@@ -16,5 +16,6 @@ ADD_SCENE(xtreme_app, protocols_freqs_add, ProtocolsFreqsAdd)
ADD_SCENE(xtreme_app, protocols_gpio, ProtocolsGpio)
ADD_SCENE(xtreme_app, misc, Misc)
ADD_SCENE(xtreme_app, misc_screen, MiscScreen)
ADD_SCENE(xtreme_app, misc_screen_color, MiscScreenColor)
ADD_SCENE(xtreme_app, misc_dolphin, MiscDolphin)
ADD_SCENE(xtreme_app, misc_rename, MiscRename)

View File

@@ -27,10 +27,34 @@ static void xtreme_app_scene_interface_graphics_asset_pack_changed(VariableItem*
app->apply_pack = true;
}
const char* const anim_speed_names[] =
{"25%", "50%", "75%", "100%", "125%", "150%", "175%", "200%", "225%", "250%", "275%", "300%"};
const uint32_t anim_speed_values[COUNT_OF(anim_speed_names)] =
{25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300};
const char* const anim_speed_names[] = {
"25%",
"50%",
"75%",
"100%",
"125%",
"150%",
"175%",
"200%",
"225%",
"250%",
"275%",
"300%",
};
const uint32_t anim_speed_values[COUNT_OF(anim_speed_names)] = {
25,
50,
75,
100,
125,
150,
175,
200,
225,
250,
275,
300,
};
static void xtreme_app_scene_interface_graphics_anim_speed_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
@@ -52,9 +76,23 @@ const char* const cycle_anims_names[] = {
"2 H",
"6 H",
"12 H",
"24 H"};
const int32_t cycle_anims_values[COUNT_OF(cycle_anims_names)] =
{-1, 0, 30, 60, 300, 600, 900, 1800, 3600, 7200, 21600, 43200, 86400};
"24 H",
};
const int32_t cycle_anims_values[COUNT_OF(cycle_anims_names)] = {
-1,
0,
30,
60,
300,
600,
900,
1800,
3600,
7200,
21600,
43200,
86400,
};
static void xtreme_app_scene_interface_graphics_cycle_anims_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);

View File

@@ -13,8 +13,15 @@ void xtreme_app_scene_interface_statusbar_var_item_list_callback(void* context,
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}
const char* const battery_icon_names[BatteryIconCount] =
{"OFF", "Bar", "%", "Inv. %", "Retro 3", "Retro 5", "Bar %"};
const char* const battery_icon_names[BatteryIconCount] = {
"OFF",
"Bar",
"%",
"Inv. %",
"Retro 3",
"Retro 5",
"Bar %",
};
static void xtreme_app_scene_interface_statusbar_battery_icon_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);

View File

@@ -29,10 +29,30 @@ static void xtreme_app_scene_misc_dolphin_dolphin_angry_changed(VariableItem* it
app->save_angry = true;
}
const char* const butthurt_timer_names[] =
{"OFF", "30 M", "1 H", "2 H", "4 H", "6 H", "8 H", "12 H", "24 H", "48 H"};
const uint32_t butthurt_timer_values[COUNT_OF(butthurt_timer_names)] =
{0, 1800, 3600, 7200, 14400, 21600, 28800, 43200, 86400, 172800};
const char* const butthurt_timer_names[] = {
"OFF",
"30 M",
"1 H",
"2 H",
"4 H",
"6 H",
"8 H",
"12 H",
"24 H",
"48 H",
};
const uint32_t butthurt_timer_values[COUNT_OF(butthurt_timer_names)] = {
0,
1800,
3600,
7200,
14400,
21600,
28800,
43200,
86400,
172800,
};
static void xtreme_app_scene_misc_dolphin_butthurt_timer_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);

View File

@@ -4,7 +4,13 @@ enum VarItemListIndex {
VarItemListIndexDarkMode,
VarItemListIndexLeftHanded,
VarItemListIndexRgbBacklight,
VarItemListIndexLcdColor,
VarItemListIndexLcdColor0,
VarItemListIndexLcdColor1,
VarItemListIndexLcdColor2,
VarItemListIndexRainbowLcd,
VarItemListIndexRainbowSpeed,
VarItemListIndexRainbowInterval,
VarItemListIndexRainbowSaturation,
};
void xtreme_app_scene_misc_screen_var_item_list_callback(void* context, uint32_t index) {
@@ -30,13 +36,117 @@ static void xtreme_app_scene_misc_screen_hand_orient_changed(VariableItem* item)
}
}
static void xtreme_app_scene_misc_screen_lcd_color_changed(VariableItem* item) {
static const struct {
char* name;
RgbColor color;
} lcd_colors[] = {
{"Orange", {255, 69, 0}},
{"Red", {255, 0, 0}},
{"Maroon", {128, 0, 0}},
{"Yellow", {255, 255, 0}},
{"Olive", {128, 128, 0}},
{"Lime", {0, 255, 0}},
{"Green", {0, 128, 0}},
{"Aqua", {0, 255, 127}},
{"Cyan", {0, 210, 210}},
{"Azure", {0, 127, 255}},
{"Teal", {0, 128, 128}},
{"Blue", {0, 0, 255}},
{"Navy", {0, 0, 128}},
{"Purple", {128, 0, 128}},
{"Fuchsia", {255, 0, 255}},
{"Pink", {173, 31, 173}},
{"Brown", {165, 42, 42}},
{"White", {255, 192, 203}},
};
static void xtreme_app_scene_misc_screen_lcd_color_changed(VariableItem* item, uint8_t led) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, rgb_backlight_get_color_text(index));
rgb_backlight_set_color(index);
variable_item_set_current_value_text(item, lcd_colors[index].name);
rgb_backlight_set_color(led, lcd_colors[index].color);
app->save_backlight = true;
}
static void xtreme_app_scene_misc_screen_lcd_color_0_changed(VariableItem* item) {
xtreme_app_scene_misc_screen_lcd_color_changed(item, 0);
}
static void xtreme_app_scene_misc_screen_lcd_color_1_changed(VariableItem* item) {
xtreme_app_scene_misc_screen_lcd_color_changed(item, 1);
}
static void xtreme_app_scene_misc_screen_lcd_color_2_changed(VariableItem* item) {
xtreme_app_scene_misc_screen_lcd_color_changed(item, 2);
}
const char* const rainbow_lcd_names[RGBBacklightRainbowModeCount] = {
"OFF",
"Wave",
"Static",
};
static void xtreme_app_scene_misc_screen_rainbow_lcd_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, rainbow_lcd_names[index]);
rgb_backlight_set_rainbow_mode(index);
app->save_backlight = true;
}
static void xtreme_app_scene_misc_screen_rainbow_speed_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item) + 1;
char str[4];
snprintf(str, sizeof(str), "%d", index);
variable_item_set_current_value_text(item, str);
rgb_backlight_set_rainbow_speed(index);
app->save_backlight = true;
}
const char* const rainbow_interval_names[] = {
"0.1 S",
"0.2 S",
"0.25 S",
"0.5 S",
"0.75 S",
"1 S",
"1.25 S",
"1.5 S",
"1.75 S",
"2 S",
"2.5 S",
"3 S",
"4 S",
"5 S",
};
const uint32_t rainbow_interval_values[COUNT_OF(rainbow_interval_names)] = {
100,
200,
250,
500,
750,
1000,
1250,
1500,
1750,
2000,
2500,
3000,
4000,
5000,
};
static void xtreme_app_scene_misc_screen_rainbow_interval_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, rainbow_interval_names[index]);
rgb_backlight_set_rainbow_interval(rainbow_interval_values[index]);
app->save_backlight = true;
}
static void xtreme_app_scene_misc_screen_rainbow_saturation_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item) + 1;
char str[4];
snprintf(str, sizeof(str), "%d", index);
variable_item_set_current_value_text(item, str);
rgb_backlight_set_rainbow_saturation(index);
app->save_backlight = true;
notification_message(app->notification, &sequence_display_backlight_on);
}
void xtreme_app_scene_misc_screen_on_enter(void* context) {
@@ -60,15 +170,87 @@ void xtreme_app_scene_misc_screen_on_enter(void* context) {
item = variable_item_list_add(var_item_list, "RGB Backlight", 1, NULL, app);
variable_item_set_current_value_text(item, xtreme_settings->rgb_backlight ? "ON" : "OFF");
struct {
uint8_t led;
const char* str;
VariableItemChangeCallback cb;
} lcd_cols[] = {
{0, "LCD Left", xtreme_app_scene_misc_screen_lcd_color_0_changed},
{1, "LCD Middle", xtreme_app_scene_misc_screen_lcd_color_1_changed},
{2, "LCD Right", xtreme_app_scene_misc_screen_lcd_color_2_changed},
};
size_t lcd_sz = COUNT_OF(lcd_colors);
for(size_t i = 0; i < COUNT_OF(lcd_cols); i++) {
item = variable_item_list_add(var_item_list, lcd_cols[i].str, lcd_sz, lcd_cols[i].cb, app);
RgbColor color = rgb_backlight_get_color(lcd_cols[i].led);
bool found = false;
for(size_t i = 0; i < lcd_sz; i++) {
if(rgbcmp(&color, &lcd_colors[i].color) != 0) continue;
value_index = i;
found = true;
break;
}
variable_item_set_current_value_index(item, found ? value_index : lcd_sz);
if(found) {
variable_item_set_current_value_text(item, lcd_colors[value_index].name);
} else {
char str[7];
snprintf(str, sizeof(str), "%02X%02X%02X", color.r, color.g, color.b);
variable_item_set_current_value_text(item, str);
}
variable_item_set_locked(item, !xtreme_settings->rgb_backlight, "Needs RGB\nBacklight!");
}
item = variable_item_list_add(
var_item_list,
"LCD Color",
rgb_backlight_get_color_count(),
xtreme_app_scene_misc_screen_lcd_color_changed,
"Rainbow LCD",
RGBBacklightRainbowModeCount,
xtreme_app_scene_misc_screen_rainbow_lcd_changed,
app);
value_index = rgb_backlight_get_settings()->display_color_index;
value_index = rgb_backlight_get_rainbow_mode();
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, rgb_backlight_get_color_text(value_index));
variable_item_set_current_value_text(item, rainbow_lcd_names[value_index]);
variable_item_set_locked(item, !xtreme_settings->rgb_backlight, "Needs RGB\nBacklight!");
item = variable_item_list_add(
var_item_list,
"Rainbow Speed",
25,
xtreme_app_scene_misc_screen_rainbow_speed_changed,
app);
value_index = rgb_backlight_get_rainbow_speed();
variable_item_set_current_value_index(item, value_index - 1);
char speed_str[4];
snprintf(speed_str, sizeof(speed_str), "%d", value_index);
variable_item_set_current_value_text(item, speed_str);
variable_item_set_locked(item, !xtreme_settings->rgb_backlight, "Needs RGB\nBacklight!");
item = variable_item_list_add(
var_item_list,
"Rainbow Interval",
COUNT_OF(rainbow_interval_values),
xtreme_app_scene_misc_screen_rainbow_interval_changed,
app);
value_index = value_index_uint32(
rgb_backlight_get_rainbow_interval(),
rainbow_interval_values,
COUNT_OF(rainbow_interval_values));
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, rainbow_interval_names[value_index]);
variable_item_set_locked(item, !xtreme_settings->rgb_backlight, "Needs RGB\nBacklight!");
item = variable_item_list_add(
var_item_list,
"Rainbow Saturation",
25,
xtreme_app_scene_misc_screen_rainbow_saturation_changed,
app);
value_index = rgb_backlight_get_rainbow_saturation();
variable_item_set_current_value_index(item, value_index - 1);
char saturation_str[4];
snprintf(saturation_str, sizeof(saturation_str), "%d", value_index);
variable_item_set_current_value_text(item, saturation_str);
variable_item_set_locked(item, !xtreme_settings->rgb_backlight, "Needs RGB\nBacklight!");
variable_item_list_set_enter_callback(
@@ -110,12 +292,23 @@ bool xtreme_app_scene_misc_screen_on_event(void* context, SceneManagerEvent even
if(change) {
XTREME_SETTINGS()->rgb_backlight = !XTREME_SETTINGS()->rgb_backlight;
app->save_settings = true;
app->save_backlight = true;
notification_message(app->notification, &sequence_display_backlight_on);
rgb_backlight_reconfigure(XTREME_SETTINGS()->rgb_backlight);
scene_manager_previous_scene(app->scene_manager);
scene_manager_next_scene(app->scene_manager, XtremeAppSceneMiscScreen);
}
break;
}
case VarItemListIndexLcdColor0:
case VarItemListIndexLcdColor1:
case VarItemListIndexLcdColor2:
scene_manager_set_scene_state(
app->scene_manager,
XtremeAppSceneMiscScreenColor,
event.event - VarItemListIndexLcdColor0);
scene_manager_next_scene(app->scene_manager, XtremeAppSceneMiscScreenColor);
break;
default:
break;
}

View File

@@ -0,0 +1,59 @@
#include "../xtreme_app.h"
enum ByteInputResult {
ByteInputResultOk,
};
void xtreme_app_scene_misc_screen_color_byte_input_callback(void* context) {
XtremeApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, ByteInputResultOk);
}
void xtreme_app_scene_misc_screen_color_on_enter(void* context) {
XtremeApp* app = context;
ByteInput* byte_input = app->byte_input;
byte_input_set_header_text(byte_input, "Set LCD Color (#RRGGBB)");
app->lcd_color = rgb_backlight_get_color(
scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneMiscScreenColor));
byte_input_set_result_callback(
byte_input,
xtreme_app_scene_misc_screen_color_byte_input_callback,
NULL,
app,
(void*)&app->lcd_color,
sizeof(app->lcd_color));
view_dispatcher_switch_to_view(app->view_dispatcher, XtremeAppViewByteInput);
}
bool xtreme_app_scene_misc_screen_color_on_event(void* context, SceneManagerEvent event) {
XtremeApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
consumed = true;
switch(event.event) {
case ByteInputResultOk:
rgb_backlight_set_color(
scene_manager_get_scene_state(app->scene_manager, XtremeAppSceneMiscScreenColor),
app->lcd_color);
app->save_backlight = true;
scene_manager_previous_scene(app->scene_manager);
break;
default:
break;
}
}
return consumed;
}
void xtreme_app_scene_misc_screen_color_on_exit(void* context) {
XtremeApp* app = context;
byte_input_set_result_callback(app->byte_input, NULL, NULL, NULL, NULL, 0);
byte_input_set_header_text(app->byte_input, "");
}

View File

@@ -193,6 +193,10 @@ XtremeApp* xtreme_app_alloc() {
view_dispatcher_add_view(
app->view_dispatcher, XtremeAppViewTextInput, text_input_get_view(app->text_input));
app->byte_input = byte_input_alloc();
view_dispatcher_add_view(
app->view_dispatcher, XtremeAppViewByteInput, byte_input_get_view(app->byte_input));
app->popup = popup_alloc();
view_dispatcher_add_view(app->view_dispatcher, XtremeAppViewPopup, popup_get_view(app->popup));
@@ -315,6 +319,8 @@ void xtreme_app_free(XtremeApp* app) {
submenu_free(app->submenu);
view_dispatcher_remove_view(app->view_dispatcher, XtremeAppViewTextInput);
text_input_free(app->text_input);
view_dispatcher_remove_view(app->view_dispatcher, XtremeAppViewByteInput);
byte_input_free(app->byte_input);
view_dispatcher_remove_view(app->view_dispatcher, XtremeAppViewPopup);
popup_free(app->popup);
view_dispatcher_remove_view(app->view_dispatcher, XtremeAppViewDialogEx);

View File

@@ -12,6 +12,7 @@
#include <gui/modules/variable_item_list.h>
#include <gui/modules/submenu.h>
#include <gui/modules/text_input.h>
#include <gui/modules/byte_input.h>
#include <gui/modules/popup.h>
#include <lib/toolbox/value_index.h>
#include <toolbox/stream/file_stream.h>
@@ -42,6 +43,7 @@ typedef struct {
VariableItemList* var_item_list;
Submenu* submenu;
TextInput* text_input;
ByteInput* byte_input;
Popup* popup;
DialogEx* dialog_ex;
@@ -57,6 +59,7 @@ typedef struct {
uint8_t subghz_hopper_index;
char subghz_freq_buffer[XTREME_SUBGHZ_FREQ_BUFFER_SIZE];
bool subghz_extend;
RgbColor lcd_color;
char device_name[FURI_HAL_VERSION_ARRAY_NAME_LENGTH];
int32_t dolphin_level;
int32_t dolphin_angry;
@@ -79,6 +82,7 @@ typedef enum {
XtremeAppViewVarItemList,
XtremeAppViewSubmenu,
XtremeAppViewTextInput,
XtremeAppViewByteInput,
XtremeAppViewPopup,
XtremeAppViewDialogEx,
} XtremeAppView;