void clearTarget(int targetImage[][], int x, int y) { int xCord,yCord; int k; int j; int tImage[8][8] = {{1, 1, 1, 0, 0, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 0, 0, 1, 1, 1}}; yCord=y; for(k=0;k<8;k++) { xCord=x; for(j=0;j<8;j++) { if(tImage[k][j]==1) { clearPixel(xCord,yCord); } xCord++; } yCord++; } }
void SSD1306::_drawChar(unsigned char ascii, uint8_t& row, uint8_t& col, bool bInvert) { uint8_t c; for(uint8_t i=0;i<5;i++) { c = (uint8_t)(pgm_read_byte(&(myFont[ascii - 32][i])))^(bInvert?0b01111111:0); for (uint8_t j = 0 ; j < 8 ;j++) c&(1<<j)?setPixel(row+j,col):clearPixel(row+j,col); col++; } }
// drawPixel sets or clears a certain pixel depending on whether the colour // is greater than 0 or not void PixelStates::drawPixel(int16_t x, int16_t y, uint16_t color) { uint16_t pixelIdx = getPixelIdx(x, y); if(pixelIdx < 0) { return; } if(color > 0) { setPixel(pixelIdx); } else { clearPixel(pixelIdx); } }
/* Place a row representing a binary number on the matrix b - value to convert to binary representation r, c - row/col in matrix d - digits (columns) to use for binary number co - color value br - brightness value */ void LedMatrixClass::placeBinary(int b, int r, int c, int p) { int rtmp, gtmp, btmp; for (int i = 0; i < p; ++i) // only need 'p' LSB from number { if (b & (0x01 << i)) setPixel(r, c + p - 1 - i); else clearPixel(r, c + p - 1 - i); } return; }
/* Place a hex digit character on the matrix cd - ClockDigit class instance r,c - Row/column for the digit co - color value br - brightness value */ void LedMatrixClass::placeChar(ClockDigitClass *cd, int r, int c) { int crows = cd->getDisplayRows(); int ccols = cd->getDisplayColumns(); // Since each char is a 16-bit value, the MSB's are unused on many of the symbols // Let's figure out how many are unused int startBit = 16 - (crows*ccols); for (int i = 0; i < crows; ++i) { for (int j = 0; j < ccols; ++j) { if (cd->getBitValue((i*ccols) + j + startBit) != 0) setPixel(r + i, c + j); else clearPixel(r + i, c + j); } } return; }