summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--project/Core/Inc/Project/player_actions.h22
-rw-r--r--project/Core/Inc/Project/project.h1
-rw-r--r--project/Core/Src/Project/player_actions.c58
-rw-r--r--project/Core/Src/Project/project.c70
4 files changed, 86 insertions, 65 deletions
diff --git a/project/Core/Inc/Project/player_actions.h b/project/Core/Inc/Project/player_actions.h
new file mode 100644
index 0000000..c6db2c5
--- /dev/null
+++ b/project/Core/Inc/Project/player_actions.h
@@ -0,0 +1,22 @@
+/*
+ * player_actions.h
+ *
+ * Created on: Oct 17, 2025
+ * Author: sowgro
+ */
+
+#ifndef INC_PROJECT_PLAYER_ACTIONS_H_
+#define INC_PROJECT_PLAYER_ACTIONS_H_
+
+#define PLAYING_STATE (1)
+#define PAUSED_STATE (2)
+#define STOPPED_STATE (3)
+
+void help();
+void next();
+void play();
+void pause();
+void pause_loop();
+void stop();
+
+#endif /* INC_PROJECT_PLAYER_ACTIONS_H_ */
diff --git a/project/Core/Inc/Project/project.h b/project/Core/Inc/Project/project.h
index a4b568b..da3590c 100644
--- a/project/Core/Inc/Project/project.h
+++ b/project/Core/Inc/Project/project.h
@@ -9,5 +9,6 @@
#define INC_PROJECT_H_
void project_run();
+void handle_input(char buffer[], uint8_t *state);
#endif /* INC_PROJECT_H_ */
diff --git a/project/Core/Src/Project/player_actions.c b/project/Core/Src/Project/player_actions.c
new file mode 100644
index 0000000..4ee2dfb
--- /dev/null
+++ b/project/Core/Src/Project/player_actions.c
@@ -0,0 +1,58 @@
+/*
+ * player_actions.c
+ *
+ * Created on: Oct 17, 2025
+ * Author: sowgro
+ */
+
+#include <stdio.h>
+#include "player_actions.h"
+#include "song_info.h"
+#include "song.h"
+#include "LED.h"
+#include "systick.h"
+
+void help() {
+ printf("\r***REMOTE LED CONTROL MENU***\r\n");
+ printf("Available User Commands:\r\n");
+ printf("NEXT - Show next song info\r\n");
+ printf("PLAY - Play the song (LED on)\r\n");
+ printf("PAUSE - Pause the song (LED flash)\r\n");
+ printf("STOP - Stop the song (LED off)\r\n");
+}
+
+void next() {
+ static int current_song = -1;
+ current_song++;
+ if (current_song > 4)
+ current_song = 0;
+
+ void *song = get_song(current_song).p_song;
+ song_info_t song_info = get_song_info(song);
+
+ printf("Song #%i\r\n", current_song + 1);
+ if (song_info.title)
+ printf("Title: %s\r\n", song_info.title);
+ if (song_info.copyright)
+ printf("Copyright: %s\r\n", song_info.copyright);
+ if (song_info.tempo)
+ printf("Tempo: %i\r\n", song_info.tempo);
+}
+
+void play() {
+ LED_On();
+}
+
+void pause() {
+ init_systick();
+}
+
+void pause_loop() {
+ if (check_systick()) {
+ LED_Toggle();
+ }
+}
+
+void stop() {
+ LED_Off();
+}
diff --git a/project/Core/Src/Project/project.c b/project/Core/Src/Project/project.c
index 1311219..3a741cb 100644
--- a/project/Core/Src/Project/project.c
+++ b/project/Core/Src/Project/project.c
@@ -5,26 +5,13 @@
* Author: bruce
*/
-#include "project.h"
-#include "LED.h"
-#include "systick.h"
+#include <string.h>
+#include <stdint.h>
#include <stdio.h>
+#include "project.h"
+#include "player_actions.h"
#include "hw4.h"
-#include <string.h>
-#include "song_info.h"
-#include "song.h"
-
-#define PLAYING_STATE (1)
-#define PAUSED_STATE (2)
-#define STOPPED_STATE (3)
-
-void handle_input(char buffer[], uint8_t *state);
-void help();
-void next();
-void play();
-void pause();
-void pause_loop();
-void stop();
+#include "player_actions.h"
void project_run() {
char buffer[8];
@@ -71,50 +58,3 @@ void handle_input(char buffer[], uint8_t *state) {
printf("Unknown command \"%s\"\n\r", buffer);
}
}
-
-void help() {
- printf("\r***REMOTE LED CONTROL MENU***\r\n");
- printf("Available User Commands:\r\n");
- printf("NEXT - Show next song info\r\n");
- printf("PLAY - Play the song (LED on)\r\n");
- printf("PAUSE - Pause the song (LED flash)\r\n");
- printf("STOP - Stop the song (LED off)\r\n");
-}
-
-void next() {
- static int current_song = -1;
- current_song++;
- if (current_song > 4)
- current_song = 0;
-
- void *song = get_song(current_song).p_song;
- song_info_t song_info = get_song_info(song);
-
- printf("Song #%i\r\n", current_song + 1);
- if (song_info.title)
- printf("Title: %s\r\n", song_info.title);
- if (song_info.copyright)
- printf("Copyright: %s\r\n", song_info.copyright);
- if (song_info.tempo)
- printf("Tempo: %i\r\n", song_info.tempo);
-}
-
-void play() {
- LED_On();
-}
-
-void pause() {
- init_systick();
-}
-
-void pause_loop() {
- if (check_systick()) {
- LED_Toggle();
- }
-}
-
-void stop() {
- LED_Off();
-}
-
-