This commit is contained in:
Clement 2024-02-01 11:53:19 +01:00
parent a105387c21
commit 35ecce7d5d
4 changed files with 16 additions and 11 deletions

View File

@ -6,6 +6,7 @@
#include "ServoMotorComponent.h" #include "ServoMotorComponent.h"
#include "NfcReader.h" #include "NfcReader.h"
#include "GRBL.h" #include "GRBL.h"
#include "BigNfcReader.h"
class Program { class Program {
public: public:
@ -26,6 +27,7 @@ private:
ServoMotorComponent *servo; ServoMotorComponent *servo;
NfcReader *nfcReader; NfcReader *nfcReader;
GRBL *grbl; GRBL *grbl;
BigNfcReader* outputReader;
}; };
#endif #endif

View File

@ -1,14 +1,14 @@
#ifndef NFC_READER_H #ifndef BIG_NFC_READER_H
#define NFC_READER_H #define BIG_NFC_READER_H
#include <Arduino.h> #include <Arduino.h>
#include <vector> #include <vector>
#include "TrameList.h" #include "TrameList.h"
class NfcReader{ class BigNfcReader{
public: public:
NfcReader(); BigNfcReader();
/** /**
* @brief initialise le lecteur NFC * @brief initialise le lecteur NFC

View File

@ -1,14 +1,14 @@
#include "../include/NfcReader.h" #include "../include/BigNfcReader.h"
NfcReader::NfcReader(){ BigNfcReader::BigNfcReader(){
Serial2.begin(115200,SERIAL_8N1,2,3);//TODO: mettre le port série en paramètre Serial2.begin(115200,SERIAL_8N1,2,3);//TODO: mettre le port série en paramètre
this->pair = true; this->pair = true;
this->trame = new std::vector<byte>(); this->trame = new std::vector<byte>();
} }
bool NfcReader::init(){ bool BigNfcReader::init(){
const std::vector<std::vector<byte>> INIT_TRAMES = {INIT_TRAM_0, INIT_TRAM_1, INIT_TRAM_2, INIT_TRAM_3, INIT_TRAM_4, INIT_TRAM_5, INIT_TRAM_6, INIT_TRAM_7}; const std::vector<std::vector<byte>> INIT_TRAMES = {INIT_TRAM_0, INIT_TRAM_1, INIT_TRAM_2, INIT_TRAM_3, INIT_TRAM_4, INIT_TRAM_5, INIT_TRAM_6, INIT_TRAM_7};
const std::vector<std::vector<byte>> REP_TRAMES = {REP_TRAM_0, REP_TRAM_1, REP_TRAM_2, REP_TRAM_3, REP_TRAM_4, REP_TRAM_5, REP_TRAM_6, REP_TRAM_7}; const std::vector<std::vector<byte>> REP_TRAMES = {REP_TRAM_0, REP_TRAM_1, REP_TRAM_2, REP_TRAM_3, REP_TRAM_4, REP_TRAM_5, REP_TRAM_6, REP_TRAM_7};
int repnb = 0; int repnb = 0;
@ -30,7 +30,7 @@ bool NfcReader::init(){
return true; return true;
} }
void NfcReader::refresh(){ void BigNfcReader::refresh(){
this->trame->clear(); this->trame->clear();
std::vector<byte> trame = READ_TRAM_0; std::vector<byte> trame = READ_TRAM_0;
if (this->pair){ if (this->pair){
@ -48,7 +48,7 @@ void NfcReader::refresh(){
} }
String NfcReader::digitify(int number){ String BigNfcReader::digitify(int number){
String sortie = ""; String sortie = "";
if(number <= 0xF){ if(number <= 0xF){
@ -62,7 +62,7 @@ String NfcReader::digitify(int number){
} }
void NfcReader::printTrame(){ void BigNfcReader::printTrame(){
for(byte i: *this->trame){ for(byte i: *this->trame){
Serial.print(this->digitify(i)); Serial.print(this->digitify(i));
Serial.print(" "); Serial.print(" ");
@ -70,6 +70,6 @@ void NfcReader::printTrame(){
Serial.println(); Serial.println();
} }
int NfcReader::getNbTags(){ int BigNfcReader::getNbTags(){
return this->trame->at(8); return this->trame->at(8);
} }

View File

@ -80,6 +80,7 @@ Program::Program() {
this->servo = new ServoMotorComponent(2, 1, 1); this->servo = new ServoMotorComponent(2, 1, 1);
this->servo->setDesiredPosition(Position::MIDDLE); this->servo->setDesiredPosition(Position::MIDDLE);
this->grbl = new GRBL(STEPMOTOR_I2C_ADDR); this->grbl = new GRBL(STEPMOTOR_I2C_ADDR);
this->outputReader = new BigNfcReader();
Wire.begin(21, 22); Wire.begin(21, 22);
grbl->init(STEPER_SPEED, STEPER_PAS, STEPER_ACC); grbl->init(STEPER_SPEED, STEPER_PAS, STEPER_ACC);
struct WifiConfig wifi_c = {WIFI_SSID, WIFI_PASSWORD}; struct WifiConfig wifi_c = {WIFI_SSID, WIFI_PASSWORD};
@ -97,6 +98,8 @@ void Program::loop() {
derniereExecution = maintenant; derniereExecution = maintenant;
} }
this->servo->refresh(); this->servo->refresh();
this->outputReader->refresh();
Serial.printf("Output colis number : ", this->outputReader->getNbTags());
String nfcId = this->nfcReader->ReadNfc(); String nfcId = this->nfcReader->ReadNfc();
//si qqc //si qqc