Merge pull request 'feat: GRBL-stepper-motor' (#14) from feat/GRBL-stepper into develop
Reviewed-on: #14
This commit is contained in:
commit
b7fe429508
@ -14,3 +14,12 @@ build_flags =
|
|||||||
-D MONITOR_SPEED=${config.monitor_speed}
|
-D MONITOR_SPEED=${config.monitor_speed}
|
||||||
; DO NOT TOUCH --- END
|
; DO NOT TOUCH --- END
|
||||||
-D WAITING_WIFI_DELAY=1000
|
-D WAITING_WIFI_DELAY=1000
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;; stepper config ;;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
-D STEPMOTOR_I2C_ADDR=0x70
|
||||||
|
-D STEPER_ACC=200
|
||||||
|
;-D STEPER_PAS=755.906 ; = 65mm
|
||||||
|
-D STEPER_PAS=58 ; = 5mm
|
||||||
|
-D STEPER_SPEED=1000 ; 12000
|
||||||
|
22
lib/GRBL/include/GRBL.h
Normal file
22
lib/GRBL/include/GRBL.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef GRBL_H
|
||||||
|
#define GRBL_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "Module_GRBL_13.2.h"
|
||||||
|
|
||||||
|
class iGRBL{
|
||||||
|
public:
|
||||||
|
virtual void init(int speed, double pas, int accel, String mode = "distance") = 0;
|
||||||
|
virtual void mouveForward(int mm) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GRBL : public iGRBL{
|
||||||
|
public:
|
||||||
|
GRBL(int grblAddr);
|
||||||
|
void init(int speed, double pas, int accel, String mode = "distance") override;
|
||||||
|
void mouveForward(int mm = 5) override;
|
||||||
|
private:
|
||||||
|
Module_GRBL* grbl;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
34
lib/GRBL/src/GRBL.cpp
Normal file
34
lib/GRBL/src/GRBL.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "../include/GRBL.h"
|
||||||
|
|
||||||
|
GRBL::GRBL(int grblAddr){
|
||||||
|
this->grbl = new Module_GRBL(grblAddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GRBL::init(int speed, double pas, int accel, String mode){
|
||||||
|
char s[1024];
|
||||||
|
|
||||||
|
this->grbl->Init(&Wire);
|
||||||
|
this->grbl->setMode(mode);
|
||||||
|
|
||||||
|
sprintf(s,"$0=%f", pas); // step/mm
|
||||||
|
this->grbl->sendGcode(s);
|
||||||
|
Serial.println(s);
|
||||||
|
|
||||||
|
sprintf(s,"$4=%d", speed); // speed
|
||||||
|
this->grbl->sendGcode(s);
|
||||||
|
Serial.println(s);
|
||||||
|
|
||||||
|
sprintf(s,"$8=%d", accel); // acceleration, mm/sec^2
|
||||||
|
this->grbl->sendGcode(s);
|
||||||
|
Serial.println(s);
|
||||||
|
|
||||||
|
sprintf(s,"$3=%d", 500); // puse/µsec
|
||||||
|
this->grbl->sendGcode(s);
|
||||||
|
Serial.println(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GRBL::mouveForward(int mm){
|
||||||
|
char s[1024];
|
||||||
|
sprintf(s, "G1 X%d", mm);
|
||||||
|
this->grbl->sendGcode(s);
|
||||||
|
}
|
@ -54,6 +54,7 @@ lib_deps =
|
|||||||
bblanchon/ArduinoJson@^6.21.3 ; JSON serializer et deserializer
|
bblanchon/ArduinoJson@^6.21.3 ; JSON serializer et deserializer
|
||||||
m5stack/M5Stack@^0.4.5 ; M5 Lib
|
m5stack/M5Stack@^0.4.5 ; M5 Lib
|
||||||
m5stack/M5GFX@^0.1.9 ; M5 Lib pour le LCD
|
m5stack/M5GFX@^0.1.9 ; M5 Lib pour le LCD
|
||||||
|
m5stack/Module_GRBL_13.2@^0.0.3 ; M5 Lib pour Stepper (GRBL)
|
||||||
; example:
|
; example:
|
||||||
; erropix/ESP32 AnalogWrite@0.2
|
; erropix/ESP32 AnalogWrite@0.2
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user