start on step 4
This commit is contained in:
parent
a9d9d747fb
commit
ef4b93e8af
@ -1,5 +1,100 @@
|
|||||||
|
#include "step4.h"
|
||||||
|
|
||||||
static const char *TAG = "step4";
|
static const char *TAG = "step4";
|
||||||
|
|
||||||
|
static int tone = 0;
|
||||||
|
static int times = 0;
|
||||||
|
|
||||||
|
static std::random_device rd;
|
||||||
|
static std::mt19937 gen(rd());
|
||||||
|
static std::uniform_int_distribution<> tone_dist(0, 5);
|
||||||
|
static std::uniform_int_distribution<> color_dist(0, 5);
|
||||||
|
|
||||||
|
static uint8_t NEOPIXEL_COLORS[6][3] = {
|
||||||
|
{20, 0, 0}, // red
|
||||||
|
{20, 10, 0}, // orange
|
||||||
|
{20, 20, 0}, // yellow
|
||||||
|
{0, 20, 0}, // green
|
||||||
|
{0, 0, 20}, // blue
|
||||||
|
{20, 0, 20}, // purple
|
||||||
|
};
|
||||||
|
|
||||||
|
static void play_tone();
|
||||||
|
static bool one_second();
|
||||||
|
static bool three_second();
|
||||||
|
static bool six_second();
|
||||||
|
|
||||||
void step4(void) {
|
void step4(void) {
|
||||||
|
// start counting down module timer immediatly
|
||||||
|
set_module_time(10*1000);
|
||||||
|
start_module_timer();
|
||||||
|
|
||||||
|
while (get_module_time() > 0) vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
|
|
||||||
|
while (times < 4) {
|
||||||
|
tone = tone_dist(gen);
|
||||||
|
play_tone();
|
||||||
|
switch (tone % 3) {
|
||||||
|
case 0:
|
||||||
|
if (one_second()) {
|
||||||
|
times++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (three_second()) {
|
||||||
|
times++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (six_second()) {
|
||||||
|
times++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool one_second() {
|
||||||
|
set_module_time(30*1000);
|
||||||
|
start_module_timer();
|
||||||
|
|
||||||
|
int speaker_indicator_color = color_dist(gen);
|
||||||
|
|
||||||
|
while (get_module_time() > 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool three_second() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool six_second() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void play_tone() {
|
||||||
|
switch (tone) {
|
||||||
|
case 0:
|
||||||
|
play_raw(MOUNT_POINT "/low-1.pcm");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
play_raw(MOUNT_POINT "/low-3.pcm");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
play_raw(MOUNT_POINT "/low-6.pcm");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
play_raw(MOUNT_POINT "/high-1.pcm");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
play_raw(MOUNT_POINT "/high-3.pcm");
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
play_raw(MOUNT_POINT "/high-6.pcm");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,12 @@
|
|||||||
#ifndef STEP_4_H
|
#ifndef STEP_4_H
|
||||||
#define STEP_4_H
|
#define STEP_4_H
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
#include "../drivers/bottom_half.h"
|
||||||
|
#include "../drivers/wires.h"
|
||||||
|
#include "../drivers/speaker.h"
|
||||||
|
#include "../drivers/game_timer.h"
|
||||||
|
|
||||||
void step4(void);
|
void step4(void);
|
||||||
|
|
||||||
#endif /* STEP_4_H */
|
#endif /* STEP_4_H */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user