Merge pull request 'feat: main-algo' (#16) from feat/main-algo into develop
Reviewed-on: #16 Reviewed-by: Nicolas <nicolas.sansd@gmail.com>
This commit is contained in:
commit
23258e2682
@ -36,4 +36,4 @@ build_flags =
|
||||
-D RIGHT_POS=18
|
||||
-D MIDDLE_POS=32
|
||||
-D LEFT_POS=52
|
||||
-D CONVOYER_LEN=100
|
||||
-D CONVOYER_LEN=150 ;mm
|
||||
|
@ -1,7 +1,6 @@
|
||||
#ifndef PROGRAM_H
|
||||
#define PROGRAM_H
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "DolibarrClient.h"
|
||||
#include <M5Stack.h>
|
||||
#include "ServoMotorComponent.h"
|
||||
|
@ -8,6 +8,7 @@ class iGRBL{
|
||||
public:
|
||||
virtual void init(int speed, double pas, int accel, String mode = "distance") = 0;
|
||||
virtual void mouveForward(int mm) = 0;
|
||||
virtual bool isIddle() = 0;
|
||||
};
|
||||
|
||||
class GRBL : public iGRBL{
|
||||
@ -15,6 +16,7 @@ public:
|
||||
GRBL(int grblAddr);
|
||||
void init(int speed, double pas, int accel, String mode = "distance") override;
|
||||
void mouveForward(int mm = 5) override;
|
||||
bool isIddle() override;
|
||||
private:
|
||||
Module_GRBL* grbl;
|
||||
};
|
||||
|
@ -32,3 +32,13 @@ void GRBL::mouveForward(int mm){
|
||||
sprintf(s, "G1 X%d", mm);
|
||||
this->grbl->sendGcode(s);
|
||||
}
|
||||
|
||||
bool GRBL::isIddle(){
|
||||
bool sortie = false;
|
||||
|
||||
if(this->grbl->readStatus().indexOf("IDLE") != -1){
|
||||
sortie = true;
|
||||
}
|
||||
|
||||
return sortie;
|
||||
}
|
||||
|
@ -11,14 +11,14 @@ String NfcReader::ReadNfc()
|
||||
this->uid.clear();
|
||||
if (!this->mfrc522->PICC_IsNewCardPresent() ||
|
||||
!this->mfrc522->PICC_ReadCardSerial()) {
|
||||
return ("0");
|
||||
return "0";
|
||||
}
|
||||
for (unsigned int i = 0; i < this->mfrc522->uid.size; i++) {
|
||||
if (this->mfrc522->uid.uidByte[i] < 0xF) {
|
||||
this->uid += '0';
|
||||
this->uid += String(this->mfrc522->uid.uidByte[i], HEX);
|
||||
} else {
|
||||
this->uid += String(this->mfrc522->uid.uidByte[i], HEX);
|
||||
this->uid += String(this->mfrc522->uid.uidByte[i], HEX);
|
||||
}
|
||||
}
|
||||
return (this->uid);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef NFCREADER_HPP_
|
||||
#define NFCREADER_HPP_
|
||||
#ifndef NFCREADER_H
|
||||
#define NFCREADER_H
|
||||
|
||||
#include <M5Stack.h>
|
||||
#include "MFRC522_I2C.h"
|
||||
@ -19,4 +19,4 @@ class NfcReader {
|
||||
String uid;
|
||||
};
|
||||
|
||||
#endif /* !NFCREADER_HPP_ */
|
||||
#endif /* !NFCREADER_H */
|
||||
|
@ -152,9 +152,8 @@ void Program::loop() {
|
||||
}
|
||||
this->grbl->mouveForward(CONVOYER_LEN);
|
||||
} else {
|
||||
//si rien
|
||||
//je check si le stepper est en iddle
|
||||
//this->grbl->mouveForward(5);
|
||||
if(this->grbl->isIddle()){
|
||||
this->grbl->mouveForward(5);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user