diff --git a/rpi/examples/hello_epaper/main.cpp b/rpi/examples/hello_epaper/main.cpp index 296b626..e8ca75f 100644 --- a/rpi/examples/hello_epaper/main.cpp +++ b/rpi/examples/hello_epaper/main.cpp @@ -7,7 +7,8 @@ #include "../../../src/bb_epaper.h" //BBEPAPER bbep(EPD213_104x212); // InkyPHAT 2.13" BBEPAPER bbep(EPD295_128x296); -// BCM GPIO numbers +//BBEPAPER bbep(EPD154R_152x152); +// BCM GPIO numbers used by Pimoroni e-paper "HATs" #define PIN_DC 22 #define PIN_RST 27 #define PIN_BUSY 17 @@ -16,18 +17,20 @@ BBEPAPER bbep(EPD295_128x296); int main(int argc, const char * argv[]) { - bbep.initIO(PIN_DC, PIN_RST, PIN_BUSY, PIN_CS, SPI_BUS, 4000000); -// bbep.allocBuffer(); + bbep.initIO(PIN_DC, PIN_RST, PIN_BUSY, PIN_CS, SPI_BUS, 8000000); + bbep.allocBuffer(); // draw into RAM first bbep.fillScreen(BBEP_WHITE); bbep.setRotation(90); - bbep.setFont(FONT_16x16); + bbep.setFont(FONT_12x16); bbep.setTextColor(BBEP_BLACK); bbep.drawString("Hello World!", 0, 0); -// bbep.writePlane(); - bbep.refresh(REFRESH_FULL); - bbep.sleep(DEEP_SLEEP); + bbep.setTextColor(BBEP_RED); // will be black on B/W panels + bbep.drawString("In red!", 0, 16); + bbep.writePlane(); // push the pixels from our RAM buffer to the e-epaper + bbep.refresh(REFRESH_FULL); // do a full refresh (only type possible on B/W/R) + bbep.sleep(DEEP_SLEEP); // turn off the epaper power circuit - return 0; + return 0; } /* main() */ diff --git a/src/bb_ep.inl b/src/bb_ep.inl index 39dc391..09f868e 100644 --- a/src/bb_ep.inl +++ b/src/bb_ep.inl @@ -1270,6 +1270,12 @@ void bbepFill(BBEPDISP *pBBEP, unsigned char ucData, int iPlane) } else if (ucData == BBEP_RED) { uc1 = 0x00; uc2 = 0xff; } + } else { // B/W + if (ucData == BBEP_WHITE) { + uc1 = uc2 = 0xff; + } else { + uc1 = uc2 = 0x00; + } } if (pBBEP->ucScreen) { // there's a local framebuffer, use it memset(pBBEP->ucScreen, uc1, iSize); diff --git a/src/bb_ep_gfx.inl b/src/bb_ep_gfx.inl index 5a947ac..6338b45 100644 --- a/src/bb_ep_gfx.inl +++ b/src/bb_ep_gfx.inl @@ -1090,7 +1090,7 @@ int bbepWriteString(BBEPDISP *pBBEP, int x, int y, char *szMsg, int iSize, int i } #endif } - pBBEP->iCursorX += iLen; + x = pBBEP->iCursorX += iLen; if (pBBEP->iCursorX >= pBBEP->width-11 && pBBEP->wrap) // word wrap enabled? { x = pBBEP->iCursorX = 0; // start at the beginning of the next line