Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
add CMD_CALIBRATOR_STATUS:
Browse files Browse the repository at this point in the history
returns 0(stoppep), 1(running), 2(backing)
  • Loading branch information
faljse committed Nov 23, 2016
1 parent 8177409 commit a908042
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
26 changes: 25 additions & 1 deletion firmware/src/main/dobot.cpp
Expand Up @@ -26,7 +26,7 @@ License: MIT
// #include "../ramps/ramps.h"
// #endif

funcPtrs cmdArray[13];
funcPtrs cmdArray[14];
// Last index in the commands pointers array.
int cmdPtrArrayLastIndex;

Expand Down Expand Up @@ -75,6 +75,7 @@ void setup() {
cmdArray[CMD_PUMP_ON] = cmdPumpOn;
cmdArray[CMD_VALVE_ON] = cmdValveOn;
cmdArray[CMD_BOARD_VERSION] = cmdBoardVersion;
cmdArray[CMD_CALIBRATOR_STATUS] = cmdCalibratorStatus;
cmdPtrArrayLastIndex = sizeof(cmdArray) / sizeof(cmdArray[0]) - 1;

implementationFunctions[LaserOn] = laserOn;
Expand Down Expand Up @@ -312,6 +313,29 @@ byte cmdExecQueue() {
return 1;
}

// CMD: Return calibrator status 0:stopped, 1:unning, 2:backing
byte cmdCalibratorStatus() {
// Check if not enough bytes yet.
if (cmdInBuffIndex < 3) {
return 1;
}
cmdInBuffIndex = 0;
if (!checkCrc(cmd, 1)) {
return 2;
}

if(calibrator.isRunning())
cmd[0] = 1;
else if(calibrator.isBacking())
cmd[0] = 2;
else
cmd[0] = 0;

// Return calibrator status.
write1(cmd);
return 3;
}

void serialInit(void) {
// Configure serial0
UBRR0H = UBRRH_VALUE;
Expand Down
3 changes: 3 additions & 0 deletions firmware/src/main/dobot.h
Expand Up @@ -39,6 +39,7 @@ License: MIT
#define CMD_PUMP_ON 10
#define CMD_VALVE_ON 11
#define CMD_BOARD_VERSION 12
#define CMD_CALIBRATOR_STATUS 13
// DO NOT FORGET TO UPDATE cmdArray SIZE!

#define GET_MOTOR_DIRECTION(X) ((prevMotorDirections >> X) & 0x01)
Expand Down Expand Up @@ -112,6 +113,8 @@ byte cmdLaserOn();
byte cmdPumpOn();
byte cmdValveOn();
byte cmdBoardVersion();
byte cmdCalibratorStatus();

void crcCcitt(byte data[], int len);
void crcCcitt(byte data[], int len, byte keepSeed);
byte read13(byte data[]);
Expand Down

0 comments on commit a908042

Please sign in to comment.