// Write number to display void writeDisplayNumber(uint16_t number, uint8_t decimalPoint) { uint8_t digit0; uint8_t digit1; uint8_t digit2; uint8_t digit3; // convert digits digit3 = number / 1000; number %= 1000; digit2 = number / 100; number %= 100; digit1 = number / 10; number %= 10; digit0 = number; // strip leading zeros if (digit3 == 0 && decimalPoint < 3) { digit3 = DIGIT_BLANK; if (digit2 == 0 && decimalPoint < 2) { digit2 = DIGIT_BLANK; if (digit1 == 0 && decimalPoint < 1) { digit1 = DIGIT_BLANK; } } } // convert and write to display uint32_t data = convertBcd(digit3, digit2, digit1, digit0, decimalPoint); writeDisplayData(data); }
/* NORMAL,REVERSE,INHIBIT,NBLINK,RBLINK,IBLINK */ uint8_t easyT6963::setTextAttrMode(uint8_t TEXT_ATTRIBUTE){ uint8_t tmp = 0; unsigned int i; switch(TEXT_ATTRIBUTE){ case NORMAL: tmp |= 0; break; case REVERSE: tmp |= 0b0101; break; case INHIBIT: tmp |= 0b0011; break; case NBLINK: tmp |=0b1000; break; case RBLINK: tmp |= 0b1101; break; case IBLINK: tmp |= 0b1011; break; default: tmp |= 0; } setAddressPointer(_graphicHome); for(i = 0; i < _graphicSize; i++){ writeDisplayData(tmp); } return tmp; }
/* Clears just Text */ void easyT6963::clearText(){ unsigned int i; setAddressPointer(_textHome); for(i = 0; i < _textSize; i++){ writeDisplayData(0); } }
//------------------------------------------------------------------------------------------------- // Writes single char pattern to character generator area of display RAM memory //------------------------------------------------------------------------------------------------- void easyT6963::defineCharacter(byte charCode, unsigned char * defChar){ uint8_t i; unsigned int address = ((_memSize / 2)-1) * 0x800; setAddressPointer(address); for(i = 0; i < 8 ; i++){ writeDisplayData(*(defChar + i)); } }
//------------------------------------------------------------------------------------------------- // Clears characters generator area of display RAM memory //------------------------------------------------------------------------------------------------- void easyT6963::clearCG(){ unsigned int i = ((_memSize/2)-1) * 0x800;//30720 setAddressPointer(i); for(i = 0; i < 2048; i++){ writeDisplayData(0); } _gx = 0; _gy = 0; }
// Parameter : x,y = Position, Picturename (not Filename see in Picturefile), Height in Pixel, Widht in Byte //HEIGHT = max 64; //Height in pixels BYTEWIDTH = max 40; //Width in bytes by 6x8 Font //----------------------------------------------------------------------- void easyT6963::drawBitmap(uint8_t x,uint8_t y, const uint8_t *PicName,uint8_t height,uint8_t bytewidth){ int j = 0; uint8_t h,i,bitmap; for (h = 0; h < height; h++){ graphicGoTo(x,y+h); for (i = 0; i < bytewidth; i++) { bitmap = pgm_read_byte_near(PicName+(i+j)); writeDisplayData(bitmap); } j = j + bytewidth; } }
/* Example: x,y = Start Position, Height in Pixel, Widht in Byte, pattern in byte(0b11111111) */ void easyT6963::drawFastRect(uint8_t x,uint8_t y,uint8_t height,uint8_t bytewidth,uint8_t pattern){ int j = 0; uint8_t h,i; graphicGoTo(x,y); for (h = 0; h < height; h++) { graphicGoTo(x,y+h); for (i = 0; i < bytewidth; i++){ writeDisplayData(pattern); } j = j + bytewidth; } }
/* Clear Display (and memory) fastMode(default) it's a bit faster */ void easyT6963::clearGraphic(uint8_t fastMode){ unsigned int i; if (!fastMode){ setAddressPointer(_graphicHome); for (i = 0; i < _graphicSize; i++){ writeDisplayData(0x00); } } else { setAddressPointer(_graphicHome); uint8_t h,j = 0; graphicGoTo(0,0); for (h = 0; h < _height; h++) { graphicGoTo(0,h); for (i = 0; i < _maxCol+1; i++){ //(PIXELS PER LINE/FONT WIDTH * NUMBER OF LINES) writeDisplayData(0b00000000); } j = j + _maxCol; } } _gx = 0; _gy = 0; }
void easyT6963::drawAnim(uint8_t x,uint8_t y, const uint8_t **string_table, int l,uint8_t height,uint8_t bytewidth){ //Position x, Position y, String of Images , Number of Images ,HEIGHT,BYTEWIDTH show bmp2c Picturefile uint8_t bitmap,a,h,i; int j; char* PicName; for (a = 0; a < l; a++) { PicName = (char*) pgm_read_word(&(string_table[a])); //PicName = pgm_read_word(&(string_table[a])); j = 0; for (h = 0; h < height-1; h++) { graphicGoTo(x,y+h); for (i = 0; i < bytewidth; i++){ bitmap = pgm_read_byte_near(PicName+(i+j)); writeDisplayData(bitmap); } j = j + bytewidth; } } }
size_t easyT6963::write(uint8_t value) { writeDisplayData(value - 32); return 1; //assume success added for Arduino 1 }