mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-20 04:54:45 -07:00
counter
This commit is contained in:
@@ -26,6 +26,7 @@ Thank you to all the supporters!
|
|||||||
- Added: [USB Midi (By DrZlo13)](https://github.com/DrZlo13/flipper-zero-usb-midi)
|
- Added: [USB Midi (By DrZlo13)](https://github.com/DrZlo13/flipper-zero-usb-midi)
|
||||||
- Cleanup for: Settings: Rename from App [(Thanks to E_Surge)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/409)
|
- Cleanup for: Settings: Rename from App [(Thanks to E_Surge)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/409)
|
||||||
- Added: [Air Mouse (By ginkage)](https://github.com/ginkage/FlippAirMouse/)
|
- Added: [Air Mouse (By ginkage)](https://github.com/ginkage/FlippAirMouse/)
|
||||||
|
- Added: [Counter (By Krulknul)](https://github.com/Krulknul/dolphin-counter)
|
||||||
|
|
||||||
## Install from Release
|
## Install from Release
|
||||||
FLASH STOCK FIRST BEFORE UPDATING TO CUSTOM FIRMWARE!
|
FLASH STOCK FIRST BEFORE UPDATING TO CUSTOM FIRMWARE!
|
||||||
@@ -189,6 +190,7 @@ $ ./fbt resources icons dolphin_ext
|
|||||||
- [Calculator (By n-o-T-I-n-s-a-n-e)](https://github.com/n-o-T-I-n-s-a-n-e)
|
- [Calculator (By n-o-T-I-n-s-a-n-e)](https://github.com/n-o-T-I-n-s-a-n-e)
|
||||||
- [Ceasar Cipher (By panki27)](https://github.com/panki27/caesar-cipher)
|
- [Ceasar Cipher (By panki27)](https://github.com/panki27/caesar-cipher)
|
||||||
- [Clock/Stopwatch (By CompaqDisc, Stopwatch & Sound Alert By RogueMaster)](https://gist.github.com/CompaqDisc/4e329c501bd03c1e801849b81f48ea61) [12/24HR (By non-bin)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/254) [Refactoring (By GMMan)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/256)
|
- [Clock/Stopwatch (By CompaqDisc, Stopwatch & Sound Alert By RogueMaster)](https://gist.github.com/CompaqDisc/4e329c501bd03c1e801849b81f48ea61) [12/24HR (By non-bin)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/254) [Refactoring (By GMMan)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/256)
|
||||||
|
- [Counter (By Krulknul)](https://github.com/Krulknul/dolphin-counter)
|
||||||
- [DAP Link (By DrZlo13)[OFW]](https://github.com/flipperdevices/flipperzero-firmware/pull/1897)
|
- [DAP Link (By DrZlo13)[OFW]](https://github.com/flipperdevices/flipperzero-firmware/pull/1897)
|
||||||
- [Deauther PWNDTOOLS V2.6.0 (By HEX0DAYS)](https://github.com/HEX0DAYS/FlipperZero-PWNDTOOLS) `Req: ESP8266` [Original](https://github.com/SpacehuhnTech/esp8266_deauther)
|
- [Deauther PWNDTOOLS V2.6.0 (By HEX0DAYS)](https://github.com/HEX0DAYS/FlipperZero-PWNDTOOLS) `Req: ESP8266` [Original](https://github.com/SpacehuhnTech/esp8266_deauther)
|
||||||
- [DHT Temp Monitor (By quen0n)](https://github.com/quen0n/FipperZero-DHT-Monitor) `Req: DHT11/DHT22(AM2302)/AM2301`
|
- [DHT Temp Monitor (By quen0n)](https://github.com/quen0n/FipperZero-DHT-Monitor) `Req: DHT11/DHT22(AM2302)/AM2301`
|
||||||
|
|||||||
8
applications/plugins/counter/README.md
Normal file
8
applications/plugins/counter/README.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Dolphin counter
|
||||||
|
This is a simple plugin for the [Flipper Zero](https://www.flipperzero.one).
|
||||||
|
It gives you access to a counter which you can increment and decrement using the up and down buttons respectively.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
# How to install this?
|
||||||
|
I'd recommend using [flipperzero-ufbt](https://github.com/flipperdevices/flipperzero-ufbt), which is a lightweight tool for quickly testing Flipper Zero applications. The app will stay present on your device so it is not necessary to flash the entire firmware.
|
||||||
12
applications/plugins/counter/application.fam
Normal file
12
applications/plugins/counter/application.fam
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
App(
|
||||||
|
appid="counter",
|
||||||
|
name="Counter",
|
||||||
|
apptype=FlipperAppType.PLUGIN,
|
||||||
|
entry_point="counterapp",
|
||||||
|
requires=[
|
||||||
|
"gui",
|
||||||
|
],
|
||||||
|
fap_category="Misc",
|
||||||
|
fap_icon="icons/counter_icon.png",
|
||||||
|
fap_icon_assets="icons",
|
||||||
|
)
|
||||||
108
applications/plugins/counter/counter.c
Normal file
108
applications/plugins/counter/counter.c
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
#include <furi.h>
|
||||||
|
#include <gui/gui.h>
|
||||||
|
#include <input/input.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <counter_icons.h>
|
||||||
|
|
||||||
|
#define MAX_COUNT 99
|
||||||
|
#define BOXTIME 2
|
||||||
|
#define BOXWIDTH 30
|
||||||
|
#define MIDDLE_X 64 - BOXWIDTH / 2
|
||||||
|
#define MIDDLE_Y 32 - BOXWIDTH / 2
|
||||||
|
#define OFFSET_Y 9
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
FuriMessageQueue* input_queue;
|
||||||
|
ViewPort* view_port;
|
||||||
|
Gui* gui;
|
||||||
|
FuriMutex** mutex;
|
||||||
|
|
||||||
|
int count;
|
||||||
|
bool pressed;
|
||||||
|
int boxtimer;
|
||||||
|
} Counter;
|
||||||
|
|
||||||
|
void state_free(Counter* c) {
|
||||||
|
gui_remove_view_port(c->gui, c->view_port);
|
||||||
|
furi_record_close(RECORD_GUI);
|
||||||
|
view_port_free(c->view_port);
|
||||||
|
furi_message_queue_free(c->input_queue);
|
||||||
|
furi_mutex_free(c->mutex);
|
||||||
|
free(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void input_callback(InputEvent* input_event, void* ctx) {
|
||||||
|
Counter* c = ctx;
|
||||||
|
if(input_event->type == InputTypeShort) {
|
||||||
|
furi_message_queue_put(c->input_queue, input_event, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void render_callback(Canvas* canvas, void* ctx) {
|
||||||
|
Counter* c = ctx;
|
||||||
|
furi_check(furi_mutex_acquire(c->mutex, FuriWaitForever) == FuriStatusOk);
|
||||||
|
canvas_clear(canvas);
|
||||||
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
canvas_set_font(canvas, FontPrimary);
|
||||||
|
canvas_draw_str_aligned(canvas, 64, 10, AlignCenter, AlignCenter, "Counter :)");
|
||||||
|
canvas_set_font(canvas, FontBigNumbers);
|
||||||
|
|
||||||
|
char scount[5];
|
||||||
|
if(c->pressed == true || c->boxtimer > 0) {
|
||||||
|
canvas_draw_rframe(canvas, MIDDLE_X, MIDDLE_Y + OFFSET_Y, BOXWIDTH, BOXWIDTH, 5);
|
||||||
|
canvas_draw_rframe(
|
||||||
|
canvas, MIDDLE_X - 1, MIDDLE_Y + OFFSET_Y - 1, BOXWIDTH + 2, BOXWIDTH + 2, 5);
|
||||||
|
canvas_draw_rframe(
|
||||||
|
canvas, MIDDLE_X - 2, MIDDLE_Y + OFFSET_Y - 2, BOXWIDTH + 4, BOXWIDTH + 4, 5);
|
||||||
|
c->pressed = false;
|
||||||
|
c->boxtimer--;
|
||||||
|
} else {
|
||||||
|
canvas_draw_rframe(canvas, MIDDLE_X, MIDDLE_Y + OFFSET_Y, BOXWIDTH, BOXWIDTH, 5);
|
||||||
|
}
|
||||||
|
snprintf(scount, sizeof(scount), "%d", c->count);
|
||||||
|
canvas_draw_str_aligned(canvas, 64, 32 + OFFSET_Y, AlignCenter, AlignCenter, scount);
|
||||||
|
furi_mutex_release(c->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
Counter* state_init() {
|
||||||
|
Counter* c = malloc(sizeof(Counter));
|
||||||
|
c->input_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
|
||||||
|
c->view_port = view_port_alloc();
|
||||||
|
c->gui = furi_record_open(RECORD_GUI);
|
||||||
|
c->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||||
|
c->count = 0;
|
||||||
|
c->boxtimer = 0;
|
||||||
|
view_port_input_callback_set(c->view_port, input_callback, c);
|
||||||
|
view_port_draw_callback_set(c->view_port, render_callback, c);
|
||||||
|
gui_add_view_port(c->gui, c->view_port, GuiLayerFullscreen);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t counterapp(void) {
|
||||||
|
Counter* c = state_init();
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
InputEvent input;
|
||||||
|
while(furi_message_queue_get(c->input_queue, &input, FuriWaitForever) == FuriStatusOk) {
|
||||||
|
furi_check(furi_mutex_acquire(c->mutex, FuriWaitForever) == FuriStatusOk);
|
||||||
|
|
||||||
|
if(input.key == InputKeyBack) {
|
||||||
|
furi_mutex_release(c->mutex);
|
||||||
|
state_free(c);
|
||||||
|
return 0;
|
||||||
|
} else if(input.key == InputKeyUp && c->count < MAX_COUNT) {
|
||||||
|
c->pressed = true;
|
||||||
|
c->boxtimer = BOXTIME;
|
||||||
|
c->count++;
|
||||||
|
} else if(input.key == InputKeyDown && c->count != 0) {
|
||||||
|
c->pressed = true;
|
||||||
|
c->boxtimer = BOXTIME;
|
||||||
|
c->count--;
|
||||||
|
}
|
||||||
|
furi_mutex_release(c->mutex);
|
||||||
|
view_port_update(c->view_port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state_free(c);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
applications/plugins/counter/icons/counter_icon.png
Normal file
BIN
applications/plugins/counter/icons/counter_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 233 B |
BIN
applications/plugins/counter/media/preview.gif
Normal file
BIN
applications/plugins/counter/media/preview.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 MiB |
Reference in New Issue
Block a user