replace #define by constexpr
This commit is contained in:
@@ -87,12 +87,12 @@
|
||||
#define LED_OFF LOW
|
||||
#endif
|
||||
|
||||
#define redLed 7 // Set Led Pins
|
||||
#define greenLed 6
|
||||
#define blueLed 5
|
||||
constexpr uint8_t redLed = 7; // Set Led Pins
|
||||
constexpr uint8_t greenLed = 6;
|
||||
constexpr uint8_t blueLed = 5;
|
||||
|
||||
#define relay 4 // Set Relay Pin
|
||||
#define wipeB 3 // Button pin for WipeMode
|
||||
constexpr uint8_t relay = 4; // Set Relay Pin
|
||||
constexpr uint8_t wipeB = 3; // Button pin for WipeMode
|
||||
|
||||
boolean match = false; // initialize card match to false
|
||||
boolean programMode = false; // initialize programming mode to false
|
||||
@@ -105,8 +105,9 @@ byte readCard[4]; // Stores scanned ID read from RFID Module
|
||||
byte masterCard[4]; // Stores master card's ID read from EEPROM
|
||||
|
||||
// Create MFRC522 instance.
|
||||
#define SS_PIN 10
|
||||
#define RST_PIN 9
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN);
|
||||
|
||||
///////////////////////////////////////// Setup ///////////////////////////////////
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_PIN 10 // Configurable, see typical pin layout above
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
|
||||
|
||||
/* Set your new UID here! */
|
||||
#define NEW_UID {0xDE, 0xAD, 0xBE, 0xEF}
|
||||
byte newUid[] = {0xDE, 0xAD, 0xBE, 0xEF};
|
||||
|
||||
MFRC522::MIFARE_Key key;
|
||||
|
||||
@@ -92,7 +92,6 @@ void loop() {
|
||||
// }
|
||||
|
||||
// Set new UID
|
||||
byte newUid[] = NEW_UID;
|
||||
if ( mfrc522.MIFARE_SetUid(newUid, (byte)4, true) ) {
|
||||
Serial.println(F("Wrote new UID to card."));
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_PIN 10 // Configurable, see typical pin layout above
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_PIN 10 // Configurable, see typical pin layout above
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_PIN 10 // Configurable, see typical pin layout above
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_PIN 3 // Configurable, see typical pin layout above
|
||||
#define IRQ_PIN 2 // Configurable, depends on hardware
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t IRQ_PIN = 2; // Configurable, depends on hardware
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 //
|
||||
#define SS_PIN 10 //
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_PIN 10 // Configurable, see typical pin layout above
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
|
||||
|
||||
@@ -37,7 +37,7 @@ MFRC522::MIFARE_Key key;
|
||||
|
||||
// Number of known default keys (hard-coded)
|
||||
// NOTE: Synchronize the NR_KNOWN_KEYS define with the defaultKeys[] array
|
||||
#define NR_KNOWN_KEYS 8
|
||||
constexpr uint8_t NR_KNOWN_KEYS = 8;
|
||||
// Known keys, see: https://code.google.com/p/mfcuk/wiki/MifareClassicDefaultKeys
|
||||
byte knownKeys[NR_KNOWN_KEYS][MFRC522::MF_KEY_SIZE] = {
|
||||
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // FF FF FF FF FF FF = factory default
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_PIN 10 // Configurable, see typical pin layout above
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define SS_PIN 10
|
||||
#define RST_PIN 9
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_1_PIN 10 // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 2
|
||||
#define SS_2_PIN 8 // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 1
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_1_PIN = 10; // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 2
|
||||
constexpr uint8_t SS_2_PIN = 8; // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 1
|
||||
|
||||
#define NR_OF_READERS 2
|
||||
constexpr uint8_t NR_OF_READERS = 2;
|
||||
|
||||
byte ssPins[] = {SS_1_PIN, SS_2_PIN};
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_PIN 10 // Configurable, see typical pin layout above
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_PIN 10 // Configurable, see typical pin layout above
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
|
||||
|
||||
// Number of known default keys (hard-coded)
|
||||
// NOTE: Synchronize the NR_KNOWN_KEYS define with the defaultKeys[] array
|
||||
#define NR_KNOWN_KEYS 8
|
||||
constexpr uint8_t NR_KNOWN_KEYS = 8;
|
||||
// Known keys, see: https://code.google.com/p/mfcuk/wiki/MifareClassicDefaultKeys
|
||||
byte knownKeys[NR_KNOWN_KEYS][MFRC522::MF_KEY_SIZE] = {
|
||||
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // FF FF FF FF FF FF = factory default
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_PIN 10 // Configurable, see typical pin layout above
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#include <SPI.h>
|
||||
#include <MFRC522.h>
|
||||
|
||||
#define RST_PIN 9 // Configurable, see typical pin layout above
|
||||
#define SS_PIN 10 // Configurable, see typical pin layout above
|
||||
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above
|
||||
constexpr uint8_t SS_PIN = 10; // Configurable, see typical pin layout above
|
||||
|
||||
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
|
||||
|
||||
|
||||
Reference in New Issue
Block a user