feat: main-algo #16

Merged
Clement merged 10 commits from feat/main-algo into develop 2024-01-26 08:47:26 +00:00
7 changed files with 21 additions and 11 deletions

View File

@ -36,4 +36,4 @@ build_flags =
-D RIGHT_POS=18 -D RIGHT_POS=18
-D MIDDLE_POS=32 -D MIDDLE_POS=32
-D LEFT_POS=52 -D LEFT_POS=52
-D CONVOYER_LEN=100 -D CONVOYER_LEN=150 ;mm

View File

@ -1,7 +1,6 @@
#ifndef PROGRAM_H #ifndef PROGRAM_H
#define PROGRAM_H #define PROGRAM_H
#include "Arduino.h"
#include "DolibarrClient.h" #include "DolibarrClient.h"
#include <M5Stack.h> #include <M5Stack.h>
#include "ServoMotorComponent.h" #include "ServoMotorComponent.h"

View File

@ -8,6 +8,7 @@ class iGRBL{
public: public:
virtual void init(int speed, double pas, int accel, String mode = "distance") = 0; virtual void init(int speed, double pas, int accel, String mode = "distance") = 0;
virtual void mouveForward(int mm) = 0; virtual void mouveForward(int mm) = 0;
virtual bool isIddle() = 0;
}; };
class GRBL : public iGRBL{ class GRBL : public iGRBL{
@ -15,6 +16,7 @@ public:
GRBL(int grblAddr); GRBL(int grblAddr);
void init(int speed, double pas, int accel, String mode = "distance") override; void init(int speed, double pas, int accel, String mode = "distance") override;
void mouveForward(int mm = 5) override; void mouveForward(int mm = 5) override;
bool isIddle() override;
private: private:
Module_GRBL* grbl; Module_GRBL* grbl;
}; };

View File

@ -32,3 +32,13 @@ void GRBL::mouveForward(int mm){
sprintf(s, "G1 X%d", mm); sprintf(s, "G1 X%d", mm);
this->grbl->sendGcode(s); this->grbl->sendGcode(s);
} }
bool GRBL::isIddle(){
bool sortie = false;
if(this->grbl->readStatus().indexOf("IDLE") != -1){
sortie = true;
}
return sortie;
}

View File

@ -11,14 +11,14 @@ String NfcReader::ReadNfc()
this->uid.clear(); this->uid.clear();
if (!this->mfrc522->PICC_IsNewCardPresent() || if (!this->mfrc522->PICC_IsNewCardPresent() ||
!this->mfrc522->PICC_ReadCardSerial()) { !this->mfrc522->PICC_ReadCardSerial()) {
return ("0"); return "0";
} }
for (unsigned int i = 0; i < this->mfrc522->uid.size; i++) { for (unsigned int i = 0; i < this->mfrc522->uid.size; i++) {
if (this->mfrc522->uid.uidByte[i] < 0xF) { if (this->mfrc522->uid.uidByte[i] < 0xF) {
this->uid += '0'; this->uid += '0';
this->uid += String(this->mfrc522->uid.uidByte[i], HEX); this->uid += String(this->mfrc522->uid.uidByte[i], HEX);
} else { } else {
this->uid += String(this->mfrc522->uid.uidByte[i], HEX); this->uid += String(this->mfrc522->uid.uidByte[i], HEX);
} }
} }
return (this->uid); return (this->uid);

View File

@ -1,5 +1,5 @@
#ifndef NFCREADER_HPP_ #ifndef NFCREADER_H
#define NFCREADER_HPP_ #define NFCREADER_H
#include <M5Stack.h> #include <M5Stack.h>
#include "MFRC522_I2C.h" #include "MFRC522_I2C.h"
@ -19,4 +19,4 @@ class NfcReader {
String uid; String uid;
}; };
#endif /* !NFCREADER_HPP_ */ #endif /* !NFCREADER_H */

View File

@ -152,9 +152,8 @@ void Program::loop() {
} }
this->grbl->mouveForward(CONVOYER_LEN); this->grbl->mouveForward(CONVOYER_LEN);
} else { } else {
//si rien if(this->grbl->isIddle()){
//je check si le stepper est en iddle this->grbl->mouveForward(5);
//this->grbl->mouveForward(5); }
} }
} }