Skip to content

Commit

Permalink
add new apps and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Aug 16, 2023
1 parent 34272b3 commit 670d4c4
Show file tree
Hide file tree
Showing 27 changed files with 1,410 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Apps contains changes needed to compile them on latest firmware, fixes has been

The Flipper and its community wouldn't be as rich as it is without your contributions and support. Thank you for all you have done.

### Apps checked & updated at `13 Aug 21:57 GMT +3`
### Apps checked & updated at `17 Aug 02:19 GMT +3`


# Default pack
Expand Down Expand Up @@ -109,6 +109,7 @@ Games:
- [Video Poker (by PixlEmly)](https://github.com/PixlEmly/flipperzero-firmware-testing/blob/420/applications/VideoPoker/poker.c)
- [Yatzee (by emfleak)](https://github.com/emfleak/flipperzero-yatzee)
- [Secret Toggle (by nostrumuva)](https://github.com/nostrumuva/secret_toggle)
- [Sudoku Game (by profelis)](https://github.com/profelis/fz-sudoku)

## GPIO
- [Air Mouse (by ginkage)](https://github.com/ginkage/FlippAirMouse/)
Expand Down Expand Up @@ -200,6 +201,7 @@ Games:
- [QR Code (by bmatcuk)](https://github.com/bmatcuk/flipperzero-qrcode)
- [Resistance calculator (by instantiator)](https://github.com/instantiator/flipper-zero-experimental-apps)
- [VB Lab Migration Assistant (by GMMan (cyanic))](https://github.com/GMMan/flipperzero-vb-migrate)
- [Simple calendar app (by Adiras)](https://github.com/Adiras/flipperzero-calendar)

## USB
- [USB HID Autofire (by pbek)](https://github.com/pbek/usb_hid_autofire)
Expand Down
16 changes: 16 additions & 0 deletions non_catalog_apps/calendar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Flipper Zero calendar application

- [Flipper Zero Official Website](https://flipperzero.one). A simple way to explain to your friends what Flipper Zero can do.
- [Flipper Zero Firmware Update](https://update.flipperzero.one). Improvements for your dolphin: latest firmware releases, upgrade tools for PC and mobile devices.
- [User Documentation](https://docs.flipperzero.one). Learn more about your dolphin: specs, usage guides, and anything you want to ask.

## How to set up and build the application

Make sure you have enough space on SD card and clone the source code inside `applications_user` folder:

```shell
git clone https://github.com/Adiras/flipperzero-calendar.git
```

- To launch app on Flipper, run `./fbt launch APPSRC=applications_user\flipperzero-calendar`
- To build app without uploading it to Flipper, use `./fbt build APPSRC=applications_user\flipperzero-calendar`
13 changes: 13 additions & 0 deletions non_catalog_apps/calendar/application.fam
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
App(
appid="calendar",
apptype=FlipperAppType.EXTERNAL,
name="Calendar",
entry_point="calendar_app",
stack_size=1 * 1024,
fap_icon="icon.png",
fap_category="Tools",
requires=[
"gui",
"dolphin",
],
)
119 changes: 119 additions & 0 deletions non_catalog_apps/calendar/calendar.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#include "calendar.h"
#include <furi.h>
#include <core/check.h>
#include <core/record.h>
#include <core/log.h>
#include <core/log.h>
#include <furi_hal_rtc.h>

static bool calendar_app_custom_event_callback(void* context, uint32_t event) {
furi_assert(context);
CalendarApp* app = context;
return scene_manager_handle_custom_event(app->scene_manager, event);
}

static bool calendar_app_back_event_callback(void* context) {
furi_assert(context);
CalendarApp* app = context;
return scene_manager_handle_back_event(app->scene_manager);
}

VariableSharedContext* calendar_app_variable_shared_context_alloc() {
FuriHalRtcDateTime datetime;
furi_hal_rtc_get_datetime(&datetime);
VariableSharedContext* variable_shared_context = malloc(sizeof(VariableSharedContext));
variable_shared_context->year_selected = datetime.year;
variable_shared_context->month_selected = datetime.month;

return variable_shared_context;
}

CalendarApp* calendar_app_alloc() {
CalendarApp* app = malloc(sizeof(CalendarApp));

// Variable shared context
app->variable_shared_context = calendar_app_variable_shared_context_alloc();

// View dispatcher
app->view_dispatcher = view_dispatcher_alloc();

// Scene manager
app->scene_manager = scene_manager_alloc(&calendar_scene_handlers, app);

view_dispatcher_enable_queue(app->view_dispatcher);
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
view_dispatcher_set_custom_event_callback(
app->view_dispatcher, calendar_app_custom_event_callback);
view_dispatcher_set_navigation_event_callback(
app->view_dispatcher, calendar_app_back_event_callback);

// Open GUI record
app->gui = furi_record_open(RECORD_GUI);
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);

// Views
app->calendar_year_picker = calendar_year_picker_alloc(
app->variable_shared_context);
view_dispatcher_add_view(
app->view_dispatcher,
CalendarAppViewYearPicker,
calendar_year_picker_get_view(app->calendar_year_picker));

app->calendar_month_picker = calendar_month_picker_alloc(
app->variable_shared_context);
view_dispatcher_add_view(
app->view_dispatcher,
CalendarAppViewMonthPicker,
calendar_month_picker_get_view(app->calendar_month_picker));

app->calendar_month_browser = calendar_month_browser_alloc(
app->variable_shared_context);
view_dispatcher_add_view(
app->view_dispatcher,
CalendarAppViewMonthBrowser,
calendar_month_browser_get_view(app->calendar_month_browser));

scene_manager_next_scene(app->scene_manager, CalendarSceneYearPicker);

return app;
}

void calendar_app_free(CalendarApp* app) {
furi_assert(app);

// Views
view_dispatcher_remove_view(
app->view_dispatcher, CalendarAppViewYearPicker);
calendar_year_picker_free(app->calendar_year_picker);

view_dispatcher_remove_view(
app->view_dispatcher, CalendarAppViewMonthPicker);
calendar_month_picker_free(app->calendar_month_picker);

view_dispatcher_remove_view(
app->view_dispatcher, CalendarAppViewMonthBrowser);
calendar_month_browser_free(app->calendar_month_browser);

// View dispatcher
view_dispatcher_free(app->view_dispatcher);

// Scene manager
scene_manager_free(app->scene_manager);

// GUI
furi_record_close(RECORD_GUI);
app->gui = NULL;

free(app);
}

int32_t calendar_app(void* p) {
UNUSED(p);
CalendarApp* app = calendar_app_alloc();

view_dispatcher_run(app->view_dispatcher);

calendar_app_free(app);

return 0;
}
27 changes: 27 additions & 0 deletions non_catalog_apps/calendar/calendar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include <gui/gui.h>
#include <gui/view.h>
#include <gui/view_dispatcher.h>
#include <gui/scene_manager.h>
#include "views/calendar_year_picker.h"
#include "views/calendar_month_picker.h"
#include "views/calendar_month_browser.h"
#include "scenes/calendar_scene.h"
#include "helpers/variable_shared_context.h"

typedef struct {
Gui* gui;
ViewDispatcher* view_dispatcher;
SceneManager* scene_manager;
YearPicker* calendar_year_picker;
MonthPicker* calendar_month_picker;
MonthBrowser* calendar_month_browser;
VariableSharedContext* variable_shared_context;
} CalendarApp;

typedef enum {
CalendarAppViewYearPicker,
CalendarAppViewMonthPicker,
CalendarAppViewMonthBrowser,
} CalendarAppView;
6 changes: 6 additions & 0 deletions non_catalog_apps/calendar/helpers/calendar_event.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

typedef enum {
CalendarAppCustomEventYearPicked,
CalendarAppCustomEventMontPicked,
} CalendarAppCustomEvent;
8 changes: 8 additions & 0 deletions non_catalog_apps/calendar/helpers/variable_shared_context.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include <furi.h>

typedef struct {
int16_t year_selected;
int8_t month_selected;
} VariableSharedContext;
Binary file added non_catalog_apps/calendar/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions non_catalog_apps/calendar/scenes/calendar_scene.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "calendar_scene.h"

// Generate scene on_enter handlers array
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
void (*const calendar_scene_on_enter_handlers[])(void*) = {
#include "calendar_scene_config.h"
};
#undef ADD_SCENE

// Generate scene on_event handlers array
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
bool (*const calendar_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = {
#include "calendar_scene_config.h"
};
#undef ADD_SCENE

// Generate scene on_exit handlers array
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
void (*const calendar_scene_on_exit_handlers[])(void* context) = {
#include "calendar_scene_config.h"
};
#undef ADD_SCENE

// Initialize scene handlers configuration structure
const SceneManagerHandlers calendar_scene_handlers = {
.on_enter_handlers = calendar_scene_on_enter_handlers,
.on_event_handlers = calendar_scene_on_event_handlers,
.on_exit_handlers = calendar_scene_on_exit_handlers,
.scene_num = CalendarSceneNum,
};
27 changes: 27 additions & 0 deletions non_catalog_apps/calendar/scenes/calendar_scene.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <gui/scene_manager.h>

extern const SceneManagerHandlers calendar_scene_handlers;

// Generate scene id and total number
#define ADD_SCENE(prefix, name, id) CalendarScene##id,
typedef enum {
#include "calendar_scene_config.h"
CalendarSceneNum,
} CalendarScene;
#undef ADD_SCENE

// Generate scene on_enter handlers declaration
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
#include "calendar_scene_config.h"
#undef ADD_SCENE

// Generate scene on_event handlers declaration
#define ADD_SCENE(prefix, name, id) \
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
#include "calendar_scene_config.h"
#undef ADD_SCENE

// Generate scene on_exit handlers declaration
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
#include "calendar_scene_config.h"
#undef ADD_SCENE
3 changes: 3 additions & 0 deletions non_catalog_apps/calendar/scenes/calendar_scene_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ADD_SCENE(calendar, year_picker, YearPicker)
ADD_SCENE(calendar, month_picker, MonthPicker)
ADD_SCENE(calendar, month_browser, MonthBrowser)
29 changes: 29 additions & 0 deletions non_catalog_apps/calendar/scenes/calendar_scene_month_browser.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "../calendar.h"
#include <furi_hal.h>
#include <gui/scene_manager.h>

void calendar_scene_month_browser_callback(CalendarAppCustomEvent event, void* context) {
furi_assert(context);
CalendarApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, event);
}

bool calendar_scene_month_browser_on_event(void* context, SceneManagerEvent event) {
UNUSED(context);
UNUSED(event);

return false;
}

void calendar_scene_month_browser_on_enter(void* context) {
CalendarApp* app = context;

calendar_year_picker_set_callback(
app->calendar_year_picker, calendar_scene_month_browser_callback, app);

view_dispatcher_switch_to_view(app->view_dispatcher, CalendarAppViewMonthBrowser);
}

void calendar_scene_month_browser_on_exit(void* context) {
UNUSED(context);
}
37 changes: 37 additions & 0 deletions non_catalog_apps/calendar/scenes/calendar_scene_month_picker.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "../calendar.h"
#include <furi_hal.h>
#include <gui/scene_manager.h>

void calendar_scene_month_picker_callback(CalendarAppCustomEvent event, void* context) {
furi_assert(context);
CalendarApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, event);
}

bool calendar_scene_month_picker_on_event(void* context, SceneManagerEvent event) {
CalendarApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case CalendarAppCustomEventMontPicked:
scene_manager_next_scene(app->scene_manager, CalendarSceneMonthBrowser);
consumed = true;
break;
}
}

return consumed;
}

void calendar_scene_month_picker_on_enter(void* context) {
CalendarApp* app = context;

calendar_month_picker_set_callback(
app->calendar_month_picker, calendar_scene_month_picker_callback, app);

view_dispatcher_switch_to_view(app->view_dispatcher, CalendarAppViewMonthPicker);
}

void calendar_scene_month_picker_on_exit(void* context) {
UNUSED(context);
}
37 changes: 37 additions & 0 deletions non_catalog_apps/calendar/scenes/calendar_scene_year_picker.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "../calendar.h"
#include <furi_hal.h>
#include <gui/scene_manager.h>

void calendar_scene_year_picker_callback(CalendarAppCustomEvent event, void* context) {
furi_assert(context);
CalendarApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, event);
}

bool calendar_scene_year_picker_on_event(void* context, SceneManagerEvent event) {
CalendarApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case CalendarAppCustomEventYearPicked:
scene_manager_next_scene(app->scene_manager, CalendarSceneMonthPicker);
consumed = true;
break;
}
}

return consumed;
}

void calendar_scene_year_picker_on_enter(void* context) {
CalendarApp* app = context;

calendar_year_picker_set_callback(
app->calendar_year_picker, calendar_scene_year_picker_callback, app);

view_dispatcher_switch_to_view(app->view_dispatcher, CalendarAppViewYearPicker);
}

void calendar_scene_year_picker_on_exit(void* context) {
UNUSED(context);
}
Loading

0 comments on commit 670d4c4

Please sign in to comment.