mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-02 17:29:14 +00:00
274c12fc56
* Streams: string stream * String stream: updated insert/delete api * Streams: generic stream interface and string stream implementation * Streams: helpers for insert and delete_and_insert * FFF: now compatible with streams * MinUnit: introduced tests with arguments * FFF: stream access violation * Streams: copy data between streams * Streams: file stream * FFF: documentation * FFStream: documentation * FFF: alloc as file * MinUnit: support for nested tests * Streams: changed delete_and_insert, now it returns success flag. Added ability dump stream inner parameters and data to cout. * FFF: simplified file open function * Streams: unit tests * FFF: tests * Streams: declare cache_size constant as define, to allow variable modified arrays * FFF: lib moved to a separate folder * iButton: new FFF * RFID: new FFF * Animations: new FFF * IR: new FFF * NFC: new FFF * Flipper file format: delete lib * U2F: new FFF * Subghz: new FFF and streams * Streams: read line * Streams: split * FuriCore: implement memset with extra asserts * FuriCore: implement extra heap asserts without inventing memset * Scene manager: protected access to the scene id stack with a size check * NFC worker: dirty fix for issue where hal_nfc was busy on app start * Furi: update allocator to erase memory on allocation. Replace furi_alloc with malloc. * FuriCore: cleanup memmgr code. * Furi HAL: furi_hal_init is split into critical and non-critical parts. The critical part is currently clock and console. * Memmgr: added ability to track allocations and deallocations through console. * FFStream: some speedup * Streams, FF: minor fixes * Tests: restore * File stream: a slightly more thread-safe version of file_stream_delete_and_insert Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
100 lines
3.6 KiB
C
Executable file
100 lines
3.6 KiB
C
Executable file
#include "battery_test_app.h"
|
|
|
|
#include <notification/notification_messages.h>
|
|
|
|
void battery_test_dialog_callback(DialogExResult result, void* context) {
|
|
furi_assert(context);
|
|
BatteryTestApp* app = context;
|
|
if(result == DialogExResultLeft) {
|
|
view_dispatcher_stop(app->view_dispatcher);
|
|
} else if(result == DialogExResultRight) {
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, BatteryTestAppViewBatteryInfo);
|
|
}
|
|
}
|
|
|
|
uint32_t battery_test_exit_confirm_view() {
|
|
return BatteryTestAppViewExitDialog;
|
|
}
|
|
|
|
static void battery_test_battery_info_update_model(void* context) {
|
|
BatteryTestApp* app = context;
|
|
power_get_info(app->power, &app->info);
|
|
BatteryInfoModel battery_info_data = {
|
|
.vbus_voltage = app->info.voltage_vbus,
|
|
.gauge_voltage = app->info.voltage_gauge,
|
|
.gauge_current = app->info.current_gauge,
|
|
.gauge_temperature = app->info.temperature_gauge,
|
|
.charge = app->info.charge,
|
|
.health = app->info.health,
|
|
};
|
|
battery_info_set_data(app->batery_info, &battery_info_data);
|
|
notification_message(app->notifications, &sequence_display_on);
|
|
}
|
|
|
|
BatteryTestApp* battery_test_alloc() {
|
|
BatteryTestApp* app = malloc(sizeof(BatteryTestApp));
|
|
|
|
// Records
|
|
app->gui = furi_record_open("gui");
|
|
app->power = furi_record_open("power");
|
|
app->notifications = furi_record_open("notification");
|
|
|
|
// View dispatcher
|
|
app->view_dispatcher = view_dispatcher_alloc();
|
|
view_dispatcher_enable_queue(app->view_dispatcher);
|
|
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
|
|
view_dispatcher_set_tick_event_callback(
|
|
app->view_dispatcher, battery_test_battery_info_update_model, 500);
|
|
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
|
|
|
// Views
|
|
app->batery_info = battery_info_alloc();
|
|
view_set_previous_callback(
|
|
battery_info_get_view(app->batery_info), battery_test_exit_confirm_view);
|
|
view_dispatcher_add_view(
|
|
app->view_dispatcher,
|
|
BatteryTestAppViewBatteryInfo,
|
|
battery_info_get_view(app->batery_info));
|
|
|
|
app->dialog = dialog_ex_alloc();
|
|
dialog_ex_set_header(app->dialog, "Close battery test?", 64, 12, AlignCenter, AlignTop);
|
|
dialog_ex_set_left_button_text(app->dialog, "Exit");
|
|
dialog_ex_set_right_button_text(app->dialog, "Stay");
|
|
dialog_ex_set_result_callback(app->dialog, battery_test_dialog_callback);
|
|
dialog_ex_set_context(app->dialog, app);
|
|
|
|
view_dispatcher_add_view(
|
|
app->view_dispatcher, BatteryTestAppViewExitDialog, dialog_ex_get_view(app->dialog));
|
|
|
|
battery_test_battery_info_update_model(app);
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, BatteryTestAppViewBatteryInfo);
|
|
return app;
|
|
}
|
|
|
|
void battery_test_free(BatteryTestApp* app) {
|
|
furi_assert(app);
|
|
|
|
// Views
|
|
view_dispatcher_remove_view(app->view_dispatcher, BatteryTestAppViewBatteryInfo);
|
|
battery_info_free(app->batery_info);
|
|
view_dispatcher_remove_view(app->view_dispatcher, BatteryTestAppViewExitDialog);
|
|
dialog_ex_free(app->dialog);
|
|
// View dispatcher
|
|
view_dispatcher_free(app->view_dispatcher);
|
|
// Records
|
|
furi_record_close("power");
|
|
furi_record_close("gui");
|
|
furi_record_close("notification");
|
|
free(app);
|
|
}
|
|
|
|
int32_t battery_test_app(void* p) {
|
|
BatteryTestApp* app = battery_test_alloc();
|
|
// Disable battery low level notification
|
|
power_enable_low_battery_level_notification(app->power, false);
|
|
|
|
view_dispatcher_run(app->view_dispatcher);
|
|
power_enable_low_battery_level_notification(app->power, true);
|
|
battery_test_free(app);
|
|
return 0;
|
|
}
|