add main algo V1 with mock

This commit is contained in:
Clement 2024-01-18 21:02:11 +01:00
parent 463e71fe10
commit 04474bfb94
2 changed files with 32 additions and 9 deletions

View File

@ -3,6 +3,7 @@
#include "DolibarrClient.h" #include "DolibarrClient.h"
#include "GRBL.h" #include "GRBL.h"
#include "NfcReader.h"
#include <Arduino.h> #include <Arduino.h>
#include <M5Stack.h> #include <M5Stack.h>
// #include <vector> // #include <vector>
@ -27,6 +28,12 @@ private:
* @brief stepper motor controller * @brief stepper motor controller
*/ */
GRBL* grbl; GRBL* grbl;
/**
* @brief nfc reader
*
*/
NfcReader* NFC;
}; };
#endif #endif

View File

@ -26,6 +26,8 @@ Program::Program() {
this->grbl = new GRBL(STEPMOTOR_I2C_ADDR); this->grbl = new GRBL(STEPMOTOR_I2C_ADDR);
Wire.begin(21, 22); Wire.begin(21, 22);
grbl->init(STEPER_SPEED, STEPER_PAS, STEPER_ACC); grbl->init(STEPER_SPEED, STEPER_PAS, STEPER_ACC);
this->NFC = new NfcReader(NFC_ADDR);
} }
void Program::loop() { void Program::loop() {
@ -40,18 +42,36 @@ void Program::loop() {
// if(this->NfcIDs->size() > 0){ // if(this->NfcIDs->size() > 0){
// } // }
//algo V1
//alog V1
//je lis la valeur NFC //je lis la valeur NFC
String nfcId = this->NFC->ReadNfc();
//si qqc //si qqc
if(nfcId != "0"){
//j'arrète le stepper
//this->grbl->stop(); //FIXME: implemente
//j'affiche le tag lue
Serial.print("new colis in comming : ");
Serial.println(nfcId);
//je demande a dolibard ou j'envoie //je demande a dolibard ou j'envoie
Serial.println("Demande a dolibard");
delay(500);// TODO: remove mock
//j'envoie au servo la commande //j'envoie au servo la commande
Serial.print("Servo : ");
Serial.println("Droite");
delay(500);// TODO: remove mock
//j'avance le moteur jusqu'a X (a definir) //j'avance le moteur jusqu'a X (a definir)
//si rien j'avance le moteur (5mm) this->grbl->mouveForward(CONVOYER_LEN);
}else{
//si rien
//je check si le stepper est en iddle
if(this->grbl->isIddle()){
//si oui j'avance de 5 mm
this->grbl->mouveForward(5);
}
}
//j'update la position du servo
//idée algo v1.5 (ajou petite gestion d'erreur) //idée algo v1.5 (ajou petite gestion d'erreur)
//alog V1
//je lis la valeur NFC //je lis la valeur NFC
//si qqc //si qqc
//je demande a dolibard ou j'envoie //je demande a dolibard ou j'envoie
@ -65,15 +85,11 @@ void Program::loop() {
//si il y a 2 colis (ou plus) //si il y a 2 colis (ou plus)
//on affiche une erreur de bourrage //on affiche une erreur de bourrage
//idée algo v2 //idée algo v2
//utiliser une pile //utiliser une pile
//utiliser le 2nd lecteur pour vidé la pile //utiliser le 2nd lecteur pour vidé la pile
//gestion d'erreur complete avec celle du dessus plus celle de la pile //gestion d'erreur complete avec celle du dessus plus celle de la pile
} }