Converted to platformio
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -15,6 +15,8 @@ local.properties
|
||||
.classpath
|
||||
.settings/
|
||||
.loadpath
|
||||
.vscode
|
||||
.pio
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
71
include/EggDuino.h
Normal file
71
include/EggDuino.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef EGGDUINO_H
|
||||
#define EGGDUINO_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Servo.h>
|
||||
#include <avr/eeprom.h>
|
||||
|
||||
#include "AccelStepper.h"
|
||||
#include "SerialCommand.h"
|
||||
#include "button.h"
|
||||
|
||||
// implemented Eggbot-Protocol-Version v13
|
||||
#define initSting "EBBv13_and_above Protocol emulated by Eggduino-Firmware V1.6a"
|
||||
|
||||
// Rotational Stepper
|
||||
#define step1 11
|
||||
#define dir1 10
|
||||
#define enableRotMotor 9
|
||||
#define rotMicrostep 16
|
||||
|
||||
// Pen Stepper
|
||||
#define step2 8
|
||||
#define dir2 7
|
||||
#define enablePenMotor 6
|
||||
#define penMicrostep 16
|
||||
|
||||
#define servoPin 3
|
||||
|
||||
#define penUpPosEEAddress ((uint16_t *)0)
|
||||
#define penDownPosEEAddress ((uint16_t *)2)
|
||||
|
||||
extern AccelStepper rotMotor;
|
||||
extern AccelStepper penMotor;
|
||||
extern Servo penServo;
|
||||
extern SerialCommand SCmd;
|
||||
|
||||
extern int penMin;
|
||||
extern int penMax;
|
||||
extern int penUpPos;
|
||||
extern int penDownPos;
|
||||
extern int servoRateUp;
|
||||
extern int servoRateDown;
|
||||
extern long rotStepError;
|
||||
extern long penStepError;
|
||||
extern int penState;
|
||||
extern uint32_t nodeCount;
|
||||
extern unsigned int layer;
|
||||
extern boolean prgButtonState;
|
||||
extern uint8_t rotStepCorrection;
|
||||
extern uint8_t penStepCorrection;
|
||||
extern float rotSpeed;
|
||||
extern float penSpeed;
|
||||
extern boolean motorsEnabled;
|
||||
|
||||
void makeComInterface();
|
||||
void initHardware();
|
||||
void moveOneStep();
|
||||
void moveToDestination();
|
||||
void sendAck();
|
||||
void sendError();
|
||||
void motorsOff();
|
||||
void motorsOn();
|
||||
void toggleMotors();
|
||||
void doTogglePen();
|
||||
void setprgButtonState();
|
||||
bool parseSMArgs(uint16_t *duration, int *penStepsEBB, int *rotStepsEBB);
|
||||
void prepareMove(uint16_t duration, int penStepsEBB, int rotStepsEBB);
|
||||
void storePenUpPosInEE();
|
||||
void storePenDownPosInEE();
|
||||
|
||||
#endif
|
||||
18
platformio.ini
Normal file
18
platformio.ini
Normal file
@@ -0,0 +1,18 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:uno]
|
||||
platform = atmelavr
|
||||
board = uno
|
||||
framework = arduino
|
||||
monitor_speed = 9600
|
||||
upload_speed = 115200
|
||||
upload_port= COM3
|
||||
lib_deps = arduino-libraries/Servo@^1.3.0
|
||||
@@ -1,23 +1,5 @@
|
||||
#include "EggDuino.h"
|
||||
|
||||
void makeComInterface(){
|
||||
SCmd.addCommand("v",sendVersion);
|
||||
SCmd.addCommand("EM",enableMotors);
|
||||
SCmd.addCommand("SC",stepperModeConfigure);
|
||||
SCmd.addCommand("SP",setPen);
|
||||
SCmd.addCommand("SM",stepperMove);
|
||||
SCmd.addCommand("SE",ignore);
|
||||
SCmd.addCommand("TP",togglePen);
|
||||
SCmd.addCommand("PO",ignore); //Engraver command, not implemented, gives fake answer
|
||||
SCmd.addCommand("NI",nodeCountIncrement);
|
||||
SCmd.addCommand("ND",nodeCountDecrement);
|
||||
SCmd.addCommand("SN",setNodeCount);
|
||||
SCmd.addCommand("QN",queryNodeCount);
|
||||
SCmd.addCommand("SL",setLayer);
|
||||
SCmd.addCommand("QL",queryLayer);
|
||||
SCmd.addCommand("QP",queryPen);
|
||||
SCmd.addCommand("QB",queryButton); //"PRG" Button,
|
||||
SCmd.setDefaultHandler(unrecognized); // Handler for command that isn't matched (says "What?")
|
||||
}
|
||||
|
||||
void queryPen() {
|
||||
char state;
|
||||
@@ -262,3 +244,23 @@ void unrecognized(const char *command){
|
||||
void ignore(){
|
||||
sendAck();
|
||||
}
|
||||
|
||||
void makeComInterface(){
|
||||
SCmd.addCommand("v",sendVersion);
|
||||
SCmd.addCommand("EM",enableMotors);
|
||||
SCmd.addCommand("SC",stepperModeConfigure);
|
||||
SCmd.addCommand("SP",setPen);
|
||||
SCmd.addCommand("SM",stepperMove);
|
||||
SCmd.addCommand("SE",ignore);
|
||||
SCmd.addCommand("TP",togglePen);
|
||||
SCmd.addCommand("PO",ignore); //Engraver command, not implemented, gives fake answer
|
||||
SCmd.addCommand("NI",nodeCountIncrement);
|
||||
SCmd.addCommand("ND",nodeCountDecrement);
|
||||
SCmd.addCommand("SN",setNodeCount);
|
||||
SCmd.addCommand("QN",queryNodeCount);
|
||||
SCmd.addCommand("SL",setLayer);
|
||||
SCmd.addCommand("QL",queryLayer);
|
||||
SCmd.addCommand("QP",queryPen);
|
||||
SCmd.addCommand("QB",queryButton); //"PRG" Button,
|
||||
SCmd.setDefaultHandler(unrecognized); // Handler for command that isn't matched (says "What?")
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
#include "EggDuino.h"
|
||||
|
||||
inline void loadPenPosFromEE() {
|
||||
penUpPos = eeprom_read_word(penUpPosEEAddress);
|
||||
penDownPos = eeprom_read_word(penDownPosEEAddress);
|
||||
penState = penUpPos;
|
||||
}
|
||||
|
||||
void initHardware(){
|
||||
// enable eeprom wait in avr/eeprom.h functions
|
||||
SPMCSR &= ~SELFPRGEN;
|
||||
@@ -16,25 +24,21 @@ void initHardware(){
|
||||
penServo.write(penState);
|
||||
}
|
||||
|
||||
inline void loadPenPosFromEE() {
|
||||
penUpPos = eeprom_read_word(penUpPosEEAddress);
|
||||
penDownPos = eeprom_read_word(penDownPosEEAddress);
|
||||
penState = penUpPos;
|
||||
}
|
||||
|
||||
inline void storePenUpPosInEE() {
|
||||
|
||||
void storePenUpPosInEE() {
|
||||
eeprom_update_word(penUpPosEEAddress, penUpPos);
|
||||
}
|
||||
|
||||
inline void storePenDownPosInEE() {
|
||||
void storePenDownPosInEE() {
|
||||
eeprom_update_word(penDownPosEEAddress, penDownPos);
|
||||
}
|
||||
|
||||
inline void sendAck(){
|
||||
void sendAck(){
|
||||
Serial.print("OK\r\n");
|
||||
}
|
||||
|
||||
inline void sendError(){
|
||||
void sendError(){
|
||||
Serial.print("unknown CMD\r\n");
|
||||
}
|
||||
|
||||
@@ -19,25 +19,7 @@
|
||||
2 implement homing sequence via microswitch or optical device
|
||||
*/
|
||||
|
||||
#include "AccelStepper.h" // nice lib from http://www.airspayce.com/mikem/arduino/AccelStepper/
|
||||
#include <Servo.h>
|
||||
#include "SerialCommand.h" //nice lib from Stefan Rado, https://github.com/kroimon/Arduino-SerialCommand
|
||||
#include <avr/eeprom.h>
|
||||
#include "button.h"
|
||||
|
||||
#define initSting "EBBv13_and_above Protocol emulated by Eggduino-Firmware V1.6a"
|
||||
//Rotational Stepper:
|
||||
#define step1 11
|
||||
#define dir1 10
|
||||
#define enableRotMotor 9
|
||||
#define rotMicrostep 16 //MicrostepMode, only 1,2,4,8,16 allowed, because of Integer-Math in this Sketch
|
||||
//Pen Stepper:
|
||||
#define step2 8
|
||||
#define dir2 7
|
||||
#define enablePenMotor 6
|
||||
#define penMicrostep 16 //MicrostepMode, only 1,2,4,8,16 allowed, because of Integer-Math in this Sketch
|
||||
|
||||
#define servoPin 3 //Servo
|
||||
#include "EggDuino.h"
|
||||
|
||||
// EXTRAFEATURES - UNCOMMENT TO USE THEM -------------------------------------------------------------------
|
||||
|
||||
@@ -47,9 +29,6 @@
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define penUpPosEEAddress ((uint16_t *)0)
|
||||
#define penDownPosEEAddress ((uint16_t *)2)
|
||||
|
||||
//make Objects
|
||||
AccelStepper rotMotor(1, step1, dir1);
|
||||
AccelStepper penMotor(1, step2, dir2);
|
||||
Reference in New Issue
Block a user