Add HardwareRfid class implementation and integrate with main loop
This commit is contained in:
@@ -1,17 +1,28 @@
|
||||
#include <Arduino.h>
|
||||
#include <hardware_led.hpp>
|
||||
#include <hardware_rfid.hpp>
|
||||
#include "hardware.pb.h"
|
||||
|
||||
// Demo for HardwareLed
|
||||
HardwareLed led(2); // Assuming NeoPixel on pin 4 (D2 on ESP8266)
|
||||
|
||||
// Demo for HardwareRfid
|
||||
HardwareRfid rfid(4, 5); // SS=D2 (GPIO4), RST=D1 (GPIO5)
|
||||
|
||||
hardware_LedConfig configs[4];
|
||||
unsigned long lastChange = 0;
|
||||
int currentConfig = 0;
|
||||
|
||||
void onRfidTag(const hardware_SensorToControlMessage& msg) {
|
||||
Serial.print("RFID Tag detected: 0x");
|
||||
Serial.println(msg.payload.rfid_reading.card_id, HEX);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
led.begin();
|
||||
rfid.begin();
|
||||
rfid.setCallback(onRfidTag);
|
||||
|
||||
// Static config
|
||||
configs[0] = {0};
|
||||
@@ -53,6 +64,7 @@ void setup() {
|
||||
|
||||
void loop() {
|
||||
led.update();
|
||||
rfid.update();
|
||||
|
||||
if (millis() - lastChange >= 10000) {
|
||||
lastChange = millis();
|
||||
|
||||
Reference in New Issue
Block a user