/******************************************************************************* * Function Name : SSD1306_Pixel * Description : Set pixel in display buffer * Input : position (x, y) and color (WHITE, BLACK, INVERSE) *******************************************************************************/ void SSD1306_Pixel(int16_t x, int16_t y, uint16_t color) { if(orient == 0) { if ((x < 0) || (x >= SSD1306_LCDWIDTH) || (y < 0) || (y >= SSD1306_LCDHEIGHT)) return; } if(orient == 1) { if ((x < 0) || (x >= SSD1306_LCDHEIGHT) || (y < 0) || (y >= SSD1306_LCDWIDTH)) return; } // check rotation, move pixel around if necessary switch(orient) { case 1: swap(x, y); x = WIDTH - x - 1; break; case 2: x = WIDTH - x - 1; y = HEIGHT - y - 1; break; case 3: swap(x, y); y = HEIGHT - y - 1; break; } // x is - column switch (color) { case WHITE: BitSet(buffer[x+ (y/8)*SSD1306_LCDWIDTH], y&7); break; case BLACK: BitReset(buffer[x+ (y/8)*SSD1306_LCDWIDTH], y&7); break; case INVERSE: BitFlip(buffer[x+ (y/8)*SSD1306_LCDWIDTH], y&7); break; } }
int main(void) { char array[64]; memset(array, '\0', sizeof(array)); BitOn(array, 5); BitOn(array, 12); BitOn(array, 500); if (IsBit(array, 5) && IsBit(array, 12) && IsBit(array, 500)) puts("These functions seem to work!"); else puts("Something's broken here!"); BitFlip(array, 12); BitOff(array, 5); if (!IsBit(array, 5) && !IsBit(array, 12) && IsBit(array, 500)) puts("These functions still seem to work!"); else puts("Something's broken here!"); return 0; }