Rework de la lib dolibarr

This commit is contained in:
2024-02-09 08:31:10 +01:00
parent 23258e2682
commit d2dec55110
7 changed files with 32 additions and 71 deletions

View File

@ -6,6 +6,8 @@
#include "NfcReader.h"
#include <Ticker.h>
TaskHandle_t task1;
uint32_t derniereExecution = 0;
const uint32_t intervalle = 1000;
std::vector<models::Warehouse> *warehouses;
@ -78,6 +80,7 @@ Program::Program() {
lcdScreen->add_log("Initialize M5LCD component....");
this->nfcReader = new NfcReader(NFC_ADDR);
this->servo = new ServoMotorComponent(2, 1, 1);
this->servo->setDesiredPosition(MIDDLE);
this->grbl = new GRBL(STEPMOTOR_I2C_ADDR);
Wire.begin(21, 22);
grbl->init(STEPER_SPEED, STEPER_PAS, STEPER_ACC);
@ -85,6 +88,11 @@ Program::Program() {
initialize_wifi(wifi_c);
}
void Program::moveStepper() {
Serial.printf("moveStepper\n");
this->grbl->mouveForward(5);
}
void Program::loop() {
lcdScreen->update();
@ -96,18 +104,13 @@ void Program::loop() {
derniereExecution = maintenant;
}
this->servo->refresh();
String nfcId = this->nfcReader->ReadNfc();
//si qqc
if(nfcId != "0"){
if (lcdScreen->get_components().wifi != COMPONENT_OK) {
lcdScreen->add_log("Wifi not connected !");
lcdScreen->set_nfc_message("Cannot send wifi request !");
return;
}
//j'arrète le stepper
//this->grbl->stop(); //FIXME: implemente
//j'affiche le tag lue
Serial.print("new colis in comming : ");
lcdScreen->add_log("new colis detected: ");
lcdScreen->add_log(nfcId.c_str());
@ -116,10 +119,6 @@ void Program::loop() {
Serial.printf("Product: %s\n%s", product.label.c_str(), product.accountancy_code_sell_export.c_str());
lcdScreen->set_product_label(product.label);
lcdScreen->set_product_id(product.id);
/*if (product.fk_default_warehouse == product.accountancy_code_sell_export) {
Serial.printf("Product already in the good warehouse !\n");
return;
}*/
auto ware = std::find_if(warehouses->begin(), warehouses->end(), [&product](models::Warehouse w) {return w.id == product.accountancy_code_sell_export;});
if (ware.base() == nullptr) {
Serial.printf("Warehouse not found !\n");
@ -150,10 +149,10 @@ void Program::loop() {
this->servo->setDesiredPosition(Position::MIDDLE);
lcdScreen->set_servo_message("MIDDLE");
}
this->grbl->mouveForward(CONVOYER_LEN);
//this->grbl->mouveForward(CONVOYER_LEN);
} else {
if(this->grbl->isIddle()){
/*if(this->grbl->isIddle()){
this->grbl->mouveForward(5);
}
}*/
}
}