diff --git a/.vscode/uberdevice.code-workspace b/.vscode/uberdevice.code-workspace new file mode 100644 index 0000000..3b10996 --- /dev/null +++ b/.vscode/uberdevice.code-workspace @@ -0,0 +1,7 @@ +{ + "folders": [ + { + "path": "D:\\Folders\\Documents\\STM32\\Uberdevice" + } + ] +} \ No newline at end of file diff --git a/Core/Inc/game.h b/Core/Inc/game.h index 40662bb..322cc9d 100644 --- a/Core/Inc/game.h +++ b/Core/Inc/game.h @@ -1,3 +1,5 @@ +#ifndef __GAME_H +#define __GAME_H #define MAX_PLAYERS 6 #define TIMER_MAX 180 #define TIMER_STEP 5 @@ -25,4 +27,5 @@ uint32_t GetCurrentPlayer(); uint32_t GetTimerValue(); void ChangeScore(int8_t delta); void ResetTurnTimer(); -void NextPlayer(); \ No newline at end of file +void NextPlayer(); +#endif \ No newline at end of file diff --git a/Core/Inc/main.h b/Core/Inc/main.h index a44f75c..3f57875 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -32,6 +32,7 @@ extern "C" { /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ +#include "stm32f1xx_hal_gpio.h" #include #include "lcd.h" #include "game.h" diff --git a/Core/Inc/music.h b/Core/Inc/music.h new file mode 100644 index 0000000..fa92f23 --- /dev/null +++ b/Core/Inc/music.h @@ -0,0 +1,9 @@ +#ifndef __MUSIC_H +#define __MUSIC_H + +#include +#include + +void MusicPlay(void); +void MusicStop(void); +#endif \ No newline at end of file diff --git a/Core/Src/game.c b/Core/Src/game.c index 205f091..f71e155 100644 --- a/Core/Src/game.c +++ b/Core/Src/game.c @@ -1,5 +1,3 @@ -#ifndef __GAME_H -#define __GAME_H #include "game.h" void InitGameEngine() { @@ -60,5 +58,4 @@ void ResetTurnTimer() { void NextPlayer() { game.currentPlayer = (game.currentPlayer + 1) % game.activePlayers; ResetTurnTimer(); -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/Core/Src/main.c b/Core/Src/main.c index ea8b231..10311b8 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -69,6 +69,7 @@ bool minusButton = false; bool bigButton = false; static TimerHandle_t secondsTimerHandle = NULL; +static TaskHandle_t xMusicHandle = NULL; /* USER CODE END PV */ @@ -499,7 +500,6 @@ void vTaskConfig(void *parameter) { vTaskDelete(NULL); } -/* void vTaskTurn(void *parameter) { xTimerReset(secondsTimerHandle, 0); @@ -526,25 +526,15 @@ void vTaskTurn(void *parameter) { xTaskCreate(vTaskOvertime, "vTaskOvertime", configMINIMAL_STACK_SIZE, NULL, 1, &xMusicHandle); } vTaskDelayUntil(&xLastWakeTime,100); - led2.Toggle(); - -#ifdef DEBUG - auto[minutes, seconds] = game.GetTimerValue(); - buffer[0] = minutes; - buffer[1] = seconds; - buffer[2] = game.currentPlayer; - buffer[4] = game.playerScore[0]; - buffer[5] = game.playerScore[1]; - buffer[6] = game.playerScore[2]; - usart.Send(); -#endif // DEBUG - + + HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin); } xTimerStop(secondsTimerHandle, 0); - game.ResetTurnTimer(); + ResetTurnTimer(); + if (xMusicHandle) { vTaskDelete(xMusicHandle); - mp.Stop(); + MusicStop(); xMusicHandle = NULL; } vTaskDelete(NULL); @@ -555,7 +545,7 @@ void vTaskTurnEnd(void *parameter) { int32_t delta = 0; while (1) { if (bigButton) { - game.ChangeScore(delta); + ChangeScore(delta); break; } else if (plusButton) @@ -568,8 +558,8 @@ void vTaskTurnEnd(void *parameter) { } vTaskDelay(10); } - } - game.NextPlayer(); + } + NextPlayer(); xTaskCreate(vTaskTurn, "TaskTurn", configMINIMAL_STACK_SIZE, NULL, 1, NULL); vTaskDelete(NULL); } @@ -577,13 +567,13 @@ void vTaskTurnEnd(void *parameter) { void vTaskOvertime(void *parameter) { while (1) { - led2.SetHigh(); - mp.Play(tracks[3]); - led2.SetLow(); + HAL_GPIO_WritePin(LED2_GPIO_Port, LED1_Pin, GPIO_PIN_SET); + MusicPlay(); + HAL_GPIO_WritePin(LED2_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); vTaskDelay(1000); } } - */ + void vTimerCallback(TimerHandle_t xTimer) { if (game.timerValue > 0) game.timerValue--; diff --git a/Core/Src/music.c b/Core/Src/music.c new file mode 100644 index 0000000..e6ff30f --- /dev/null +++ b/Core/Src/music.c @@ -0,0 +1,9 @@ +#include "music.h" + +void MusicPlay(void) { + +} + +void MusicStop(void) { + +} diff --git a/Makefile b/Makefile index 089f976..f8d8081 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ TARGET = Uberdevice # debug build? DEBUG = 1 # optimization -OPT = -Og +OPT = -Og #######################################