Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
PlayerBase.h
00001 #ifndef PLAYER_BASE_H 00002 #define PLAYER_BASE_H 00003 00004 #include "stdint.h" 00005 00006 namespace olc { 00007 00008 class PlayerBase 00009 { 00010 public: 00011 PlayerBase(); 00012 virtual void setGalvo(uint16_t x, uint16_t y); 00013 virtual void setLaserPower(uint16_t power); 00014 virtual void wait(uint16_t ms); 00015 virtual void reportBufferInSize() {}; 00016 00017 // this is for scanning to calibrate camera. 00018 virtual void calibrationScan() {}; 00019 virtual void point(uint16_t x, uint16_t y) {}; 00020 00021 // this is for color scanning 00022 virtual void readColor() {}; 00023 virtual void setLaserPowerRgb(uint8_t red, uint8_t green, uint8_t blue) {}; 00024 00025 virtual void ready() {}; 00026 virtual void areYouThere() {}; 00027 virtual void message(int aLevel, int aLength, char *aString) {}; 00028 00029 00030 inline void penDown() { 00031 mPenDown = true; 00032 setLaserPower(mLaserPower); 00033 } 00034 inline void penUp() { 00035 mPenDown = false; 00036 setLaserPower(0); 00037 } 00038 00039 void setData(uint8_t *data, int size); 00040 void setStepSize(uint16_t s) { mStepSize = s; }; 00041 uint16_t getStepSize() { return mStepSize; }; 00042 void setDelay(uint16_t ms) { mDelay = ms; }; 00043 void reset(); 00044 bool hasNext(); 00045 bool playOne(); 00046 00047 uint16_t getX() { return mGalvoX; }; 00048 uint16_t getY() { return mGalvoY; }; 00049 00050 protected: 00051 void rasterLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int step=1); 00052 00053 00054 inline virtual int bytesLeft() { 00055 return mSize - mPlayHead; 00056 } 00057 inline virtual uint8_t get() { 00058 mPlayHead++; 00059 return mData[mPlayHead-1]; 00060 } 00061 00062 // TODO(dps): take care of endian 00063 inline uint16_t decodeU16() { 00064 uint16_t i; 00065 i = (uint16_t)get() << 8; 00066 i |= (uint16_t)get(); 00067 return i; 00068 } 00069 00070 00071 uint8_t *mData; 00072 int mSize; 00073 int mPlayHead; 00074 00075 bool mPenDown; 00076 uint16_t mLaserPower; 00077 uint16_t mGalvoX; 00078 uint16_t mGalvoY; 00079 uint16_t mDelay; 00080 uint16_t mStepSize; 00081 }; 00082 00083 00084 }; // end namespace ol 00085 00086 #endif // PLAYER_BASE_H
Generated on Thu Jul 28 2022 18:01:06 by
1.7.2