update schematic and add production files

This commit is contained in:
2021-10-08 16:00:18 +02:00
parent d83bea3725
commit 72ce01ef37
24 changed files with 296 additions and 92 deletions

View File

@@ -64,7 +64,7 @@ void initAudio()
{
Serial.println("init Audio");
audioLogger = &Serial;
delay(500);
out = new AudioOutputI2S();
out->SetPinout(I2S_BCLK, I2S_WCLK, I2S_DATA); //bclk, wclk, data
out->SetGain(AUDIOGAIN);
@@ -72,7 +72,7 @@ void initAudio()
mp3 = new AudioGeneratorMP3();
mp3->RegisterStatusCB(StatusCallback, (void *)"mp3");
Serial.println("init Audio Done");
//playSong(i);
playSong(i);
}
void handleAudio()
@@ -81,7 +81,7 @@ void handleAudio()
{
if (!mp3->loop())
{
//mp3->stop();
mp3->stop();
if(n++ >= AUDIOREPEATS)
{
i++;

View File

@@ -7,7 +7,7 @@
#include "AudioFileSourceID3.h"
#include "AudioOutputI2S.h"
#define AUDIOGAIN 1
#define AUDIOGAIN 0.7
#define AUDIONSONGS 3
#define AUDIOREPEATS 3

View File

@@ -4,10 +4,17 @@
#define I2S_BCLK 21
#define I2S_WCLK 13
#define I2S_DATA 14
#define DAC_SDMODE
#define DAC_SDMODE 27
#define NFC_SS 25
#define NFC_SCK 18
#define NFC_MOSI 23
#define NFC_MISO 19
#define NFC_RST 22 //not connectedx
#define NFC_RST 22 //not connectedx
#define PWR_HOLD 4
#define PWR_BTN 9
#define MEAS_EN 10
#define MEAS_ADC 35 //ADC1_CH7
#define HALL_INPUT 36 //ADC1_CH0

View File

@@ -20,12 +20,8 @@ void loadConfig(const char *fname)
StaticJsonDocument<512> doc;
DeserializationError error = deserializeJson(doc, file);
if (error)
Serial.println(F("Failed to read file, using default configuration"));
JsonArray array = doc.as<JsonArray>();
for(JsonVariant v : array) {
Serial.print("json entry: ");
Serial.println(v.as<String>());
}
Serial.println(F("Failed to read file"));
serializeJsonPretty(doc, Serial);
Serial.println("config: load done");

View File

@@ -1,12 +1,20 @@
#include "game.h"
uint64_t last_hall_read;
void initGame(void)
{
pinMode(HALL_INPUT, ANALOG);
}
void handleGame(void)
{
uint32_t timeNow = millis();
if(timeNow - last_hall_read > HALLINTERVAL)
{
Serial.println(analogRead(HALL_INPUT));
last_hall_read = timeNow;
}
}

View File

@@ -1,4 +1,9 @@
#pragma once
#include "Arduino.h"
#include "board.h"
#define HALLINTERVAL 500
void initGame(void);
void handleGame(void);

View File

@@ -1,6 +1,6 @@
#include <Arduino.h>
#include "power.h"
#include "storage.h"
#include "audio.h"
#include "rfid.h"
@@ -10,9 +10,10 @@
void setup()
{
initPower();
Serial.begin(115200);
delay(2000);
initStorage();
initConfig();
initAudio();
@@ -25,6 +26,7 @@ void setup()
void loop()
{
handleAudio();
handleRfid();
//handleRfid();
handleGame();
handlePower();
}

View File

@@ -0,0 +1,41 @@
#include "power.h"
bool powerbutton_released = true;
void initPowerOn(void)
{
pinMode(PWR_HOLD, OUTPUT);
pinMode(PWR_BTN, INPUT);
digitalWrite(PWR_HOLD, HIGH);
powerbutton_released = false;
//dac_sdMode
pinMode(DAC_SDMODE, OUTPUT);
digitalWrite(DAC_SDMODE, HIGH);
//powerstate = poweringOn;
//buttonPower.begin();
}
void initPower(void)
{
Serial.println("initPower");
initPowerOn();
Serial.println("initPower: done");
}
void handlePower(void)
{
if(digitalRead(PWR_BTN) && powerbutton_released)
{
while(digitalRead(PWR_BTN)) {}
digitalWrite(PWR_HOLD, LOW);
}
else{
powerbutton_released = true;
}
}

View File

@@ -0,0 +1,7 @@
#pragma once
#include "board.h"
#include "Arduino.h"
void initPower(void);
void handlePower(void);