usability fixes

master
Dmitry Maylarov 7 years ago
parent 8da6ded99b
commit 2f796255f6

@ -2,7 +2,7 @@
#define __GAME_H #define __GAME_H
#define MAX_PLAYERS 6 #define MAX_PLAYERS 6
#define TIMER_MAX 180 #define TIMER_MAX 180
#define TIMER_STEP 5 #define TIMER_STEP 10
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>

@ -98,6 +98,11 @@ void LCD_MoveCursor(LCD_HandleTypeDef *lcd, uint8_t line, uint8_t column) {
LCD_SendCommand(lcd, LCD_SETDDRAMADDR | (LINE_BEGIN[line] + column) ); LCD_SendCommand(lcd, LCD_SETDDRAMADDR | (LINE_BEGIN[line] + column) );
} }
void LCD_MoveHome(LCD_HandleTypeDef *lcd) {
LCD_SendCommand(lcd, LCD_RETURNHOME );
vTaskDelay(2);
}
void LCD_Init(LCD_HandleTypeDef *lcd) { void LCD_Init(LCD_HandleTypeDef *lcd) {
//http://easyelectronics.ru/avr-uchebnyj-kurs-podklyuchenie-k-avr-lcd-displeya-hd44780.html //http://easyelectronics.ru/avr-uchebnyj-kurs-podklyuchenie-k-avr-lcd-displeya-hd44780.html
//http://nerdralph.blogspot.com/2014/07/controlling-hd44780-displays.html //http://nerdralph.blogspot.com/2014/07/controlling-hd44780-displays.html

@ -456,13 +456,13 @@ void vTaskPlayerSetup(void *parameter)
vTaskDelay(50); vTaskDelay(50);
LCD_Init(&hlcd); LCD_Init(&hlcd);
vTaskDelay(50); vTaskDelay(50);
LCD_MoveCursor(&hlcd, 0, 0); LCD_MoveHome(&hlcd);
LCD_SendString(&hlcd, "Settings"); LCD_SendString(&hlcd, "Settings");
LCD_MoveCursor(&hlcd, 1, 0); LCD_MoveCursor(&hlcd, 1, 0);
while (1) while (1)
{ {
LCD_MoveCursor(&hlcd, 1, 0); LCD_MoveCursor(&hlcd, 1, 0);
sprintf(lcdBuffer, "Players: %d ", game.activePlayers); sprintf(lcdBuffer, "Players: %1d ", game.activePlayers);
LCD_SendString(&hlcd, lcdBuffer); LCD_SendString(&hlcd, lcdBuffer);
vTaskDelay(1); vTaskDelay(1);
if (xSemaphoreTake(buttonPressed, portMAX_DELAY) == pdPASS ) if (xSemaphoreTake(buttonPressed, portMAX_DELAY) == pdPASS )
@ -477,7 +477,7 @@ void vTaskPlayerSetup(void *parameter)
minusButton->pressed = false; minusButton->pressed = false;
RemovePlayer(); RemovePlayer();
} }
else if (bigButton->pressed) else if (bigButton->pressed && game.activePlayers > 1)
{ {
break; break;
} }
@ -488,12 +488,12 @@ void vTaskPlayerSetup(void *parameter)
} }
void vTaskTimerSetup(void *parameter) { void vTaskTimerSetup(void *parameter) {
LCD_MoveCursor(&hlcd, 0, 0); LCD_MoveHome(&hlcd);
LCD_SendString(&hlcd, "Settings"); LCD_SendString(&hlcd, "Settings");
while (1) while (1)
{ {
LCD_MoveCursor(&hlcd, 1, 0); LCD_MoveCursor(&hlcd, 1, 0);
sprintf(lcdBuffer, "Turn time: %3ld s ", game.turnTime); sprintf(lcdBuffer, "Turn time: %1ld:%02ld ",game.turnTime / 60, game.turnTime % 60);
LCD_SendString(&hlcd, lcdBuffer); LCD_SendString(&hlcd, lcdBuffer);
vTaskDelay(1); vTaskDelay(1);
if (xSemaphoreTake(buttonPressed, portMAX_DELAY) == pdPASS ) if (xSemaphoreTake(buttonPressed, portMAX_DELAY) == pdPASS )
@ -526,7 +526,7 @@ void vTaskTimerSetup(void *parameter) {
} }
void vTaskConfig(void *parameter) { void vTaskConfig(void *parameter) {
LCD_MoveCursor(&hlcd, 0, 0); LCD_MoveHome(&hlcd);
LCD_SendString(&hlcd, "Settings"); LCD_SendString(&hlcd, "Settings");
while (1) while (1)
{ {
@ -552,7 +552,9 @@ void vTaskConfig(void *parameter) {
void vTaskTurn(void *parameter) { void vTaskTurn(void *parameter) {
xTimerReset(secondsTimerHandle, 0); xTimerReset(secondsTimerHandle, 0);
LCD_MoveHome(&hlcd);
TickType_t xLastWakeTime; TickType_t xLastWakeTime;
xLastWakeTime = xTaskGetTickCount(); xLastWakeTime = xTaskGetTickCount();
@ -642,13 +644,13 @@ void vTaskButtonPoll(void *parameter) {
state = HAL_GPIO_ReadPin(buttons[i].port, buttons[i].pin); state = HAL_GPIO_ReadPin(buttons[i].port, buttons[i].pin);
if (state != buttons[i].pressed) if (state != buttons[i].pressed)
{ {
vTaskDelay(50); vTaskDelay(25);
state = HAL_GPIO_ReadPin(buttons[i].port, buttons[i].pin); state = HAL_GPIO_ReadPin(buttons[i].port, buttons[i].pin);
if (state != buttons[i].pressed) if (state != buttons[i].pressed)
buttons[i].pressed = !buttons[i].pressed; buttons[i].pressed = !buttons[i].pressed;
xSemaphoreGive(buttonPressed); xSemaphoreGive(buttonPressed);
} }
vTaskDelay(25); vTaskDelay(50);
} }
} }
} }

Loading…
Cancel
Save