forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Lee
committed
Nov 16, 2023
0 parents
commit c852646
Showing
57 changed files
with
1,690 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Flipper Zero Color Guessing Game | ||
<div style="text-align:center"> | ||
<img src="assets/flipper_logo_orange.png"/> | ||
<img src="assets/preview.jpg" /> | ||
</div> | ||
|
||
## What this is? | ||
As a web developer I enjoy guessing colours by HEX Code. This game is targeted at other Devs and graphic designers<br> | ||
that also enjoy this. | ||
<br><br> | ||
|
||
### Mode 1 | ||
The LED will display a color and you must try and guess it by adjusting the HEX values on the screen. A timer will show<br> | ||
how fast you were. Three levels of difficulty are available. Vibro hints given to help you find the solution. | ||
|
||
### Mode 2 | ||
You can define a color using the HEX code on-screen and the LED will display this color | ||
|
||
|
||
## How to install on Flipper Zero | ||
- If you do not have one, download a firmware<br> | ||
- Plug your Flipper Zero in via USB. <br> | ||
- Copy the contents of this folder into the applications_user folder of your firmware. <br> | ||
|
||
Then run the command: | ||
``` | ||
.\fbt launch_app APPSRC=applications_user/color_guess | ||
``` | ||
The application will be compiled and copied onto your device. | ||
|
||
## Licensing | ||
This code is open-source and may be used for whatever you want to do with it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
App( | ||
appid="color_guess", | ||
name="Color Guess", | ||
apptype=FlipperAppType.EXTERNAL, | ||
entry_point="color_guess_app", | ||
cdefines=["APP_COLOR_GUESS"], | ||
requires=[ | ||
"gui", | ||
], | ||
stack_size=2 * 1024, | ||
order=10, | ||
fap_icon="color_guess_10px.png", | ||
fap_icon_assets="icons", | ||
fap_version="1.1", | ||
fap_category="Games", | ||
fap_author="Leedave", | ||
fap_description="Color Guessing Game", | ||
fap_weburl="https://github.com/leedave/Leeds-Flipper-Zero-Applications", | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## v1.1 | ||
|
||
Added GFX to start screen | ||
|
||
## v1.0 | ||
|
||
First release to Application Catalog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#include "color_guess.h" | ||
#include "helpers/digits.h" | ||
|
||
bool color_guess_custom_event_callback(void* context, uint32_t event) { | ||
furi_assert(context); | ||
ColorGuess* app = context; | ||
return scene_manager_handle_custom_event(app->scene_manager, event); | ||
} | ||
|
||
void color_guess_tick_event_callback(void* context) { | ||
furi_assert(context); | ||
ColorGuess* app = context; | ||
scene_manager_handle_tick_event(app->scene_manager); | ||
} | ||
|
||
//leave app if back button pressed | ||
bool color_guess_navigation_event_callback(void* context) { | ||
furi_assert(context); | ||
ColorGuess* app = context; | ||
return scene_manager_handle_back_event(app->scene_manager); | ||
} | ||
|
||
ColorGuess* color_guess_app_alloc() { | ||
ColorGuess* app = malloc(sizeof(ColorGuess)); | ||
app->gui = furi_record_open(RECORD_GUI); | ||
app->notification = furi_record_open(RECORD_NOTIFICATION); | ||
app->error = false; | ||
|
||
// Set Defaults if no config exists | ||
app->haptic = 1; | ||
app->led = 1; | ||
app->save_settings = 1; | ||
|
||
// Load configs | ||
color_guess_read_settings(app); | ||
|
||
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); | ||
notification_message(notification, &sequence_display_backlight_on); | ||
|
||
//Scene additions | ||
app->view_dispatcher = view_dispatcher_alloc(); | ||
view_dispatcher_enable_queue(app->view_dispatcher); | ||
|
||
app->scene_manager = scene_manager_alloc(&color_guess_scene_handlers, app); | ||
view_dispatcher_set_event_callback_context(app->view_dispatcher, app); | ||
view_dispatcher_set_navigation_event_callback( | ||
app->view_dispatcher, color_guess_navigation_event_callback); | ||
view_dispatcher_set_tick_event_callback( | ||
app->view_dispatcher, color_guess_tick_event_callback, 100); | ||
view_dispatcher_set_custom_event_callback( | ||
app->view_dispatcher, color_guess_custom_event_callback); | ||
app->submenu = submenu_alloc(); | ||
|
||
view_dispatcher_add_view( | ||
app->view_dispatcher, ColorGuessViewIdMenu, submenu_get_view(app->submenu)); | ||
app->variable_item_list = variable_item_list_alloc(); | ||
view_dispatcher_add_view( | ||
app->view_dispatcher, | ||
ColorGuessViewIdSettings, | ||
variable_item_list_get_view(app->variable_item_list)); | ||
app->color_guess_startscreen = color_guess_startscreen_alloc(); | ||
view_dispatcher_add_view( | ||
app->view_dispatcher, | ||
ColorGuessViewIdStartscreen, | ||
color_guess_startscreen_get_view(app->color_guess_startscreen)); | ||
app->color_guess_color_set = color_guess_color_set_alloc(); | ||
view_dispatcher_add_view( | ||
app->view_dispatcher, | ||
ColorGuessViewIdColorSet, | ||
color_guess_color_set_get_view(app->color_guess_color_set)); | ||
app->color_guess_play = color_guess_play_alloc(); | ||
view_dispatcher_add_view( | ||
app->view_dispatcher, | ||
ColorGuessViewIdPlay, | ||
color_guess_play_get_view(app->color_guess_play)); | ||
|
||
//End Scene Additions | ||
|
||
return app; | ||
} | ||
|
||
void color_guess_app_free(ColorGuess* app) { | ||
furi_assert(app); | ||
|
||
// Scene manager | ||
scene_manager_free(app->scene_manager); | ||
|
||
// View Dispatcher | ||
view_dispatcher_remove_view(app->view_dispatcher, ColorGuessViewIdMenu); | ||
view_dispatcher_remove_view(app->view_dispatcher, ColorGuessViewIdStartscreen); | ||
view_dispatcher_remove_view(app->view_dispatcher, ColorGuessViewIdColorSet); | ||
view_dispatcher_remove_view(app->view_dispatcher, ColorGuessViewIdPlay); | ||
view_dispatcher_remove_view(app->view_dispatcher, ColorGuessViewIdSettings); | ||
submenu_free(app->submenu); | ||
|
||
view_dispatcher_free(app->view_dispatcher); | ||
|
||
// GUI | ||
furi_record_close(RECORD_GUI); | ||
|
||
app->view_port = NULL; | ||
app->gui = NULL; | ||
app->notification = NULL; | ||
|
||
//Remove whatever is left | ||
free(app); | ||
} | ||
|
||
int32_t color_guess_app(void* p) { | ||
UNUSED(p); | ||
ColorGuess* app = color_guess_app_alloc(); | ||
if(app->error) { | ||
return 255; | ||
} | ||
|
||
/* //This exits if run in RM FW | ||
if(!furi_hal_region_is_provisioned()) { | ||
color_guess_app_free(app); | ||
return 1; | ||
}*/ | ||
|
||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); | ||
|
||
scene_manager_next_scene(app->scene_manager, ColorGuessSceneStartscreen); | ||
|
||
furi_hal_power_suppress_charge_enter(); | ||
|
||
view_dispatcher_run(app->view_dispatcher); | ||
|
||
color_guess_save_settings(app); | ||
|
||
furi_hal_power_suppress_charge_exit(); | ||
|
||
color_guess_app_free(app); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
|
||
#include <furi.h> | ||
#include <furi_hal.h> | ||
#include <gui/gui.h> | ||
#include <input/input.h> | ||
#include <stdlib.h> | ||
#include <notification/notification_messages.h> | ||
#include <gui/view_dispatcher.h> | ||
#include <gui/modules/submenu.h> | ||
#include <gui/scene_manager.h> | ||
#include <gui/modules/variable_item_list.h> | ||
#include "helpers/color_guess_custom_event.h" | ||
#include "scenes/color_guess_scene.h" | ||
#include "views/color_guess_color_set.h" | ||
#include "views/color_guess_play.h" | ||
#include "views/color_guess_startscreen.h" | ||
#include "helpers/color_guess_storage.h" | ||
|
||
#define TAG "Color_Guess" | ||
|
||
typedef struct { | ||
Gui* gui; | ||
NotificationApp* notification; | ||
ViewPort* view_port; | ||
ViewDispatcher* view_dispatcher; | ||
Submenu* submenu; | ||
VariableItemList* variable_item_list; | ||
SceneManager* scene_manager; | ||
ColorGuessColorSet* color_guess_color_set; | ||
ColorGuessPlay* color_guess_play; | ||
ColorGuessStartscreen* color_guess_startscreen; | ||
Submenu* color_guess_settings; | ||
bool error; | ||
uint32_t haptic; | ||
//uint32_t speaker; | ||
uint32_t led; | ||
uint32_t save_settings; | ||
} ColorGuess; | ||
|
||
typedef enum { | ||
ColorGuessViewIdStartscreen, | ||
ColorGuessViewIdMenu, | ||
ColorGuessViewIdPlay, | ||
ColorGuessViewIdColorSet, | ||
ColorGuessViewIdSettings, | ||
} ColorGuessViewId; | ||
|
||
typedef enum { | ||
ColorGuessHapticOff, | ||
ColorGuessHapticOn, | ||
} ColorGuessHapticState; | ||
|
||
typedef enum { | ||
ColorGuessSpeakerOff, | ||
ColorGuessSpeakerOn, | ||
} ColorGuessSpeakerState; | ||
|
||
typedef enum { | ||
ColorGuessLedOff, | ||
ColorGuessLedOn, | ||
} ColorGuessLedState; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## Color Guessing Game | ||
|
||
Targeted at Web Developers, Graphical Designers and other nerds. | ||
This app will let your devices LED glow in a random color. Your job is to guess the Hex Code of the color. | ||
|
||
## Features | ||
- 3 Difficulties | ||
- Optional haptic feedback helps you guess | ||
- Percentage calculation to show how close you are | ||
- Practice mode that lets you define colors yourself | ||
|
||
## How HEX color codes work | ||
|
||
Example #FF44CC | ||
- Each digit is a number from 0 - F | ||
- One digit represents 0 - 15, two digits represent 0 - 255 | ||
- Each colors intensity is defined by two digits (black to full color) | ||
- The first color is red (example: FF) | ||
- The second color is green (example: 44) | ||
- The third color is blue (example: CC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## v1.0 | ||
|
||
First release to Application Catalog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
int colorsEasy[] = { | ||
0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff, 0xffffff, 0x500000, | ||
0x005000, 0x000050, 0x505000, 0x500050, 0x005050, 0x505050, 0x0000c0, 0x010101, | ||
0xcccccc, 0xcc00cc, 0x00cccc, 0xcccc00, 0xcc0000, 0x00cc00, 0x0000cc, 0x000000, | ||
}; | ||
|
||
int colorsNormal[] = { | ||
0xa04a00, 0x308030, 0xc03030, 0x00e090, 0x0000ad, 0xaf00af, 0xbb3030, 0xcccc00, | ||
0xcc8000, 0x0080f0, 0x009020, 0x902050, 0xbc00ff, 0xff6a00, 0xc5c5c5, 0xafafc0, | ||
0xcece00, 0xcf6500, 0x2b2b00, 0x55ee11, 0xff33ff, 0x2266ff, 0x530053, 0x3399ff, | ||
0xff0033, 0x99ff22, 0xab00ab, 0x55ff55, 0x9999ff, 0xe500e5, | ||
}; | ||
|
||
int colorsHard[] = { | ||
0x94275d, 0xb4f73e, 0xc833fd, 0x813f00, 0xb77b51, 0xe2b739, 0x378b3a, 0x373e8b, 0x8b3785, | ||
0x8b4137, 0xffbdb5, 0x3a3aa7, 0x37a6bd, 0xbd4737, 0x621308, 0x086238, 0x2d4137, 0x711761, | ||
0xdc26bc, 0xdc266e, 0x26dc81, 0x8d4500, 0xb8c22b, 0x2bc2a0, 0x9064c1, 0x732bc2, 0x5610a3, | ||
0xa31034, 0xe50c41, 0x6d001a, 0x159bbc, 0x32bc15, 0x53e60c, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
typedef enum { | ||
ColorGuessCustomEventStartscreenUp, | ||
ColorGuessCustomEventStartscreenDown, | ||
ColorGuessCustomEventStartscreenLeft, | ||
ColorGuessCustomEventStartscreenRight, | ||
ColorGuessCustomEventStartscreenOk, | ||
ColorGuessCustomEventStartscreenBack, | ||
ColorGuessCustomEventColorSetUp, | ||
ColorGuessCustomEventColorSetDown, | ||
ColorGuessCustomEventColorSetLeft, | ||
ColorGuessCustomEventColorSetRight, | ||
ColorGuessCustomEventColorSetOk, | ||
ColorGuessCustomEventColorSetBack, | ||
ColorGuessCustomEventPlayUp, | ||
ColorGuessCustomEventPlayDown, | ||
ColorGuessCustomEventPlayLeft, | ||
ColorGuessCustomEventPlayRight, | ||
ColorGuessCustomEventPlayOk, | ||
ColorGuessCustomEventPlayBack, | ||
} ColorGuessCustomEvent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "color_guess_haptic.h" | ||
#include "../color_guess.h" | ||
|
||
void color_guess_play_happy_bump(void* context) { | ||
ColorGuess* app = context; | ||
if(app->haptic != 1) { | ||
return; | ||
} | ||
notification_message(app->notification, &sequence_set_vibro_on); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 20); | ||
notification_message(app->notification, &sequence_reset_vibro); | ||
} | ||
|
||
void color_guess_play_bad_bump(void* context) { | ||
ColorGuess* app = context; | ||
if(app->haptic != 1) { | ||
return; | ||
} | ||
notification_message(app->notification, &sequence_set_vibro_on); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 100); | ||
notification_message(app->notification, &sequence_reset_vibro); | ||
} | ||
|
||
void color_guess_play_long_bump(void* context) { | ||
ColorGuess* app = context; | ||
if(app->haptic != 1) { | ||
return; | ||
} | ||
for(int i = 0; i < 4; i++) { | ||
notification_message(app->notification, &sequence_set_vibro_on); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 50); | ||
notification_message(app->notification, &sequence_reset_vibro); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 100); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include <notification/notification_messages.h> | ||
|
||
void color_guess_play_happy_bump(void* context); | ||
|
||
void color_guess_play_bad_bump(void* context); | ||
|
||
void color_guess_play_long_bump(void* context); |
Oops, something went wrong.