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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| #include <SPI.h> #include <Wire.h> #include <Adafruit\_GFX.h> #include <Adafruit\_SSD1306.h> #include <SdFat.h> #include <ArduinoJson.h>
#define SCREEN\_WIDTH 128 // OLED display width, in pixels #define SCREEN\_HEIGHT 64 // OLED display height, in pixels
#define LOGO\_HEIGHT 32 #define LOGO\_WIDTH 32
#define OLED\_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) #define SCREEN\_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const uint8\_t cn_huan [] PROGMEM = {0x00,0x80,0x00,0x80,0xFC,0x80,0x04,0xFC,0x05,0x04,0x49,0x08,0x2A,0x40,0x14,0x40, 0x10,0x40,0x28,0xA0,0x24,0xA0,0x45,0x10,0x81,0x10,0x02,0x08,0x04,0x04,0x08,0x02};/\*"欢",0\*/
const uint8\_t cn_ying [] PROGMEM = {0x00,0x00,0x20,0x80,0x13,0x3C,0x12,0x24,0x02,0x24,0x02,0x24,0xF2,0x24,0x12,0x24, 0x12,0x24,0x12,0xB4,0x13,0x28,0x12,0x20,0x10,0x20,0x28,0x20,0x47,0xFE,0x00,0x00};/\*"迎",1\*/
const uint8\_t cn_shi [] PROGMEM = {0x10,0x40,0x10,0x40,0x1F,0xFE,0x20,0x40,0x20,0x40,0x67,0xFC,0x64,0x44,0xA4,0x44, 0x27,0xFC,0x20,0x40,0x22,0x40,0x21,0x40,0x20,0x80,0x21,0x40,0x22,0x30,0x2C,0x0E};/\*"使",2\*/
const uint8\_t cn_yong [] PROGMEM = {0x00,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x21,0x08, 0x21,0x08,0x3F,0xF8,0x21,0x08,0x21,0x08,0x21,0x08,0x41,0x08,0x41,0x28,0x80,0x10};/\*"用",3\*/
const uint8\_t cn_tian [] PROGMEM = {0x00,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00, 0x02,0x80,0x02,0x80,0x04,0x40,0x04,0x40,0x08,0x20,0x10,0x10,0x20,0x08,0xC0,0x06};/\*"天",4\*/
const uint8\_t cn_qi [] PROGMEM = {0x10,0x00,0x10,0x00,0x3F,0xFC,0x20,0x00,0x4F,0xF0,0x80,0x00,0x3F,0xF0,0x00,0x10, 0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x0A,0x00,0x0A,0x00,0x06,0x00,0x02};/\*"气",5\*/
const uint8\_t cn_yu [] PROGMEM = {0x00,0x00,0xF9,0xFE,0x08,0x20,0x50,0x40,0x21,0xFC,0x11,0x04,0xFD,0x24,0x25,0x24, 0x29,0x24,0x21,0x24,0x21,0x24,0x21,0x44,0x20,0x50,0x20,0x88,0xA1,0x04,0x42,0x02};/\*"预",6\*/
const uint8\_t cn_bao [] PROGMEM = {0x10,0x00,0x11,0xFC,0x11,0x04,0x11,0x04,0xFD,0x14,0x11,0x08,0x11,0x00,0x15,0xFC, 0x19,0x44,0x31,0x44,0xD1,0x28,0x11,0x28,0x11,0x10,0x11,0x28,0x51,0x44,0x21,0x82};/\*"报",7\*/
const int cn_allArray_LEN = 8; const uint8\_t\* cn_allArray[8] = { cn_huan,cn_ying,cn_shi,cn_yong,cn_tian,cn_qi,cn_yu,cn_bao };
void setup() { // put your setup code here, to run once: Serial.begin(9600);
// SSD1306\_SWITCHCAPVCC = generate display voltage from 3.3V internally if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1306 allocation failed")); for(;;); // Don't proceed, loop forever }
// Show initial display buffer contents on the screen -- // the library initializes this with an Adafruit splash screen. display.display(); // Clear the buffer display.clearDisplay(); display.setTextSize(1); //设置字体大小 display.setTextColor(SSD1306_WHITE);//开像素点发光 // testdrawbitmap(cn\_allArray[0],16,16); for(int i = 0;i < 8;i++){ display.drawBitmap(i \* 16, 0, cn_allArray[i], 16, 16, 1); delay(1); } display.display(); /\* display.drawBitmap(32, 32, str1, 16, 16, 1); //画出字符对应点阵数据 display.drawBitmap(48, 32, str2, 16, 16, 1); //画出字符对应点阵数据 display.drawBitmap(64, 32, str3, 16, 16, 1); //画出字符对应点阵数据 display.drawBitmap(80, 32, str4, 16, 16, 1); //画出字符对应点阵数据 display.display();//开显示 \*/ }
void loop() { // put your main code here, to run repeatedly:
}
void testdrawbitmap(uint8\_t\* datas,int width,int height) { //display.clearDisplay(); // display.fillRect((display.width() - width ) / 2, // (display.height() - height) / 2,width, height,SSD1306\_BLACK); display.drawBitmap( (display.width() - width ) / 2, (display.height() - height) / 2, datas, width, height, 1); display.display(); delay(1000); }
|