feat:V1.0 #8

Merged
Clement merged 58 commits from develop into master 2024-02-02 16:03:25 +00:00
2 changed files with 80 additions and 4 deletions
Showing only changes of commit 7cf9e88995 - Show all commits

View File

@ -54,6 +54,7 @@ lib_deps =
bblanchon/ArduinoJson@^6.21.3 ; JSON serializer et deserializer
m5stack/M5Stack@^0.4.5 ; M5 Lib
m5stack/M5GFX@^0.1.9 ; M5 Lib pour le LCD
m5stack/Module_GRBL_13.2@^0.0.3 ; M5 Lib pour Stepper (GRBL)
; example:
; erropix/ESP32 AnalogWrite@0.2

View File

@ -1,10 +1,85 @@
#include "Program.h"
Program* program;
// #include "Program.h"
// Program* program;
// void setup() {
// program = new Program();
// }
// void loop() {
// program->loop();
// }
#include <Arduino.h>
#include <M5Stack.h>
#include "Module_GRBL_13.2.h"
#define STEPMOTOR_I2C_ADDR 0x70
// #define STEPMOTOR_I2C_ADDR 0x71
Module_GRBL _GRBL = Module_GRBL(STEPMOTOR_I2C_ADDR);
/**
* @brief initialise le GRBL pour le stepper
*
* @param speed vitesse par defaut du moteur
* @param pas nombre de pas par mm du moteur
* @param accel vitesse d'acceleration du mptuer (mm/sec²)
* @param mode mode de fonctionnement (defaut = distance) absolute
*/
void init(int speed, double pas, int accel ,String mode = "distance"){
_GRBL.Init(&Wire);
_GRBL.setMode(mode);
Serial.print("3");
char* s = "";
Serial.print("4");
printf(s,"$0=%d", pas); // step/mm
Serial.print("5");
_GRBL.sendGcode(s);
printf(s,"$4=%f", speed); // speed
_GRBL.sendGcode(s);
printf(s,"$8=%d", pas); // acceleration, mm/sec^2
_GRBL.sendGcode(s);
}
void setup() {
program = new Program();
M5.begin();
M5.Power.begin();
Wire.begin(21, 22);
Serial.begin(115200);
M5.Lcd.setTextColor(WHITE, BLACK);
M5.Lcd.setTextSize(3);
M5.lcd.setBrightness(100);
M5.Lcd.setCursor(80, 40);
M5.Lcd.println("GRBL 13.2");
M5.Lcd.setCursor(50, 80);
M5.Lcd.println("Press Btn A/B");
M5.Lcd.setCursor(50, 120);
delay(1000);
M5.Lcd.println("Control Motor");
Serial.println("\n\n\n\n\n0");
init(100, 755.906, 50);
Serial.println("\n\n\n\n\n000000000000000000");
}
void loop() {
program->loop();
if (M5.BtnA.wasPressed())
{
Serial.print(_GRBL.readStatus());
_GRBL.setMotor(5, 5, 5, 200);
_GRBL.setMotor(0, 0, 0, 200);
}
if (M5.BtnB.wasPressed()) {
_GRBL.sendGcode("G1 X5Y5Z5");
_GRBL.sendGcode("G1 X0Y0Z0");
}
if (M5.BtnC.wasReleased()) {
_GRBL.unLock();
}
M5.update();
}