1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| #include <Wire.h> #include <Adafruit\_GFX.h> #include <Adafruit\_SSD1306.h>
// 图像数据 // '105-sun-shower', 32x32px // '105-sun-shower', 32x32px const unsigned char epd_bitmap_105_sun_shower [] PROGMEM = { 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x08, 0x18, 0x18, 0x00, 0x0c, 0x00, 0x38, 0x00, 0x06, 0x00, 0x70, 0x00, 0x02, 0x7e, 0x20, 0x00, 0x00, 0xe7, 0x00, 0x00, 0x01, 0xc1, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x1c, 0x00, 0xc0, 0x00, 0xff, 0x80, 0x4f, 0x01, 0xc1, 0xc0, 0x4f, 0x03, 0x80, 0x60, 0xc0, 0x07, 0x00, 0x31, 0xc0, 0x1e, 0x00, 0x31, 0x80, 0x3c, 0x00, 0x18, 0x00, 0x60, 0x00, 0x1c, 0x60, 0xc0, 0x00, 0x06, 0x30, 0xc0, 0x00, 0x03, 0x18, 0xc0, 0x00, 0x03, 0x00, 0xc2, 0x02, 0x03, 0x00, 0xc6, 0x06, 0x03, 0x00, 0x66, 0x66, 0x66, 0x00, 0x64, 0x44, 0x4e, 0x00, 0x0c, 0xcc, 0xcc, 0x00, 0x0c, 0xcc, 0xc0, 0x00, 0x08, 0x88, 0x80, 0x00, 0x19, 0x99, 0x80, 0x00, 0x11, 0x91, 0x80, 0x00, 0x03, 0x03, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00 };
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 144) const int epd_bitmap_allArray_LEN = 1; const unsigned char\* epd_bitmap_allArray[1] = { epd_bitmap_105_sun_shower };
// 屏幕大小 #define SCREEN\_WIDTH 128 // OLED display width, in pixels #define SCREEN\_HEIGHT 64 // OLED display height, in pixels
// 图片大小 #define IMG\_HEIGHT 32 #define IMG\_WIDTH 32
// OLED重置引脚,I2C时和与板载重置引脚共用时,设置-1 #define OLED\_RESET -1 // OLED地址 #define SCREEN\_ADDRESS 0x3C // OLED对象 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() { Serial.begin(9600);
// 初始化OLED if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1306 allocation failed")); for(;;); }
// 显示欢迎画面 // Clear the buffer Adafruit\_SSD1306.h文件中将 #define SSD1306\_NO\_SPLASH 打开屏蔽 display.display(); delay(1000); // 清屏 display.clearDisplay();
testdrawbitmap((const uint8\_t\*)epd_bitmap_allArray[0],32,32); }
void loop() { }
void testdrawbitmap(const uint8\_t\* datas,int width,int height) { display.clearDisplay(); // 绘制图片 display.drawBitmap( (display.width() - width ) / 2, (display.height() - height) / 2, datas, width, height, 1); display.display(); delay(1000); }
|