/* * remote_control.c * * Created on: Nov 4, 2025 * Author: sowgro */ #include #include #include #include "player_actions.h" #include "UART.h" #include "project.h" #include "systick.h" #include "player_actions.h" static char buffer[80]; static char* cur = buffer; void remote_control_init() { NVIC_EnableIRQ (USART2_IRQn); USART2->CR1 |= USART_CR1_RXNEIE; // 1 << 5 player_help(); } void remote_control_loop() { } static void parse_input(char buffer[]) { if (!strcmp(buffer, "HELP")) { player_help(); } else if (!strcmp(buffer, "NEXT")) { player_next(); } else if (!strcmp(buffer, "PLAY")) { player_play(); } else if (!strcmp(buffer, "PAUSE")) { player_pause(); } else if (!strcmp(buffer, "STOP")) { player_stop(); } else { printf("Unknown command \"%s\"\n\r", buffer); } } void USART2_IRQHandler() { int ch = USART_Read(USART2); if (project_get_mode() != REMOTE_MODE) { cur = buffer; return; } putchar(ch); if (!ch) return; if (ch == '\r') { putchar('\n'); *cur = 0; parse_input(buffer); cur = buffer; return; } if (ch == 0x08 || ch == 0x7F) { if (cur <= buffer) return; cur--; printf("\b \b"); return; } *cur++ = ch; }