add thread for rfid_reader
This commit is contained in:
@@ -2,14 +2,12 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
rfid_reader::rfid_reader()
|
rfid_reader::rfid_reader()
|
||||||
{
|
{
|
||||||
mfrc.PCD_Init();
|
mfrc.PCD_Init();
|
||||||
loop();
|
thread = std::thread(&rfid_reader::loop, this);
|
||||||
std::this_thread::sleep_for(1s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t rfid_reader::last_id() const
|
uint32_t rfid_reader::last_id() const
|
||||||
@@ -43,5 +41,7 @@ void rfid_reader::loop()
|
|||||||
printf("%X\n", last_id());
|
printf("%X\n", last_id());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(1s);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define RFIDREADER_HPP_
|
#define RFIDREADER_HPP_
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#include "MFRC522.h"
|
#include "MFRC522.h"
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
MFRC522 mfrc;
|
MFRC522 mfrc;
|
||||||
uint32_t uid;
|
uint32_t uid;
|
||||||
|
std::thread thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user