more configuration

This commit is contained in:
2024-05-21 13:43:40 +02:00
parent faf75e158a
commit 2827046b8b
14 changed files with 74 additions and 19 deletions

View File

@ -8,6 +8,7 @@
#include "shapes.h"
#include "canvas.h"
#include "sound.h"
#include "eeprom.h"
bool mutedFlag = true;
@ -107,6 +108,7 @@ void buttonsExec(void *handle) {
canvasShow();
if (mutedFlag) {
eepromIncGameCounter();
soundCtrl(SOUND_UNMUTE);
mutedFlag = false;
}

View File

@ -71,7 +71,7 @@ static void configHandleAmplitude() {
}
}
void (*configHandler[])(void) = { configHandleFlash, configHandleResetHighScore, configHandleBrightness,configHandleAmplitude };
void (*configHandler[])(void) = { configHandleResetHighScore, configHandleFlash, configHandleBrightness, configHandleAmplitude };
void configExec(void *handle) {

View File

@ -1,10 +1,15 @@
#include <stdint.h>
#include <string.h>
#include <sys/param.h>
#include "eeprom.h"
#include "spi.h"
#include "scheduler.h"
#include "display.h"
#include "canvas.h"
#include "../rgb-driver/colors.h"
#define MAGIC 0xb002
#define MAGIC 0xb003
#define HIGHSCORE_ADDR 0x00
#define DUMMY 0x00
#define CMD_READ 0b00000011
@ -16,6 +21,7 @@
typedef struct {
uint16_t magic;
uint16_t highScore;
uint16_t gameCounter;
uint8_t flashColor;
uint8_t brightness;
uint8_t amplitude;
@ -69,6 +75,35 @@ void eepromCommit() {
writeBuf();
}
void eepromShowValues() {
canvasClear();
canvasFillRow(0, _green);
canvasShow();
displaySetValue(buf.v.highScore);
wait(2);
canvasClear();
canvasFillRow(1, _green);
canvasShow();
displaySetValue(MIN(buf.v.gameCounter, 9999));
wait(2);
canvasClear();
canvasFillRow(2, _green);
canvasShow();
displaySetValue(buf.v.flashColor);
wait(2);
canvasClear();
canvasFillRow(3, _green);
canvasShow();
displaySetValue(buf.v.brightness);
wait(2);
canvasClear();
canvasFillRow(4, _green);
canvasShow();
displaySetValue(buf.v.amplitude);
wait(2);
}
uint16_t eepromReadHighScore() {
return buf.v.highScore;
}
@ -102,3 +137,9 @@ void eepromSetAmplitude(uint8_t v) {
buf.v.amplitude = v;
}
void eepromIncGameCounter() {
buf.v.gameCounter += 1;
writeBuf();
}

View File

@ -6,6 +6,7 @@
void eepromInit();
void eepromCommit();
void eepromShowValues();
uint16_t eepromReadHighScore();
void eepromSetHighScore(uint16_t v);
uint8_t eepromReadFlashColor();
@ -14,6 +15,7 @@ uint8_t eepromReadBrightness();
void eepromSetBrightness(uint8_t v);
uint8_t eepromReadAmplitude();
void eepromSetAmplitude(uint8_t v);
void eepromIncGameCounter();

View File

@ -38,6 +38,8 @@ int main() {
soundInit();
buttonsInit();
eepromShowValues();
if (isConfigMode()) {
configInit();
} else {

View File

@ -109,3 +109,9 @@ uint32_t getSeconds() {
return s;
}
void wait(uint8_t t) {
uint8_t startTime = getSeconds();
while (getSeconds() < (startTime + t));
}

View File

@ -32,6 +32,6 @@ void schExec();
void schUpdate();
uint8_t schTaskCnt();
uint32_t getSeconds();
void wait(uint8_t t);
#endif /* PONTCOOPSCHEDULER_H_ */