Converted to platformio
This commit is contained in:
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
|
||||
59
include/button.h
Normal file
59
include/button.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* button.h
|
||||
*
|
||||
* Created: 04.05.2015 21:38:42
|
||||
* Author: Yogi
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __BUTTON_H__
|
||||
#define __BUTTON_H__
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define debounceDelay 50
|
||||
|
||||
typedef void (*ActionCb)(void);
|
||||
|
||||
class Button
|
||||
{
|
||||
|
||||
private:
|
||||
long debounce;
|
||||
byte state:1;
|
||||
byte lastState:1;
|
||||
byte pin;
|
||||
ActionCb action;
|
||||
Button( const Button &c );
|
||||
Button& operator=( const Button &c );
|
||||
|
||||
public:
|
||||
|
||||
Button(byte p, ActionCb a): debounce(0), state(1), lastState(1), action(a), pin(p) {
|
||||
pinMode(pin, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
void check() {
|
||||
byte b = digitalRead(pin);
|
||||
long t = millis();
|
||||
|
||||
if (b != lastState) {
|
||||
debounce = t;
|
||||
}
|
||||
|
||||
if ((t - debounce) > debounceDelay) {
|
||||
if (b != state) {
|
||||
state = b;
|
||||
|
||||
if (!state) {
|
||||
(*action)();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastState = b;
|
||||
}
|
||||
}; //button
|
||||
|
||||
#endif //__BUTTON_H__
|
||||
|
||||
Reference in New Issue
Block a user