diff --git a/PixelHub-Client/src/PixelBot.h b/PixelHub-Client/src/PixelBot.h
index cf55c76..c12b3d8 100644
--- a/PixelHub-Client/src/PixelBot.h
+++ b/PixelHub-Client/src/PixelBot.h
@@ -38,11 +38,11 @@ public:
PixelBot();
~PixelBot();
- ///
- /// The current protocol version that this this PixelBot implementation understands.
- /// Very important to avoid strange behavious when a PixelBot hasn't has it's code updated.
- ///
- static const unsigned short PROTOCOL_VERSION = 1;
+ ///
+ /// The current protocol version that this this PixelBot implementation understands.
+ /// Very important to avoid strange behavious when a PixelBot hasn't has it's code updated.
+ ///
+ static const unsigned short PROTOCOL_VERSION = 1;
///
/// Listens for beacon pings that reveal the location of the PixelHub server.
@@ -66,7 +66,7 @@ public:
/// Very useful if you want to do other things at the same time as handling commands from the PixelHub server.
///
bool Tick();
-
+
private:
// ~~~ Manual Settings ~~~ //
char desiredRemoteRole[7] = { 's', 'e', 'r', 'v', 'e', 'r', '\0' };
@@ -91,6 +91,5 @@ private:
// The TCP client to use as the PixelHub server transport connection.
WiFiClient tcpClient = WiFiClient();
-
+
};
-
diff --git a/PixelHub-Client/src/PixelBotController.cpp b/PixelHub-Client/src/PixelBotController.cpp
index 0def1ba..cc24b47 100644
--- a/PixelHub-Client/src/PixelBotController.cpp
+++ b/PixelHub-Client/src/PixelBotController.cpp
@@ -4,7 +4,7 @@
PixelBotController::PixelBotController()
{
-
+
}
PixelBotController::~PixelBotController()
@@ -14,52 +14,51 @@ PixelBotController::~PixelBotController()
unsigned long PixelBotController::GetTicksTravelled()
{
- return ticksTravelled;
+ return ticksTravelled;
}
void PixelBotController::MoveDistance(int direction, int ticks)
{
- for(int i = 0; i < ticks; i++) {
- MoveTick(direction);
- delay(tickDelay);
- }
+ for(int i = 0; i < ticks; i++) {
+ MoveTick(direction);
+ delay(tickDelay);
+ }
}
void PixelBotController::MoveTick(int direction)
{
- for(int i = 0; i < 8; i++)
- {
- switch(direction) {
- case STOP:
- return;
- case FORWARDS:
- sendTickPart(i,7-i);
- break;
- case BACKWARDS:
- sendTickPart(7-i,i);
- break;
- case LEFT:
- sendTickPart(7-i,7-i);
- break;
- case RIGHT:
- sendTickPart(i,i);
- break;
- }
- delayMicroseconds(motorSpeed);
- }
- ticksTravelled++;
+ for(int i = 0; i < 8; i++)
+ {
+ switch(direction) {
+ case STOP:
+ return;
+ case FORWARDS:
+ sendTickPart(i,7-i);
+ break;
+ case BACKWARDS:
+ sendTickPart(7-i,i);
+ break;
+ case LEFT:
+ sendTickPart(7-i,7-i);
+ break;
+ case RIGHT:
+ sendTickPart(i,i);
+ break;
+ }
+ delayMicroseconds(motorSpeed);
+ }
+ ticksTravelled++;
}
void PixelBotController::sendTickPart(int leftCode, int rightCode)
{
- digitalWrite(lmotorPin1, bitRead(motorLookup[leftCode], 0));
- digitalWrite(lmotorPin2, bitRead(motorLookup[leftCode], 1));
- digitalWrite(lmotorPin3, bitRead(motorLookup[leftCode], 2));
- digitalWrite(lmotorPin4, bitRead(motorLookup[leftCode], 3));
-
- digitalWrite(rmotorPin1, bitRead(motorLookup[rightCode], 0));
- digitalWrite(rmotorPin2, bitRead(motorLookup[rightCode], 1));
- digitalWrite(rmotorPin3, bitRead(motorLookup[rightCode], 2));
- digitalWrite(rmotorPin4, bitRead(motorLookup[rightCode], 3));
+ digitalWrite(lmotorPin1, bitRead(motorLookup[leftCode], 0));
+ digitalWrite(lmotorPin2, bitRead(motorLookup[leftCode], 1));
+ digitalWrite(lmotorPin3, bitRead(motorLookup[leftCode], 2));
+ digitalWrite(lmotorPin4, bitRead(motorLookup[leftCode], 3));
+
+ digitalWrite(rmotorPin1, bitRead(motorLookup[rightCode], 0));
+ digitalWrite(rmotorPin2, bitRead(motorLookup[rightCode], 1));
+ digitalWrite(rmotorPin3, bitRead(motorLookup[rightCode], 2));
+ digitalWrite(rmotorPin4, bitRead(motorLookup[rightCode], 3));
}
-
diff --git a/PixelHub-Client/src/PixelBotController.h b/PixelHub-Client/src/PixelBotController.h
index e240fd0..be63ada 100644
--- a/PixelHub-Client/src/PixelBotController.h
+++ b/PixelHub-Client/src/PixelBotController.h
@@ -8,35 +8,35 @@ class PixelBotController
public:
PixelBotController();
~PixelBotController();
-
- static const int STOP = 0;
- static const int FORWARDS = 1;
- static const int BACKWARDS = 2;
- static const int LEFT = 3;
- static const int RIGHT = 4;
+
+ static const int STOP = 0;
+ static const int FORWARDS = 1;
+ static const int BACKWARDS = 2;
+ static const int LEFT = 3;
+ static const int RIGHT = 4;
- void MoveDistance(int direction, int ticks);
+ void MoveDistance(int direction, int ticks);
void MoveTick(int direction);
- unsigned long GetTicksTravelled();
-
+ unsigned long GetTicksTravelled();
+
private:
- const int rmotorPin1 = 16;
- const int rmotorPin2 = 5;
- const int rmotorPin3 = 4;
- const int rmotorPin4 = 0;
-
- const int lmotorPin1 = 2;
- const int lmotorPin2 = 14;
- const int lmotorPin3 = 12;
- const int lmotorPin4 = 13;
-
- int motorLookup[8] = { 0b01000, 0b01100, 0b00100, 0b00110, 0b00010, 0b00011, 0b00001, 0b01001 };
-
- int motorSpeed = 1200; // The speed at which the stepper motor accepts bits
- unsigned long ticksTravelled = 0; // Number of steps travelled (including turns)
- int ticksPerRevolution = 512; // Number of steps per full revolution of the wheels
- int tickDelay = 1; // The delay in between ticks
+ const int rmotorPin1 = 16;
+ const int rmotorPin2 = 5;
+ const int rmotorPin3 = 4;
+ const int rmotorPin4 = 0;
+
+ const int lmotorPin1 = 2;
+ const int lmotorPin2 = 14;
+ const int lmotorPin3 = 12;
+ const int lmotorPin4 = 13;
+
+ int motorLookup[8] = { 0b01000, 0b01100, 0b00100, 0b00110, 0b00010, 0b00011, 0b00001, 0b01001 };
+
+ int motorSpeed = 1200; // The speed at which the stepper motor accepts bits
+ unsigned long ticksTravelled = 0; // Number of steps travelled (including turns)
+ int ticksPerRevolution = 512; // Number of steps per full revolution of the wheels
+ int tickDelay = 1; // The delay in between ticks
- void sendTickPart(int leftCode, int rightCode);
+ void sendTickPart(int leftCode, int rightCode);
};
diff --git a/PixelHub-Client/src/PixelMessage.cpp b/PixelHub-Client/src/PixelMessage.cpp
index 854e8a1..eb48244 100644
--- a/PixelHub-Client/src/PixelMessage.cpp
+++ b/PixelHub-Client/src/PixelMessage.cpp
@@ -4,28 +4,27 @@
PixelMessage::PixelMessage()
{
-
+
}
PixelMessage::PixelMessage(byte* rawMessage) : PixelMessage()
{
- // Casting solution from http://stackoverflow.com/a/300837/1460422
- // Basically, it casts a byte* pointer reference to the start of the bit we want to extract
- // into a void* (which is just a point that points to a specific point in memory without a
- // specific type associated with it), which we then cast into a pointer of the type we
- // actually want. This extra step is needed to get it to cast multiple consecutive bytes
- // in the raw message into the type we want.
- // With the casts done, we simply dereference the pointer to shove the value into the
- // instance of this class that we're building.
- ProtocolVersion = *(static_cast(static_cast(rawMessage)));
- MessageType = *(static_cast(static_cast(rawMessage + 2)));
- MessageId = *(static_cast(static_cast(rawMessage + 4)));
- MessageLength = *(static_cast(static_cast(rawMessage + 8)));
+ // Casting solution from http://stackoverflow.com/a/300837/1460422
+ // Basically, it casts a byte* pointer reference to the start of the bit we want to extract
+ // into a void* (which is just a point that points to a specific point in memory without a
+ // specific type associated with it), which we then cast into a pointer of the type we
+ // actually want. This extra step is needed to get it to cast multiple consecutive bytes
+ // in the raw message into the type we want.
+ // With the casts done, we simply dereference the pointer to shove the value into the
+ // instance of this class that we're building.
+ ProtocolVersion = *(static_cast(static_cast(rawMessage)));
+ MessageType = *(static_cast(static_cast(rawMessage + 2)));
+ MessageId = *(static_cast(static_cast(rawMessage + 4)));
+ MessageLength = *(static_cast(static_cast(rawMessage + 8)));
- // TODO: Sort out the payload here.
+ // TODO: Sort out the payload here.
}
PixelMessage::~PixelMessage()
{
-
+
}
-
diff --git a/PixelHub-Client/src/PixelMessage.h b/PixelHub-Client/src/PixelMessage.h
index eeccdbf..107b9e4 100644
--- a/PixelHub-Client/src/PixelMessage.h
+++ b/PixelHub-Client/src/PixelMessage.h
@@ -6,25 +6,24 @@
struct PixelMessage
{
public:
- PixelMessage();
- PixelMessage(byte* rawMessage);
- ~PixelMessage();
+ PixelMessage();
+ PixelMessage(byte* rawMessage);
+ ~PixelMessage();
- ///
- /// The length of the message header, in bytes.
- /// The message header contains things like the protocol version, the payload length, and the message type.
- ///
- static const unsigned int MESSAGE_HEADER_LENGTH = 12;
-
- // The protocol version associated with this message.
- unsigned short ProtocolVersion = 1;
- unsigned short MessageType = 1;
- unsigned int MessageId = 0;
- unsigned int MessageLength = 0;
+ ///
+ /// The length of the message header, in bytes.
+ /// The message header contains things like the protocol version, the payload length, and the message type.
+ ///
+ static const unsigned int MESSAGE_HEADER_LENGTH = 12;
- //const byte* Payload;
-
+ // The protocol version associated with this message.
+ unsigned short ProtocolVersion = 1;
+ unsigned short MessageType = 1;
+ unsigned int MessageId = 0;
+ unsigned int MessageLength = 0;
+
+ //const byte* Payload;
+
private:
-
+
};
-
diff --git a/PixelHub-Client/src/Utilities.cpp b/PixelHub-Client/src/Utilities.cpp
index 3f7c949..eed5696 100644
--- a/PixelHub-Client/src/Utilities.cpp
+++ b/PixelHub-Client/src/Utilities.cpp
@@ -15,9 +15,9 @@ int findChar(char* str, char targetChar)
/*
int getPosition(const char *array, size_t size, char c)
{
- const char* end = array + size;
- const char* match = std::find(array, end, c);
- return (end == match)? -1 : (match-array);
+ const char* end = array + size;
+ const char* match = std::find(array, end, c);
+ return (end == match)? -1 : (match-array);
}
*/
@@ -29,4 +29,3 @@ void Utilities::PrintCharsAsHex(char* charArray, size_t length)
Serial.print(" ");
}
}
-