|
@@ -11,6 +11,41 @@
|
|
|
|
|
|
|
|
#define TAG "FinikEthApp"
|
|
#define TAG "FinikEthApp"
|
|
|
|
|
|
|
|
|
|
+static void draw_process_selector(Canvas* canvas, DrawProcess selector, CursorPosition cursor) {
|
|
|
|
|
+ uint8_t y = 0;
|
|
|
|
|
+ if(selector == PROCESS_INIT) y = 11;
|
|
|
|
|
+ if(selector == PROCESS_DHCP) y = 22;
|
|
|
|
|
+ if(selector == PROCESS_STATIC) y = 34;
|
|
|
|
|
+ if(selector == PROCESS_PING) y = 44;
|
|
|
|
|
+ if(selector == PROCESS_RESET) y = 55;
|
|
|
|
|
+
|
|
|
|
|
+ if(cursor != CURSOR_INSIDE_PROCESS) {
|
|
|
|
|
+ canvas_draw_line(canvas, 0, y + 1, 0, y + 7);
|
|
|
|
|
+ canvas_draw_line(canvas, 23, y + 1, 23, y + 7);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ canvas_draw_line(canvas, 1, y, 22, y);
|
|
|
|
|
+ canvas_draw_line(canvas, 1, y + 8, 22, y + 8);
|
|
|
|
|
+
|
|
|
|
|
+ if(cursor == CURSOR_CLICK_PROCESS) {
|
|
|
|
|
+ canvas_draw_box(canvas, 1, y, 22, 9);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void draw_battery_cunsumption(Canvas* canvas, double cons) {
|
|
|
|
|
+ FuriString* string = furi_string_alloc_set("aaaaaaaa");
|
|
|
|
|
+ if(cons >= 0) {
|
|
|
|
|
+ furi_string_printf(string, "--");
|
|
|
|
|
+ } else if(cons < -1) {
|
|
|
|
|
+ furi_string_printf(string, "%1.1fk", -cons);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ furi_string_printf(string, "%3.f", -(cons * 1000));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ canvas_draw_str(canvas, 112, 7, furi_string_get_cstr(string));
|
|
|
|
|
+ furi_string_free(string);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void finik_eth_app_draw_callback(Canvas* canvas, void* ctx) {
|
|
static void finik_eth_app_draw_callback(Canvas* canvas, void* ctx) {
|
|
|
furi_assert(ctx);
|
|
furi_assert(ctx);
|
|
|
FinikEthApp* app = ctx;
|
|
FinikEthApp* app = ctx;
|
|
@@ -18,22 +53,27 @@ static void finik_eth_app_draw_callback(Canvas* canvas, void* ctx) {
|
|
|
canvas_clear(canvas);
|
|
canvas_clear(canvas);
|
|
|
|
|
|
|
|
DrawMode mode = app->draw_mode;
|
|
DrawMode mode = app->draw_mode;
|
|
|
- if(mode == DRAW_ONLY_PICTURES || mode == DRAW_ALL)
|
|
|
|
|
- canvas_draw_icon(canvas, 0, 29, &I_amperka_ru_logo_128x35px);
|
|
|
|
|
- if(mode == DRAW_ONLY_TEXT || mode == DRAW_ALL) {
|
|
|
|
|
- canvas_set_font(canvas, FontPrimary);
|
|
|
|
|
- canvas_draw_str(canvas, 4, 8, "This is an example app!");
|
|
|
|
|
- canvas_set_font(canvas, FontSecondary);
|
|
|
|
|
- elements_multiline_text_aligned(
|
|
|
|
|
- canvas,
|
|
|
|
|
- 127,
|
|
|
|
|
- 15,
|
|
|
|
|
- AlignRight,
|
|
|
|
|
- AlignTop,
|
|
|
|
|
- "Some long long long long \n aligned multiline text");
|
|
|
|
|
|
|
+ DrawProcess process = app->draw_process;
|
|
|
|
|
+ CursorPosition cursor = app->cursor_position;
|
|
|
|
|
+ float consumption = app->info.current_gauge;
|
|
|
|
|
+
|
|
|
|
|
+ canvas_set_font(canvas, FontSecondary);
|
|
|
|
|
+
|
|
|
|
|
+ if(cursor == CURSOR_EXIT_APP) {
|
|
|
|
|
+ canvas_draw_icon(canvas, 0, 0, &I_exit_128x64px);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ canvas_draw_icon(canvas, 0, 0, &I_main_128x64px);
|
|
|
|
|
+ draw_process_selector(canvas, process, cursor);
|
|
|
|
|
+ draw_battery_cunsumption(canvas, (double)consumption);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static void finik_eth_battery_info_update_model(void* ctx) {
|
|
|
|
|
+ furi_assert(ctx);
|
|
|
|
|
+ FinikEthApp* app = ctx;
|
|
|
|
|
+ power_get_info(app->power, &app->info);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void finik_eth_app_input_callback(InputEvent* input_event, void* ctx) {
|
|
static void finik_eth_app_input_callback(InputEvent* input_event, void* ctx) {
|
|
|
furi_assert(ctx);
|
|
furi_assert(ctx);
|
|
|
|
|
|
|
@@ -55,9 +95,10 @@ FinikEthApp* finik_eth_app_alloc() {
|
|
|
|
|
|
|
|
app->notifications = furi_record_open(RECORD_NOTIFICATION);
|
|
app->notifications = furi_record_open(RECORD_NOTIFICATION);
|
|
|
|
|
|
|
|
- app->eth_worker = eth_worker_alloc();
|
|
|
|
|
-
|
|
|
|
|
- eth_worker_task(app->eth_worker);
|
|
|
|
|
|
|
+ app->power = furi_record_open(RECORD_POWER);
|
|
|
|
|
+ //app->eth_worker = eth_worker_alloc();
|
|
|
|
|
+
|
|
|
|
|
+ //eth_worker_task(app->eth_worker);
|
|
|
|
|
|
|
|
return app;
|
|
return app;
|
|
|
}
|
|
}
|
|
@@ -75,6 +116,10 @@ void finik_eth_app_free(FinikEthApp* app) {
|
|
|
furi_record_close(RECORD_NOTIFICATION);
|
|
furi_record_close(RECORD_NOTIFICATION);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void finik_eth_update_consumtion(FinikEthApp* app) {
|
|
|
|
|
+ furi_assert(app);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
int32_t finik_eth_app(void* p) {
|
|
int32_t finik_eth_app(void* p) {
|
|
|
UNUSED(p);
|
|
UNUSED(p);
|
|
|
FinikEthApp* app = finik_eth_app_alloc();
|
|
FinikEthApp* app = finik_eth_app_alloc();
|
|
@@ -82,27 +127,37 @@ int32_t finik_eth_app(void* p) {
|
|
|
InputEvent event;
|
|
InputEvent event;
|
|
|
|
|
|
|
|
while(1) {
|
|
while(1) {
|
|
|
- if(furi_message_queue_get(app->event_queue, &event, 100) == FuriStatusOk) {
|
|
|
|
|
|
|
+ finik_eth_battery_info_update_model(app);
|
|
|
|
|
+ if(furi_message_queue_get(app->event_queue, &event, 300) == FuriStatusOk) {
|
|
|
if(event.type == InputTypePress) {
|
|
if(event.type == InputTypePress) {
|
|
|
- if(event.key == InputKeyBack)
|
|
|
|
|
- break;
|
|
|
|
|
- else if(event.key == InputKeyUp) {
|
|
|
|
|
- FURI_LOG_I(TAG, "example_led_sequence");
|
|
|
|
|
- notification_message(app->notifications, &example_led_sequence);
|
|
|
|
|
- } else if(event.key == InputKeyDown) {
|
|
|
|
|
- FURI_LOG_I(TAG, "example_vibro_sequence");
|
|
|
|
|
- notification_message(app->notifications, &example_vibro_sequence);
|
|
|
|
|
- } else if(event.key == InputKeyOk) {
|
|
|
|
|
- FURI_LOG_I(TAG, "example_sound_sequence");
|
|
|
|
|
- notification_message(app->notifications, &example_sound_sequence);
|
|
|
|
|
|
|
+ if(app->cursor_position == CURSOR_CHOOSE_PROCESS) {
|
|
|
|
|
+ if(event.key == InputKeyUp) {
|
|
|
|
|
+ app->draw_process =
|
|
|
|
|
+ (app->draw_process + PROCESS_RESET) % (PROCESS_RESET + 1);
|
|
|
|
|
+ } else if(event.key == InputKeyDown) {
|
|
|
|
|
+ app->draw_process =
|
|
|
|
|
+ (app->draw_process + PROCESS_RESET + 2) % (PROCESS_RESET + 1);
|
|
|
|
|
+ } else if(event.key == InputKeyRight) {
|
|
|
|
|
+ app->cursor_position = CURSOR_INSIDE_PROCESS;
|
|
|
|
|
+ } else if(event.key == InputKeyOk) {
|
|
|
|
|
+ app->cursor_position = CURSOR_CLICK_PROCESS;
|
|
|
|
|
+ view_port_update(app->view_port);
|
|
|
|
|
+ furi_delay_ms(150);
|
|
|
|
|
+ app->cursor_position = CURSOR_INSIDE_PROCESS;
|
|
|
|
|
+ } else if(event.key == InputKeyBack) {
|
|
|
|
|
+ app->cursor_position = CURSOR_EXIT_APP;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if(app->cursor_position == CURSOR_INSIDE_PROCESS) {
|
|
|
|
|
+ if(event.key == InputKeyLeft || event.key == InputKeyBack) {
|
|
|
|
|
+ app->cursor_position = CURSOR_CHOOSE_PROCESS;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if(app->cursor_position == CURSOR_EXIT_APP) {
|
|
|
|
|
+ if(event.key == InputKeyBack) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ } else if(event.key == InputKeyOk) {
|
|
|
|
|
+ app->cursor_position = CURSOR_CHOOSE_PROCESS;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- } else if(event.type == InputTypeLong) {
|
|
|
|
|
- DrawMode mode = app->draw_mode;
|
|
|
|
|
- if(event.key == InputKeyLeft)
|
|
|
|
|
- app->draw_mode = (mode - 1 + TOTAL_DRAW_MODES) % TOTAL_DRAW_MODES;
|
|
|
|
|
- else if(event.key == InputKeyRight)
|
|
|
|
|
- app->draw_mode = (mode + 1) % TOTAL_DRAW_MODES;
|
|
|
|
|
-
|
|
|
|
|
view_port_update(app->view_port);
|
|
view_port_update(app->view_port);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|