Skip to content

Commit 2eda818

Browse files
committed
Latest changes
1 parent 167c415 commit 2eda818

File tree

7 files changed

+274
-64
lines changed

7 files changed

+274
-64
lines changed

src/Group5.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ typedef struct g5_enc_image_tag
148148
// 16-bit marker at the start of a BB_BITMAP file
149149
// (BitBank BitmapFile)
150150
#define BB_BITMAP_MARKER 0xBBBF
151+
#define BB_BITMAP2_MARKER 0xBBB2
151152

152153
// Font info per large character (glyph)
153154
typedef struct {

src/OneBitDisplay.cpp

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
// This define (WIMPY_MCU) precludes the use of hardware interfaces
1818
// such as I2C & SPI
1919
//
20-
#include "OneBitDisplay.h"
21-
2220
#if defined (__AVR_ATtiny85__) || defined (ARDUINO_ARCH_MCS51)
2321
#define WIMPY_MCU
2422
#endif
2523
#include "Group5.h"
26-
#ifdef _LINUX_
24+
#ifdef __LINUX__
2725
#include <stdint.h>
2826
#include <stdlib.h>
2927
#include <unistd.h>
@@ -34,31 +32,39 @@
3432
#include <sys/ioctl.h>
3533
#include <linux/i2c-dev.h>
3634
#include <math.h>
37-
#include <armbianio.h>
3835
#endif // MEMORY_ONLY
3936
// convert wire library constants into ArmbianIO values
37+
#ifdef GPIO_OUT
4038
#define OUTPUT GPIO_OUT
4139
#define INPUT GPIO_IN
4240
#define INPUT_PULLUP GPIO_IN_PULLUP
41+
#else
42+
#define OUTPUT 0
43+
#define INPUT 1
44+
#define INPUT_PULLUP 2
45+
#endif
4346
#define HIGH 1
4447
#define LOW 0
4548
void delay(int);
46-
#else // Arduino/IDF
47-
#ifdef ARDUINO
49+
#else // Arduino
50+
4851
#include <Arduino.h>
49-
#include "obd_io.inl" // I/O (non-portable) code is in here
5052
#ifdef __AVR__
5153
#include <avr/pgmspace.h>
5254
#endif
5355

5456
#ifndef WIMPY_MCU
5557
#include <SPI.h>
5658
#endif
57-
#else // !ARDUINO
58-
#include "esp_generic.inl"
59-
#endif
6059

61-
#endif // !_LINUX_
60+
#endif // __LINUX__
61+
#include "OneBitDisplay.h"
62+
#ifdef __LINUX__
63+
#include "linux_io.inl"
64+
#endif // __LINUX__
65+
#ifdef ARDUINO
66+
#include "obd_io.inl" // I/O (non-portable) code is in here
67+
#endif
6268
#include "obd.inl" // All of the display interface code is in here
6369
#include "obd_gfx.inl" // drawing code
6470
#ifdef __cplusplus
@@ -100,6 +106,9 @@ void ONE_BIT_DISPLAY::setI2CPins(int iSDA, int iSCL, int iReset)
100106
_obd.iSDAPin = iSDA;
101107
_obd.iSCLPin = iSCL;
102108
_obd.iRSTPin = iReset;
109+
#ifdef __LINUX__
110+
_obd.bbi2c.file_i2c = -1;
111+
#endif
103112
}
104113
void ONE_BIT_DISPLAY::setBitBang(bool bBitBang)
105114
{
@@ -192,7 +201,7 @@ void ONE_BIT_DISPLAY::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint1
192201
obdRectangle(&_obd, x, y, x+w-1, y+h-1, color, 1);
193202
} /* fillRect() */
194203

195-
void ONE_BIT_DISPLAY::setWordWrap(bool bWrap)
204+
void ONE_BIT_DISPLAY::setTextWrap(bool bWrap)
196205
{
197206
_obd.wrap = (int)bWrap;
198207
}
@@ -211,11 +220,11 @@ void ONE_BIT_DISPLAY::setCursor(int x, int y)
211220
_obd.iCursorY = y;
212221
} /* setCursor() */
213222

214-
int ONE_BIT_DISPLAY::drawG5Image(const uint8_t *pG5, int x, int y, int iFG, int iBG, float fScale)
223+
int ONE_BIT_DISPLAY::loadG5Image(const uint8_t *pG5, int x, int y, int iFG, int iBG, float fScale)
215224
{
216225
return obdLoadG5(&_obd, pG5, x, y, iFG, iBG, fScale);
217226
}
218-
int ONE_BIT_DISPLAY::drawBMP(const uint8_t *pBMP, int x, int y, int iFG, int iBG)
227+
int ONE_BIT_DISPLAY::loadBMP(const uint8_t *pBMP, int x, int y, int iFG, int iBG)
219228
{
220229
return obdLoadBMP(&_obd, pBMP, x, y, iFG, iBG);
221230
} /* loadBMP() */
@@ -266,7 +275,8 @@ int y, iLines;
266275
}
267276
memset(&pOBD->ucScreen[(iLines-iAmount) * pOBD->width], (char)pOBD->iBG, pOBD->width*iAmount);
268277
} /* obdScroll1Line() */
269-
#ifdef _LINUX_
278+
#ifdef __LINUX__
279+
#ifdef FUTURE
270280
void ONE_BIT_DISPLAY::print(const string &str)
271281
{
272282
print(str.c_str());
@@ -282,7 +292,7 @@ char ucTemp[4];
282292
ucTemp[2] = 0;
283293
print((const char *)ucTemp);
284294
} /* print() */
285-
295+
#endif // FUTURE
286296
void ONE_BIT_DISPLAY::print(const char *pString)
287297
{
288298
uint8_t *s = (uint8_t *)pString;
@@ -363,11 +373,11 @@ char ucTemp[4];
363373
print((const char *)ucTemp);
364374
} /* println() */
365375

366-
#endif // _LINUX_
376+
#endif // __LINUX__
367377
//
368378
// write (Arduino Print friend class)
369379
//
370-
#if !defined( __AVR__ ) && defined( ARDUINO )
380+
#ifndef __AVR__
371381
size_t ONE_BIT_DISPLAY::write(uint8_t c) {
372382
char szTemp[2]; // used to draw 1 character at a time to the C methods
373383
int w, h;
@@ -448,8 +458,8 @@ static uint8_t u8Unicode0, u8Unicode1;
448458
} else { // Custom font
449459
BB_FONT *pBBF;
450460
BB_FONT_SMALL *pBBFS;
451-
BB_GLYPH *pGlyph;
452-
BB_GLYPH_SMALL *pSmallGlyph;
461+
BB_GLYPH *pGlyph=NULL;
462+
BB_GLYPH_SMALL *pSmallGlyph=NULL;
453463
int first, last;
454464
if (pgm_read_word(_obd.pFont) == BB_FONT_MARKER) {
455465
pBBF = (BB_FONT *)_obd.pFont; pBBFS = NULL;
@@ -518,6 +528,14 @@ void ONE_BIT_DISPLAY::getStringBox(const String &str, BB_RECT *pRect)
518528
obdGetStringBox(&_obd, str.c_str(), pRect);
519529
}
520530
#endif
531+
int ONE_BIT_DISPLAY::dataTime(void)
532+
{
533+
return _obd.iDataTime;
534+
}
535+
int ONE_BIT_DISPLAY::opTime(void)
536+
{
537+
return _obd.iOpTime;
538+
}
521539
int16_t ONE_BIT_DISPLAY::width(void)
522540
{
523541
return _obd.width;
@@ -602,7 +620,7 @@ void ONE_BIT_DISPLAY::drawString(String text, int x, int y)
602620
{
603621
drawString(text.c_str(), x, y);
604622
} /* drawString() */
605-
#endif // ARDUINO
623+
#endif
606624
void ONE_BIT_DISPLAY::backlight(int bOn)
607625
{
608626
obdBacklight(&_obd, bOn);

src/OneBitDisplay.h

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,24 @@
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__
2327
typedef 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
5248
enum {
@@ -136,14 +132,12 @@ enum {
136132
ANGLE_FLIPY
137133
};
138134

139-
#ifndef __BB_EPAPER__
140135
typedef struct {
141136
int x;
142137
int y;
143138
int w;
144139
int h;
145140
} BB_RECT;
146-
#endif
147141

148142
typedef 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>
179173
using namespace std;
180174
class ONE_BIT_DISPLAY
181175
#else // Arduino
182-
#if !defined( __AVR__ ) && defined( ARDUINO )
176+
#ifndef __AVR__
183177
class ONE_BIT_DISPLAY : public Print
184178
#else
185179
class 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)
299297
extern "C" {
300298
#endif
301299

@@ -540,7 +538,7 @@ uint8_t * obdPlayAnimFrame(OBDISP *pOBD, uint8_t *pAnimation, uint8_t *pCurrent,
540538
void obdWriteCommand(OBDISP *pOBD, unsigned char c);
541539
void obdSetPosition(OBDISP *pOBD, int x, int y, int bRender);
542540
void 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
//
617615
int 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

src/g5enc.inl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static void G5ENCFlushBits(G5_BUFFERED_BITS *bb)
8484
// Initialize the compressor
8585
// This must be called before adding data to the output
8686
//
87-
int g5_encode_init(G5ENCIMAGE *pImage, int iWidth, int iHeight, uint8_t *pOut, int iOutSize)
87+
static int g5_encode_init(G5ENCIMAGE *pImage, int iWidth, int iHeight, uint8_t *pOut, int iOutSize)
8888
{
8989
int iError = G5_SUCCESS;
9090

@@ -197,7 +197,7 @@ doblack:
197197
// Returns G5ENC_SUCCESS for each line if all is well and G5ENC_IMAGE_COMPLETE
198198
// for the last line
199199
//
200-
int g5_encode_encodeLine(G5ENCIMAGE *pImage, uint8_t *pPixels)
200+
static int g5_encode_encodeLine(G5ENCIMAGE *pImage, uint8_t *pPixels)
201201
{
202202
int16_t a0, a0_c, b2, a1;
203203
int dx, run1, run2;
@@ -302,7 +302,7 @@ G5_BUFFERED_BITS bb;
302302
//
303303
// Returns the number of bytes of G5 created by the encoder
304304
//
305-
int g5_encode_getOutSize(G5ENCIMAGE *pImage)
305+
static int g5_encode_getOutSize(G5ENCIMAGE *pImage)
306306
{
307307
int iSize = 0;
308308
if (pImage != NULL)

0 commit comments

Comments
 (0)