//Including the needed libraries #include #include //Some necessary definitions of how big our glyphs and font library are #define OLEDChar 8 //number of bytes in a glyph #define OLEDUserFont (32*OLEDChar) //number of bytes in user font table OledClass OLED; //a class uint8_t UserFont[OLEDUserFont] = { // This font table defines the lower 32 bytes of the screen 0x00, 0x00, 0x00, 0x00, 0xC0, 0x30, 0x0C, 0x03, // 0x00 0xC0, 0x30, 0x0C, 0x03, 0xC0, 0xB0, 0x8C, 0x83, // 0x01 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x86, 0x98, // 0x02 0xE0, 0x81, 0x86, 0x98, 0xE0, 0x00, 0x03, 0x0C, // 0x03 0x30, 0xC0, 0x00, 0x00, 0x00, 0x07, 0x07, 0x06, // 0x04 0x06, 0x86, 0x83, 0x81, 0x00, 0x00, 0x00, 0x80, // 0x05 0x86, 0x86, 0x86, 0x07, 0x07, 0x86, 0x06, 0x06, // 0x06 0x00, 0x80, 0x00, 0x01, 0x03, 0x86, 0x86, 0x06, // 0x07 0x06, 0x06, 0x87, 0x03, 0x00, 0x00, 0x80, 0x06, // 0x08 0x06, 0x86, 0x87, 0x87, 0x06, 0x06, 0x06, 0x00, // 0x09 0x00, 0x00, 0x07, 0x87, 0x86, 0x86, 0x86, 0x86, // 0x0A 0x06, 0x06, 0x80, 0x00, 0x00, 0x87, 0x07, 0x06, // 0x0B 0x86, 0x86, 0x86, 0x86, 0x06, 0x00, 0x00, 0x80, // 0x0C 0x87, 0x07, 0x00, 0x00, 0x80, 0x80, 0x81, 0x03, // 0x0D 0x07, 0x07, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, // 0x0E 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x0F 0x00, 0x10, 0x2C, 0x43, 0xC0, 0xB0, 0x8C, 0x83, // 0x10 0x80, 0x80, 0x8C, 0x8B, 0x88, 0x88, 0x88, 0x88, // 0x11 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, // 0x12 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, // 0x13 0x88, 0x88, 0x4B, 0x3C, 0x00, 0x00, 0x00, 0x00, // 0x14 0x00, 0x3F, 0x24, 0x24, 0x1F, 0x00, 0x00, 0x3F, // 0x15 0x24, 0x24, 0x20, 0x00, 0x00, 0x03, 0x04, 0x38, // 0x16 0x04, 0x03, 0x00, 0x00, 0x1F, 0x20, 0x20, 0x1F, // 0x17 0x00, 0x00, 0x3F, 0x01, 0x0E, 0x10, 0x3F, 0x00, // 0x18 0x00, 0x3F, 0x20, 0x20, 0x1F, 0x00, 0x00, 0x00, // 0x19 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, // 0x1A 0x00, 0x00, 0x3F, 0x04, 0x04, 0x3F, 0x00, 0x00, // 0x1B 0x3F, 0x24, 0x24, 0x20, 0x00, 0x00, 0x1F, 0x20, // 0x1C 0x20, 0x1F, 0x00, 0x00, 0x3F, 0x04, 0x0C, 0x33, // 0x1D 0x00, 0x00, 0x03, 0x04, 0x38, 0x04, 0x03, 0x00, // 0x1E 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x1F }; uint8_t bitmap[] = { // This bitmap defines the upper 32 bytes of the screen 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0 0x00, 0x00, 0x00, 0x00, 0xC0, 0x30, 0x0C, 0x02, // char 1 0x81, 0x03, 0x05, 0x19, 0x61, 0x81, 0x02, 0x0C, // char 2 0x30, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 3 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x18, // char 4 0x18, 0x18, 0x30, 0xE0, 0xC0, 0x00, 0x00, 0x00, // char 5 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x18, 0x18, 0x18, // char 6 0x00, 0x00, 0x00, 0xE0, 0xF0, 0x18, 0x18, 0x18, // char 7 0x18, 0x38, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x18, // char 8 0x18, 0x18, 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x00, // char 9 0x00, 0x00, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, // char A 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x18, // char B 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, // char C 0xF8, 0xF8, 0x38, 0x70, 0xE0, 0x80, 0x00, 0x00, // char D 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, // char E 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, // char F 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 10 0xC0, 0x30, 0x0C, 0x03, 0xC0, 0x30, 0x0C, 0x03, // char 11 0xC0, 0x33, 0x0C, 0x10, 0x60, 0x81, 0x06, 0x18, // char 12 0x60, 0x80, 0x03, 0x0C, 0x30, 0xC0, 0x00, 0x00, // char 13 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, // char 14 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // char 15 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // char 16 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, // char 17 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, // char 18 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, // char 19 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, // char 1A 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x18, // char 1B 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // char 1C 0xFF, 0xFF, 0x00, 0x00, 0x7F, 0xFF, 0x80, 0x00, // char 1D 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 1E 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 1F }; void setup(){ OLED.begin(); // start the PmodOLED int ch; for (ch = 0; ch < 32; ch++) { OLED.defineUserChar(ch, &UserFont[ch*OLEDChar]); // define all 32 characters in the font table } } void loop(){ OLED.clearBuffer(); //clear the display OLED.putBmp(128,16,bitmap); //place the upper 32 bits //place the next 16 bits OLED.setCursor(0,2); OLED.putChar(0x00); OLED.setCursor(1,2); OLED.putChar(0x01); OLED.setCursor(2,2); OLED.putChar(0x02); OLED.setCursor(3,2); OLED.putChar(0x03); OLED.setCursor(4,2); OLED.putChar(0x04); OLED.setCursor(5,2); OLED.putChar(0x05); OLED.setCursor(6,2); OLED.putChar(0x06); OLED.setCursor(7,2); OLED.putChar(0x07); OLED.setCursor(8,2); OLED.putChar(0x08); OLED.setCursor(9,2); OLED.putChar(0x09); OLED.setCursor(10,2); OLED.putChar(0x0A); OLED.setCursor(11,2); OLED.putChar(0x0B); OLED.setCursor(12,2); OLED.putChar(0x0C); OLED.setCursor(13,2); OLED.putChar(0x0D); OLED.setCursor(14,2); OLED.putChar(0x0E); OLED.setCursor(15,2); OLED.putChar(0x0F); //place the final 16 bits OLED.setCursor(0,3); OLED.putChar(0x10); OLED.setCursor(1,3); OLED.putChar(0x11); OLED.setCursor(2,3); OLED.putChar(0x12); OLED.setCursor(3,3); OLED.putChar(0x13); OLED.setCursor(4,3); OLED.putChar(0x14); OLED.setCursor(5,3); OLED.putChar(0x15); OLED.setCursor(6,3); OLED.putChar(0x16); OLED.setCursor(7,3); OLED.putChar(0x17); OLED.setCursor(8,3); OLED.putChar(0x18); OLED.setCursor(9,3); OLED.putChar(0x19); OLED.setCursor(10,3); OLED.putChar(0x1A); OLED.setCursor(11,3); OLED.putChar(0x1B); OLED.setCursor(12,3); OLED.putChar(0x1C); OLED.setCursor(13,3); OLED.putChar(0x1D); OLED.setCursor(14,3); OLED.putChar(0x1E); OLED.setCursor(15,3); OLED.putChar(0x1F); OLED.updateDisplay(); //update the display delay(5000); //delay so you can see the screen }