MCPcopy Create free account
hub / github.com/OpenStickCommunity/GP2040-CE / SharpDumpBuffer

Function SharpDumpBuffer

lib/OneBitDisplay/OneBitDisplay.cpp:710–786  ·  view source on GitHub ↗

Special case for Sharp Memory LCD

Source from the content-addressed store, hash-verified

708// Special case for Sharp Memory LCD
709//
710static void SharpDumpBuffer(OBDISP *pOBD, uint8_t *pBuffer)
711{
712 int x, y;
713 uint8_t c, ucInvert, *s, *d, ucStart;
714 uint8_t ucLineBuf[56];
715 int iPitch = pOBD->width / 8;
716 static uint8_t ucVCOM = 0;
717 int iBit;
718 uint8_t ucMask;
719
720 ucInvert = (pOBD->invert) ? 0x00 : 0xff;
721 gpio_put(pOBD->iCSPin, HIGH); // active high
722
723 ucLineBuf[0] = 0;
724 ucStart = 0x80; // write command
725 if (ucVCOM)
726 ucStart |= 0x40; // VCOM bit
727 ucLineBuf[1] = ucStart;
728 // this code assumes I2C, so the first byte is ignored
729 _I2CWrite(pOBD, ucLineBuf, 2); // write command(01) + vcom(02)
730 ucVCOM = !ucVCOM; // need to toggle this each transaction
731
732 // We need to flip and invert the image in code because the Sharp memory LCD
733 // controller only has the simplest of commands for data writing
734 if (pOBD->flip)
735 {
736 for (y = 0; y < pOBD->height; y++) // we have to write the memory in the wrong direction
737 {
738 ucMask = 0x80 >> (y & 7);
739 s = &pBuffer[pOBD->width - 1 + (pOBD->width * ((pOBD->height - 1 - y) >> 3))]; // point to last line first
740 d = &ucLineBuf[2];
741 ucLineBuf[1] = ucMirror[y + 1]; // current line number
742 for (x = 0; x < pOBD->width / 8; x++)
743 {
744 c = ucInvert; // we need to brute-force invert it
745 for (iBit = 7; iBit >= 0; iBit--)
746 {
747 if (s[0] & ucMask)
748 c ^= (1 << iBit);
749 s--;
750 }
751 *d++ = c;
752 } // for y
753 // write this line to the display
754 ucLineBuf[iPitch + 2] = 0; // end of line
755 _I2CWrite(pOBD, ucLineBuf, iPitch + 3);
756 } // for x
757 }
758 else // normal orientation
759 {
760 for (y = 0; y < pOBD->height; y++) // we have to write the memory in the wrong direction
761 {
762 ucMask = 1 << (y & 7);
763 s = &pBuffer[pOBD->width * (y >> 3)]; // point to last line first
764 d = &ucLineBuf[2];
765
766 ucLineBuf[1] = ucMirror[y + 1]; // current line number
767 for (x = 0; x < pOBD->width / 8; x++)

Callers 1

obdDumpBufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected