Skip to content

Commit 06b271b

Browse files
gh 0.0.1 Source Code
1 parent b542cb6 commit 06b271b

File tree

2 files changed

+62
-28
lines changed

2 files changed

+62
-28
lines changed

Readme.md

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ es: FlipperZero | Guía de definitiva para compilar apps en FlipperZero
44

55
![Miguel Gargallo How to deploy Flipper Zero Apps](https://repository-images.githubusercontent.com/659406324/9c80b562-0837-4187-87c7-74663e6b0d1b)
66

7+
## Disclaimer
8+
9+
es: Descargo de responsabilidad
10+
11+
Use at your own risk. I am not responsible for any damage that may be caused to your device.
12+
13+
es: Úselo bajo su propio riesgo. No soy responsable de ningún daño que pueda causar a su dispositivo.
14+
715
## In this new version:
816

917
es: En esta nueva versión:
@@ -15,6 +23,7 @@ Users can now longpress and shortpress with an indicator on the screen.
1523
es: Los usuarios ahora pueden mantener presionado y presionar brevemente con un indicador en la pantalla.
1624

1725
- [FlipperZero | Ultimate compile guide](#flipperzero--ultimate-compile-guide)
26+
- [Disclaimer](#disclaimer)
1827
- [In this new version:](#in-this-new-version)
1928
- [Installation](#installation)
2029
- [Create the app](#create-the-app)

my_first_app/my_first_app.c

+53-28
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
/**************************|
2-
o o |
3-
| o myFlipperApps o |
4-
| o by MiguelGargallo o |
5-
| o 001 - My First App o |
6-
| o Version: 3.0.0b o |
7-
| o Date: 06-28-2023 o |
2+
| o myFlipperApps o |
3+
| o by MiguelGargallo o |
4+
| o 001 - My First App o |
5+
| o Version: 3.0.0b o |
6+
| o Date: 06-28-2023 o |
87
| o o |
98
**************************/
109

1110
#include <stdio.h>
1211
#include <furi.h>
1312
#include <gui/gui.h>
1413

15-
// Create a message to display based on user input
14+
// Create messages to display based on user input
1615
static char* message = "Press any button...";
1716
static char* exitMessage = "";
17+
static char numberMessage[2] = ""; // Create a new message string for numbers
18+
19+
// Create a variable to keep track of long press count
20+
static int longPressCount = 0;
1821

1922
// Function to clear canvas and draw GUI elements
2023
static void drawGui(Canvas* canvas, void* context) {
@@ -30,6 +33,9 @@ static void drawGui(Canvas* canvas, void* context) {
3033
canvas_draw_str(canvas, 15, 40, message);
3134
canvas_draw_str(canvas, 15, 55, exitMessage); // Exit message
3235

36+
// Draw the number message
37+
canvas_draw_str(canvas, 65, 32, numberMessage); // Number message
38+
3339
// Draw a line
3440
canvas_draw_line(canvas, 2, 23, 126, 23);
3541
}
@@ -44,27 +50,46 @@ static void handleInput(InputEvent* input_event, void* context) {
4450

4551
// Change the message depending on which key was pressed
4652
switch(input_event->key) {
47-
case InputKeyUp:
48-
message = longPress ? "You long-pressed ^^^" : "You pressed ^";
49-
break;
50-
case InputKeyDown:
51-
message = longPress ? "You long-pressed vvv" : "You pressed v";
52-
break;
53-
case InputKeyLeft:
54-
message = longPress ? "You long-pressed <<<" : "You pressed <";
55-
break;
56-
case InputKeyRight:
57-
message = longPress ? "You long-pressed >>>" : "You pressed >";
58-
break;
59-
case InputKeyOk:
60-
message = longPress ? "You long-pressed ooo" : "You pressed o";
61-
break;
62-
case InputKeyBack:
63-
message = longPress ? "You long-pressed ---" : "You pressed -";
64-
exitMessage = longPress ? "Exiting the App." : "Long press to exit.";
65-
break;
66-
default:
67-
message = "Press any button...";
53+
case InputKeyUp:
54+
message = longPress ? "You long-pressed ^^^" : "You pressed ^";
55+
break;
56+
case InputKeyDown:
57+
message = longPress ? "You long-pressed vvv" : "You pressed v";
58+
break;
59+
case InputKeyLeft:
60+
message = longPress ? "You long-pressed <<<" : "You pressed <";
61+
break;
62+
case InputKeyRight:
63+
message = longPress ? "You long-pressed >>>" : "You pressed >";
64+
break;
65+
case InputKeyOk:
66+
message = longPress ? "You long-pressed ooo" : "You pressed o";
67+
break;
68+
case InputKeyBack:
69+
message = longPress ? "You long-pressed ---" : "You pressed -";
70+
exitMessage = longPress ? "Exiting the App." : "Long press to exit.";
71+
break;
72+
default:
73+
message = "Press any button...";
74+
}
75+
76+
// Update the longPressCount and numberMessage based on the type of press
77+
if (longPress) {
78+
longPressCount++;
79+
switch (longPressCount) {
80+
case 1:
81+
snprintf(numberMessage, sizeof(numberMessage), "1");
82+
break;
83+
case 2:
84+
snprintf(numberMessage, sizeof(numberMessage), "2");
85+
break;
86+
case 3:
87+
snprintf(numberMessage, sizeof(numberMessage), "3");
88+
break;
89+
}
90+
} else {
91+
longPressCount = 0; // Reset the count on a short press
92+
numberMessage[0] = '\0'; // Clear the string
6893
}
6994

7095
furi_message_queue_put(event_queue, input_event, FuriWaitForever);

0 commit comments

Comments
 (0)