Skip to content

Commit

Permalink
Fixed Sharp LCD initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurence Bank authored and Laurence Bank committed Jul 7, 2024
1 parent 5d3d41b commit 1aa7cb8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/OneBitDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ void ONE_BIT_DISPLAY::setBB(BBI2C *pBB)
memcpy(&_obd.bbi2c, pBB, sizeof(BBI2C));
} /* setBB() */

void ONE_BIT_DISPLAY::createVirtualDisplay(int width, int height, uint8_t *buffer)
{
obdCreateVirtualDisplay(&_obd, width, height, buffer);
}

void ONE_BIT_DISPLAY::SPIbegin(int iType, int32_t iSpeed)
{
obdSPIInit(&_obd, iType, _obd.iDCPin, _obd.iCSPin, _obd.iRSTPin, _obd.iMOSIPin, _obd.iCLKPin, _obd.iLEDPin, _obd.flip, _obd.invert, _obd.bBitBang, iSpeed);
Expand Down
1 change: 1 addition & 0 deletions src/OneBitDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ class ONE_BIT_DISPLAY
int displayPartial(int x, int y, int w, int h, uint8_t *pBuffer = NULL);
void setBitBang(bool bBitBang);
void setRender(bool bRAMOnly);
void createVirtualDisplay(int width, int height, uint8_t *buffer);
int I2Cbegin(int iType=OLED_128x64, int iAddr=-1, int32_t iSpeed=400000);
void setRotation(int iAngle);
uint8_t getRotation(void);
Expand Down
28 changes: 17 additions & 11 deletions src/obd.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,11 @@ void obdSPIInit(OBDISP *pOBD, int iType, int iDC, int iCS, int iReset, int iMOSI
if (pOBD->iCSPin != 0xff)
{
pinMode(pOBD->iCSPin, OUTPUT);
digitalWrite(pOBD->iCSPin, HIGH); // set to not-active
if (iType == SHARP_400x240 || iType == SHARP_128x128 || iType == SHARP_160x68) {
digitalWrite(pOBD->iCSPin, LOW);
} else {
digitalWrite(pOBD->iCSPin, HIGH); // set to not-active
}
}
if (bBitBang)
{
Expand Down Expand Up @@ -1648,6 +1652,8 @@ void obdSPIInit(OBDISP *pOBD, int iType, int iDC, int iCS, int iReset, int iMOSI
pOBD->chip_type = OBD_CHIP_SHARP;
pOBD->can_flip = 0;
pOBD->iDCPin = 0xff; // no D/C wire on this display
pOBD->iOrientation = 0;
return;
}
else if (iType == EPD583_648x480) {
pOBD->native_width = pOBD->width = 648;
Expand Down Expand Up @@ -2890,6 +2896,7 @@ static int EPDDumpFast(OBDISP *pOBD, uint8_t *pBuffer, int x, int y, int w, int
EPD154_Finish(pOBD, true);
}
if (pOBD->type == EPD29_128x296) {
pOBD->iOrientation = (pOBD->iOrientation + 180) % 360; // fix 180 deg offset of this init
EPD29_Begin(pOBD, x, y, w, h, true);
#ifndef WIMPY_MCU
EPDWriteImage(pOBD, UC8151_DTM2, NULL, x, y, w, h, 0);
Expand All @@ -2901,6 +2908,7 @@ static int EPDDumpFast(OBDISP *pOBD, uint8_t *pBuffer, int x, int y, int w, int
EPDWriteImage(pOBD, UC8151_DTM1, NULL, x, y, w, h, 0);
EPDWriteImage(pOBD, UC8151_DTM2, NULL, x, y, w, h, 0);
#endif
pOBD->iOrientation = (pOBD->iOrientation + 180) % 360; // restore original rotation
} else if (pOBD->type == EPD213_104x212 || pOBD->type == EPD213_122x250) {
EPD213_Begin(pOBD, x, y, w, h, true);
#ifndef WIMPY_MCU
Expand Down Expand Up @@ -4026,17 +4034,16 @@ uint8_t ucMask, uc1, *s, *d;
static int SharpDumpBuffer(OBDISP *pOBD, uint8_t *pBuffer)
{
int x, y;
uint8_t c, ucInvert, *s, *d, ucStart;
uint8_t ucLineBuf[56];
uint8_t c, ucInvert, ucStart, ucMask;
uint8_t *s, *d;
uint8_t ucLineBuf[64];
int iPitch = pOBD->native_width / 8;
static uint8_t ucVCOM = 0;
static int ucVCOM = 0;
int iBit;
uint8_t ucMask;

ucInvert = (pOBD->invert) ? 0x00 : 0xff;
digitalWrite(pOBD->iCSPin, HIGH); // active high

ucLineBuf[0] = 0;
ucLineBuf[0] = 0; // Tell RawWrite that it's command (doesn't matter for Sharp LCDs)
ucStart = 0x80; // write command
if (ucVCOM)
ucStart |= 0x40; // VCOM bit
Expand Down Expand Up @@ -4078,7 +4085,6 @@ uint8_t ucMask;
ucMask = 1 << (y & 7);
s = &pBuffer[pOBD->width * (y >> 3)]; // point to last line first
d = &ucLineBuf[2];

ucLineBuf[1] = pgm_read_byte(&ucMirror[y+1]); // current line number
for (x=0; x<pOBD->width/8; x++)
{
Expand All @@ -4090,11 +4096,11 @@ uint8_t ucMask;
s++;
}
*d++ = c;
} // for y
} // for x
// write this line to the display
ucLineBuf[iPitch+2] = 0; // end of line
*d++ = 0; // end of line
RawWrite(pOBD, ucLineBuf, iPitch+3);
} // for x
} // for y
} else if (pOBD->iOrientation == 90) {
for (x=0; x<pOBD->width; x++) {
s = &pBuffer[x+((pOBD->height-1)>>3)*pOBD->width];
Expand Down
2 changes: 1 addition & 1 deletion src/obd_io.inl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ uint8_t port, bitSCK, bitMOSI; // bit mask for the chosen pins
{
c = *pData++;
iLen--;
if (pOBD->iDCPin == 0xff) // 3-wire SPI, write D/C bit first
if (pOBD->iDCPin == 0xff && pOBD->chip_type != OBD_CHIP_SHARP) // 3-wire SPI, write D/C bit first
{
#ifdef __AVR__
if (pOBD->mode == MODE_DATA)
Expand Down

0 comments on commit 1aa7cb8

Please sign in to comment.