update rfid firmware
This commit is contained in:
Submodule FW/leo_muziekdoos_esp32/lib/NDEF updated: c7262f2108...4d119fdce3
@@ -14,6 +14,8 @@ board = m5stack-atom
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
bblanchon/ArduinoJson@^6.18.5
|
||||
joaolopesf/SerialDebug@^0.9.82
|
||||
monitor_speed = 115200
|
||||
;upload_speed = 115200
|
||||
lib_ldf_mode = deep+
|
||||
extra_scripts = ./littlefsbuilder.py
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "math.h"
|
||||
|
||||
|
||||
uint32_t last_hall_read;
|
||||
uint16_t last_hall_sample;
|
||||
uint8_t hall_idle_count;
|
||||
@@ -10,50 +9,51 @@ bool hall_is_Idle = true;
|
||||
|
||||
void initGame(void)
|
||||
{
|
||||
printlnI("Game: init");
|
||||
pinMode(HALL_INPUT, ANALOG);
|
||||
//analogReadResolution(10);
|
||||
analogSetAttenuation(ADC_11db);
|
||||
printlnI("Game: init: done");
|
||||
}
|
||||
|
||||
|
||||
void handleGame(void)
|
||||
{
|
||||
uint32_t timeNow = millis();
|
||||
if(timeNow - last_hall_read > HALLINTERVAL)
|
||||
if (timeNow - last_hall_read > HALLINTERVAL)
|
||||
{
|
||||
uint16_t hall_sample = analogRead(HALL_INPUT);
|
||||
uint16_t hall_delta = (last_hall_sample > hall_sample)? (last_hall_sample - hall_sample) : (hall_sample - last_hall_sample);
|
||||
if(hall_delta > HALLIDLETHRESHOLD)
|
||||
uint16_t hall_sample = analogRead(HALL_INPUT);
|
||||
uint16_t hall_delta = (last_hall_sample > hall_sample) ? (last_hall_sample - hall_sample) : (hall_sample - last_hall_sample);
|
||||
if (hall_delta > HALLIDLETHRESHOLD)
|
||||
{
|
||||
if (hall_idle_count > HALLIDLESAMPLES)
|
||||
{
|
||||
if(hall_idle_count > HALLIDLESAMPLES)
|
||||
{
|
||||
hall_is_Idle = false;
|
||||
hall_idle_count = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
hall_idle_count++;
|
||||
}
|
||||
hall_is_Idle = false;
|
||||
hall_idle_count = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(hall_idle_count == 0)
|
||||
{
|
||||
hall_is_Idle = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
hall_idle_count--;
|
||||
}
|
||||
hall_idle_count++;
|
||||
}
|
||||
Serial.printf("HallSensor: val=%d, delta=%d, count=%d, idle=%s\n",
|
||||
hall_sample,
|
||||
hall_delta,
|
||||
hall_idle_count,
|
||||
(hall_is_Idle? "yes":"no"));
|
||||
last_hall_sample = hall_sample;
|
||||
last_hall_read = timeNow;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hall_idle_count == 0)
|
||||
{
|
||||
hall_is_Idle = true;
|
||||
printlnI("Game: Idle");
|
||||
}
|
||||
else
|
||||
{
|
||||
hall_idle_count--;
|
||||
}
|
||||
}
|
||||
// debugD("HallSensor: val=%d, delta=%d, count=%d, idle=%s\n",
|
||||
// hall_sample,
|
||||
// hall_delta,
|
||||
// hall_idle_count,
|
||||
// (hall_is_Idle? "yes":"no"));
|
||||
last_hall_sample = hall_sample;
|
||||
last_hall_read = timeNow;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "board.h"
|
||||
#include "SerialDebug.h"
|
||||
|
||||
#define HALLINTERVAL 200
|
||||
#define HALLIDLETHRESHOLD 6
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <Arduino.h>
|
||||
#include "SerialDebug.h"
|
||||
|
||||
#include "power.h"
|
||||
#include "storage.h"
|
||||
@@ -8,6 +9,7 @@
|
||||
#include "game.h"
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
initPower();
|
||||
@@ -25,6 +27,8 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
debugHandle();
|
||||
|
||||
handleAudio();
|
||||
//handleRfid();
|
||||
handleGame();
|
||||
|
||||
@@ -11,7 +11,7 @@ bool powerbutton_released = true;
|
||||
void initPowerOn(void)
|
||||
{
|
||||
//disable brownout
|
||||
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
||||
//WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
||||
|
||||
//enable LDO
|
||||
pinMode(PWR_HOLD, OUTPUT);
|
||||
@@ -29,9 +29,9 @@ void initPowerOn(void)
|
||||
|
||||
void initPower(void)
|
||||
{
|
||||
Serial.println("initPower");
|
||||
printlnI(F("Power: init"));
|
||||
initPowerOn();
|
||||
Serial.println("initPower: done");
|
||||
printlnI(F("Power: init: done"));
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ void handlePower(void)
|
||||
{
|
||||
if(digitalRead(PWR_BTN) && powerbutton_released)
|
||||
{
|
||||
printlnA("poweringDown!");
|
||||
debugHandle();
|
||||
while(digitalRead(PWR_BTN)) {}
|
||||
digitalWrite(PWR_HOLD, LOW);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "board.h"
|
||||
#include "Arduino.h"
|
||||
#include "SerialDebug.h"
|
||||
|
||||
|
||||
void initPower(void);
|
||||
void handlePower(void);
|
||||
@@ -1,21 +1,31 @@
|
||||
#include "rfid.h"
|
||||
|
||||
|
||||
//PN532_SPI pn532spi(SPI, NFC_SS, NFC_SCK, NFC_MISO, NFC_MOSI);
|
||||
|
||||
uint32_t last_rfid_update = 0;
|
||||
|
||||
//*****************************************************************************************//
|
||||
void initRfid()
|
||||
{
|
||||
printlnI(F("rfid init")); //shows in serial that it is ready to read
|
||||
|
||||
//int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1);
|
||||
ConfigManager_HWInit(NFC_SCK, NFC_MISO, NFC_MOSI, NFC_SS);
|
||||
Serial.println(F("rfid init done")); //shows in serial that it is ready to read
|
||||
printlnI(F("rfid init done")); //shows in serial that it is ready to read
|
||||
}
|
||||
|
||||
//*****************************************************************************************//
|
||||
void handleRfid()
|
||||
{
|
||||
uint32_t timeNow = millis();
|
||||
int8_t TagType = TRACK_NOTHING;
|
||||
|
||||
if(timeNow - last_rfid_update > RFIDINTERVAL)
|
||||
{
|
||||
Serial.printf("rfid: tagreader start\n");
|
||||
TagType = ConfigManager_TagHunting(TRACK_ALL);
|
||||
Serial.printf("rfid: tagreader done: %d\n",TagType);
|
||||
last_rfid_update = timeNow;
|
||||
}
|
||||
}
|
||||
//*****************************************************************************************//
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "board.h"
|
||||
#include "Arduino.h"
|
||||
#include "SerialDebug.h"
|
||||
|
||||
#include <SPI.h>
|
||||
#include "lib_95HFConfigManager.h"
|
||||
@@ -9,6 +10,7 @@
|
||||
#include "lib_wrapper.h"
|
||||
#include "miscellaneous.h"
|
||||
|
||||
#define RFIDINTERVAL 200
|
||||
|
||||
void initRfid(void);
|
||||
void handleRfid(void);
|
||||
@@ -1,5 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SerialDebug.h"
|
||||
|
||||
|
||||
void initStorage();
|
||||
Reference in New Issue
Block a user