Diff: WriterBase.h
- Revision:
- 1:578d6bbe9f09
- Child:
- 2:ce4c7e5ab241
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WriterBase.h Fri Dec 16 07:14:05 2011 +0000 @@ -0,0 +1,70 @@ +#ifndef WRITER_BASE_H +#define WRITER_BASE_H + +#include "stdint.h" + +namespace olc { + +/** + * write ol commands to a bytestring. + **/ + +class WriterBase { + public: + WriterBase(); + + bool penUp(); + bool penDown(); + bool wait(uint16_t aWait); + + + bool moveTo(uint16_t aX, uint16_t aY ); + bool lineTo(uint16_t aX, uint16_t aY ); + bool setLaserPower(uint16_t aPower ); + bool setStepSize(uint16_t aStepSize ); + bool bitmapU8(uint8_t *aData, uint8_t aSize); + bool areYouThere(); + bool ready(); + bool message(int aLevel, const char *aString); + + bool readRgb(); + bool reportRgb(uint8_t r, uint8_t g, uint8_t b); + + void setData(uint8_t *aData, int aCapacity); + + + // overload this for different buffer type. + virtual int size() { + return mPlayHead; + } + virtual int spaceLeft() { + return mCapacity - mPlayHead; + } + + protected: + + // overload this for different buffer type. + virtual void put(uint8_t aData) { + mData[mPlayHead] = aData; + mPlayHead++; + } + + void encodeU16(uint16_t u) { + put( (uint8_t)(u >> 8) ); + put( (uint8_t)(u & 0xFF) ); + } + + uint8_t *mData; + int mPlayHead; + int mCapacity; + + bool mPenDown; + uint16_t mLaserPower; + uint16_t mGalvoX; + uint16_t mGalvoY; +}; + + +} // end namespace ol + +#endif // WRITER_BASE_H