Skip to content

Commit

Permalink
MNTM: Add flipper Shell Color spoofing support
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Apr 7, 2024
1 parent 6fc6d50 commit 73e8c63
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@

enum VarItemListIndex {
VarItemListIndexFlipperName, // TODO: Split into name, mac, serial
VarItemListIndexShellColor,
};

const char* const shell_color_names[FuriHalVersionColorCount] = {
"Real",
"Black",
"White",
"Transparent",
};
static void momentum_app_scene_misc_spoof_shell_color_changed(VariableItem* item) {
MomentumApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, shell_color_names[index]);
momentum_settings.spoof_color = index;
app->save_settings = true;
app->require_reboot = true;
}

void momentum_app_scene_misc_spoof_var_item_list_callback(void* context, uint32_t index) {
MomentumApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
Expand All @@ -17,6 +33,15 @@ void momentum_app_scene_misc_spoof_on_enter(void* context) {
item = variable_item_list_add(var_item_list, "Flipper Name", 0, NULL, app);
variable_item_set_current_value_text(item, app->device_name);

item = variable_item_list_add(
var_item_list,
"Shell Color",
FuriHalVersionColorCount,
momentum_app_scene_misc_spoof_shell_color_changed,
app);
variable_item_set_current_value_index(item, momentum_settings.spoof_color);
variable_item_set_current_value_text(item, shell_color_names[momentum_settings.spoof_color]);

variable_item_list_set_enter_callback(
var_item_list, momentum_app_scene_misc_spoof_var_item_list_callback, app);

Expand Down
2 changes: 2 additions & 0 deletions lib/momentum/momentum.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <furi_hal_serial_types.h>
#include <furi_hal_version.h>
#include <toolbox/colors.h>
#include <gui/canvas.h>

Expand Down Expand Up @@ -89,6 +90,7 @@ typedef struct {
VgmColorMode vgm_color_mode;
Rgb565Color vgm_color_fg;
Rgb565Color vgm_color_bg;
FuriHalVersionColor spoof_color;
} MomentumSettings;

typedef struct {
Expand Down
2 changes: 2 additions & 0 deletions lib/momentum/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ MomentumSettings momentum_settings = {
.vgm_color_mode = VgmColorModeDefault, // Default
.vgm_color_fg.value = 0x0000, // Default Black
.vgm_color_bg.value = 0xFC00, // Default Orange
.spoof_color = FuriHalVersionColorUnknown, // Real
};

typedef enum {
Expand Down Expand Up @@ -112,6 +113,7 @@ static const struct {
{setting_enum(vgm_color_mode, VgmColorModeCount)},
{setting_uint(vgm_color_fg, 0x0000, 0xFFFF)},
{setting_uint(vgm_color_bg, 0x0000, 0xFFFF)},
{setting_enum(spoof_color, FuriHalVersionColorCount)},
};

void momentum_settings_load(void) {
Expand Down
7 changes: 6 additions & 1 deletion targets/f7/furi_hal/furi_hal_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <stdio.h>
#include <ble/ble.h>

#include <momentum/momentum.h>

#define TAG "FuriHalVersion"

#define FURI_HAL_VERSION_OTP_HEADER_MAGIC 0xBABE
Expand Down Expand Up @@ -241,7 +243,10 @@ uint8_t furi_hal_version_get_hw_body(void) {
}

FuriHalVersionColor furi_hal_version_get_hw_color(void) {
return furi_hal_version.board_color;
if(momentum_settings.spoof_color == FuriHalVersionColorUnknown) {
return furi_hal_version.board_color;
}
return momentum_settings.spoof_color;
}

uint8_t furi_hal_version_get_hw_connect(void) {
Expand Down
1 change: 1 addition & 0 deletions targets/furi_hal_include/furi_hal_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ typedef enum {
FuriHalVersionColorBlack = 0x01,
FuriHalVersionColorWhite = 0x02,
FuriHalVersionColorTransparent = 0x03,
FuriHalVersionColorCount,
} FuriHalVersionColor;

/** Device Regions */
Expand Down

0 comments on commit 73e8c63

Please sign in to comment.