1515// limitations under the License.
1616#ifndef __ONEBITDISPLAY__
1717#define __ONEBITDISPLAY__
18- #include < stdint.h>
19- #include < string.h>
20- #if defined( ARDUINO ) && !defined( MEMORY_ONLY )
18+
19+ #if !defined( MEMORY_ONLY ) && defined(ARDUINO)
2120#include < BitBang_I2C.h>
22- #else
21+ #endif
22+
23+ // For Linux and esp-idf we add a file/device handle member
24+ // to the BBI2C structure
25+ #if !defined( ARDUINO ) && !defined(__BB_I2C__)
26+ #define __BB_I2C__
2327typedef struct _tagbbi2c
2428{
2529 int file_i2c;
2630 uint8_t iSDA, iSCL;
2731 uint8_t bWire;
2832} BBI2C;
29- #define PROGMEM
30- #define LOW 0
31- #define HIGH 1
32- #define pgm_read_byte (a ) (*(uint8_t *)a)
33- #define pgm_read_word (a ) (*(uint16_t *)a)
34- #define memcpy_P memcpy
35- static void delayMicroseconds (uint32_t iTime);
36- static void _delay (int ms);
3733#endif
3834
39- #if defined ( IDF_PLATFORM ) || defined( _LINUX_ )
35+ #ifdef __LINUX__
4036// for Print support
4137#define DEC 10
4238#define HEX 16
@@ -46,7 +42,7 @@ static void _delay(int ms);
4642#include < stdlib.h>
4743#include < string.h>
4844#include < stdio.h>
49- #endif // _LINUX_
45+ #endif // __LINUX__
5046
5147// error messages
5248enum {
@@ -136,14 +132,12 @@ enum {
136132 ANGLE_FLIPY
137133};
138134
139- #ifndef __BB_EPAPER__
140135typedef struct {
141136 int x;
142137 int y;
143138 int w;
144139 int h;
145140} BB_RECT;
146- #endif
147141
148142typedef struct obdstruct
149143{
@@ -174,20 +168,20 @@ uint8_t bBitBang;
174168} OBDISP;
175169
176170#ifdef __cplusplus
177- #ifdef _LINUX_
171+ #ifdef __LINUX__
178172#include < string>
179173using namespace std ;
180174class ONE_BIT_DISPLAY
181175#else // Arduino
182- #if !defined( __AVR__ ) && defined( ARDUINO )
176+ #ifndef __AVR__
183177class ONE_BIT_DISPLAY : public Print
184178#else
185179class ONE_BIT_DISPLAY
186180#endif // !__AVR__
187- #endif // _LINUX_
181+ #endif // __LINUX__
188182{
189183 public:
190- ONE_BIT_DISPLAY () { memset (&_obd, 0 , sizeof (_obd)); _obd.iFG = OBD_BLACK; _obd.render = 1 ; _obd.type = OLED_128x64; _obd.iSpeed = 400000 ;}
184+ ONE_BIT_DISPLAY () { _obd.iFG = OBD_BLACK; _obd.render = 1 ; _obd.type = OLED_128x64; _obd.iSpeed = 400000 ;}
191185 void SPIbegin (int iType = OLED_128x64, int32_t iSpeed = 2000000 );
192186 void setSPIPins (int iCS, int iMOSI, int iSCLK, int iDC, int iReset=-1 , int iLED=-1 );
193187 void setI2CPins (int iSDA, int iSCL, int iReset=-1 );
@@ -200,6 +194,8 @@ class ONE_BIT_DISPLAY
200194 void setContrast (uint8_t ucContrast);
201195 int display (bool bRefresh = true , bool bWait = true , bool bFast = false );
202196 void displayLines (int iStartLine, int iLineCount);
197+ int dataTime ();
198+ int opTime ();
203199 void setBitBang (bool bBitBang);
204200 void setRender (bool bRAMOnly);
205201 void createVirtualDisplay (int width, int height, uint8_t *buffer);
@@ -222,15 +218,17 @@ class ONE_BIT_DISPLAY
222218 void setTextColor (int iFG, int iBG = -1 );
223219 void setCursor (int x, int y);
224220 void setPower (bool bOn);
225- int drawBMP (const uint8_t *pBMP, int x, int y, int iFG, int iBG);
226- int drawG5Image (const uint8_t *pG5, int x, int y, int iFG = OBD_BLACK, int iBG = OBD_WHITE, float fScale = 1 .0f );
221+ int loadBMP (const uint8_t *pBMP, int x, int y, int iFG, int iBG);
222+ int loadG5Image (const uint8_t *pG5, int x, int y, int iFG = OBD_BLACK, int iBG = OBD_WHITE, float fScale = 1 .0f );
227223 int16_t getCursorX (void );
228224 int16_t getCursorY (void );
225+ void wake (void );
226+ void sleep (int bDeep);
229227 void getStringBox (const char *string, BB_RECT *pRect);
230- #ifdef ARDUINO
228+ #ifdef ARDUINO
231229 void getStringBox (const String &str, BB_RECT *pRect);
232- #endif
233- void setWordWrap (bool bWrap);
230+ #endif
231+ void setTextWrap (bool bWrap);
234232 void setFont (int iFont);
235233 void setFont (const void *pFont);
236234 int16_t height (void );
@@ -252,7 +250,7 @@ class ONE_BIT_DISPLAY
252250 void drawEllipse (int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color);
253251 void fillEllipse (int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color);
254252 int drawGFX (uint8_t *pSrc, int iSrcCol, int iSrcRow, int iDestCol, int iDestRow, int iWidth, int iHeight, int iSrcPitch);
255- #ifdef _LINUX_
253+ #ifdef __LINUX__
256254 void print (const char *pString);
257255 void println (const char *pString);
258256 void print (int , int );
@@ -262,11 +260,11 @@ class ONE_BIT_DISPLAY
262260 size_t write (uint8_t ucChar);
263261 void delayMicroseconds (int iTime);
264262#else
265- #if !defined( __AVR__ ) && defined( ARDUINO )
263+ #ifndef __AVR__
266264 using Print::write;
267265 virtual size_t write (uint8_t );
268266#endif // !__AVR__
269- #endif // _LINUX_
267+ #endif // __LINUX__
270268
271269 private:
272270 OBDISP _obd;
@@ -295,7 +293,7 @@ typedef struct smenu {
295293} SIMPLEMENU;
296294
297295// Make the Linux library interface C instead of C++
298- #if defined(_LINUX_ ) && defined(__cplusplus)
296+ #if defined(__LINUX__ ) && defined(__cplusplus)
299297extern " C" {
300298#endif
301299
@@ -540,7 +538,7 @@ uint8_t * obdPlayAnimFrame(OBDISP *pOBD, uint8_t *pAnimation, uint8_t *pCurrent,
540538void obdWriteCommand (OBDISP *pOBD, unsigned char c);
541539void obdSetPosition (OBDISP *pOBD, int x, int y, int bRender);
542540void obdWriteDataBlock (OBDISP *pOBD, unsigned char *ucBuf, int iLen, int bRender);
543- void RawWriteData (OBDISP *pOBD, unsigned char *ucBuf, int iLen);
541+ // void RawWriteData(OBDISP *pOBD, unsigned char *ucBuf, int iLen);
544542//
545543// Scroll the internal buffer by 1 scanline (up/down)
546544// width is in pixels, lines is group of 8 rows
@@ -616,9 +614,9 @@ int obdMenuDelta(SIMPLEMENU *sm, int iDelta);
616614//
617615int obdMenuRun (SIMPLEMENU *sm);
618616
619- #if defined(_LINUX_ ) && defined(__cplusplus)
617+ #if defined(__LINUX__ ) && defined(__cplusplus)
620618}
621- #endif // _LINUX_
619+ #endif // __LINUX__
622620
623621#endif // __ONEBITDISPLAY__
624622
0 commit comments