multi-mode
Ondřej Hruška 9 years ago
parent b4fe9dc546
commit d4e386daa9
  1. 8
      f103-ledmatrix.pro
  2. 50
      project/main.c
  3. 14
      project/mode_audio.c
  4. 2
      project/mode_audio.h
  5. 21
      project/mode_life.c
  6. 11
      project/mode_life.h
  7. 21
      project/mode_snake.c
  8. 11
      project/mode_snake.h

@ -93,7 +93,9 @@ HEADERS += \
lib/cmsis/DSP_Lib/Include/core_cmSimd.h \
project/mode_audio.h \
project/font.h \
project/scrolltext.h
project/scrolltext.h \
project/mode_snake.h \
project/mode_life.h
SOURCES += \
lib/cmsis/core_cm3.c \
@ -425,7 +427,9 @@ SOURCES += \
lib/cmsis/DSP_Lib/Source/TransformFunctions/arm_rfft_q15.c \
lib/cmsis/DSP_Lib/Source/TransformFunctions/arm_rfft_q31.c \
project/mode_audio.c \
project/scrolltext.c
project/scrolltext.c \
project/mode_snake.c \
project/mode_life.c
DISTFILES += \
style.astylerc \

@ -15,8 +15,11 @@
#include "dotmatrix.h"
#include "arm_math.h"
#include <arm_math.h>
#include "mode_audio.h"
#include "mode_snake.h"
#include "mode_life.h"
#include "scrolltext.h"
@ -68,21 +71,20 @@ static void activate_mode(void)
info("MODE: Life");
scrolltext("Game of Life", SCROLL_STEP);
//
mode_life_start();
} else {
//
mode_life_stop();
}
// --- Snake Minigame ---
if (app_mode == MODE_SNAKE) {
info("MODE: Snake");
scrolltext("Snake", SCROLL_STEP);
//
mode_snake_start();
} else {
//
mode_snake_stop();
}
}
@ -94,11 +96,12 @@ int main(void)
banner("*** FFT dot matrix display ***");
banner_info("(c) Ondrej Hruska, 2016");
scrolltext("STM32 LED MATRIX DEMO", SCROLL_STEP);
gamepad_iface->rx_callback = gamepad_rx;
mode_audio_init();
mode_life_init();
mode_snake_init();
mode_audio_start();
ms_time_t last;
@ -137,14 +140,29 @@ static void poll_subsystems(void)
static void gamepad_rx(ComIface *iface)
{
uint8_t ch;
while(com_rx(iface, &ch)) {
// com_tx(debug_iface, ch);
// com_tx(debug_iface, '\n');
/* SELECT */
if (ch == 'I') {
tq_post(switch_mode, NULL);
char ch;
while(com_rx(iface, (uint8_t*)&ch)) {
switch (ch) {
case 'I': // Select pressed
tq_post(switch_mode, NULL);
break;
case 'i': // Select released
break;
default:
switch (app_mode) {
case MODE_AUDIO:
// discard
break;
case MODE_LIFE:
mode_life_btn(ch);
break;
case MODE_SNAKE:
mode_snake_btn(ch);
break;
}
}
}
}

@ -24,9 +24,9 @@ static union samp_buf_union samp_buf;
static task_pid_t capture_task_id;
// prototypes
static void audio_capture_done(void* unused);
static void capture_audio(void *unused);
static void boot_animation(void)
@ -102,12 +102,7 @@ void DMA1_Channel1_IRQHandler(void)
TIM_Cmd(TIM3, DISABLE);
ADC_DMACmd(ADC1, DISABLE);
if (audio_mode_active) {
tq_post(audio_capture_done, NULL);
} else {
// unset 'pending'
capture_pending = false;
}
tq_post(audio_capture_done, NULL);
}
@ -116,6 +111,11 @@ static void audio_capture_done(void* unused)
{
(void)unused;
if (! audio_mode_active) {
capture_pending = false;
return;
}
const int samp_count = SAMP_BUF_LEN/2;
const int bin_count = SAMP_BUF_LEN/4;

@ -3,8 +3,6 @@
#include "main.h"
void capture_audio(void *unused);
void mode_audio_init(void);
void mode_audio_start(void);
void mode_audio_stop(void);

@ -0,0 +1,21 @@
#include "mode_life.h"
void mode_life_init(void)
{
//
}
void mode_life_start(void)
{
//
}
void mode_life_stop(void)
{
//
}
void mode_life_btn(char key)
{
//
}

@ -0,0 +1,11 @@
#ifndef MODE_LIFE_H
#define MODE_LIFE_H
#include "main.h"
void mode_life_init(void);
void mode_life_start(void);
void mode_life_stop(void);
void mode_life_btn(char key);
#endif // MODE_LIFE_H

@ -0,0 +1,21 @@
#include "mode_snake.h"
void mode_snake_init(void)
{
//
}
void mode_snake_start(void)
{
//
}
void mode_snake_stop(void)
{
//
}
void mode_snake_btn(char key)
{
//
}

@ -0,0 +1,11 @@
#ifndef MODE_SNAKE_H
#define MODE_SNAKE_H
#include "main.h"
void mode_snake_init(void);
void mode_snake_start(void);
void mode_snake_stop(void);
void mode_snake_btn(char key);
#endif // MODE_SNAKE_H
Loading…
Cancel
Save