2020-10-26 17:00:17 +00:00
|
|
|
#include "irukagotchi.h"
|
|
|
|
|
|
|
|
#include <flipper_v2.h>
|
|
|
|
|
|
|
|
#include <gui/gui.h>
|
|
|
|
#include <gui/widget.h>
|
|
|
|
#include <gui/canvas.h>
|
|
|
|
#include <menu/menu.h>
|
|
|
|
|
|
|
|
#include <assets_icons.h>
|
|
|
|
|
|
|
|
struct Irukagotchi {
|
|
|
|
Icon* icon;
|
|
|
|
Widget* widget;
|
|
|
|
ValueMutex* menu_vm;
|
|
|
|
};
|
|
|
|
|
|
|
|
void irukagotchi_draw_callback(CanvasApi* canvas, void* context) {
|
|
|
|
Irukagotchi* irukagotchi = context;
|
|
|
|
|
|
|
|
canvas->clear(canvas);
|
|
|
|
canvas->set_color(canvas, ColorBlack);
|
2020-11-06 09:31:06 +00:00
|
|
|
canvas->draw_icon(canvas, 128 - 80, 0, irukagotchi->icon);
|
|
|
|
canvas->set_font(canvas, FontSecondary);
|
|
|
|
canvas->draw_str(canvas, 2, 10, TARGET " " BUILD_DATE);
|
|
|
|
canvas->draw_str(canvas, 2, 22, GIT_BRANCH);
|
|
|
|
canvas->draw_str(canvas, 2, 34, GIT_BRANCH_NUM);
|
|
|
|
canvas->draw_str(canvas, 2, 46, GIT_COMMIT);
|
2020-10-26 17:00:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void irukagotchi_input_callback(InputEvent* event, void* context) {
|
|
|
|
Irukagotchi* irukagotchi = context;
|
|
|
|
|
|
|
|
if(!event->state || event->input != InputOk) return;
|
|
|
|
|
|
|
|
with_value_mutex(
|
|
|
|
irukagotchi->menu_vm, (Menu * menu) { menu_ok(menu); });
|
|
|
|
}
|
|
|
|
|
|
|
|
Irukagotchi* irukagotchi_alloc() {
|
|
|
|
Irukagotchi* irukagotchi = furi_alloc(sizeof(Irukagotchi));
|
|
|
|
|
2020-10-29 07:11:16 +00:00
|
|
|
irukagotchi->icon = assets_icons_get(I_Flipper_young_80x60);
|
2020-10-26 17:00:17 +00:00
|
|
|
icon_start_animation(irukagotchi->icon);
|
|
|
|
|
|
|
|
irukagotchi->widget = widget_alloc();
|
|
|
|
widget_draw_callback_set(irukagotchi->widget, irukagotchi_draw_callback, irukagotchi);
|
|
|
|
widget_input_callback_set(irukagotchi->widget, irukagotchi_input_callback, irukagotchi);
|
|
|
|
|
|
|
|
irukagotchi->menu_vm = furi_open("menu");
|
2020-10-29 06:27:17 +00:00
|
|
|
furi_check(irukagotchi->menu_vm);
|
2020-10-26 17:00:17 +00:00
|
|
|
|
|
|
|
return irukagotchi;
|
|
|
|
}
|
|
|
|
|
|
|
|
void irukagotchi_task() {
|
|
|
|
Irukagotchi* irukagotchi = irukagotchi_alloc();
|
|
|
|
|
|
|
|
FuriRecordSubscriber* gui_record = furi_open_deprecated("gui", false, false, NULL, NULL, NULL);
|
2020-10-29 06:27:17 +00:00
|
|
|
furi_check(gui_record);
|
2020-10-26 17:00:17 +00:00
|
|
|
GuiApi* gui = furi_take(gui_record);
|
2020-10-29 06:27:17 +00:00
|
|
|
furi_check(gui);
|
2020-10-26 17:00:17 +00:00
|
|
|
gui->add_widget(gui, irukagotchi->widget, GuiLayerNone);
|
|
|
|
furi_commit(gui_record);
|
|
|
|
|
|
|
|
furiac_ready();
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
osDelay(osWaitForever);
|
|
|
|
}
|
|
|
|
}
|