Added multiple apps

Added Geiger Counter, Nightstand, Scrambler, Pomodoro
This commit is contained in:
VerstreuteSeele
2023-02-08 04:32:23 +01:00
parent 15ec5b4e0d
commit 25ce710b6e
69 changed files with 2936 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 RaZe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,16 @@
# Setting up the Rubik's Cube Scrambler
## Installation
To install the Rubik's Cube Scrambler, simply add the `rubiks_cube_scrambler` folder to your `application_users` folder.
## Cleaning the code and removing old files
Run `./fbt -c fap_rubiks_cube_scrambler` to clean the code and remove any old binaries or compilation artifacts.
## Compiling the FAP
To compile the FAP, run `./fbt fap_rubiks_cube_scrambler`.
## Launching the app
To run the Rubik's Cube Scrambler directly from the Flip.x0, use `./fbt launch_app APPSRC=rubiks_cube_scrambler`.
# A special thanks to Tanish for their c scrambler example 🙏
https://github.com/TanishBhongade/RubiksCubeScrambler-C/

View File

@@ -0,0 +1,20 @@
# COMPILE ISTRUCTIONS:
# Clean the code and remove old binaries/compilation artefact
# ./fbt -c fap_rubiks_cube_scrambler
# Compile FAP
# ./fbt fap_rubiks_cube_scrambler
# Run application directly inside the Flip.x0
# ./fbt launch_app APPSRC=rubiks_cube_scrambler
App(
appid="Rubiks_Cube_Scrambler",
name="Rubik's Cube Scrambler",
apptype=FlipperAppType.EXTERNAL,
entry_point="rubiks_cube_scrambler_main",
stack_size=1 * 1024,
fap_category="Misc",
fap_icon="cube.png",
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

View File

@@ -0,0 +1,115 @@
#include <stdio.h>
#include <furi.h>
#include <gui/gui.h>
#include <input/input.h>
#include <gui/elements.h>
#include <furi_hal.h>
#include "scrambler.h"
#include "furi_hal_random.h"
int scrambleStarted = 0;
char scramble_str[100] = {0};
char scramble_start[100] = {0};
char scramble_end[100] = {0};
int notifications_enabled = 0;
static void success_vibration() {
furi_hal_vibro_on(false);
furi_hal_vibro_on(true);
furi_delay_ms(50);
furi_hal_vibro_on(false);
return;
}
void split_array(char original[], int size, char first[], char second[]) {
int mid = size / 2;
if(size % 2 != 0) {
mid++;
}
int first_index = 0, second_index = 0;
for(int i = 0; i < size; i++) {
if(i < mid) {
first[first_index++] = original[i];
} else {
if(i == mid && (original[i] == '2' || original[i] == '\'')) {
continue;
}
second[second_index++] = original[i];
}
}
first[first_index] = '\0';
second[second_index] = '\0';
}
static void draw_callback(Canvas* canvas, void* ctx) {
UNUSED(ctx);
canvas_clear(canvas);
canvas_set_font(canvas, FontPrimary);
canvas_draw_str(canvas, 4, 13, "Rubik's Cube Scrambler");
if(scrambleStarted) {
genScramble();
scrambleReplace();
strcpy(scramble_str, printData());
if(notifications_enabled) {
success_vibration();
}
split_array(scramble_str, strlen(scramble_str), scramble_start, scramble_end);
scrambleStarted = 0;
}
canvas_set_font(canvas, FontSecondary);
canvas_draw_str_aligned(canvas, 64, 28, AlignCenter, AlignCenter, scramble_start);
canvas_draw_str_aligned(canvas, 64, 38, AlignCenter, AlignCenter, scramble_end);
elements_button_center(canvas, "New");
elements_button_left(canvas, notifications_enabled ? "On" : "Off");
};
static void 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 rubiks_cube_scrambler_main(void* p) {
UNUSED(p);
InputEvent event;
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
ViewPort* view_port = view_port_alloc();
view_port_draw_callback_set(view_port, draw_callback, NULL);
view_port_input_callback_set(view_port, input_callback, event_queue);
Gui* gui = furi_record_open(RECORD_GUI);
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
while(true) {
furi_check(furi_message_queue_get(event_queue, &event, FuriWaitForever) == FuriStatusOk);
if(event.key == InputKeyOk && event.type == InputTypeShort) {
scrambleStarted = 1;
}
if(event.key == InputKeyLeft && event.type == InputTypeShort) {
if(notifications_enabled) {
notifications_enabled = 0;
} else {
notifications_enabled = 1;
success_vibration();
}
}
if(event.key == InputKeyBack) {
break;
}
}
furi_message_queue_free(event_queue);
gui_remove_view_port(gui, view_port);
view_port_free(view_port);
furi_record_close(RECORD_GUI);
return 0;
}

View File

@@ -0,0 +1,102 @@
/*
Authors: Tanish Bhongade and RaZe
*/
#include <stdio.h>
#include <furi.h>
#include <gui/gui.h>
#include "furi_hal_random.h"
#include <input/input.h>
#include <gui/elements.h>
#include "scrambler.h"
// 6 moves along with direction
char moves[6] = {'R', 'U', 'F', 'B', 'L', 'D'};
char dir[4] = {' ', '\'', '2'};
const int SLEN = 20;
#define RESULT_SIZE 100
// Structure which holds main scramble
struct GetScramble {
char mainScramble[25][3];
};
struct GetScramble a; // Its object
// Function prototypes to avoid bugs
void scrambleReplace();
void genScramble();
void valid();
int getRand(int upr, int lwr);
char* printData();
void writeToFile();
// Main function
/* int main(){
genScramble ();//Calling genScramble
scrambleReplace();//Calling scrambleReplace
valid();//Calling valid to validate the scramble
printData ();//Printing the final scramble
//writeToFile();//If you want to write to a file, please uncomment this
return 0;
} */
void genScramble() {
// Stage 1
for(int i = 0; i < SLEN; i++) {
strcpy(a.mainScramble[i], "00");
}
// This makes array like this 00 00 00.......
}
void scrambleReplace() {
// Stage 2
// Actual process begins here
// Initialize the mainScramble array with all the possible moves
for(int i = 0; i < SLEN; i++) {
a.mainScramble[i][0] = moves[furi_hal_random_get() % 6];
a.mainScramble[i][1] = dir[furi_hal_random_get() % 3];
}
// Perform the Fisher-Yates shuffle
for(int i = 6 - 1; i > 0; i--) {
int j = rand() % (i + 1);
char temp[3];
strcpy(temp, a.mainScramble[i]);
strcpy(a.mainScramble[i], a.mainScramble[j]);
strcpy(a.mainScramble[j], temp);
}
// Select the first 10 elements as the scramble, using only the first three elements of the dir array
for(int i = 0; i < SLEN; i++) {
a.mainScramble[i][1] = dir[furi_hal_random_get() % 3];
}
for(int i = 1; i < SLEN; i++) {
while(a.mainScramble[i][0] == a.mainScramble[i - 2][0] ||
a.mainScramble[i][0] == a.mainScramble[i - 1][0]) {
a.mainScramble[i][0] = moves[furi_hal_random_get() % 5];
}
}
}
// Let this function be here for now till I find out what is causing the extra space bug in the scrambles
void remove_double_spaces(char* str) {
int i, j;
int len = strlen(str);
for(i = 0, j = 0; i < len; i++, j++) {
if(str[i] == ' ' && str[i + 1] == ' ') {
i++;
}
str[j] = str[i];
}
str[j] = '\0';
}
char* printData() {
static char result[RESULT_SIZE];
int offset = 0;
for(int loop = 0; loop < SLEN; loop++) {
offset += snprintf(result + offset, RESULT_SIZE - offset, "%s ", a.mainScramble[loop]);
}
remove_double_spaces(result);
return result;
}

View File

@@ -0,0 +1,3 @@
void scrambleReplace();
void genScramble();
char* printData();