// ported from Screen_HX8353E void _fastFill(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t colour) { if (x1 > x2) _swapU(&x1, &x2); if (y1 > y2) _swapU(&y1, &y2); _setWindow(x1, y1, x2, y2); gioSetBit(_portDataCommand, _pinDataCommand, 1); // uint32_t t; // todo: this can be extremely optimized using the mibspi buffer + dma // for (t=(uint32_t)(y2-y1+1)*(x2-x1+1); t>1; t--) { // mibspiSetData(mibspiREG3, 2, &colour); // mibspiTransfer(mibspiREG3, 2 ); // while(!(mibspiIsTransferComplete(mibspiREG3, 2))) { // } // } // mibspiSetData(mibspiREG3, 1, &colour); // mibspiTransfer(mibspiREG3, 1 ); // while(!(mibspiIsTransferComplete(mibspiREG3, 1))) { // } uint32_t t; // todo: this can be extremely optimized using the mibspi buffer + dma for (t=(uint32_t)(y2-y1+1)*(x2-x1+1); t>0; t--) { mibspiSetData(mibspiREG3, 1, &colour); mibspiTransfer(mibspiREG3, 1 ); while(!(mibspiIsTransferComplete(mibspiREG3, 1))) { } } }
// ported from Screen_HX8353E void setBitmapInOneThrow(bitmap_t *bmp) { uint32_t yy; for (yy = 0; yy < bmp->height; yy++) { _setWindow(0, yy, bmp->width, yy ); flashBitmapLine(bmp, yy); } }
void Screen_HX8353E::_fastFill(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t colour) { if (x1 > x2) _swap(x1, x2); if (y1 > y2) _swap(y1, y2); _setWindow(x1, y1, x2, y2); digitalWrite(_pinDataCommand, HIGH); digitalWrite(_pinChipSelect, LOW); uint8_t hi = highByte(colour); uint8_t lo = lowByte(colour); for (uint32_t t=(uint32_t)(y2-y1+1)*(x2-x1+1); t>0; t--) { SPI.transfer(hi); SPI.transfer(lo); } digitalWrite(_pinChipSelect, HIGH); }
// ported from LCS_screen_font void gText(uint16_t x0, uint16_t y0, uint8_t *s, uint32_t length, uint16_t textColour, uint16_t backColour, uint32_t ix, uint32_t iy) { uint8_t c; uint32_t line, line1, line2; uint32_t x, y; uint32_t i, j, k; if ((ix > 1) || (iy > 1) || !_fontSolid) { if ((_fontSize == 0) && ((ix > 1) || (iy > 1))) { bool oldPenSolid = _penSolid; setPenSolid(true); for (k=0; k<length; k++) { x = x0 + 6 * k * ix; y = y0; c = s[k]-' '; for ( i=0; i<6; i++ ) { line = _getCharacter(c, i); for ( j = 0; j<8; j++) { if (bitRead(line, j)) rectangle(x+i*ix, y+j*iy, x+i*ix+ix-1, y+j*iy+iy-1, textColour); else if (_fontSolid) rectangle(x+i*ix, y+j*iy, x+i*ix+ix-1, y+j*iy+iy-1, backColour); } } } setPenSolid(oldPenSolid); } else { if (_fontSize == 0) { for (k=0; k<length; k++) { c = s[k]-' '; for (i=0; i<6; i++) { line = _getCharacter(c, i); for (j=0; j<8; j++) if (bitRead(line, j)) point(x0 + 6*k + i, y0 + j, textColour); else if (_fontSolid) point(x0 + 6*k + i, y0 + j, backColour); } } } else if (_fontSize == 1) { for (k=0; k<length; k++) { c = s[k]-' '; for (i=0; i<8; i++) { line = _getCharacter(c, 2*i); line1 =_getCharacter(c, 2*i+1); for (j=0; j<8; j++) { if (bitRead(line, j)) point(x0 + 8*k + i, y0 + j, textColour); else if (_fontSolid) point(x0 + 8*k + i, y0 + j, backColour); if (bitRead(line1, j)) point(x0 + 8*k + i, y0 +8 + j, textColour); else if ((_fontSolid) && (j<4)) point(x0 + 8*k + i, y0 +8 + j, backColour); } } } } else if (_fontSize == 2) { for (k=0; k<length; k++) { c = s[k]-' '; for (i=0; i<12; i++) { line = _getCharacter(c, 2*i); line1 =_getCharacter(c, 2*i+1); for (j=0; j<8; j++) { if (bitRead(line, j)) point(x0 + 12*k + i, y0 + j, textColour); else if (_fontSolid) point(x0 + 12*k + i, y0 + j, backColour); if (bitRead(line1, j)) point(x0 + 12*k + i, y0 +8 + j, textColour); else if (_fontSolid) point(x0 + 12*k + i, y0 +8 + j, backColour); } } } } else if (_fontSize == 3) { for (k=0; k<length; k++) { c = s[k]-' '; for (i=0; i<16; i++) { line =_getCharacter(c, 3*i); line1 =_getCharacter(c, 3*i+1); line2 =_getCharacter(c, 3*i+2); for (j=0; j<8; j++) { if (bitRead(line, j)) point(x0 + 16*k + i, y0 + j, textColour); else if (_fontSolid) point(x0 + 16*k + i, y0 + j, backColour); if (bitRead(line1, j)) point(x0 + 16*k + i, y0 +8 + j, textColour); else if (_fontSolid) point(x0 + 16*k + i, y0 +8 + j, backColour); if (bitRead(line2, j)) point(x0 + 16*k + i, y0 +16 + j, textColour); else if (_fontSolid) point(x0 + 16*k + i, y0 +16 + j, backColour); } } } } } } else { uint8_t c; uint32_t i, j, k; if (_fontSize == 0) { for (k=0; k<length; k++) { c = s[k]-' '; _setWindow(x0 +fontSizeX()*k, y0, x0 +fontSizeX()*(k+1)-1, y0+fontSizeY()-1); for (j=0; j<8; j++) { for (i=0; i<6; i++) { line = _getCharacter(c, i); if (bitRead(line, j)) { _writeData16(textColour); } else { _writeData16(backColour); } } } } } else if (_fontSize == 1) { for (k=0; k<length; k++) { c = s[k]-' '; _setWindow(x0 +fontSizeX()*k, y0, x0 +fontSizeX()*(k+1)-1, y0+fontSizeY()-1); for (j=0; j<8; j++) { for (i=0; i<8; i++) { line = _getCharacter(c, 2*i); if (bitRead(line, j)) { _writeData16(textColour); } else { _writeData16(backColour); } } } for (j=0; j<4; j++) { for (i=0; i<8; i++) { line = _getCharacter(c, 2*i+1); if (bitRead(line, j)) { _writeData16(textColour); } else { _writeData16(backColour); } } } } } else if (_fontSize == 2) { for (k=0; k<length; k++) { c = s[k]-' '; _setWindow(x0 +fontSizeX()*k, y0, x0 +fontSizeX()*(k+1)-1, y0+fontSizeY()-1); for (j=0; j<8; j++) { for (i=0; i<12; i++) { line = _getCharacter(c, 2*i); if (bitRead(line, j)) { _writeData16(textColour); } else { _writeData16(backColour); } } } for (j=0; j<8; j++) { for (i=0; i<12; i++) { line = _getCharacter(c, 2*i+1); if (bitRead(line, j)) { _writeData16(textColour); } else { _writeData16(backColour); } } } } } else if (_fontSize == 3) { for (k=0; k<length; k++) { c = s[k]-' '; _setWindow(x0 +fontSizeX()*k, y0, x0 +fontSizeX()*(k+1)-1, y0+fontSizeY()-1); for (j=0; j<8; j++) { for (i=0; i<16; i++) { line = _getCharacter(c, 3*i); if (bitRead(line, j)) { _writeData16(textColour); } else { _writeData16(backColour); } } } for (j=0; j<8; j++) { for (i=0; i<16; i++) { line = _getCharacter(c, 3*i+1); if (bitRead(line, j)) { _writeData16(textColour); } else { _writeData16(backColour); } } } for (j=0; j<8; j++) { for (i=0; i<16; i++) { line = _getCharacter(c, 3*i+2); if (bitRead(line, j)) { _writeData16(textColour); } else { _writeData16(backColour); } } } } } } }
// ported from Screen_HX8353E void _setPoint(uint16_t x1, uint16_t y1, uint16_t colour) { if( /*(x1 < 0) || */(x1 >= screenSizeX()) || /*(y1 < 0) || */(y1 >= screenSizeY()) ) return; _setWindow(x1, y1, x1+1, y1+1); _writeData16(colour); }
void Screen_HX8353E::_setPoint(uint16_t x1, uint16_t y1, uint16_t colour) { if( (x1 < 0) || (x1 >= screenSizeX()) || (y1 < 0) || (y1 >= screenSizeY()) ) return; _setWindow(x1, y1, x1+1, y1+1); _writeData16(colour); }
void LCD_screen_font::gText(uint16_t x0, uint16_t y0, String s, uint16_t textColour, uint16_t backColour, uint8_t ix, uint8_t iy) { uint8_t c; uint8_t line, line1, line2, line3; uint16_t x, y; uint8_t i, j, k; if ((ix > 1) || (iy > 1) || !_fontSolid) { if ((_fontSize == 0) && ((ix > 1) || (iy > 1))) { bool oldPenSolid = _penSolid; setPenSolid(true); for (k=0; k<s.length(); k++) { x = x0 + 6 * k * ix; y = y0; c = s.charAt(k)-' '; for ( i=0; i<6; i++ ) { line = _getCharacter(c, i); for ( j = 0; j<8; j++) { if (bitRead(line, j)) rectangle(x+i*ix, y+j*iy, x+i*ix+ix-1, y+j*iy+iy-1, textColour); else if (_fontSolid) rectangle(x+i*ix, y+j*iy, x+i*ix+ix-1, y+j*iy+iy-1, backColour); } } } setPenSolid(oldPenSolid); } else { #if (MAX_FONT_SIZE > 0) if (_fontSize == 0) { for (k=0; k<s.length(); k++) { c = s.charAt(k)-' '; for (i=0; i<6; i++) { line = _getCharacter(c, i); for (j=0; j<8; j++) if (bitRead(line, j)) point(x0 + 6*k + i, y0 + j, textColour); else if (_fontSolid) point(x0 + 6*k + i, y0 + j, backColour); } } } #if (MAX_FONT_SIZE > 1) else if (_fontSize == 1) { for (k=0; k<s.length(); k++) { c = s.charAt(k)-' '; for (i=0; i<8; i++) { line = _getCharacter(c, 2*i); line1 =_getCharacter(c, 2*i+1); for (j=0; j<8; j++) { if (bitRead(line, j)) point(x0 + 8*k + i, y0 + j, textColour); else if (_fontSolid) point(x0 + 8*k + i, y0 + j, backColour); if (bitRead(line1, j)) point(x0 + 8*k + i, y0 +8 + j, textColour); else if ((_fontSolid) && (j<4)) point(x0 + 8*k + i, y0 +8 + j, backColour); } } } } #if (MAX_FONT_SIZE > 2) else if (_fontSize == 2) { for (k=0; k<s.length(); k++) { c = s.charAt(k)-' '; for (i=0; i<12; i++) { line = _getCharacter(c, 2*i); line1 =_getCharacter(c, 2*i+1); for (j=0; j<8; j++) { if (bitRead(line, j)) point(x0 + 12*k + i, y0 + j, textColour); else if (_fontSolid) point(x0 + 12*k + i, y0 + j, backColour); if (bitRead(line1, j)) point(x0 + 12*k + i, y0 +8 + j, textColour); else if (_fontSolid) point(x0 + 12*k + i, y0 +8 + j, backColour); } } } } #if (MAX_FONT_SIZE > 3) else if (_fontSize == 3) { for (k=0; k<s.length(); k++) { c = s.charAt(k)-' '; for (i=0; i<16; i++) { line =_getCharacter(c, 3*i); line1 =_getCharacter(c, 3*i+1); line2 =_getCharacter(c, 3*i+2); for (j=0; j<8; j++) { if (bitRead(line, j)) point(x0 + 16*k + i, y0 + j, textColour); else if (_fontSolid) point(x0 + 16*k + i, y0 + j, backColour); if (bitRead(line1, j)) point(x0 + 16*k + i, y0 +8 + j, textColour); else if (_fontSolid) point(x0 + 16*k + i, y0 +8 + j, backColour); if (bitRead(line2, j)) point(x0 + 16*k + i, y0 +16 + j, textColour); else if (_fontSolid) point(x0 + 16*k + i, y0 +16 + j, backColour); } } } } #endif #endif #endif #endif } } else { uint8_t c; uint8_t line, line1; uint16_t x, y; uint8_t i, j, k; uint8_t highTextColour = highByte(textColour); uint8_t lowTextColour = lowByte(textColour); uint8_t highBackColour = highByte(backColour); uint8_t lowBackColour = lowByte(backColour); #if (MAX_FONT_SIZE > 0) if (_fontSize == 0) { for (k=0; k<s.length(); k++) { c = s.charAt(k)-' '; _setWindow(x0 +fontSizeX()*k, y0, x0 +fontSizeX()*(k+1)-1, y0+fontSizeY()-1); for (j=0; j<8; j++) { for (i=0; i<6; i++) { line = _getCharacter(c, i); if (bitRead(line, j)) { _writeData88(highTextColour, lowTextColour); } else { _writeData88(highBackColour, lowBackColour); } } } } } #if (MAX_FONT_SIZE > 1) else if (_fontSize == 1) { for (k=0; k<s.length(); k++) { c = s.charAt(k)-' '; _setWindow(x0 +fontSizeX()*k, y0, x0 +fontSizeX()*(k+1)-1, y0+fontSizeY()-1); for (j=0; j<8; j++) { for (i=0; i<8; i++) { line = _getCharacter(c, 2*i); if (bitRead(line, j)) { _writeData88(highTextColour, lowTextColour); } else { _writeData88(highBackColour, lowBackColour); } } } for (j=0; j<4; j++) { for (i=0; i<8; i++) { line = _getCharacter(c, 2*i+1); if (bitRead(line, j)) { _writeData88(highTextColour, lowTextColour); } else { _writeData88(highBackColour, lowBackColour); } } } } } #if (MAX_FONT_SIZE > 2) else if (_fontSize == 2) { for (k=0; k<s.length(); k++) { c = s.charAt(k)-' '; _setWindow(x0 +fontSizeX()*k, y0, x0 +fontSizeX()*(k+1)-1, y0+fontSizeY()-1); for (j=0; j<8; j++) { for (i=0; i<12; i++) { line = _getCharacter(c, 2*i); if (bitRead(line, j)) { _writeData88(highTextColour, lowTextColour); } else { _writeData88(highBackColour, lowBackColour); } } } for (j=0; j<8; j++) { for (i=0; i<12; i++) { line = _getCharacter(c, 2*i+1); if (bitRead(line, j)) { _writeData88(highTextColour, lowTextColour); } else { _writeData88(highBackColour, lowBackColour); } } } } } #if (MAX_FONT_SIZE > 3) else if (_fontSize == 3) { for (k=0; k<s.length(); k++) { c = s.charAt(k)-' '; _setWindow(x0 +fontSizeX()*k, y0, x0 +fontSizeX()*(k+1)-1, y0+fontSizeY()-1); for (j=0; j<8; j++) { for (i=0; i<16; i++) { line = _getCharacter(c, 3*i); if (bitRead(line, j)) { _writeData88(highTextColour, lowTextColour); } else { _writeData88(highBackColour, lowBackColour); } } } for (j=0; j<8; j++) { for (i=0; i<16; i++) { line = _getCharacter(c, 3*i+1); if (bitRead(line, j)) { _writeData88(highTextColour, lowTextColour); } else { _writeData88(highBackColour, lowBackColour); } } } for (j=0; j<8; j++) { for (i=0; i<16; i++) { line = _getCharacter(c, 3*i+2); if (bitRead(line, j)) { _writeData88(highTextColour, lowTextColour); } else { _writeData88(highBackColour, lowBackColour); } } } } } #endif #endif #endif #endif } }