diff --git a/examples/three_color/three_color.ino b/examples/three_color/three_color.ino index 8c90ddd..220d6c3 100644 --- a/examples/three_color/three_color.ino +++ b/examples/three_color/three_color.ino @@ -12,14 +12,17 @@ BBEPAPER bbep(EPD154R_152x152); // 1.54" 152x152 B/W/R void setup() { bbep.initIO(DC_PIN, RESET_PIN, BUSY_PIN, CS_PIN); -// bbep.allocBuffer(); // use a back buffer + bbep.allocBuffer(); // use a back buffer bbep.fillScreen(BBEP_WHITE); bbep.setTextColor(BBEP_RED); - bbep.setFont(FONT_8x8); + bbep.setFont(FONT_12x16); bbep.println("bb_epaper v1"); bbep.setTextColor(BBEP_BLACK); bbep.println("B/W/R Test"); -// bbep.writePlane(); + for (int i=1; i<44; i++) { + bbep.drawCircle(bbep.width()/2, bbep.height()/2, i, (i < 22) ? BBEP_BLACK : BBEP_RED); + } + bbep.writePlane(); bbep.refresh(REFRESH_FULL); bbep.wait(); bbep.sleep(DEEP_SLEEP); diff --git a/src/bb_ep_gfx.inl b/src/bb_ep_gfx.inl index 7aad243..5a947ac 100644 --- a/src/bb_ep_gfx.inl +++ b/src/bb_ep_gfx.inl @@ -1303,7 +1303,7 @@ void bbepDrawLine(BBEPDISP *pBBEP, int x1, int y1, int x2, int y2, uint8_t ucCol for(; y1 <= y2; y1++) { mask = 0x80 >> (x1 & 7); // current bit offset if (pBBEP->ucScreen) { - p = &pBBEP->ucScreen[iRedOffset + (x1>>3) + (y1 * iPitch)]; // point if (ucColor == BBEP_BLACK) + p = &pBBEP->ucScreen[iRedOffset + (x1>>3) + (y1 * iPitch)]; // point bOld = bNew = p[0]; // current pixels } else { bOld = bNew = ucFill; @@ -1345,10 +1345,6 @@ static void DrawScaledPixel(BBEPDISP *pBBEP, int iCX, int iCY, int x, int y, int int iRedOffset = 0; iPitch = (pBBEP->width + 7) >> 3; - if (ucColor >= BBEP_YELLOW && pBBEP->iFlags & (BBEP_3COLOR | BBEP_4COLOR)) { - // use the second half of the image buffer - iRedOffset = iPitch * pBBEP->height; - } if (iXFrac != 0x10000) x = ((x * iXFrac) >> 16); if (iYFrac != 0x10000) y = ((y * iYFrac) >> 16); x += iCX; y += iCY; @@ -1356,12 +1352,26 @@ static void DrawScaledPixel(BBEPDISP *pBBEP, int iCX, int iCY, int x, int y, int pBBEP->last_error = BBEP_ERROR_BAD_PARAMETER; return; // off the screen } - d = &pBBEP->ucScreen[iRedOffset + (x>>3) + (y * iPitch)]; ucMask = 0x80 >> (x & 7); - if (ucColor) - *d |= ucMask; - else - *d &= ~ucMask; + d = &pBBEP->ucScreen[(x>>3) + (y * iPitch)]; + if (pBBEP->iFlags & (BBEP_3COLOR | BBEP_4COLOR)) { + // use the second half of the image buffer + iRedOffset = iPitch * pBBEP->height; + if (ucColor == BBEP_RED) { + d[iRedOffset] |= ucMask; // red has priority + } else { + d[iRedOffset] &= ~ucMask; // must remove red first + if (ucColor == BBEP_WHITE) + *d |= ucMask; + else + *d &= ~ucMask; + } + } else { + if (ucColor == BBEP_WHITE) + *d |= ucMask; + else + *d &= ~ucMask; + } } /* DrawScaledPixel() */ // // For drawing filled ellipses