Skip to content

Commit c852646

Browse files
author
David Lee
committed
Ported to own Repo
0 parents  commit c852646

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1690
-0
lines changed

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Flipper Zero Color Guessing Game
2+
<div style="text-align:center">
3+
<img src="assets/flipper_logo_orange.png"/>
4+
<img src="assets/preview.jpg" />
5+
</div>
6+
7+
## What this is?
8+
As a web developer I enjoy guessing colours by HEX Code. This game is targeted at other Devs and graphic designers<br>
9+
that also enjoy this.
10+
<br><br>
11+
12+
### Mode 1
13+
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>
14+
how fast you were. Three levels of difficulty are available. Vibro hints given to help you find the solution.
15+
16+
### Mode 2
17+
You can define a color using the HEX code on-screen and the LED will display this color
18+
19+
20+
## How to install on Flipper Zero
21+
- If you do not have one, download a firmware<br>
22+
- Plug your Flipper Zero in via USB. <br>
23+
- Copy the contents of this folder into the applications_user folder of your firmware. <br>
24+
25+
Then run the command:
26+
```
27+
.\fbt launch_app APPSRC=applications_user/color_guess
28+
```
29+
The application will be compiled and copied onto your device.
30+
31+
## Licensing
32+
This code is open-source and may be used for whatever you want to do with it.

application.fam

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
App(
2+
appid="color_guess",
3+
name="Color Guess",
4+
apptype=FlipperAppType.EXTERNAL,
5+
entry_point="color_guess_app",
6+
cdefines=["APP_COLOR_GUESS"],
7+
requires=[
8+
"gui",
9+
],
10+
stack_size=2 * 1024,
11+
order=10,
12+
fap_icon="color_guess_10px.png",
13+
fap_icon_assets="icons",
14+
fap_version="1.1",
15+
fap_category="Games",
16+
fap_author="Leedave",
17+
fap_description="Color Guessing Game",
18+
fap_weburl="https://github.com/leedave/Leeds-Flipper-Zero-Applications",
19+
)

assets/flipper_logo_orange.png

715 Bytes
Loading

assets/preview.jpg

18.6 KB
Loading

changelog.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## v1.1
2+
3+
Added GFX to start screen
4+
5+
## v1.0
6+
7+
First release to Application Catalog

color_guess.c

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
#include "color_guess.h"
2+
#include "helpers/digits.h"
3+
4+
bool color_guess_custom_event_callback(void* context, uint32_t event) {
5+
furi_assert(context);
6+
ColorGuess* app = context;
7+
return scene_manager_handle_custom_event(app->scene_manager, event);
8+
}
9+
10+
void color_guess_tick_event_callback(void* context) {
11+
furi_assert(context);
12+
ColorGuess* app = context;
13+
scene_manager_handle_tick_event(app->scene_manager);
14+
}
15+
16+
//leave app if back button pressed
17+
bool color_guess_navigation_event_callback(void* context) {
18+
furi_assert(context);
19+
ColorGuess* app = context;
20+
return scene_manager_handle_back_event(app->scene_manager);
21+
}
22+
23+
ColorGuess* color_guess_app_alloc() {
24+
ColorGuess* app = malloc(sizeof(ColorGuess));
25+
app->gui = furi_record_open(RECORD_GUI);
26+
app->notification = furi_record_open(RECORD_NOTIFICATION);
27+
app->error = false;
28+
29+
// Set Defaults if no config exists
30+
app->haptic = 1;
31+
app->led = 1;
32+
app->save_settings = 1;
33+
34+
// Load configs
35+
color_guess_read_settings(app);
36+
37+
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
38+
notification_message(notification, &sequence_display_backlight_on);
39+
40+
//Scene additions
41+
app->view_dispatcher = view_dispatcher_alloc();
42+
view_dispatcher_enable_queue(app->view_dispatcher);
43+
44+
app->scene_manager = scene_manager_alloc(&color_guess_scene_handlers, app);
45+
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
46+
view_dispatcher_set_navigation_event_callback(
47+
app->view_dispatcher, color_guess_navigation_event_callback);
48+
view_dispatcher_set_tick_event_callback(
49+
app->view_dispatcher, color_guess_tick_event_callback, 100);
50+
view_dispatcher_set_custom_event_callback(
51+
app->view_dispatcher, color_guess_custom_event_callback);
52+
app->submenu = submenu_alloc();
53+
54+
view_dispatcher_add_view(
55+
app->view_dispatcher, ColorGuessViewIdMenu, submenu_get_view(app->submenu));
56+
app->variable_item_list = variable_item_list_alloc();
57+
view_dispatcher_add_view(
58+
app->view_dispatcher,
59+
ColorGuessViewIdSettings,
60+
variable_item_list_get_view(app->variable_item_list));
61+
app->color_guess_startscreen = color_guess_startscreen_alloc();
62+
view_dispatcher_add_view(
63+
app->view_dispatcher,
64+
ColorGuessViewIdStartscreen,
65+
color_guess_startscreen_get_view(app->color_guess_startscreen));
66+
app->color_guess_color_set = color_guess_color_set_alloc();
67+
view_dispatcher_add_view(
68+
app->view_dispatcher,
69+
ColorGuessViewIdColorSet,
70+
color_guess_color_set_get_view(app->color_guess_color_set));
71+
app->color_guess_play = color_guess_play_alloc();
72+
view_dispatcher_add_view(
73+
app->view_dispatcher,
74+
ColorGuessViewIdPlay,
75+
color_guess_play_get_view(app->color_guess_play));
76+
77+
//End Scene Additions
78+
79+
return app;
80+
}
81+
82+
void color_guess_app_free(ColorGuess* app) {
83+
furi_assert(app);
84+
85+
// Scene manager
86+
scene_manager_free(app->scene_manager);
87+
88+
// View Dispatcher
89+
view_dispatcher_remove_view(app->view_dispatcher, ColorGuessViewIdMenu);
90+
view_dispatcher_remove_view(app->view_dispatcher, ColorGuessViewIdStartscreen);
91+
view_dispatcher_remove_view(app->view_dispatcher, ColorGuessViewIdColorSet);
92+
view_dispatcher_remove_view(app->view_dispatcher, ColorGuessViewIdPlay);
93+
view_dispatcher_remove_view(app->view_dispatcher, ColorGuessViewIdSettings);
94+
submenu_free(app->submenu);
95+
96+
view_dispatcher_free(app->view_dispatcher);
97+
98+
// GUI
99+
furi_record_close(RECORD_GUI);
100+
101+
app->view_port = NULL;
102+
app->gui = NULL;
103+
app->notification = NULL;
104+
105+
//Remove whatever is left
106+
free(app);
107+
}
108+
109+
int32_t color_guess_app(void* p) {
110+
UNUSED(p);
111+
ColorGuess* app = color_guess_app_alloc();
112+
if(app->error) {
113+
return 255;
114+
}
115+
116+
/* //This exits if run in RM FW
117+
if(!furi_hal_region_is_provisioned()) {
118+
color_guess_app_free(app);
119+
return 1;
120+
}*/
121+
122+
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
123+
124+
scene_manager_next_scene(app->scene_manager, ColorGuessSceneStartscreen);
125+
126+
furi_hal_power_suppress_charge_enter();
127+
128+
view_dispatcher_run(app->view_dispatcher);
129+
130+
color_guess_save_settings(app);
131+
132+
furi_hal_power_suppress_charge_exit();
133+
134+
color_guess_app_free(app);
135+
136+
return 0;
137+
}

color_guess.h

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#pragma once
2+
3+
#include <furi.h>
4+
#include <furi_hal.h>
5+
#include <gui/gui.h>
6+
#include <input/input.h>
7+
#include <stdlib.h>
8+
#include <notification/notification_messages.h>
9+
#include <gui/view_dispatcher.h>
10+
#include <gui/modules/submenu.h>
11+
#include <gui/scene_manager.h>
12+
#include <gui/modules/variable_item_list.h>
13+
#include "helpers/color_guess_custom_event.h"
14+
#include "scenes/color_guess_scene.h"
15+
#include "views/color_guess_color_set.h"
16+
#include "views/color_guess_play.h"
17+
#include "views/color_guess_startscreen.h"
18+
#include "helpers/color_guess_storage.h"
19+
20+
#define TAG "Color_Guess"
21+
22+
typedef struct {
23+
Gui* gui;
24+
NotificationApp* notification;
25+
ViewPort* view_port;
26+
ViewDispatcher* view_dispatcher;
27+
Submenu* submenu;
28+
VariableItemList* variable_item_list;
29+
SceneManager* scene_manager;
30+
ColorGuessColorSet* color_guess_color_set;
31+
ColorGuessPlay* color_guess_play;
32+
ColorGuessStartscreen* color_guess_startscreen;
33+
Submenu* color_guess_settings;
34+
bool error;
35+
uint32_t haptic;
36+
//uint32_t speaker;
37+
uint32_t led;
38+
uint32_t save_settings;
39+
} ColorGuess;
40+
41+
typedef enum {
42+
ColorGuessViewIdStartscreen,
43+
ColorGuessViewIdMenu,
44+
ColorGuessViewIdPlay,
45+
ColorGuessViewIdColorSet,
46+
ColorGuessViewIdSettings,
47+
} ColorGuessViewId;
48+
49+
typedef enum {
50+
ColorGuessHapticOff,
51+
ColorGuessHapticOn,
52+
} ColorGuessHapticState;
53+
54+
typedef enum {
55+
ColorGuessSpeakerOff,
56+
ColorGuessSpeakerOn,
57+
} ColorGuessSpeakerState;
58+
59+
typedef enum {
60+
ColorGuessLedOff,
61+
ColorGuessLedOn,
62+
} ColorGuessLedState;

color_guess_10px.png

7.64 KB
Loading

docs/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Color Guessing Game
2+
3+
Targeted at Web Developers, Graphical Designers and other nerds.
4+
This app will let your devices LED glow in a random color. Your job is to guess the Hex Code of the color.
5+
6+
## Features
7+
- 3 Difficulties
8+
- Optional haptic feedback helps you guess
9+
- Percentage calculation to show how close you are
10+
- Practice mode that lets you define colors yourself
11+
12+
## How HEX color codes work
13+
14+
Example #FF44CC
15+
- Each digit is a number from 0 - F
16+
- One digit represents 0 - 15, two digits represent 0 - 255
17+
- Each colors intensity is defined by two digits (black to full color)
18+
- The first color is red (example: FF)
19+
- The second color is green (example: 44)
20+
- The third color is blue (example: CC)

docs/changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## v1.0
2+
3+
First release to Application Catalog

helpers/color_guess_colors.h

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
3+
int colorsEasy[] = {
4+
0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff, 0xffffff, 0x500000,
5+
0x005000, 0x000050, 0x505000, 0x500050, 0x005050, 0x505050, 0x0000c0, 0x010101,
6+
0xcccccc, 0xcc00cc, 0x00cccc, 0xcccc00, 0xcc0000, 0x00cc00, 0x0000cc, 0x000000,
7+
};
8+
9+
int colorsNormal[] = {
10+
0xa04a00, 0x308030, 0xc03030, 0x00e090, 0x0000ad, 0xaf00af, 0xbb3030, 0xcccc00,
11+
0xcc8000, 0x0080f0, 0x009020, 0x902050, 0xbc00ff, 0xff6a00, 0xc5c5c5, 0xafafc0,
12+
0xcece00, 0xcf6500, 0x2b2b00, 0x55ee11, 0xff33ff, 0x2266ff, 0x530053, 0x3399ff,
13+
0xff0033, 0x99ff22, 0xab00ab, 0x55ff55, 0x9999ff, 0xe500e5,
14+
};
15+
16+
int colorsHard[] = {
17+
0x94275d, 0xb4f73e, 0xc833fd, 0x813f00, 0xb77b51, 0xe2b739, 0x378b3a, 0x373e8b, 0x8b3785,
18+
0x8b4137, 0xffbdb5, 0x3a3aa7, 0x37a6bd, 0xbd4737, 0x621308, 0x086238, 0x2d4137, 0x711761,
19+
0xdc26bc, 0xdc266e, 0x26dc81, 0x8d4500, 0xb8c22b, 0x2bc2a0, 0x9064c1, 0x732bc2, 0x5610a3,
20+
0xa31034, 0xe50c41, 0x6d001a, 0x159bbc, 0x32bc15, 0x53e60c,
21+
};

helpers/color_guess_custom_event.h

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
typedef enum {
4+
ColorGuessCustomEventStartscreenUp,
5+
ColorGuessCustomEventStartscreenDown,
6+
ColorGuessCustomEventStartscreenLeft,
7+
ColorGuessCustomEventStartscreenRight,
8+
ColorGuessCustomEventStartscreenOk,
9+
ColorGuessCustomEventStartscreenBack,
10+
ColorGuessCustomEventColorSetUp,
11+
ColorGuessCustomEventColorSetDown,
12+
ColorGuessCustomEventColorSetLeft,
13+
ColorGuessCustomEventColorSetRight,
14+
ColorGuessCustomEventColorSetOk,
15+
ColorGuessCustomEventColorSetBack,
16+
ColorGuessCustomEventPlayUp,
17+
ColorGuessCustomEventPlayDown,
18+
ColorGuessCustomEventPlayLeft,
19+
ColorGuessCustomEventPlayRight,
20+
ColorGuessCustomEventPlayOk,
21+
ColorGuessCustomEventPlayBack,
22+
} ColorGuessCustomEvent;

helpers/color_guess_haptic.c

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "color_guess_haptic.h"
2+
#include "../color_guess.h"
3+
4+
void color_guess_play_happy_bump(void* context) {
5+
ColorGuess* app = context;
6+
if(app->haptic != 1) {
7+
return;
8+
}
9+
notification_message(app->notification, &sequence_set_vibro_on);
10+
furi_thread_flags_wait(0, FuriFlagWaitAny, 20);
11+
notification_message(app->notification, &sequence_reset_vibro);
12+
}
13+
14+
void color_guess_play_bad_bump(void* context) {
15+
ColorGuess* app = context;
16+
if(app->haptic != 1) {
17+
return;
18+
}
19+
notification_message(app->notification, &sequence_set_vibro_on);
20+
furi_thread_flags_wait(0, FuriFlagWaitAny, 100);
21+
notification_message(app->notification, &sequence_reset_vibro);
22+
}
23+
24+
void color_guess_play_long_bump(void* context) {
25+
ColorGuess* app = context;
26+
if(app->haptic != 1) {
27+
return;
28+
}
29+
for(int i = 0; i < 4; i++) {
30+
notification_message(app->notification, &sequence_set_vibro_on);
31+
furi_thread_flags_wait(0, FuriFlagWaitAny, 50);
32+
notification_message(app->notification, &sequence_reset_vibro);
33+
furi_thread_flags_wait(0, FuriFlagWaitAny, 100);
34+
}
35+
}

helpers/color_guess_haptic.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include <notification/notification_messages.h>
4+
5+
void color_guess_play_happy_bump(void* context);
6+
7+
void color_guess_play_bad_bump(void* context);
8+
9+
void color_guess_play_long_bump(void* context);

0 commit comments

Comments
 (0)