From 8e74f98298b6ef7da24b2730c549e9b911941692 Mon Sep 17 00:00:00 2001 From: miguelgargallo Date: Wed, 28 Jun 2023 16:24:45 +0200 Subject: [PATCH 1/9] gh 0.0.2 Source Code --- .gitignore | 1 - dragon/License.md | 23 ++++++++++ dragon/application.fam | 9 ++++ dragon/dragon.c | 99 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 dragon/License.md create mode 100644 dragon/application.fam create mode 100644 dragon/dragon.c diff --git a/.gitignore b/.gitignore index abc0bfe..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +0,0 @@ -dragon \ No newline at end of file diff --git a/dragon/License.md b/dragon/License.md new file mode 100644 index 0000000..5aa86b6 --- /dev/null +++ b/dragon/License.md @@ -0,0 +1,23 @@ +# DRAGON Graphics Motor by [Miguel Gargallo](https://twitter.com/miguelgargallo) + +## PYLAR AI CREATIVE ML LICENSE + +[OFFICIAL REFERENCE](https://huggingface.co/spaces/superdatas/LICENSE) + +Version 0.0.5, 27th June 2023, Miguel Gargallo + +The following conditions govern the use of the Pylar AI software and its associated documentation files (collectively referred to as the "Software"): + +1. **Grant of License**: This license grants you, the end-user, the right to use the Software for educational, research, and personal learning purposes. Any use of the Software outside of these purposes, including any attempt to make profit from its use or redistribution, is strictly prohibited. + +2. **Limitations on Use**: You may not sell, rent, lease, sublicense, distribute, redistribute, or transfer the Software or any portion thereof to any third party. Furthermore, you may not modify, adapt, translate, reverse engineer, decompile, disassemble or otherwise attempt to derive source code from the Software. + +3. **Intellectual Property Rights**: All rights, title, and interest in and to the Software (including but not limited to any images, photographs, animations, video, audio, music, text, and "applets" incorporated into the Software), and any copies of the Software, are owned by Miguel Gargallo or his suppliers. All rights not specifically granted under this license are reserved by Miguel Gargallo or his suppliers. + +4. **Non-Commercial Use**: The Software is intended solely for educational and informative purposes. Commercial use, including but not limited to the sale of the Software or any associated materials, is prohibited. + +5. **Self-Hosting Prohibited**: You are strictly prohibited from hosting the Software, making it available to others via servers, cloud services, or online platforms, or using it in a way that it is accessible to others. + +6. **Disclaimer of Warranty**: The Software is provided "as is" without any warranties of any kind, whether express or implied, including but not limited to warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event will Miguel Gargallo or his suppliers be liable for any damages whatsoever arising out of the use of or inability to use the Software. + +By using the Software, you agree to abide by the terms and conditions of this license. If you do not agree to these terms, you are not authorized to use or access the Software. diff --git a/dragon/application.fam b/dragon/application.fam new file mode 100644 index 0000000..4562ffd --- /dev/null +++ b/dragon/application.fam @@ -0,0 +1,9 @@ +App( + appid="dragon", + name="Graphics Motor Dragon", + apptype=FlipperAppType.EXTERNAL, + entry_point="dragon_main", + requires=["gui"], + stack_size=1 * 1024, + fap_category="Games", +) diff --git a/dragon/dragon.c b/dragon/dragon.c new file mode 100644 index 0000000..cbb1277 --- /dev/null +++ b/dragon/dragon.c @@ -0,0 +1,99 @@ +#include +#include +#include + +static int position[] = {5, 5}; // Starting position +static char currentSymbol[] = "o"; // Changed from char to char array + +static void drawGui(Canvas* canvas, void* context) { + UNUSED(context); + canvas_clear(canvas); + + // Draw the currentSymbol + canvas_set_font(canvas, FontPrimary); + canvas_draw_str(canvas, position[0], position[1], currentSymbol); +} + +static void handleInput(InputEvent* input_event, void* context) { + FuriMessageQueue* event_queue = context; + furi_assert(event_queue != NULL); + + bool longPress = (input_event->type == InputTypeLong) ? true : false; + int step = longPress ? 2 : 1; // Move 2 positions if long pressed, 1 otherwise + + switch(input_event->key) { + case InputKeyUp: + position[1] -= step; + break; + case InputKeyDown: + position[1] += step; + break; + case InputKeyLeft: + position[0] -= step; + break; + case InputKeyRight: + position[0] += step; + break; + case InputKeyOk: + strcpy(currentSymbol, "."); // Replace string copy instead of assignment + break; + case InputKeyBack: + strcpy(currentSymbol, "O"); // Replace string copy instead of assignment + break; + case InputKeyMAX: + // Add handling for InputKeyMAX here if necessary + break; + } + + // Bounds check + if(position[0] < 0) position[0] = 0; + if(position[0] > 126) position[0] = 126; // 128 pixels, adjust as necessary + if(position[1] < 0) position[1] = 0; + if(position[1] > 62) position[1] = 62; // 64 pixels, adjust as necessary + + furi_message_queue_put(event_queue, input_event, FuriWaitForever); +} + +// Main function of the app +int32_t dragon_main(void* parameter) { + UNUSED(parameter); + + // Create an event queue and a viewport for GUI + InputEvent input_event; + FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); + ViewPort* viewport = view_port_alloc(); + + // Error checking + if(!event_queue || !viewport) { + printf("Error: Failed to allocate event_queue or viewport!\n"); + return -1; + } + + // Set callbacks for drawing GUI and handling input + view_port_draw_callback_set(viewport, drawGui, NULL); + view_port_input_callback_set(viewport, handleInput, event_queue); + + // Create a GUI and associate it with the viewport + Gui* gui = furi_record_open(RECORD_GUI); + gui_add_view_port(gui, viewport, GuiLayerFullscreen); + + // Main event loop + while(true) { + // Check the queue for events + FuriStatus status = furi_message_queue_get(event_queue, &input_event, FuriWaitForever); + furi_check(status == FuriStatusOk); + + // Exit the loop if the back button is long-pressed + if(input_event.type == InputTypeLong && input_event.key == InputKeyBack) { + break; + } + } + + // Cleanup: free resources and close GUI record + furi_message_queue_free(event_queue); + gui_remove_view_port(gui, viewport); + view_port_free(viewport); + furi_record_close(RECORD_GUI); + + return 0; +} From 8d6b15c2f0da2618893cb3f2272b87fa5bd71c91 Mon Sep 17 00:00:00 2001 From: miguelgargallo Date: Wed, 28 Jun 2023 16:37:55 +0200 Subject: [PATCH 2/9] gh 0.0.2 Source Code --- Readme.md | 13 +++++++++++++ dragon/Readme.md | 9 +++++++++ 2 files changed, 22 insertions(+) create mode 100644 dragon/Readme.md diff --git a/Readme.md b/Readme.md index de2ec75..0389471 100644 --- a/Readme.md +++ b/Readme.md @@ -38,6 +38,7 @@ es: Los usuarios ahora pueden mantener presionado y presionar brevemente con un - [⬅️ Go left button screen](#️-go-left-button-screen) - [⬆️ Go up button screen](#️-go-up-button-screen) - [➡️ Go right button screen](#️-go-right-button-screen) + - [Dragon Graphics Motor](#dragon-graphics-motor) - [License](#license) ### Installation @@ -149,6 +150,18 @@ es: En tocar, cualquier botón interactúa, con esto puedes crear un juego de ### ➡️ Go right button screen ![➡️ Go right button screen](https://github.com/miguelgargallo/flipperzero/assets/5947268/20ab20f1-7a43-479e-b852-9a8f3636f557) +## Dragon Graphics Motor + +Here you have the DRAGON Graphics Engine. The idea behind my developments is to encourage the community to program their apps, either inspired by my code via forks, or because they want to contribute directly to me. + +es: Aquí tenéis al DRAGON Graphics Motor. La idea que hay detrás de mis desarrollos es enfatizar a la comunidad a que programen sus apps, a partir de la inspiración de mi codigo, ya sea por forks o bien porque quieran contribuir directamente conmigo. + +Please refer to the source code for a detailed look into the implementation of the DRAGON Graphics Engine. + +es: Por favor, consulte el código fuente para obtener un vistazo detallado a la implementación del motor gráfico DRAGON. + +[See the code](./dragon/dragon.c) + ## License [PYLAR AI CREATIVE ML LICENSE](License.md) diff --git a/dragon/Readme.md b/dragon/Readme.md new file mode 100644 index 0000000..52c746c --- /dev/null +++ b/dragon/Readme.md @@ -0,0 +1,9 @@ +# DRAGON Graphics Motor by [Miguel Gargallo](https://twitter.com/miguelgargallo) + +Here you have the DRAGON Graphics Engine. The idea behind my developments is to encourage the community to program their apps, either inspired by my code via forks, or because they want to contribute directly to me. + +es: Aquí tenéis al DRAGON Graphics Motor. La idea que hay detrás de mis desarrollos es enfatizar a la comunidad a que programen sus apps, a partir de la inspiración de mi codigo, ya sea por forks o bien porque quieran contribuir directamente conmigo. + +Please refer to the source code for a detailed look into the implementation of the DRAGON Graphics Engine. + +es: Por favor, consulte el código fuente para obtener un vistazo detallado a la implementación del motor gráfico DRAGON. \ No newline at end of file From 51ee2b55b6d10f15a79f90d9377634d49753c9f7 Mon Sep 17 00:00:00 2001 From: miguelgargallo Date: Wed, 28 Jun 2023 16:39:07 +0200 Subject: [PATCH 3/9] gh 0.0.2 Source Code --- Readme.md | 4 ---- dragon/Readme.md | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Readme.md b/Readme.md index 0389471..6e7a23d 100644 --- a/Readme.md +++ b/Readme.md @@ -156,10 +156,6 @@ Here you have the DRAGON Graphics Engine. The idea behind my developments is to es: Aquí tenéis al DRAGON Graphics Motor. La idea que hay detrás de mis desarrollos es enfatizar a la comunidad a que programen sus apps, a partir de la inspiración de mi codigo, ya sea por forks o bien porque quieran contribuir directamente conmigo. -Please refer to the source code for a detailed look into the implementation of the DRAGON Graphics Engine. - -es: Por favor, consulte el código fuente para obtener un vistazo detallado a la implementación del motor gráfico DRAGON. - [See the code](./dragon/dragon.c) ## License diff --git a/dragon/Readme.md b/dragon/Readme.md index 52c746c..dc9df41 100644 --- a/dragon/Readme.md +++ b/dragon/Readme.md @@ -4,6 +4,4 @@ Here you have the DRAGON Graphics Engine. The idea behind my developments is to es: Aquí tenéis al DRAGON Graphics Motor. La idea que hay detrás de mis desarrollos es enfatizar a la comunidad a que programen sus apps, a partir de la inspiración de mi codigo, ya sea por forks o bien porque quieran contribuir directamente conmigo. -Please refer to the source code for a detailed look into the implementation of the DRAGON Graphics Engine. - -es: Por favor, consulte el código fuente para obtener un vistazo detallado a la implementación del motor gráfico DRAGON. \ No newline at end of file +[See the code](./dragon.c) \ No newline at end of file From db0649d349e357a489ffe0dd141e95ae4453aa30 Mon Sep 17 00:00:00 2001 From: miguelgargallo Date: Wed, 28 Jun 2023 18:28:56 +0200 Subject: [PATCH 4/9] gh 0.0.2 Source Code --- dragon/application.fam | 9 ---- dragon/dragon.c | 99 ------------------------------------ {dragon => human}/License.md | 0 {dragon => human}/Readme.md | 0 human/application.fam | 10 ++++ human/dragon.c | 81 +++++++++++++++++++++++++++++ 6 files changed, 91 insertions(+), 108 deletions(-) delete mode 100644 dragon/application.fam delete mode 100644 dragon/dragon.c rename {dragon => human}/License.md (100%) rename {dragon => human}/Readme.md (100%) create mode 100644 human/application.fam create mode 100644 human/dragon.c diff --git a/dragon/application.fam b/dragon/application.fam deleted file mode 100644 index 4562ffd..0000000 --- a/dragon/application.fam +++ /dev/null @@ -1,9 +0,0 @@ -App( - appid="dragon", - name="Graphics Motor Dragon", - apptype=FlipperAppType.EXTERNAL, - entry_point="dragon_main", - requires=["gui"], - stack_size=1 * 1024, - fap_category="Games", -) diff --git a/dragon/dragon.c b/dragon/dragon.c deleted file mode 100644 index cbb1277..0000000 --- a/dragon/dragon.c +++ /dev/null @@ -1,99 +0,0 @@ -#include -#include -#include - -static int position[] = {5, 5}; // Starting position -static char currentSymbol[] = "o"; // Changed from char to char array - -static void drawGui(Canvas* canvas, void* context) { - UNUSED(context); - canvas_clear(canvas); - - // Draw the currentSymbol - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, position[0], position[1], currentSymbol); -} - -static void handleInput(InputEvent* input_event, void* context) { - FuriMessageQueue* event_queue = context; - furi_assert(event_queue != NULL); - - bool longPress = (input_event->type == InputTypeLong) ? true : false; - int step = longPress ? 2 : 1; // Move 2 positions if long pressed, 1 otherwise - - switch(input_event->key) { - case InputKeyUp: - position[1] -= step; - break; - case InputKeyDown: - position[1] += step; - break; - case InputKeyLeft: - position[0] -= step; - break; - case InputKeyRight: - position[0] += step; - break; - case InputKeyOk: - strcpy(currentSymbol, "."); // Replace string copy instead of assignment - break; - case InputKeyBack: - strcpy(currentSymbol, "O"); // Replace string copy instead of assignment - break; - case InputKeyMAX: - // Add handling for InputKeyMAX here if necessary - break; - } - - // Bounds check - if(position[0] < 0) position[0] = 0; - if(position[0] > 126) position[0] = 126; // 128 pixels, adjust as necessary - if(position[1] < 0) position[1] = 0; - if(position[1] > 62) position[1] = 62; // 64 pixels, adjust as necessary - - furi_message_queue_put(event_queue, input_event, FuriWaitForever); -} - -// Main function of the app -int32_t dragon_main(void* parameter) { - UNUSED(parameter); - - // Create an event queue and a viewport for GUI - InputEvent input_event; - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); - ViewPort* viewport = view_port_alloc(); - - // Error checking - if(!event_queue || !viewport) { - printf("Error: Failed to allocate event_queue or viewport!\n"); - return -1; - } - - // Set callbacks for drawing GUI and handling input - view_port_draw_callback_set(viewport, drawGui, NULL); - view_port_input_callback_set(viewport, handleInput, event_queue); - - // Create a GUI and associate it with the viewport - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, viewport, GuiLayerFullscreen); - - // Main event loop - while(true) { - // Check the queue for events - FuriStatus status = furi_message_queue_get(event_queue, &input_event, FuriWaitForever); - furi_check(status == FuriStatusOk); - - // Exit the loop if the back button is long-pressed - if(input_event.type == InputTypeLong && input_event.key == InputKeyBack) { - break; - } - } - - // Cleanup: free resources and close GUI record - furi_message_queue_free(event_queue); - gui_remove_view_port(gui, viewport); - view_port_free(viewport); - furi_record_close(RECORD_GUI); - - return 0; -} diff --git a/dragon/License.md b/human/License.md similarity index 100% rename from dragon/License.md rename to human/License.md diff --git a/dragon/Readme.md b/human/Readme.md similarity index 100% rename from dragon/Readme.md rename to human/Readme.md diff --git a/human/application.fam b/human/application.fam new file mode 100644 index 0000000..9a5f8e0 --- /dev/null +++ b/human/application.fam @@ -0,0 +1,10 @@ +App( + appid="example_images", + name="Example: Images", + apptype=FlipperAppType.EXTERNAL, + entry_point="example_images_main", + requires=["gui"], + stack_size=1 * 1024, + fap_category="Examples", + fap_icon_assets="images", +) diff --git a/human/dragon.c b/human/dragon.c new file mode 100644 index 0000000..b00818c --- /dev/null +++ b/human/dragon.c @@ -0,0 +1,81 @@ +#include +#include + +#include +#include + +/* Magic happens here -- this file is generated by fbt. + * Just set fap_icon_assets in application.fam and #include {APPID}_icons.h */ +#include "example_images_icons.h" + +typedef struct { + uint8_t x, y; +} ImagePosition; + +static ImagePosition image_position = {.x = 0, .y = 0}; + +// Screen is 128x64 px +static void app_draw_callback(Canvas* canvas, void* ctx) { + UNUSED(ctx); + + canvas_clear(canvas); + canvas_draw_icon(canvas, image_position.x % 128, image_position.y % 64, &I_dolphin_71x25); +} + +static void app_input_callback(InputEvent* input_event, void* ctx) { + furi_assert(ctx); + + FuriMessageQueue* event_queue = ctx; + furi_message_queue_put(event_queue, input_event, FuriWaitForever); +} + +int32_t example_images_main(void* p) { + UNUSED(p); + FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); + + // Configure view port + ViewPort* view_port = view_port_alloc(); + view_port_draw_callback_set(view_port, app_draw_callback, view_port); + view_port_input_callback_set(view_port, app_input_callback, event_queue); + + // Register view port in GUI + Gui* gui = furi_record_open(RECORD_GUI); + gui_add_view_port(gui, view_port, GuiLayerFullscreen); + + InputEvent event; + + bool running = true; + while(running) { + if(furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) { + if((event.type == InputTypePress) || (event.type == InputTypeRepeat)) { + switch(event.key) { + case InputKeyLeft: + image_position.x -= 2; + break; + case InputKeyRight: + image_position.x += 2; + break; + case InputKeyUp: + image_position.y -= 2; + break; + case InputKeyDown: + image_position.y += 2; + break; + default: + running = false; + break; + } + } + } + view_port_update(view_port); + } + + view_port_enabled_set(view_port, false); + gui_remove_view_port(gui, view_port); + view_port_free(view_port); + furi_message_queue_free(event_queue); + + furi_record_close(RECORD_GUI); + + return 0; +} From 47b6c898924a158564df05f56b72e075eb97f068 Mon Sep 17 00:00:00 2001 From: miguelgargallo Date: Wed, 28 Jun 2023 18:29:18 +0200 Subject: [PATCH 5/9] gh 0.0.2 Source Code --- human/application.fam | 9 ++- human/dragon.c | 134 ++++++++++++++++++++++++------------------ 2 files changed, 80 insertions(+), 63 deletions(-) diff --git a/human/application.fam b/human/application.fam index 9a5f8e0..9b3e7b1 100644 --- a/human/application.fam +++ b/human/application.fam @@ -1,10 +1,9 @@ App( - appid="example_images", - name="Example: Images", + appid="human", + name="Graphics Motor Dragon", apptype=FlipperAppType.EXTERNAL, - entry_point="example_images_main", + entry_point="human_main", requires=["gui"], stack_size=1 * 1024, - fap_category="Examples", - fap_icon_assets="images", + fap_category="Games", ) diff --git a/human/dragon.c b/human/dragon.c index b00818c..48987a1 100644 --- a/human/dragon.c +++ b/human/dragon.c @@ -1,80 +1,98 @@ +#include #include -#include - #include -#include - -/* Magic happens here -- this file is generated by fbt. - * Just set fap_icon_assets in application.fam and #include {APPID}_icons.h */ -#include "example_images_icons.h" - -typedef struct { - uint8_t x, y; -} ImagePosition; - -static ImagePosition image_position = {.x = 0, .y = 0}; -// Screen is 128x64 px -static void app_draw_callback(Canvas* canvas, void* ctx) { - UNUSED(ctx); +static int position[] = {5, 5}; // Starting position +static char currentSymbol[] = "o"; // Changed from char to char array +static void drawGui(Canvas* canvas, void* context) { + UNUSED(context); canvas_clear(canvas); - canvas_draw_icon(canvas, image_position.x % 128, image_position.y % 64, &I_dolphin_71x25); + + // Draw the currentSymbol + canvas_set_font(canvas, FontPrimary); + canvas_draw_str(canvas, position[0], position[1], currentSymbol); } -static void app_input_callback(InputEvent* input_event, void* ctx) { - furi_assert(ctx); +static void handleInput(InputEvent* input_event, void* context) { + FuriMessageQueue* event_queue = context; + furi_assert(event_queue != NULL); + + bool longPress = (input_event->type == InputTypeLong) ? true : false; + int step = longPress ? 2 : 1; // Move 2 positions if long pressed, 1 otherwise + + switch(input_event->key) { + case InputKeyUp: + position[1] -= step; + break; + case InputKeyDown: + position[1] += step; + break; + case InputKeyLeft: + position[0] -= step; + break; + case InputKeyRight: + position[0] += step; + break; + case InputKeyOk: + strcpy(currentSymbol, "."); // Replace string copy instead of assignment + break; + case InputKeyBack: + strcpy(currentSymbol, "O"); // Replace string copy instead of assignment + break; + case InputKeyMAX: + // Add handling for InputKeyMAX here if necessary + break; + } + + // Bounds check + if(position[0] < 0) position[0] = 0; + if(position[0] > 126) position[0] = 126; // 128 pixels, adjust as necessary + if(position[1] < 0) position[1] = 0; + if(position[1] > 62) position[1] = 62; // 64 pixels, adjust as necessary - FuriMessageQueue* event_queue = ctx; furi_message_queue_put(event_queue, input_event, FuriWaitForever); } -int32_t example_images_main(void* p) { - UNUSED(p); +// Main function of the app +int32_t human_main(void* parameter) { + UNUSED(parameter); + + // Create an event queue and a viewport for GUI + InputEvent input_event; FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); + ViewPort* viewport = view_port_alloc(); + + // Error checking + if(!event_queue || !viewport) { + printf("Error: Failed to allocate event_queue or viewport!\n"); + return -1; + } - // Configure view port - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, app_draw_callback, view_port); - view_port_input_callback_set(view_port, app_input_callback, event_queue); + // Set callbacks for drawing GUI and handling input + view_port_draw_callback_set(viewport, drawGui, NULL); + view_port_input_callback_set(viewport, handleInput, event_queue); - // Register view port in GUI + // Create a GUI and associate it with the viewport Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - InputEvent event; - - bool running = true; - while(running) { - if(furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) { - if((event.type == InputTypePress) || (event.type == InputTypeRepeat)) { - switch(event.key) { - case InputKeyLeft: - image_position.x -= 2; - break; - case InputKeyRight: - image_position.x += 2; - break; - case InputKeyUp: - image_position.y -= 2; - break; - case InputKeyDown: - image_position.y += 2; - break; - default: - running = false; - break; - } - } + gui_add_view_port(gui, viewport, GuiLayerFullscreen); + + // Main event loop + while(true) { + // Check the queue for events + FuriStatus status = furi_message_queue_get(event_queue, &input_event, FuriWaitForever); + furi_check(status == FuriStatusOk); + + // Exit the loop if the back button is long-pressed + if(input_event.type == InputTypeLong && input_event.key == InputKeyBack) { + break; } - view_port_update(view_port); } - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - view_port_free(view_port); + // Cleanup: free resources and close GUI record furi_message_queue_free(event_queue); - + gui_remove_view_port(gui, viewport); + view_port_free(viewport); furi_record_close(RECORD_GUI); return 0; From 4a401603e82480d5fe445b13f253139295449e00 Mon Sep 17 00:00:00 2001 From: miguelgargallo Date: Wed, 28 Jun 2023 18:56:41 +0200 Subject: [PATCH 6/9] gh 0.0.3 Human --- human/Readme.md | 2 +- human/{dragon.c => human.c} | 29 ++++++++++++----------------- 2 files changed, 13 insertions(+), 18 deletions(-) rename human/{dragon.c => human.c} (79%) diff --git a/human/Readme.md b/human/Readme.md index dc9df41..21d5502 100644 --- a/human/Readme.md +++ b/human/Readme.md @@ -4,4 +4,4 @@ Here you have the DRAGON Graphics Engine. The idea behind my developments is to es: Aquí tenéis al DRAGON Graphics Motor. La idea que hay detrás de mis desarrollos es enfatizar a la comunidad a que programen sus apps, a partir de la inspiración de mi codigo, ya sea por forks o bien porque quieran contribuir directamente conmigo. -[See the code](./dragon.c) \ No newline at end of file +[See the code](./human.c) \ No newline at end of file diff --git a/human/dragon.c b/human/human.c similarity index 79% rename from human/dragon.c rename to human/human.c index 48987a1..425bdd5 100644 --- a/human/dragon.c +++ b/human/human.c @@ -1,9 +1,18 @@ +/**************************| +| o myFlipperApps o | +| o by JohnDoe o | +| o 002 - Horizontal Move o | +| o Version: 3.0.0b o | +| o Date: 06-28-2023 o | +| o o | +**************************/ + #include #include #include static int position[] = {5, 5}; // Starting position -static char currentSymbol[] = "o"; // Changed from char to char array +static char currentSymbol[] = "x"; // Changed from "o" to "x" static void drawGui(Canvas* canvas, void* context) { UNUSED(context); @@ -22,34 +31,20 @@ static void handleInput(InputEvent* input_event, void* context) { int step = longPress ? 2 : 1; // Move 2 positions if long pressed, 1 otherwise switch(input_event->key) { - case InputKeyUp: - position[1] -= step; - break; - case InputKeyDown: - position[1] += step; - break; case InputKeyLeft: position[0] -= step; break; case InputKeyRight: position[0] += step; break; - case InputKeyOk: - strcpy(currentSymbol, "."); // Replace string copy instead of assignment - break; - case InputKeyBack: - strcpy(currentSymbol, "O"); // Replace string copy instead of assignment - break; - case InputKeyMAX: - // Add handling for InputKeyMAX here if necessary + default: + // Do nothing for other keys break; } // Bounds check if(position[0] < 0) position[0] = 0; if(position[0] > 126) position[0] = 126; // 128 pixels, adjust as necessary - if(position[1] < 0) position[1] = 0; - if(position[1] > 62) position[1] = 62; // 64 pixels, adjust as necessary furi_message_queue_put(event_queue, input_event, FuriWaitForever); } From 31ceb45d4f16cac9ca46327cafb50c39bfe41131 Mon Sep 17 00:00:00 2001 From: miguelgargallo Date: Wed, 28 Jun 2023 18:58:45 +0200 Subject: [PATCH 7/9] gh 0.0.3 Human --- {my_first_app => button}/License.md | 0 button/application.fam | 9 +++++++++ my_first_app/my_first_app.c => button/button.c | 2 +- human/application.fam | 2 +- my_first_app/application.fam | 9 --------- 5 files changed, 11 insertions(+), 11 deletions(-) rename {my_first_app => button}/License.md (100%) create mode 100644 button/application.fam rename my_first_app/my_first_app.c => button/button.c (99%) delete mode 100644 my_first_app/application.fam diff --git a/my_first_app/License.md b/button/License.md similarity index 100% rename from my_first_app/License.md rename to button/License.md diff --git a/button/application.fam b/button/application.fam new file mode 100644 index 0000000..e87459f --- /dev/null +++ b/button/application.fam @@ -0,0 +1,9 @@ +App( + appid="button", + name="button", + apptype=FlipperAppType.EXTERNAL, + entry_point="button_main", + requires=["gui"], + stack_size=1 * 1024, + fap_category="miguelgargallo", +) diff --git a/my_first_app/my_first_app.c b/button/button.c similarity index 99% rename from my_first_app/my_first_app.c rename to button/button.c index cc0d320..5460d09 100644 --- a/my_first_app/my_first_app.c +++ b/button/button.c @@ -96,7 +96,7 @@ static void handleInput(InputEvent* input_event, void* context) { } // Main function of the app -int32_t my_first_app_main(void* parameter) { +int32_t button_main(void* parameter) { UNUSED(parameter); // Create an event queue and a viewport for GUI diff --git a/human/application.fam b/human/application.fam index 9b3e7b1..b4b56dc 100644 --- a/human/application.fam +++ b/human/application.fam @@ -5,5 +5,5 @@ App( entry_point="human_main", requires=["gui"], stack_size=1 * 1024, - fap_category="Games", + fap_category="miguelgargallo", ) diff --git a/my_first_app/application.fam b/my_first_app/application.fam deleted file mode 100644 index 9a50e39..0000000 --- a/my_first_app/application.fam +++ /dev/null @@ -1,9 +0,0 @@ -App( - appid="my_first_app", - name="My First App", - apptype=FlipperAppType.EXTERNAL, - entry_point="my_first_app_main", - requires=["gui"], - stack_size=1 * 1024, - fap_category="Examples", -) From 101075ea80c4b9b6fefcc43e2c10b4b936f72941 Mon Sep 17 00:00:00 2001 From: miguelgargallo Date: Wed, 28 Jun 2023 19:58:47 +0200 Subject: [PATCH 8/9] gh 0.0.3 Human --- Readme.md | 16 ++--- applications_user/Readme.md | 1 + .../button}/License.md | 2 +- .../button}/application.fam | 0 {button => applications_user/button}/button.c | 0 {human => applications_user/human}/License.md | 0 {human => applications_user/human}/Readme.md | 0 .../human}/application.fam | 0 {human => applications_user/human}/human.c | 60 +++++++++++------- {other/assets => assets}/logs/01.log | 0 {other/assets => assets}/logs/02.log | 0 .../screenshots/flipper/goback.jpg | Bin .../screenshots/flipper/gocenter.jpg | Bin .../screenshots/flipper/godown.jpg | Bin .../screenshots/flipper/goleft.jpg | Bin .../screenshots/flipper/goright.jpg | Bin .../screenshots/flipper/goup.jpg | Bin .../screenshots/flipper/initial.jpg | Bin .../screenshots/windows/windows.png | Bin fapps/button.fap | Bin 0 -> 3168 bytes fapps/human.fap | Bin 0 -> 2156 bytes not_README.md | 3 - other/build/License.md | 21 ------ other/build/my_first_app.fap | Bin 3180 -> 0 bytes 24 files changed, 48 insertions(+), 55 deletions(-) create mode 100644 applications_user/Readme.md rename {button => applications_user/button}/License.md (97%) rename {button => applications_user/button}/application.fam (100%) rename {button => applications_user/button}/button.c (100%) rename {human => applications_user/human}/License.md (100%) rename {human => applications_user/human}/Readme.md (100%) rename {human => applications_user/human}/application.fam (100%) rename {human => applications_user/human}/human.c (60%) rename {other/assets => assets}/logs/01.log (100%) rename {other/assets => assets}/logs/02.log (100%) rename {other/assets => assets}/screenshots/flipper/goback.jpg (100%) rename {other/assets => assets}/screenshots/flipper/gocenter.jpg (100%) rename {other/assets => assets}/screenshots/flipper/godown.jpg (100%) rename {other/assets => assets}/screenshots/flipper/goleft.jpg (100%) rename {other/assets => assets}/screenshots/flipper/goright.jpg (100%) rename {other/assets => assets}/screenshots/flipper/goup.jpg (100%) rename {other/assets => assets}/screenshots/flipper/initial.jpg (100%) rename {other/assets => assets}/screenshots/windows/windows.png (100%) create mode 100644 fapps/button.fap create mode 100644 fapps/human.fap delete mode 100644 not_README.md delete mode 100644 other/build/License.md delete mode 100644 other/build/my_first_app.fap diff --git a/Readme.md b/Readme.md index 6e7a23d..e11596a 100644 --- a/Readme.md +++ b/Readme.md @@ -65,9 +65,9 @@ es: Ejecuta `./fbt`. ### Create the app -Then you will see this log on console log from the [log](./other/01.log) +Then you will see this log on console log from the [log](./assets/01.log) -es: Luego verás este registro en el registro de la consola desde el [log](./other/01.log). +es: Luego verás este registro en el registro de la consola desde el [log](./assets/01.log). We put the code inside the folder applications_user/my_first_app. @@ -77,10 +77,10 @@ es: Ponemos el código dentro de la carpeta applications_user/mi_primera_app. Inside my_first_app we add 2 files: -es: Dentro de mi_primera_app agregamos 2 archivos: +es: Dentro de mi primera app "button" agregamos 2 archivos: -- [my_first_app.c](./my_first_app/my_first_app.c) -- [application.fam](./my_first_app/application.fam) +- [button.c](./applications_user/button.c) +- [application.fam](./applications_user/application.fam) ### Compile @@ -92,9 +92,9 @@ es: Ahora podemos compilar la aplicación: ./fbt fap_dist ``` -Then you will see this log on console log from the [log](./other/02.log) +Then you will see this log on console log from the [log](./assets/02.log) -es: Luego verás este registro en el registro de la consola desde el [log](./other/02.log). +es: Luego verás este registro en el registro de la consola desde el [log](./assets/02.log). `D:/unleashed-firmware/build/latest/.extapps/my_first_app.fap` will need to drag and drop to the qFlipper. @@ -156,7 +156,7 @@ Here you have the DRAGON Graphics Engine. The idea behind my developments is to es: Aquí tenéis al DRAGON Graphics Motor. La idea que hay detrás de mis desarrollos es enfatizar a la comunidad a que programen sus apps, a partir de la inspiración de mi codigo, ya sea por forks o bien porque quieran contribuir directamente conmigo. -[See the code](./dragon/dragon.c) +[See the code](./human/human.c) ## License diff --git a/applications_user/Readme.md b/applications_user/Readme.md new file mode 100644 index 0000000..8bb7823 --- /dev/null +++ b/applications_user/Readme.md @@ -0,0 +1 @@ +Put your custom applications in this folder. \ No newline at end of file diff --git a/button/License.md b/applications_user/button/License.md similarity index 97% rename from button/License.md rename to applications_user/button/License.md index 08b9748..f7bc74d 100644 --- a/button/License.md +++ b/applications_user/button/License.md @@ -1,4 +1,4 @@ -# Clicks SDK by [Miguel Gargallo](https://twitter.com/miguelgargallo) +# Button by [Miguel Gargallo](https://twitter.com/miguelgargallo) ## PYLAR AI CREATIVE ML LICENSE diff --git a/button/application.fam b/applications_user/button/application.fam similarity index 100% rename from button/application.fam rename to applications_user/button/application.fam diff --git a/button/button.c b/applications_user/button/button.c similarity index 100% rename from button/button.c rename to applications_user/button/button.c diff --git a/human/License.md b/applications_user/human/License.md similarity index 100% rename from human/License.md rename to applications_user/human/License.md diff --git a/human/Readme.md b/applications_user/human/Readme.md similarity index 100% rename from human/Readme.md rename to applications_user/human/Readme.md diff --git a/human/application.fam b/applications_user/human/application.fam similarity index 100% rename from human/application.fam rename to applications_user/human/application.fam diff --git a/human/human.c b/applications_user/human/human.c similarity index 60% rename from human/human.c rename to applications_user/human/human.c index 425bdd5..6954092 100644 --- a/human/human.c +++ b/applications_user/human/human.c @@ -1,20 +1,28 @@ -/**************************| -| o myFlipperApps o | -| o by JohnDoe o | +/***************************| +| o o | +| o myFlipperApps o | +| o by MiguelGargallo o | | o 002 - Horizontal Move o | -| o Version: 3.0.0b o | -| o Date: 06-28-2023 o | -| o o | -**************************/ +| o Version: 3.0.0b o | +| o Date: 06-28-2023 o | +| o o | +****************************/ #include #include #include -static int position[] = {5, 5}; // Starting position -static char currentSymbol[] = "x"; // Changed from "o" to "x" +// Starting position at the center center +// static int position[] = {64, 32}; +// Starting position at the bottom center +// static int position[] = {64, 64}; +// Starting position at the bottom left +static int position[] = {0, 64}; -static void drawGui(Canvas* canvas, void* context) { +static char currentSymbol[] = "x"; // The symbol to be displayed + +static void drawGui(Canvas *canvas, void *context) +{ UNUSED(context); canvas_clear(canvas); @@ -23,14 +31,16 @@ static void drawGui(Canvas* canvas, void* context) { canvas_draw_str(canvas, position[0], position[1], currentSymbol); } -static void handleInput(InputEvent* input_event, void* context) { - FuriMessageQueue* event_queue = context; +static void handleInput(InputEvent *input_event, void *context) +{ + FuriMessageQueue *event_queue = context; furi_assert(event_queue != NULL); bool longPress = (input_event->type == InputTypeLong) ? true : false; int step = longPress ? 2 : 1; // Move 2 positions if long pressed, 1 otherwise - switch(input_event->key) { + switch (input_event->key) + { case InputKeyLeft: position[0] -= step; break; @@ -43,23 +53,27 @@ static void handleInput(InputEvent* input_event, void* context) { } // Bounds check - if(position[0] < 0) position[0] = 0; - if(position[0] > 126) position[0] = 126; // 128 pixels, adjust as necessary + if (position[0] < 0) + position[0] = 0; + if (position[0] > 126) + position[0] = 126; // 128 pixels, adjust as necessary furi_message_queue_put(event_queue, input_event, FuriWaitForever); } // Main function of the app -int32_t human_main(void* parameter) { +int32_t human_main(void *parameter) +{ UNUSED(parameter); // Create an event queue and a viewport for GUI InputEvent input_event; - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); - ViewPort* viewport = view_port_alloc(); + FuriMessageQueue *event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); + ViewPort *viewport = view_port_alloc(); // Error checking - if(!event_queue || !viewport) { + if (!event_queue || !viewport) + { printf("Error: Failed to allocate event_queue or viewport!\n"); return -1; } @@ -69,17 +83,19 @@ int32_t human_main(void* parameter) { view_port_input_callback_set(viewport, handleInput, event_queue); // Create a GUI and associate it with the viewport - Gui* gui = furi_record_open(RECORD_GUI); + Gui *gui = furi_record_open(RECORD_GUI); gui_add_view_port(gui, viewport, GuiLayerFullscreen); // Main event loop - while(true) { + while (true) + { // Check the queue for events FuriStatus status = furi_message_queue_get(event_queue, &input_event, FuriWaitForever); furi_check(status == FuriStatusOk); // Exit the loop if the back button is long-pressed - if(input_event.type == InputTypeLong && input_event.key == InputKeyBack) { + if (input_event.type == InputTypeLong && input_event.key == InputKeyBack) + { break; } } diff --git a/other/assets/logs/01.log b/assets/logs/01.log similarity index 100% rename from other/assets/logs/01.log rename to assets/logs/01.log diff --git a/other/assets/logs/02.log b/assets/logs/02.log similarity index 100% rename from other/assets/logs/02.log rename to assets/logs/02.log diff --git a/other/assets/screenshots/flipper/goback.jpg b/assets/screenshots/flipper/goback.jpg similarity index 100% rename from other/assets/screenshots/flipper/goback.jpg rename to assets/screenshots/flipper/goback.jpg diff --git a/other/assets/screenshots/flipper/gocenter.jpg b/assets/screenshots/flipper/gocenter.jpg similarity index 100% rename from other/assets/screenshots/flipper/gocenter.jpg rename to assets/screenshots/flipper/gocenter.jpg diff --git a/other/assets/screenshots/flipper/godown.jpg b/assets/screenshots/flipper/godown.jpg similarity index 100% rename from other/assets/screenshots/flipper/godown.jpg rename to assets/screenshots/flipper/godown.jpg diff --git a/other/assets/screenshots/flipper/goleft.jpg b/assets/screenshots/flipper/goleft.jpg similarity index 100% rename from other/assets/screenshots/flipper/goleft.jpg rename to assets/screenshots/flipper/goleft.jpg diff --git a/other/assets/screenshots/flipper/goright.jpg b/assets/screenshots/flipper/goright.jpg similarity index 100% rename from other/assets/screenshots/flipper/goright.jpg rename to assets/screenshots/flipper/goright.jpg diff --git a/other/assets/screenshots/flipper/goup.jpg b/assets/screenshots/flipper/goup.jpg similarity index 100% rename from other/assets/screenshots/flipper/goup.jpg rename to assets/screenshots/flipper/goup.jpg diff --git a/other/assets/screenshots/flipper/initial.jpg b/assets/screenshots/flipper/initial.jpg similarity index 100% rename from other/assets/screenshots/flipper/initial.jpg rename to assets/screenshots/flipper/initial.jpg diff --git a/other/assets/screenshots/windows/windows.png b/assets/screenshots/windows/windows.png similarity index 100% rename from other/assets/screenshots/windows/windows.png rename to assets/screenshots/windows/windows.png diff --git a/fapps/button.fap b/fapps/button.fap new file mode 100644 index 0000000000000000000000000000000000000000..e962b06419cbc00a8f62ae4b56ec26fddc9d47ab GIT binary patch literal 3168 zcmbVOU1%It6h8ZtCXH#EHnD$6)5#`nH)*pbX{AL&ZKavb&(>C{XhAxe>`s!Uo1Jxb zHf=y`(U&4V6!D=*9}4xMg2-B^pb&gf@Np|X6cH2=wus0oRjU;A`{pOvY!?wPoco>c zoOACz_ujc@_rhpG4Fm$>w}3>2>^;wPvDxu79B?2iE%J!8-g@@KklLi4UfjOe&_8+S z+q=O^W5?c}{ZF2#1X>=Oyb=%fZ79VOv5EGnP~TG}i42T4PeF1gDt`}eQ}-gGb!l(n z=W?hoRO(OkBJRg>U*a!^M-vM8_vJkv-<{|L|GK=(a=*NOLP@kwEtS`eH_ruzo2P>Pjipfk+ESqZliO=2hPpRi{HWYGF$}y} zZkX5){GjZgL)cS%Yz2=(4na;rrXc4bmmt?5MaUPB3WV(rB#blM3d!Aitr%9@v1{p8 z)V61e@wUlz5e53D<2T{~U@_i0*)bQ5Y=C|vz8?BPPj8u2B1awTmWaIdYEKY)Q{q}Y zSj;V938(GD8f<>9K2~nMUTo@aQoFHo*y&~8P-%@S(HQQeYrG5gh}tzis8Z`1W8bKT zBSY#AXuPYms;C{%8`L`=FWnC-M}BSC|IX9D+*Z`hunwt*)JK7XPQQMPJB+HKVr8jq ztPMJ5c>MSBiAu0#Bba>ZX8CZR^YVY#<61_l{HM)=lCz9_-bg8D;3m(Q+1Y_*;~APA zyKh>k7q_rL^QyR!dT}EoG_Q&~TrckMVVYOPnf2mKljc=%1NGtt256Q9_U3L_u}#G| zpSEK%iargqJ!dFKbGaDfPV!6?J-et(7i`6l1~2+S{$Fc_d0e;qx*@A zyP^~JzdLshEfq5|Go0jw^xZ%IZL*MrR=GpVU%zV($r`7QtpwFZ1em`QGl&fZp>bdB z%L4+=jN7X?{omAZ|LqC#;k)BpZVN~olp%1|34i`eReq`~-?lscMveba(4CE$(#3ml zTgc%)6K}u%+xPj3KkUS>_`}k%;*?hCtZ#lJXRY%a`6-_O$@LnZuivia&d;8>;F;XZ&^MY*S`atzhhq^Zc{KIeKr20HT+BsH*2``rli-FIX#=o7~|Po z!IqSzpNr#(XxdD{N^40=&(BFx&o1bBjXo`JTf*n0@jbbwB%a;0o;<7N4cm`RW(?gD zXAa9qnpR3nX3V_dTITVz^;yGxpV}-&If1Lq&RecpYQ{1QzFtjFrL^S?kmxx}&uPd# zUvC!f$x9#EX)|Wlb|$fmd2_+2nx{HdGiPMIBB0Id>1@4;ophGd(9%3Tt=>sEr+xCXxs#NDX=Aj9*d_835s!R|xJx8OjEKw;cZg(& zC~!F<#@oc5s8>XsGaK!!8AOTY7w2t#8faTC&iR^UWMZ~)-j*{qo@xPfhiZ;ejIPRc_obLg; zK{)(9!Q{jd`KO~Q9VhO2I=trlM!|iZu1lD&-HRb`T{gy49hY2%<1!5Vd(W$8oS!dq b^V>fBNM5K~z*jdSU{xF@I^_=n`f>jNhR*^# literal 0 HcmV?d00001 diff --git a/fapps/human.fap b/fapps/human.fap new file mode 100644 index 0000000000000000000000000000000000000000..fbe415e91675806ce9105b97f09ac6abc122351a GIT binary patch literal 2156 zcma)7O=ufO6n?u}IkFM1Z0DzOVr3;#5TX@ve!!F*OmW8YPjLw;n9{NyYezq1wX4jo z{BubUz4eqs4x#iAXnX6yE%?xb$)$%J73iVRmL3w&RW0=I)V{Z?*~p728JPXv_uiW~ zZ+_nF$G6s*rfHy>1|=Z&)ll*CSSX~ghfsnE7>C^9Ki{NShJCP~D(8DzVRm0HU+ksI zsb|yc#pdnV;#O{Tx(VfTKTRUuFYCW#SML|5wl)U;UOmqy)*dbAjy48bHiMF0__c4~ zsEMWG*7Lr;3h4K|4^NEY`~mt6ik*zOs|ZsP3({FAzOcpv6SoRn8D#E2bn^K z70}-ZzwqXKZ;U~y(t~1tC6D?d%dcEvB;~90J;jXTJexy_GHo%FT|ha_e*Es}Z^K;t zJ$>!7cYb?jva_h2XAA5M;+60_Sv`$%iKPw(M>EwKlrh4MKl>X4Jv)UAo~Rs?80~9P zdosTzr6=Du8E-klHUrP(j^ovMAWX3%+`zim6@!F&H%q94Z z1gA?xZ^RGSr*#cJO4#9Y08Q@Nj#zO!-2g7zU`xKcjMve!>Rs8gYLfd+sBw3P`xeZ1)*QhlgfXP3dD6COj^~R=(-ywZ8zQO&tAV3J$K&d- zZbqi6OChLIENUD&BQm`-f~AWk5+$9}~WY zb%W=pp9WYUyaaHQ5Fdy|LcHKhgjfJo!a0C-LhSDmVlmtyJPWW%h{gCJ;YENg!dc9Z z@C@chIF0!cV($>10|*E)U#R%|?SOA11~S5?lB94df!GV6B0ZZ294gVb&O2>EwBdFw zTWoh5PRqTEv0ky^a>Mr^`qf2m$R6gSnyP!M`El%vL&MWFz*CfQo5Jzrm%;wVkY7cl zIA3EQeGkZw!oM{{dJPXy@dA4mW!2QY*HA(Jstu65uLz>D-5in0T*Y&yw@Eb>kNnXT pw@o70DR(*o@}qII*3p-G6Af)O8QPSH*Xx+y1Kh|p)TyTY{sX?6Oe6pR literal 0 HcmV?d00001 diff --git a/not_README.md b/not_README.md deleted file mode 100644 index 485bc28..0000000 --- a/not_README.md +++ /dev/null @@ -1,3 +0,0 @@ -Put your custom applications in this folder. - -If you see this file, you know where you are 😏 \ No newline at end of file diff --git a/other/build/License.md b/other/build/License.md deleted file mode 100644 index 22d1cae..0000000 --- a/other/build/License.md +++ /dev/null @@ -1,21 +0,0 @@ -PYLAR AI CREATIVE ML LICENSE - -[OFFICIAL REFERENCE](https://huggingface.co/spaces/superdatas/LICENSE) - -Version 0.0.5, 27th June 2023, Miguel Gargallo - -The following conditions govern the use of the Pylar AI software and its associated documentation files (collectively referred to as the "Software"): - -1. **Grant of License**: This license grants you, the end-user, the right to use the Software for educational, research, and personal learning purposes. Any use of the Software outside of these purposes, including any attempt to make profit from its use or redistribution, is strictly prohibited. - -2. **Limitations on Use**: You may not sell, rent, lease, sublicense, distribute, redistribute, or transfer the Software or any portion thereof to any third party. Furthermore, you may not modify, adapt, translate, reverse engineer, decompile, disassemble or otherwise attempt to derive source code from the Software. - -3. **Intellectual Property Rights**: All rights, title, and interest in and to the Software (including but not limited to any images, photographs, animations, video, audio, music, text, and "applets" incorporated into the Software), and any copies of the Software, are owned by Miguel Gargallo or his suppliers. All rights not specifically granted under this license are reserved by Miguel Gargallo or his suppliers. - -4. **Non-Commercial Use**: The Software is intended solely for educational and informative purposes. Commercial use, including but not limited to the sale of the Software or any associated materials, is prohibited. - -5. **Self-Hosting Prohibited**: You are strictly prohibited from hosting the Software, making it available to others via servers, cloud services, or online platforms, or using it in a way that it is accessible to others. - -6. **Disclaimer of Warranty**: The Software is provided "as is" without any warranties of any kind, whether express or implied, including but not limited to warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event will Miguel Gargallo or his suppliers be liable for any damages whatsoever arising out of the use of or inability to use the Software. - -By using the Software, you agree to abide by the terms and conditions of this license. If you do not agree to these terms, you are not authorized to use or access the Software. diff --git a/other/build/my_first_app.fap b/other/build/my_first_app.fap deleted file mode 100644 index ddecb892e284cb5012d30402313ab7fd2aa4583b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3180 zcmb7GU1%It6h8ZtCXH#EHnD$c)5#{ao3vSzw535qZKavb&(>C{U_m;W>`s!Uo1Jxb zHf=yu6ro5Tiuh2Z4*`9sFR~UYDg<8?eB6o;MFd5JEg}-7YSDsz-~4QLw?Xv6x!?KD zIrrXk@7;4}Umi`Ufj~g~7Lcfrz2})OH#?q&Lk>ixMIMsYn@@ibQk&GXi#rz^`X+CG zdndTk*s;I+;Nz!O0xgeDUX6!(HIEb$Nf{ z=W?hwRO(CgAnwOc6d`Ml4u7H^){50 zL>IKr%Sz%m$i4E$2_?}!wOrmX-aHo=YMu)AHI_ns>q~*YPj0QB80^~o%7^8~i6P*P za>K+y;QM9&9KxRBV=H(RG7LElnSxw|T!Jh?ijXfLD-gEZkTA}0J0y4W)nZs}$F8MI zQQMv>#@i-0L=@;-PF{}(fW>(0WXD`IvI+Y2_(teQJiTR7i5z#V+amJjOWi@}O^Ky= zu$WuM5>7jSHQ4-IeO$TuTCu6CN$tYQVW*b^gQaz&|DLDbgj6fM`^B!GuMhUO`2=s`qzr<@26Q3*qggy#Woe= zV%m<$DEc(a_MD*{&*fr_JIymu^z5QCU9fF48;ix{dOCyC z!*qHkVcm5YilnQjDn$pGF62zh?h=_Tq&ZY<+yQ^fV<+OzxYw~q8r`4x z1M4^g{%1G8sLe1}P0!`DRLscCh-}mUy7q6=gd|ks4pl0^HHT!K^Omg!)kg%l2Pb9# zn+ihX-r6ez0?v#(t2q7N)N#N51o^P`IG5W3(gtM^oNt9c|D`HF)z#m(JN|l|e>mvQ z#!TtrUAQgeaG!~{U%&o+zUmJ<@vHu@bgVk16*}KIzmfC3^BegYp8(1AI-alNZ`AR3 z>iCU1{#hL_)$z&$4LjHWqt4$_IUCo%yN(~O_*%Ay$s?J}iZTvHOIH?1enYk9-= zW0M&}x5SylGLoj1(vlf7Z@89ul(#->xHYQHVw4kDYj*0nYN;8^Fj&Ewo=Rzz43Ovr zOV4S@J-^m0+>@6+veRbFtnEx<8T00XQ8iC>s%Fl}t~HsHLS<AfpM($;0}??#4eF5M95pjZ6a5R7=O*fB_i^F zm$(o02VZa(-UuR!^BA#3=|OW$aBO_k>`mh_96ZhcVBI2CcXy@BOlvsXo-qxpqw&miSuUSSWW*Zl6iCJb!w{;*a zt~Q;|OKe8Z%^S4OW(!)%m@drXn$L5I|J0C{^NwNLPCJDDMdax>=E%mkZ9U`|gzcjy z><_uq#w{=oCc&{ed Date: Wed, 28 Jun 2023 19:59:24 +0200 Subject: [PATCH 9/9] gh 0.0.3 Human --- applications_user/button/button.c | 126 ++++++++++++++++-------------- 1 file changed, 69 insertions(+), 57 deletions(-) diff --git a/applications_user/button/button.c b/applications_user/button/button.c index 5460d09..8f493e2 100644 --- a/applications_user/button/button.c +++ b/applications_user/button/button.c @@ -1,26 +1,28 @@ -/**************************| -| o myFlipperApps o | -| o by MiguelGargallo o | -| o 001 - My First App o | -| o Version: 3.0.0b o | -| o Date: 06-28-2023 o | -| o o | -**************************/ +/***************************| +| o o | +| o myFlipperApps o | +| o by MiguelGargallo o | +| o 002 - Button o | +| o Version: 3.0.0b o | +| o Date: 06-28-2023 o | +| o o | +****************************/ #include #include #include // Create messages to display based on user input -static char* message = "Press any button..."; -static char* exitMessage = ""; -static char numberMessage[2] = ""; // Create a new message string for numbers +static char *message = "Press any button..."; +static char *exitMessage = ""; +static char numberMessage[2] = ""; // Create a new message string for numbers // Create a variable to keep track of long press count static int longPressCount = 0; // Function to clear canvas and draw GUI elements -static void drawGui(Canvas* canvas, void* context) { +static void drawGui(Canvas *canvas, void *context) +{ UNUSED(context); canvas_clear(canvas); @@ -41,71 +43,79 @@ static void drawGui(Canvas* canvas, void* context) { } // Function to handle user input -static void handleInput(InputEvent* input_event, void* context) { - FuriMessageQueue* event_queue = context; +static void handleInput(InputEvent *input_event, void *context) +{ + FuriMessageQueue *event_queue = context; furi_assert(event_queue != NULL); // Check if the button was long-pressed or not bool longPress = (input_event->type == InputTypeLong) ? true : false; // Change the message depending on which key was pressed - switch(input_event->key) { - case InputKeyUp: - message = longPress ? "You long-pressed ^^^" : "You pressed ^"; - break; - case InputKeyDown: - message = longPress ? "You long-pressed vvv" : "You pressed v"; - break; - case InputKeyLeft: - message = longPress ? "You long-pressed <<<" : "You pressed <"; - break; - case InputKeyRight: - message = longPress ? "You long-pressed >>>" : "You pressed >"; - break; - case InputKeyOk: - message = longPress ? "You long-pressed ooo" : "You pressed o"; - break; - case InputKeyBack: - message = longPress ? "You long-pressed ---" : "You pressed -"; - exitMessage = longPress ? "Exiting the App." : "Long press to exit."; - break; - default: - message = "Press any button..."; + switch (input_event->key) + { + case InputKeyUp: + message = longPress ? "You long-pressed ^^^" : "You pressed ^"; + break; + case InputKeyDown: + message = longPress ? "You long-pressed vvv" : "You pressed v"; + break; + case InputKeyLeft: + message = longPress ? "You long-pressed <<<" : "You pressed <"; + break; + case InputKeyRight: + message = longPress ? "You long-pressed >>>" : "You pressed >"; + break; + case InputKeyOk: + message = longPress ? "You long-pressed ooo" : "You pressed o"; + break; + case InputKeyBack: + message = longPress ? "You long-pressed ---" : "You pressed -"; + exitMessage = longPress ? "Exiting the App." : "Long press to exit."; + break; + default: + message = "Press any button..."; } // Update the longPressCount and numberMessage based on the type of press - if (longPress) { + if (longPress) + { longPressCount++; - switch (longPressCount) { - case 1: - snprintf(numberMessage, sizeof(numberMessage), "1"); - break; - case 2: - snprintf(numberMessage, sizeof(numberMessage), "2"); - break; - case 3: - snprintf(numberMessage, sizeof(numberMessage), "3"); - break; + switch (longPressCount) + { + case 1: + snprintf(numberMessage, sizeof(numberMessage), "1"); + break; + case 2: + snprintf(numberMessage, sizeof(numberMessage), "2"); + break; + case 3: + snprintf(numberMessage, sizeof(numberMessage), "3"); + break; } - } else { - longPressCount = 0; // Reset the count on a short press - numberMessage[0] = '\0'; // Clear the string + } + else + { + longPressCount = 0; // Reset the count on a short press + numberMessage[0] = '\0'; // Clear the string } furi_message_queue_put(event_queue, input_event, FuriWaitForever); } // Main function of the app -int32_t button_main(void* parameter) { +int32_t button_main(void *parameter) +{ UNUSED(parameter); // Create an event queue and a viewport for GUI InputEvent input_event; - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); - ViewPort* viewport = view_port_alloc(); + FuriMessageQueue *event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); + ViewPort *viewport = view_port_alloc(); // Error checking - if(!event_queue || !viewport) { + if (!event_queue || !viewport) + { printf("Error: Failed to allocate event_queue or viewport!\n"); return -1; } @@ -115,17 +125,19 @@ int32_t button_main(void* parameter) { view_port_input_callback_set(viewport, handleInput, event_queue); // Create a GUI and associate it with the viewport - Gui* gui = furi_record_open(RECORD_GUI); + Gui *gui = furi_record_open(RECORD_GUI); gui_add_view_port(gui, viewport, GuiLayerFullscreen); // Main event loop - while(true) { + while (true) + { // Check the queue for events FuriStatus status = furi_message_queue_get(event_queue, &input_event, FuriWaitForever); furi_check(status == FuriStatusOk); // Exit the loop if the back button is long-pressed - if(input_event.type == InputTypeLong && input_event.key == InputKeyBack) { + if (input_event.type == InputTypeLong && input_event.key == InputKeyBack) + { break; } }