Witam.
Mam problem z wyświetlenie znaku na tym wyświetlaczu.Wszystko inne daje radę wyświetlić (kwadraty,koła i inne). Wszystko sie kompiluje, ale po wysłaniu do uC ekran jest czarny, nawet jak przed wyświetleniem znaku wypełniam ekran na biało.
Zamieszczam kod funkcji. W czym może być problem?
Mam problem z wyświetlenie znaku na tym wyświetlaczu.Wszystko inne daje radę wyświetlić (kwadraty,koła i inne). Wszystko sie kompiluje, ale po wysłaniu do uC ekran jest czarny, nawet jak przed wyświetleniem znaku wypełniam ekran na biało.
Zamieszczam kod funkcji. W czym może być problem?
void LCDPutChar(char c, int x, int y, int size, int fColor, int bColor) {
extern const unsigned char FONT6x8[97][8];
extern const unsigned char FONT8x8[97][8];
extern const unsigned char FONT8x16[97][16];
int i,j;
unsigned int nCols;
unsigned int nRows;
unsigned int nBytes;
unsigned char PixelRow;
unsigned char Mask;
unsigned int Word0;
unsigned int Word1;
unsigned char *pFont;
unsigned char *pChar;
unsigned char *FontTable[] = {(unsigned char *)FONT6x8,
(unsigned char *)FONT8x8,
(unsigned char *)FONT8x16};
// get pointer to the beginning of the selected font table
pFont = (unsigned char *)FontTable[size];
// get the nColumns, nRows and nBytes
nCols = *pFont;
nRows = *(pFont + 1);
nBytes = *(pFont + 2);
// get pointer to the last byte of the desired character
pChar = pFont + (nBytes * (c - 0x1F)) + nBytes - 1;
// Row address set (command 0x2B)
sendCMD(PASET);
sendData(x);
sendData(x + nRows - 1);
// Column address set (command 0x2A)
sendCMD(CASET);
sendData(y);
sendData(y + nCols - 1);
// WRITE MEMORY
sendCMD(RAMWR);
// loop on each row, working backwards from the bottom to the top
for (i = nRows - 1; i >= 0; i--) {
// copy pixel row from font table and then decrement row
PixelRow = *pChar--;
// loop on each pixel in the row (left to right)
// Note: we do two pixels each loop
Mask = 0x80;
for (j = 0; j < nCols; j += 2) {
// if pixel bit set, use foreground color; else use the background color
// now get the pixel color for two successive pixels
if ((PixelRow & Mask) == 0)
Word0 = bColor;
else
Word0 = fColor;
Mask = Mask >> 1;
if ((PixelRow & Mask) == 0)
Word1 = bColor;
else
Word1 = fColor;
Mask = Mask >> 1;
// use this information to output three data bytes
sendData((Word0 >> 4) & 0xFF);
sendData(((Word0 & 0xF) << 4) | ((Word1 >> 8) & 0xF));
sendData(Word1 & 0xFF);
}
}
// terminate the Write Memory command
sendCMD(NOP);
}