daniel saakes / Olc
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WriterBase.h Source File

WriterBase.h

00001 #ifndef WRITER_BASE_H
00002 #define WRITER_BASE_H
00003 
00004 #include "stdint.h"
00005 
00006 namespace olc {
00007   
00008 /**
00009  *   write ol commands to a bytestring. 
00010  **/
00011 
00012 class WriterBase {
00013   public:
00014     WriterBase();
00015     
00016     bool penUp();
00017     bool penDown();
00018     bool wait(uint16_t aWait);
00019 
00020     
00021     bool moveTo(uint16_t aX, uint16_t aY );
00022     bool lineTo(uint16_t aX, uint16_t aY );
00023     bool setLaserPower(uint16_t aPower );
00024     bool setStepSize(uint16_t aStepSize );
00025     bool bitmapU8(uint8_t *aData, uint8_t aSize);
00026     bool areYouThere();
00027     bool ready();
00028     bool message(int aLevel, const char *aString);
00029   
00030     bool reportBufferInSize();
00031     bool bufferInSize(uint16_t aSize);
00032   
00033     bool readColor();
00034     bool reportColor(uint8_t c);
00035   
00036     void setData(uint8_t *aData, int aCapacity);
00037 
00038   
00039   // overload this for different buffer type.
00040   virtual int size() {
00041     return mPlayHead;
00042   }
00043   virtual int spaceLeft() {
00044     return mCapacity - mPlayHead;
00045   }
00046   
00047   protected:
00048   
00049   // overload this for different buffer type.
00050   virtual void put(uint8_t aData) {
00051     mData[mPlayHead] = aData;
00052     mPlayHead++;
00053   }
00054   
00055   void encodeU16(uint16_t u) {
00056     put( (uint8_t)(u >> 8) );
00057     put( (uint8_t)(u & 0xFF) );
00058   }
00059   
00060   uint8_t *mData;
00061   int mPlayHead;
00062   int mCapacity;
00063     
00064   bool mPenDown;
00065   uint16_t mLaserPower;
00066   uint16_t mGalvoX;
00067   uint16_t mGalvoY;
00068 };
00069   
00070   
00071 } // end namespace ol
00072 
00073 #endif // WRITER_BASE_H