Skip to content

Commit

Permalink
Merge pull request #18 from jaylikesbunda/main
Browse files Browse the repository at this point in the history
v1.1.3
  • Loading branch information
jaylikesbunda authored Nov 16, 2024
2 parents d3a5906 + 936ded6 commit bddb7af
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v1.1.3
- **Added specific buttondown icon for help menu button to not be dependent on firmware icons**

## v1.1.2
- improved ESP connection check reliability by trying AT command first with shorter timeouts, while keeping original 'stop' command as fallback

Expand Down
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ App(
fap_category="GPIO/ESP",
# Optional values
icon="A_GhostESP_14",
fap_version="1.1.2",
fap_version="1.1.3",
fap_icon="ghost_esp.png", # 10x10 1-bit PNG
fap_icon_assets="images", # Image assets to compile for this application
)
47 changes: 28 additions & 19 deletions gui_modules/mainmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define ICON_WIDTH 20
#define ICON_PADDING 3
#define TEXT_BOTTOM_MARGIN 8
#define BUTTON_HEIGHT 12

typedef struct {
uint8_t x;
Expand Down Expand Up @@ -108,6 +109,31 @@ void main_menu_set_help_callback(MainMenu* main_menu, MainMenuItemCallback callb
main_menu->help_context = context;
}

static void draw_help_button(Canvas* canvas) {
const char* str = "Help";
const size_t vertical_offset = 3;
const size_t horizontal_offset = 3;
const size_t string_width = canvas_string_width(canvas, str);

// Create a small arrow icon directly
const uint8_t arrow_width = 7;
const uint8_t arrow_height = 4;
const int32_t icon_h_offset = 3;
const int32_t icon_width_with_offset = arrow_width + icon_h_offset;
const size_t button_width = string_width + horizontal_offset * 2 + icon_width_with_offset;

const int32_t x = (canvas_width(canvas) - button_width) / 2;
const int32_t y = canvas_height(canvas);

// Draw text
canvas_draw_str(canvas, x + horizontal_offset, y - vertical_offset, str);

// Draw small down arrow
const int32_t arrow_x = x + horizontal_offset + string_width + icon_h_offset;
const int32_t arrow_y = y - vertical_offset - arrow_height;
canvas_draw_line(canvas, arrow_x + 3, arrow_y + 3, arrow_x + 6, arrow_y);
canvas_draw_line(canvas, arrow_x + 3, arrow_y + 3, arrow_x, arrow_y);
}

static CardLayout calculate_card_layout(
Canvas* canvas,
Expand Down Expand Up @@ -250,27 +276,10 @@ static void main_menu_view_draw_callback(Canvas* canvas, void* _model) {
position++;
}

// Draw help button last, so it's on top of everything
// Draw help button last
canvas_set_font(canvas, FontSecondary);
canvas_set_color(canvas, ColorBlack);

const size_t vertical_offset = 3;
const size_t horizontal_offset = 3;
const size_t string_width = canvas_string_width(canvas, "Help");
const Icon* icon = &I_ButtonDown_7x4;
const int32_t icon_h_offset = 3;
const int32_t icon_width_with_offset = icon_get_width(icon) + icon_h_offset;
const int32_t icon_v_offset = icon_get_height(icon) + vertical_offset + 1;
const size_t button_width = string_width + horizontal_offset * 2 + icon_width_with_offset;

const int32_t x = (canvas_width(canvas) - button_width) / 2;
const int32_t y = canvas_height(canvas);

// Position at bottom with proper margins
canvas_draw_str(canvas, x + horizontal_offset, y - vertical_offset, "Help");
canvas_draw_icon(
canvas, x + horizontal_offset + string_width + icon_h_offset, y - icon_v_offset, icon);
// Reset color
draw_help_button(canvas);
canvas_set_color(canvas, ColorBlack);
}
static bool main_menu_view_input_callback(InputEvent* event, void* context) {
Expand Down
3 changes: 1 addition & 2 deletions src/ghost_esp_icons.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
extern const Icon I_Wifi_icon;
extern const Icon I_BLE_icon;
extern const Icon I_GPS_icon;
extern const Icon I_Cog;
extern const Icon I_ButtonDown_7x4;
extern const Icon I_Cog;
2 changes: 1 addition & 1 deletion src/settings_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ bool settings_custom_event_callback(void* context, uint32_t event_id) {
"Updated by: Jay Candel\n"
"Built with <3";

confirmation_view_set_header(app_state->confirmation_view, "Ghost ESP v1.1.2");
confirmation_view_set_header(app_state->confirmation_view, "Ghost ESP v1.1.3");
confirmation_view_set_text(app_state->confirmation_view, info_text);

// Save current view before switching
Expand Down

0 comments on commit bddb7af

Please sign in to comment.