forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 552
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
Showing
13 changed files
with
428 additions
and
74 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
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
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,50 @@ | ||
#include "mine_sweeper_haptic.h" | ||
#include "../minesweeper.h" | ||
|
||
|
||
void mine_sweeper_play_happy_bump(void* context) { | ||
MineSweeperApp* app = context; | ||
|
||
notification_message(app->notification, &sequence_set_vibro_on); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 20); | ||
notification_message(app->notification, &sequence_reset_vibro); | ||
} | ||
|
||
void mine_sweeper_play_long_ok_bump(void* context) { | ||
MineSweeperApp* app = context; | ||
|
||
for (int i = 0; i < 2; i++) { | ||
notification_message(app->notification, &sequence_set_vibro_on); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 20); | ||
notification_message(app->notification, &sequence_reset_vibro); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 20); | ||
} | ||
} | ||
|
||
void mine_sweeper_play_oob_bump(void* context) { | ||
MineSweeperApp* app = context; | ||
|
||
notification_message(app->notification, &sequence_set_vibro_on); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 20); | ||
notification_message(app->notification, &sequence_reset_vibro); | ||
} | ||
|
||
void mine_sweeper_play_lose_bump(void* context) { | ||
MineSweeperApp* app = context; | ||
|
||
notification_message(app->notification, &sequence_set_vibro_on); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 100); | ||
notification_message(app->notification, &sequence_reset_vibro); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 400); | ||
} | ||
|
||
void mine_sweeper_play_win_bump(void* context) { | ||
MineSweeperApp* app = context; | ||
|
||
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,17 @@ | ||
#ifndef MINESWEEPER_HAPTIC_H | ||
#define MINESWEEPER_HAPTIC_H | ||
|
||
#include <notification/notification_messages.h> | ||
|
||
void mine_sweeper_play_happy_bump(void* context); | ||
|
||
void mine_sweeper_play_long_ok_bump(void* context); | ||
|
||
void mine_sweeper_play_oob_bump(void* context); | ||
|
||
void mine_sweeper_play_lose_bump(void* context); | ||
|
||
void mine_sweeper_play_win_bump(void* context); | ||
|
||
|
||
#endif |
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,61 @@ | ||
#include "mine_sweeper_led.h" | ||
#include "../minesweeper.h" | ||
|
||
|
||
|
||
void mine_sweeper_led_set_rgb(void* context, int red, int green, int blue) { | ||
MineSweeperApp* app = context; | ||
|
||
NotificationMessage notification_led_message_1; | ||
notification_led_message_1.type = NotificationMessageTypeLedRed; | ||
NotificationMessage notification_led_message_2; | ||
notification_led_message_2.type = NotificationMessageTypeLedGreen; | ||
NotificationMessage notification_led_message_3; | ||
notification_led_message_3.type = NotificationMessageTypeLedBlue; | ||
|
||
notification_led_message_1.data.led.value = red; | ||
notification_led_message_2.data.led.value = green; | ||
notification_led_message_3.data.led.value = blue; | ||
const NotificationSequence notification_sequence = { | ||
¬ification_led_message_1, | ||
¬ification_led_message_2, | ||
¬ification_led_message_3, | ||
&message_do_not_reset, | ||
NULL, | ||
}; | ||
notification_message(app->notification, ¬ification_sequence); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set | ||
} | ||
|
||
void mine_sweeper_led_blink_red(void* context) { | ||
furi_assert(context); | ||
MineSweeperApp* app = context; | ||
|
||
notification_message(app->notification, &sequence_blink_red_100); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set | ||
} | ||
|
||
void mine_sweeper_led_blink_magenta(void* context) { | ||
furi_assert(context); | ||
MineSweeperApp* app = context; | ||
|
||
notification_message(app->notification, &sequence_blink_magenta_100); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set | ||
} | ||
|
||
void mine_sweeper_led_blink_cyan(void* context) { | ||
furi_assert(context); | ||
MineSweeperApp* app = context; | ||
|
||
notification_message(app->notification, &sequence_blink_cyan_100); | ||
furi_thread_flags_wait(0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set | ||
} | ||
|
||
void mine_sweeper_led_reset(void* context) { | ||
MineSweeperApp* app = context; | ||
notification_message(app->notification, &sequence_reset_red); | ||
notification_message(app->notification, &sequence_reset_green); | ||
notification_message(app->notification, &sequence_reset_blue); | ||
|
||
furi_thread_flags_wait(0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set | ||
} |
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,15 @@ | ||
#ifndef MINESWEEPER_LED_H | ||
#define MINESWEEPER_LED_H | ||
|
||
void mine_sweeper_led_set_rgb(void* context, int red, int green, int blue); | ||
|
||
void mine_sweeper_led_blink_red(void* context); | ||
|
||
void mine_sweeper_led_blink_magenta(void* context); | ||
|
||
void mine_sweeper_led_blink_cyan(void* context); | ||
|
||
void mine_sweeper_led_reset(void* context); | ||
|
||
|
||
#endif |
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,64 @@ | ||
#include "mine_sweeper_speaker.h" | ||
#include "../minesweeper.h" | ||
|
||
static const float volume = 0.8f; | ||
|
||
void mine_sweeper_play_ok_sound(void* context) { | ||
MineSweeperApp* app = context; | ||
UNUSED(app); | ||
|
||
if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { | ||
furi_hal_speaker_start(NOTE_LOSE, volume); | ||
} | ||
|
||
} | ||
|
||
void mine_sweeper_play_flag_sound(void* context) { | ||
MineSweeperApp* app = context; | ||
UNUSED(app); | ||
|
||
if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { | ||
furi_hal_speaker_start(NOTE_FLAG, volume); | ||
} | ||
|
||
} | ||
|
||
void mine_sweeper_play_oob_sound(void* context) { | ||
MineSweeperApp* app = context; | ||
UNUSED(app); | ||
|
||
if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { | ||
furi_hal_speaker_start(NOTE_OOB, volume); | ||
} | ||
|
||
} | ||
|
||
void mine_sweeper_play_win_sound(void* context) { | ||
MineSweeperApp* app = context; | ||
UNUSED(app); | ||
|
||
if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { | ||
furi_hal_speaker_start(NOTE_WIN, volume); | ||
} | ||
|
||
} | ||
|
||
void mine_sweeper_play_lose_sound(void* context) { | ||
MineSweeperApp* app = context; | ||
UNUSED(app); | ||
|
||
if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) { | ||
furi_hal_speaker_start(NOTE_LOSE, volume); | ||
} | ||
|
||
} | ||
|
||
void mine_sweeper_stop_all_sound(void* context) { | ||
MineSweeperApp* app = context; | ||
UNUSED(app); | ||
|
||
if(furi_hal_speaker_is_mine()) { | ||
furi_hal_speaker_stop(); | ||
furi_hal_speaker_release(); | ||
} | ||
} |
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,18 @@ | ||
#ifndef MINESWEEPER_SPEAKER_H | ||
#define MINESWEEPER_SPEAKER_H | ||
|
||
#define NOTE_OK 3078.95f //G_4 | ||
#define NOTE_FLAG 384.87f //G_4 | ||
#define NOTE_OOB 342.88f //F_4 | ||
#define NOTE_WIN 432.00f //Divine | ||
#define NOTE_LOSE 4170.00f //Cursed | ||
|
||
void mine_sweeper_play_ok_sound(void* context); | ||
void mine_sweeper_play_flag_sound(void* context); | ||
void mine_sweeper_play_oob_sound(void* context); | ||
void mine_sweeper_play_win_sound(void* context); | ||
void mine_sweeper_play_lose_sound(void* context); | ||
void mine_sweeper_stop_all_sound(void* context); | ||
|
||
|
||
#endif |
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
Oops, something went wrong.