more configuration
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
||||
|
||||
|
@ -38,6 +38,8 @@ int main() {
|
||||
soundInit();
|
||||
buttonsInit();
|
||||
|
||||
eepromShowValues();
|
||||
|
||||
if (isConfigMode()) {
|
||||
configInit();
|
||||
} else {
|
||||
|
@ -109,3 +109,9 @@ uint32_t getSeconds() {
|
||||
return s;
|
||||
}
|
||||
|
||||
void wait(uint8_t t) {
|
||||
uint8_t startTime = getSeconds();
|
||||
|
||||
while (getSeconds() < (startTime + t));
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,6 @@ void schExec();
|
||||
void schUpdate();
|
||||
uint8_t schTaskCnt();
|
||||
uint32_t getSeconds();
|
||||
|
||||
void wait(uint8_t t);
|
||||
|
||||
#endif /* PONTCOOPSCHEDULER_H_ */
|
||||
|
Reference in New Issue
Block a user