Add ADS1X15 code

This commit is contained in:
2021-11-28 12:19:21 +01:00
parent b42ad028ed
commit e37b1120ff
5 changed files with 45 additions and 6 deletions

View File

@@ -74,7 +74,7 @@ void initAudio()
mp3 = new AudioGeneratorMP3();
mp3->RegisterStatusCB(StatusCallback, (void *)"mp3");
Serial.println("init Audio Done");
//playSong(audio_current_Song);
playSong(audio_current_Song);
}
void handleAudio()

View File

@@ -18,10 +18,13 @@
#define PWR_HOLD 4
#define PWR_BTN 5
#define MEAS_EN 12
#define MEAS_ADC 35 //ADC1_CH7
#define MEAS_EN 22
#define HALL_INPUT 36 //ADC1_CH0
#define I2C_SDA 33
#define I2C_SCL 32
#define MEAS_ADC 1 //ADC1_CH7
#define HALL_INPUT 0 //ADC1_CH0
#endif
#if HARDWARE == 1

View File

@@ -5,6 +5,7 @@
#include "storage.h"
#include "audio.h"
#include "rfid.h"
#include "sensor.h"
#include "config.h"
#include "ota.h"
#include "game.h"
@@ -20,7 +21,7 @@ void setup()
//initOta();
initAudio();
initRfid();
initSensor();
initGame();
}
@@ -30,7 +31,8 @@ void loop()
debugHandle();
handleAudio();
//handleRfid();
handleRfid();
handleSensor
//handleGame();
handlePower();
//handleOta();

View File

@@ -0,0 +1,24 @@
#include "sensor.h"
ADS1115 ADS(0x48);
uint32_t lastADS = 0;
uint16_t BatterySensor = 0;
uint16_t HallSensor = 0;
void initSensor(void)
{
ADS.begin(I2C_SDA, I2C_SCL);
}
void handleSensor(void)
{
uint32_t timeNow = millis();
if(lastADS - timeNow > SENSORINTERVAL)
{
HallSensor = ADS.readADC(HALL_INPUT);
BatterySensor = ADS.readADC(MEAS_ADC);
Serial.printf("Read sensor: Hall=%d, vbatt=%d",HallSensor, BatterySensor);
}
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "ADS1X15.h"
#include "board.h"
#define SENSORINTERVAL 250
void initSensor(void);
void handleSensor(void);