Revision 2:ce4c7e5ab241, committed 2011-12-22
- Comitter:
- daan
- Date:
- Thu Dec 22 09:44:29 2011 +0000
- Parent:
- 1:578d6bbe9f09
- Commit message:
Changed in this revision
--- a/PlayerBase.cpp Fri Dec 16 07:14:05 2011 +0000
+++ b/PlayerBase.cpp Thu Dec 22 09:44:29 2011 +0000
@@ -109,7 +109,9 @@
break;
// sending a message. length is as strlen: number of characters
// preceeding the terminating /0 character
-
+ case olc:: REPORT_BUFFER_IN_SIZE:
+ reportBufferInSize();
+ break;
case olc::WAIT:
delay = decodeU16();
wait(delay);
@@ -138,8 +140,8 @@
y = decodeU16();
point(x,y);
break;
- case olc::READ_RGB:
- readRgb();
+ case olc::READ_COLOR:
+ readColor();
break;
case olc::AYT:
areYouThere();
@@ -153,7 +155,7 @@
g = get();
b = get();
setLaserPowerRgb(r,g,b);
-
+ break;
case olc::LASER_POWER:
//std::cout << "laser power" << std::endl;
mLaserPower = decodeU16();
--- a/PlayerBase.h Fri Dec 16 07:14:05 2011 +0000
+++ b/PlayerBase.h Thu Dec 22 09:44:29 2011 +0000
@@ -12,13 +12,14 @@
virtual void setGalvo(uint16_t x, uint16_t y);
virtual void setLaserPower(uint16_t power);
virtual void wait(uint16_t ms);
+ virtual void reportBufferInSize() {};
// this is for scanning to calibrate camera.
virtual void calibrationScan() {};
virtual void point(uint16_t x, uint16_t y) {};
// this is for color scanning
- virtual void readRgb() {};
+ virtual void readColor() {};
virtual void setLaserPowerRgb(uint8_t red, uint8_t green, uint8_t blue) {};
virtual void ready() {};
--- a/PlayerEmbedded.h Fri Dec 16 07:14:05 2011 +0000
+++ b/PlayerEmbedded.h Thu Dec 22 09:44:29 2011 +0000
@@ -13,7 +13,7 @@
class PlayerEmbedded : public PlayerBase
{
public:
- PlayerEmbedded(fou::RingBuffer2k &aBuffer) : mBuffer(aBuffer) {};
+ PlayerEmbedded(fou::RingBuffer8k &aBuffer) : mBuffer(aBuffer) {};
// void setGalvo(uint16_t x, uint16_t y);
// void setLaserPower(uint16_t power);
@@ -30,7 +30,7 @@
return d;
};
- fou::RingBuffer2k& mBuffer;
+ fou::RingBuffer8k& mBuffer;
};
--- a/VectorFormat.h Fri Dec 16 07:14:05 2011 +0000
+++ b/VectorFormat.h Thu Dec 22 09:44:29 2011 +0000
@@ -68,14 +68,21 @@
CALIBRATION_SCAN = 17, // 1 uint8 opcode uint16 top_x, uint16 left_y, uint16 bottom_x, uint16 right_y
POINT = 18, // 1 unit8 opcode uint16 x, uint16 y
- READ_RGB = 19, // 1 uint8 opcode uint8
+ READ_COLOR = 19, // 1 uint8 opcode uint8
MESSAGE = 20, // 3+x uint8 opcode, level, length of message, x bytes
BUFFER_LEFT_REPORT = 21, // opcode, uint16_t
WAIT = 22, // opcode, uint16t time
AYT = 23, // are you there
- REPORT_RGB = 25, // 1 + 3 x uint8
+ REPORT_COLOR = 25, // 1 + 3 x uint8
+
+
+ REPORT_BUFFER_IN_SIZE = 26, // 1 + uint16 size
+ BUFFER_IN_SIZE = 27, // 1
+
+ ACK = 30,
+ NACK = 31,
LINE_TO = PEN_DOWN + MOVE_TO, // 5 uint8 opcode, uint16 x, uint16 y
H_LINE_TO = PEN_DOWN + H_MOVE_TO, // 3 uint8 opcode, uint16 x
--- a/WriterBase.cpp Fri Dec 16 07:14:05 2011 +0000
+++ b/WriterBase.cpp Thu Dec 22 09:44:29 2011 +0000
@@ -74,24 +74,38 @@
return true;
}
-bool olc::WriterBase::readRgb()
+bool olc::WriterBase::readColor()
{
if (spaceLeft() < 2) return false;
- put( (uint8_t)olc::READ_RGB );
+ put( (uint8_t)olc::READ_COLOR );
return true;
}
-bool olc::WriterBase::reportRgb(uint8_t r, uint8_t g, uint8_t b)
+bool olc::WriterBase::reportColor(uint8_t c)
{
if (spaceLeft() < 4) return false;
- put( (uint8_t)olc::REPORT_RGB );
- put( r );
- put( g );
- put( b );
+ put( (uint8_t)olc::REPORT_COLOR );
+ put( c );
return true;
}
-bool olc::WriterBase::bitmapU8(uint8_t *aData, uint8_t aSize) {
+bool olc::WriterBase::reportBufferInSize()
+{
+ if (spaceLeft() < 2) return false;
+ put( (uint8_t)olc::REPORT_BUFFER_IN_SIZE );
+ return true;
+}
+
+bool olc::WriterBase::bufferInSize(uint16_t aSize)
+{
+ if (spaceLeft() < 3) return false;
+ put( (uint8_t)olc::BUFFER_IN_SIZE );
+ encodeU16( aSize );
+ return true;
+}
+
+bool olc::WriterBase::bitmapU8(uint8_t *aData, uint8_t aSize)
+{
if (spaceLeft() < 2) return false;
put( (uint8_t)olc::BITMAPU8 );
put( aSize );
--- a/WriterBase.h Fri Dec 16 07:14:05 2011 +0000
+++ b/WriterBase.h Thu Dec 22 09:44:29 2011 +0000
@@ -27,8 +27,11 @@
bool ready();
bool message(int aLevel, const char *aString);
- bool readRgb();
- bool reportRgb(uint8_t r, uint8_t g, uint8_t b);
+ bool reportBufferInSize();
+ bool bufferInSize(uint16_t aSize);
+
+ bool readColor();
+ bool reportColor(uint8_t c);
void setData(uint8_t *aData, int aCapacity);