Skip to content

Commit

Permalink
FlipWeather - v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jblanked committed Nov 24, 2024
1 parent f8b72b7 commit a43fab1
Show file tree
Hide file tree
Showing 14 changed files with 769 additions and 356 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v1.2
Updates from Derek Jamison:
- Improved progress display.
- Added connectivity check on startup.

## 1.1
- Improved memory allocation.
- Updated WiFi configuration.
Expand Down
21 changes: 8 additions & 13 deletions alloc/flip_weather_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,20 @@ FlipWeatherApp *flip_weather_app_alloc()
{
return NULL;
}

view_dispatcher_set_custom_event_callback(app->view_dispatcher, flip_weather_custom_event_callback);
// Main view
if (!easy_flipper_set_view(&app->view_weather, FlipWeatherViewWeather, flip_weather_view_draw_callback_weather, NULL, callback_to_submenu, &app->view_dispatcher, app))
if (!easy_flipper_set_view(&app->view_loader, FlipWeatherViewLoader, flip_weather_loader_draw_callback, NULL, callback_to_submenu, &app->view_dispatcher, app))
{
return NULL;
}
if (!easy_flipper_set_view(&app->view_gps, FlipWeatherViewGPS, flip_weather_view_draw_callback_gps, NULL, callback_to_submenu, &app->view_dispatcher, app))
flip_weather_loader_init(app->view_loader);

// Widget
if (!easy_flipper_set_widget(&app->widget, FlipWeatherViewAbout, "FlipWeather v1.2\n-----\nUse WiFi to get GPS and \nWeather information.\n-----\nwww.github.com/jblanked", callback_to_submenu, &app->view_dispatcher))
{
return NULL;
}

// Widget
if (!easy_flipper_set_widget(&app->widget, FlipWeatherViewAbout, "FlipWeather v1.1\n-----\nUse WiFi to get GPS and \nWeather information.\n-----\nwww.github.com/jblanked", callback_to_submenu, &app->view_dispatcher))
if (!easy_flipper_set_widget(&app->widget_result, FlipWeatherViewWidgetResult, "Error, try again.", callback_to_submenu, &app->view_dispatcher))
{
return NULL;
}
Expand All @@ -77,7 +78,7 @@ FlipWeatherApp *flip_weather_app_alloc()
variable_item_set_current_value_text(app->variable_item_password, "");

// Submenu
if (!easy_flipper_set_submenu(&app->submenu, FlipWeatherViewSubmenu, "FlipWeather v1.1", callback_exit_app, &app->view_dispatcher))
if (!easy_flipper_set_submenu(&app->submenu, FlipWeatherViewSubmenu, "FlipWeather v1.2", callback_exit_app, &app->view_dispatcher))
{
return NULL;
}
Expand Down Expand Up @@ -107,12 +108,6 @@ FlipWeatherApp *flip_weather_app_alloc()
}
}

// Popup
if (!easy_flipper_set_popup(&app->popup_error, FlipWeatherViewPopupError, "[ERROR]", 0, 0, "Wifi Dev Board disconnected.\nIf your board is connected,\nmake sure you have the\nlatest FlipperHTTP flash.", 0, 12, flip_weather_popup_callback, callback_to_submenu, &app->view_dispatcher, app))
{
return NULL;
}

// Switch to the main view
view_dispatcher_switch_to_view(app->view_dispatcher, FlipWeatherViewSubmenu);

Expand Down
39 changes: 35 additions & 4 deletions app.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ int32_t flip_weather_app(void *p)
UNUSED(p);

// Initialize the FlipWeather application
FlipWeatherApp *app = flip_weather_app_alloc();
if (!app)
app_instance = flip_weather_app_alloc();
if (!app_instance)
{
FURI_LOG_E(TAG, "Failed to allocate FlipWeatherApp");
return -1;
Expand All @@ -21,11 +21,42 @@ int32_t flip_weather_app(void *p)
return -1;
}

// Thanks to Derek Jamison for the following edits
if (app_instance->uart_text_input_buffer_ssid != NULL &&
app_instance->uart_text_input_buffer_password != NULL)
{
// Try to wait for pong response.
uint8_t counter = 10;
while (fhttp.state == INACTIVE && --counter > 0)
{
FURI_LOG_D(TAG, "Waiting for PONG");
furi_delay_ms(100);
}

if (counter == 0)
{
DialogsApp *dialogs = furi_record_open(RECORD_DIALOGS);
DialogMessage *message = dialog_message_alloc();
dialog_message_set_header(
message, "[FlipperHTTP Error]", 64, 0, AlignCenter, AlignTop);
dialog_message_set_text(
message,
"Ensure your WiFi Developer\nBoard or Pico W is connected\nand the latest FlipperHTTP\nfirmware is installed.",
0,
63,
AlignLeft,
AlignBottom);
dialog_message_show(dialogs, message);
dialog_message_free(message);
furi_record_close(RECORD_DIALOGS);
}
}

// Run the view dispatcher
view_dispatcher_run(app->view_dispatcher);
view_dispatcher_run(app_instance->view_dispatcher);

// Free the resources used by the FlipWeather application
flip_weather_app_free(app);
flip_weather_app_free(app_instance);

// Return 0 to indicate success
return 0;
Expand Down
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ App(
fap_description="Use WiFi to get GPS and Weather information on your Flipper Zero.",
fap_author="JBlanked",
fap_weburl="https://github.com/jblanked/FlipWeather",
fap_version = "1.1",
fap_version = "1.2",
)
Binary file modified assets/01-home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a43fab1

Please # to comment.