2024-03-14 14:46:31 +01:00
|
|
|
#include "stddef.h"
|
|
|
|
#include "stdint.h"
|
|
|
|
|
|
|
|
#include "buttons.h"
|
2024-03-18 12:51:57 +01:00
|
|
|
#include "scheduler.h"
|
2024-03-14 14:46:31 +01:00
|
|
|
#include "shapes.h"
|
|
|
|
#include "canvas.h"
|
|
|
|
#include "led.h"
|
|
|
|
|
|
|
|
|
|
|
|
// TEST CODE
|
|
|
|
uint16_t counter;
|
|
|
|
|
|
|
|
|
|
|
|
static uint8_t buttonsMoveLeftPressed() {
|
|
|
|
// -----------------------
|
|
|
|
// TEST CODE
|
2024-03-15 12:54:32 +01:00
|
|
|
//if (counter == 95) {
|
2024-03-14 17:25:45 +01:00
|
|
|
// ledGreenToggle();
|
|
|
|
// return 1;
|
|
|
|
//}
|
2024-03-14 14:46:31 +01:00
|
|
|
// -----------------------
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t buttonsMoveRightPressed() {
|
2024-03-15 12:54:32 +01:00
|
|
|
// -----------------------
|
|
|
|
// TEST CODE
|
|
|
|
if (counter == 95) {
|
|
|
|
ledGreenToggle();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
// -----------------------
|
2024-03-14 14:46:31 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t buttonsRotateLeftPressed() {
|
2024-03-15 12:54:32 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t buttonsRotateRightPressed() {
|
2024-03-14 14:46:31 +01:00
|
|
|
// -----------------------
|
|
|
|
// TEST CODE
|
2024-03-14 17:25:45 +01:00
|
|
|
if (counter == 35) {
|
2024-03-14 14:46:31 +01:00
|
|
|
ledGreenToggle();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
// -----------------------
|
2024-03-15 12:54:32 +01:00
|
|
|
// -----------------------
|
|
|
|
// TEST CODE
|
|
|
|
if (counter == 45) {
|
|
|
|
ledGreenToggle();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
// -----------------------
|
2024-03-14 17:25:45 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-03-14 14:46:31 +01:00
|
|
|
void buttonsExec(void *handle) {
|
2024-03-15 10:22:11 +01:00
|
|
|
if (! stoneIsValid()) {
|
2024-03-14 14:46:31 +01:00
|
|
|
// don't do anything, the stone has not been initialized
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TEST CODE
|
|
|
|
counter++;
|
|
|
|
|
|
|
|
uint8_t buttonPressed = 0;
|
|
|
|
|
|
|
|
if (buttonsMoveLeftPressed()) {
|
|
|
|
stoneMoveLeft();
|
|
|
|
buttonPressed = 1;
|
|
|
|
}
|
|
|
|
if (buttonsMoveRightPressed()) {
|
|
|
|
stoneMoveRight();
|
|
|
|
buttonPressed = 1;
|
|
|
|
}
|
|
|
|
if (buttonsRotateLeftPressed()) {
|
|
|
|
stoneRotateLeft();
|
|
|
|
buttonPressed = 1;
|
|
|
|
}
|
|
|
|
if (buttonsRotateRightPressed()) {
|
|
|
|
stoneRotateRight();
|
|
|
|
buttonPressed = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buttonPressed == 1) {
|
|
|
|
canvasShow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void buttonsInit() {
|
|
|
|
// TEST CODE
|
|
|
|
counter = 0;
|
|
|
|
|
|
|
|
schAdd(buttonsExec, NULL, 0, 100);
|
|
|
|
}
|
|
|
|
|