//draw a ascii character //x and y is left top coord static void DrawaAscChar( HDC hDC, int xPos, int yPos, char* pChar ) { char pBuffer[128],*pCurPointer; //int iWinWidth,iWinHeight; int iCharWidth,iCharHeight; int iCharWidthBytes; RECT rc; FONT* pFont; COLORREF crColor; COLORREF crTextBkColor; BOOL isTextBkTrans; int x,y; GetClientRect(hDC->hWnd,&rc); //iWinWidth=rc.right-rc.left+1; //iWinHeight=rc.bottom-rc.top+1; SetRect(&rc,0,0,rc.right - rc.left, rc.bottom - rc.top); crColor =hDC->crTextColor; crTextBkColor =hDC->crTextBkColor; isTextBkTrans =hDC->isTextBkTrans; pFont=GetFont(hDC); GetAscFontData(pBuffer,pFont,pChar); pCurPointer=pBuffer; iCharWidth=pFont->FontLibHeader.iAscWidth; iCharHeight=pFont->FontLibHeader.iAscHeight; if(iCharWidth%8==0) iCharWidthBytes=iCharWidth/8; else iCharWidthBytes=iCharWidth/8+1; for(y=0; y<iCharHeight; y++) { if((y+yPos< rc.top || y+yPos > rc.bottom)) continue; for(x=0; x<iCharWidth; x++) { if(x+xPos < rc.left || x+xPos>rc.right) continue; if(GetBitValue(pCurPointer,x)) winSetPixel(hDC, xPos+x, yPos+y, crColor); else { if(!isTextBkTrans) winSetPixel(hDC,xPos+x,yPos+y,crTextBkColor); } } pCurPointer=pCurPointer + iCharWidthBytes; } }
static void DrawaChnCharAngle( HDC hDC, int xPos, int yPos, char* pChar, double fDirection ) { char pBuffer[128],*pCurPointer; int iCharWidth,iCharHeight; int iCharWidthBytes; RECT rc; FONT* pFont; COLORREF crColor; COLORREF crTextBkColor; BOOL isTextBkTrans; int x,y; int xCoord,yCoord; GetClientRect(hDC->hWnd,&rc); SetRect(&rc,0,0,rc.right - rc.left, rc.bottom - rc.top); crColor =hDC->crTextColor; crTextBkColor =hDC->crTextBkColor; isTextBkTrans =hDC->isTextBkTrans; pFont=GetFont(hDC); GetChnFontData(pBuffer,pFont,pChar); pCurPointer=pBuffer; iCharWidth=pFont->FontLibHeader.iChnWidth; iCharHeight=pFont->FontLibHeader.iChnHeight; if(iCharWidth%8==0) iCharWidthBytes=iCharWidth/8; else iCharWidthBytes=iCharWidth/8+1; for(y=0; y<iCharHeight; y++) { for(x=0; x<iCharWidth; x++) { xCoord = (int)((double)xPos + (double)x * cos(DEG2RAD(fDirection)) + (double)y * sin(DEG2RAD(fDirection))); yCoord = (int)((double)yPos - (double)x * sin(DEG2RAD(fDirection)) + (double)y * cos(DEG2RAD(fDirection))); if(xCoord<rc.left || xCoord>rc.right) continue; if(yCoord<rc.top || yCoord>rc.bottom) continue; if(GetBitValue(pCurPointer,x)) winSetPixel(hDC, xCoord, yCoord, crColor); else { if(!isTextBkTrans) winSetPixel(hDC,xCoord,yCoord,crTextBkColor); } } pCurPointer=pCurPointer + iCharWidthBytes; } }
void WriteToLCD(char dx) { int temp = dx; char numb[8]; itoa(temp, numb); int len = 0; for(len = 0; numb[len] != '\0'; len++); //write value to LCD int i = 0; for(i = 0; i < 8; i++) //cycle for all pages { P5OUT &= ~BIT6; // DOGS102 format: command DOGS102_SPI(176 + i); // set page address char bit[8]; if(i < len) { GetBitValue(bit, numb[i]); } int count_l = 0; int count_m = 0; if(mirror == 0) { count_l = 0; count_m = 0; } else { count_l = 14; count_m = 1; } int j = 0; for(j = 0; j < 8; j++) // cycle for all columns { P5OUT &= ~BIT6; // DOGS102 format: command if(count_l == 16) { count_l = 0; count_m++; } DOGS102_SPI(0 + count_l); // set LSB column address DOGS102_SPI(16 + count_m); // set MSB column address P5OUT |= BIT6; // DOGS102 format: data if(i < len) { DOGS102_SPI(bit[j]); // 8 pixels set } else { DOGS102_SPI(0xFF); // 8 pixels set } count_l++; } } }