Making a start on the movement code.
This commit is contained in:
parent
404e1ad533
commit
00ca902341
11 changed files with 89 additions and 92 deletions
9
GCodes.h
9
GCodes.h
|
@ -26,10 +26,12 @@ class GCodes
|
|||
{
|
||||
public:
|
||||
|
||||
GCodes(Platform* p, Move* m, Heat* h, Webserver* w);
|
||||
GCodes(Platform* p, Webserver* w);
|
||||
void Spin();
|
||||
void Init();
|
||||
void Exit();
|
||||
boolean ReadMove(float* m);
|
||||
boolean ReadHeat(float* h);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -37,12 +39,13 @@ class GCodes
|
|||
|
||||
Platform* platform;
|
||||
boolean active;
|
||||
Move* move;
|
||||
Heat* heat;
|
||||
Webserver* webserver;
|
||||
unsigned long lastTime;
|
||||
char gcodeBuffer[GCODE_LENGTH];
|
||||
int gcodePointer;
|
||||
boolean moveAvailable;
|
||||
boolean heatAvailable;
|
||||
float moveBuffer[DRIVES];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
23
GCodes.ino
23
GCodes.ino
|
@ -21,13 +21,11 @@ Licence: GPL
|
|||
|
||||
#include "RepRapFirmware.h"
|
||||
|
||||
GCodes::GCodes(Platform* p, Move* m, Heat* h, Webserver* w)
|
||||
GCodes::GCodes(Platform* p, Webserver* w)
|
||||
{
|
||||
active = false;
|
||||
//Serial.println("GCodes constructor");
|
||||
platform = p;
|
||||
move = m;
|
||||
heat = h;
|
||||
webserver = w;
|
||||
}
|
||||
|
||||
|
@ -41,6 +39,8 @@ void GCodes::Init()
|
|||
lastTime = platform->Time();
|
||||
gcodePointer = 0;
|
||||
active = true;
|
||||
moveAvailable = false;
|
||||
heatAvailable = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,3 +80,20 @@ void GCodes::Spin()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
boolean GCodes::ReadMove(float* m)
|
||||
{
|
||||
if(!moveAvailable)
|
||||
return false;
|
||||
for(char i = 0; i < DRIVES; i++)
|
||||
m[i] = moveBuffer[i];
|
||||
moveAvailable = false;
|
||||
}
|
||||
|
||||
|
||||
boolean GCodes::ReadHeat(float* h)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
12
Heat.h
12
Heat.h
|
@ -36,19 +36,17 @@ class Heat
|
|||
|
||||
public:
|
||||
|
||||
Heat(Platform* p);
|
||||
Heat(Platform* p, GCodes* g);
|
||||
void Spin();
|
||||
void Init();
|
||||
void Exit();
|
||||
|
||||
private:
|
||||
|
||||
Platform* platform;
|
||||
boolean active;
|
||||
unsigned long lastTime;
|
||||
//float frac;
|
||||
//float inc;
|
||||
|
||||
Platform* platform;
|
||||
GCodes* gCodes;
|
||||
boolean active;
|
||||
unsigned long lastTime;
|
||||
};
|
||||
|
||||
|
||||
|
|
15
Heat.ino
15
Heat.ino
|
@ -20,10 +20,10 @@ Licence: GPL
|
|||
|
||||
#include "RepRapFirmware.h"
|
||||
|
||||
Heat::Heat(Platform* p)
|
||||
Heat::Heat(Platform* p, GCodes* g)
|
||||
{
|
||||
//Serial.println("Heat constructor");
|
||||
platform = p;
|
||||
gCodes = g;
|
||||
active = false;
|
||||
}
|
||||
|
||||
|
@ -49,15 +49,4 @@ void Heat::Spin()
|
|||
if(t - lastTime < 3000)
|
||||
return;
|
||||
lastTime = t;
|
||||
/* if(frac > 1 || frac < 0)
|
||||
{
|
||||
inc = -inc;
|
||||
//Serial.print("Temps: ");
|
||||
//Serial.print(platform->getTemperature(0));
|
||||
// Serial.print(", ");
|
||||
//Serial.println(platform->getTemperature(1));
|
||||
}
|
||||
platform->setHeater(0, frac);
|
||||
platform->setHeater(1, 1 - frac);
|
||||
frac += inc;*/
|
||||
}
|
||||
|
|
11
Move.h
11
Move.h
|
@ -21,20 +21,29 @@ Licence: GPL
|
|||
#ifndef MOVE_H
|
||||
#define MOVE_H
|
||||
|
||||
#define BUFFER_LENGTH 10
|
||||
|
||||
class Move
|
||||
{
|
||||
public:
|
||||
|
||||
Move(Platform* p);
|
||||
Move(Platform* p, GCodes* g);
|
||||
void Init();
|
||||
void Spin();
|
||||
void Exit();
|
||||
void Qmove();
|
||||
|
||||
private:
|
||||
|
||||
Platform* platform;
|
||||
GCodes* gCodes;
|
||||
unsigned long lastTime;
|
||||
boolean active;
|
||||
float currentPosition[AXES]; // Note - drives above AXES are always relative moves
|
||||
float nextMove[DRIVES];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
29
Move.ino
29
Move.ino
|
@ -20,20 +20,19 @@ Licence: GPL
|
|||
|
||||
#include "RepRapFirmware.h"
|
||||
|
||||
Move::Move(Platform* p)
|
||||
Move::Move(Platform* p, GCodes* g)
|
||||
{
|
||||
//Serial.println("Move constructor");
|
||||
platform = p;
|
||||
gCodes = g;
|
||||
active = false;
|
||||
}
|
||||
|
||||
void Move::Init()
|
||||
{
|
||||
lastTime = platform->Time();
|
||||
platform->SetDirection(X_AXIS, FORWARDS);
|
||||
platform->SetDirection(Y_AXIS, FORWARDS);
|
||||
platform->SetDirection(Z_AXIS, FORWARDS);
|
||||
platform->SetDirection(3, FORWARDS);
|
||||
for(char i = 0; i < DRIVES; i++)
|
||||
platform->SetDirection(i, FORWARDS);
|
||||
active = true;
|
||||
}
|
||||
|
||||
|
@ -46,15 +45,13 @@ void Move::Spin()
|
|||
{
|
||||
if(!active)
|
||||
return;
|
||||
|
||||
unsigned long t = platform->Time();
|
||||
if(t - lastTime < 300)
|
||||
return;
|
||||
lastTime = t;
|
||||
//Serial.println("tick");
|
||||
/* platform->step(X_AXIS);
|
||||
platform->step(Y_AXIS);
|
||||
platform->step(Z_AXIS);
|
||||
platform->step(3);
|
||||
*/
|
||||
Qmove();
|
||||
}
|
||||
|
||||
|
||||
void Move::Qmove()
|
||||
{
|
||||
if(!gCodes->ReadMove(nextMove))
|
||||
return;
|
||||
|
||||
}
|
||||
|
|
13
Platform.h
13
Platform.h
|
@ -65,6 +65,9 @@ Licence: GPL
|
|||
#define ENABLE 0 // What to send to enable...
|
||||
#define DISABLE 1 // ...and disable a drive
|
||||
#define DISABLE_DRIVES {false, false, true, false} // Set true to disable a drive when it becomes idle
|
||||
#define LOW_STOP_PINS {3, 14, 17, -1}
|
||||
#define HIGH_STOP_PINS {-1, -1, -1, -1}
|
||||
#define ENDSTOP_HIT 1 // when a stop == this it is hit
|
||||
#define MAX_FEEDRATES {300, 300, 3, 45} // mm/sec
|
||||
#define MAX_ACCELERATIONS {800, 800, 30, 250} // mm/sec^2?? Maximum start speed for accelerated moves.
|
||||
#define DRIVE_STEPS_PER_UNIT {91.4286, 91.4286, 4000, 929}
|
||||
|
@ -73,9 +76,7 @@ Licence: GPL
|
|||
|
||||
// AXES
|
||||
|
||||
#define LOW_STOP_PINS {3, 14, 17}
|
||||
#define HIGH_STOP_PINS {-1, -1, -1}
|
||||
#define ENDSTOP_HIT 1 // when a stop == this it is hit
|
||||
|
||||
#define AXIS_LENGTHS {210, 210, 120} // mm
|
||||
#define FAST_HOME_FEEDRATES {50*60, 50*60, 1*60} // mm/min
|
||||
|
||||
|
@ -162,6 +163,8 @@ class Platform
|
|||
{
|
||||
public:
|
||||
|
||||
friend class Move;
|
||||
|
||||
Platform(RepRap* r);
|
||||
|
||||
RepRap* GetRepRap();
|
||||
|
@ -248,6 +251,8 @@ class Platform
|
|||
char directionPins[DRIVES];
|
||||
char enablePins[DRIVES];
|
||||
boolean disableDrives[DRIVES];
|
||||
char lowStopPins[DRIVES];
|
||||
char highStopPins[DRIVES];
|
||||
float maxFeedrates[DRIVES];
|
||||
float maxAccelerations[DRIVES];
|
||||
float driveStepsPerUnit[DRIVES];
|
||||
|
@ -256,8 +261,6 @@ class Platform
|
|||
|
||||
// AXES
|
||||
|
||||
char lowStopPins[AXES];
|
||||
char highStopPins[AXES];
|
||||
float axisLengths[AXES];
|
||||
float fastHomeFeedrates[AXES];
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ void Platform::Init()
|
|||
byte i;
|
||||
|
||||
Serial.begin(BAUD_RATE);
|
||||
//Serial.println("\n\n\nPlatform constructor");
|
||||
|
||||
lastTime = Time();
|
||||
|
||||
|
@ -59,6 +58,8 @@ void Platform::Init()
|
|||
directionPins = DIRECTION_PINS;
|
||||
enablePins = ENABLE_PINS;
|
||||
disableDrives = DISABLE_DRIVES;
|
||||
lowStopPins = LOW_STOP_PINS;
|
||||
highStopPins = HIGH_STOP_PINS;
|
||||
maxFeedrates = MAX_FEEDRATES;
|
||||
maxAccelerations = MAX_ACCELERATIONS;
|
||||
driveStepsPerUnit = DRIVE_STEPS_PER_UNIT;
|
||||
|
@ -67,8 +68,6 @@ void Platform::Init()
|
|||
|
||||
// AXES
|
||||
|
||||
lowStopPins = LOW_STOP_PINS;
|
||||
highStopPins = HIGH_STOP_PINS;
|
||||
axisLengths = AXIS_LENGTHS;
|
||||
fastHomeFeedrates = FAST_HOME_FEEDRATES;
|
||||
|
||||
|
@ -491,8 +490,6 @@ void Platform::Spin()
|
|||
if(Time() - lastTime < 2000000)
|
||||
return;
|
||||
lastTime = Time();
|
||||
//Serial.print("Client status: ");
|
||||
//Serial.println(clientStatus);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,12 +42,7 @@ class RepRap
|
|||
void Init();
|
||||
void Spin();
|
||||
void Exit();
|
||||
|
||||
// Platform* getPlatform();
|
||||
// Move* getMove();
|
||||
// Heat* getHeat();
|
||||
// GCodes* getGcodes();
|
||||
// Webserver* getWebserver();
|
||||
|
||||
void Interrupt();
|
||||
|
||||
|
||||
|
@ -57,34 +52,18 @@ class RepRap
|
|||
boolean active;
|
||||
Move* move;
|
||||
Heat* heat;
|
||||
GCodes* gcodes;
|
||||
GCodes* gCodes;
|
||||
Webserver* webserver;
|
||||
};
|
||||
|
||||
#include "Configuration.h"
|
||||
#include "Platform.h"
|
||||
#include "Webserver.h"
|
||||
#include "GCodes.h"
|
||||
#include "Move.h"
|
||||
#include "Heat.h"
|
||||
#include "GCodes.h"
|
||||
#include "Webserver.h"
|
||||
|
||||
// Do nothing more in the constructor; put what you want in RepRap:Init()
|
||||
|
||||
inline RepRap::RepRap()
|
||||
{
|
||||
active = false;
|
||||
platform = new Platform(this);
|
||||
move = new Move(platform);
|
||||
heat = new Heat(platform);
|
||||
webserver = new Webserver(platform);
|
||||
gcodes = new GCodes(platform, move, heat, webserver);
|
||||
}
|
||||
|
||||
//inline Platform* RepRap::getPlatform() { return platform; }
|
||||
//inline Move* RepRap::getMove() { return move; }
|
||||
//inline Heat* RepRap::getHeat() { return heat; }
|
||||
//inline GCodes* RepRap::getGcodes() { return gcodes; }
|
||||
//inline Webserver* RepRap::getWebserver() { return webserver; }
|
||||
|
||||
extern RepRap reprap;
|
||||
|
||||
|
|
|
@ -52,14 +52,25 @@ RepRap reprap;
|
|||
|
||||
//*************************************************************************************************
|
||||
|
||||
// Do nothing more in the constructor; put what you want in RepRap:Init()
|
||||
|
||||
RepRap::RepRap()
|
||||
{
|
||||
active = false;
|
||||
platform = new Platform(this);
|
||||
webserver = new Webserver(platform);
|
||||
gCodes = new GCodes(platform, webserver);
|
||||
move = new Move(platform, gCodes);
|
||||
heat = new Heat(platform, gCodes);
|
||||
}
|
||||
|
||||
void RepRap::Init()
|
||||
{
|
||||
platform->Init();
|
||||
gCodes->Init();
|
||||
webserver->Init();
|
||||
move->Init();
|
||||
heat->Init();
|
||||
gcodes->Init();
|
||||
webserver->Init();
|
||||
platform->Message(HOST_MESSAGE, "RepRapPro RepRap Firmware (Re)Started<br>\n");
|
||||
active = true;
|
||||
}
|
||||
|
@ -67,10 +78,10 @@ void RepRap::Init()
|
|||
void RepRap::Exit()
|
||||
{
|
||||
active = false;
|
||||
webserver->Exit();
|
||||
gcodes->Exit();
|
||||
heat->Exit();
|
||||
move->Exit();
|
||||
gCodes->Exit();
|
||||
webserver->Exit();
|
||||
platform->Exit();
|
||||
}
|
||||
|
||||
|
@ -80,10 +91,10 @@ void RepRap::Spin()
|
|||
return;
|
||||
|
||||
platform->Spin();
|
||||
webserver->Spin();
|
||||
gCodes->Spin();
|
||||
move->Spin();
|
||||
heat->Spin();
|
||||
gcodes->Spin();
|
||||
webserver->Spin();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ boolean Webserver::MatchBoundary(char c)
|
|||
|
||||
//****************************************************************************************************
|
||||
|
||||
// Handling G Codes for the rest of the software
|
||||
// Feeding G Codes to the GCodes class
|
||||
|
||||
boolean Webserver::Available()
|
||||
{
|
||||
|
@ -182,15 +182,9 @@ boolean Webserver::LoadGcodeBuffer(char* gc, boolean convertWeb)
|
|||
gcodeBuffer[gcodePointer] = 0;
|
||||
gcodePointer = 0;
|
||||
|
||||
// We intercept two G Codes so we can deal with file manipulation. That
|
||||
// We intercept a G Code so we can deal with file manipulation. That
|
||||
// way things don't get out of sync.
|
||||
|
||||
/* if(StringStartsWith(gc, "M28")) // Upload file?
|
||||
{
|
||||
uploadFile(&gc[4]);
|
||||
return;
|
||||
}*/
|
||||
|
||||
if(StringStartsWith(gcodeBuffer, "M30 ")) // Delete file?
|
||||
{
|
||||
if(!platform->DeleteFile(&gcodeBuffer[4]))
|
||||
|
|
Reference in a new issue