ESP8266

————————————————————————————————————————


————————————————————————————————————————

_________________________________________________________

一 .驱动0.96LCD

1.字体测试

tft.setTextSize(1);//字体大小《 2号字体是16像素》《 4号字体是26像素》
  tft.fillScreen(TFT_BLACK);
  tft.setTextColor(TFT_GREEN, TFT_BLACK);//字体颜色和背景颜色

  tft.drawString(" !\"#$%&'()*+,-./0123456", 0, 0, 2);//int16_t drawString(const String &string, int32_t x, int32_t y, uint8_t font)
  tft.drawString("789:;<=>?@ABCDEFGHIJKL", 0, 16, 2);//int16_t drawString(const String &string, int32_t x, int32_t y)
  tft.drawString("MNOPQRSTUVWXYZ[\\]^_`", 0, 32, 2);
  tft.drawString("abcdefghijklmnopqrstuvw", 0, 48, 2);
  int xpos = 0;
  xpos += tft.drawString("xyz{|}~", 0, 64, 2);
  tft.drawChar(127, xpos, 64, 2);
  delay(WAIT);
  

一. 2号字体
在这里插入图片描述

tft.fillScreen(TFT_BLACK);
  tft.setTextColor(TFT_GREEN, TFT_BLACK);

  tft.drawString(" !\"#$%&'()*+,-.", 0, 0, 4);
  tft.drawString("/0123456789:;", 0, 26, 4);
  tft.drawString("<=>?@ABCDE", 0, 52, 4);
  tft.drawString("FGHIJKLMNO", 0, 78, 4);
  tft.drawString("PQRSTUVWX", 0, 104, 4);
  delay(WAIT);

二.4号字体
在这里插入图片描述
三.6号字体

tft.drawString("012345", 0, 0, 6);
  tft.drawString("6789", 0, 40, 6);
  tft.drawString("apm-:.", 0, 80, 6);
  delay(WAIT);

在这里插入图片描述
四.7号数码管字体

tft.drawString("0123", 0, 0, 7);
  tft.drawString("4567", 0, 60, 7);
  delay(WAIT);

在这里插入图片描述
五.8号字体

 tft.drawString("23", 0, 0, 8);
  delay(WAIT);

在这里插入图片描述
————————————————————————————————————————

2.字体测试完整代码

————————————————————————————————————————

/*
 Display all the fast rendering fonts.

 This sketch uses the GLCD (font 1) and fonts 2, 4, 6, 7, 8
 
 Make sure all the display driver and pin connections are correct by
 editing the User_Setup.h file in the TFT_eSPI library folder.

 #########################################################################
 ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
 #########################################################################
*/

// New background colour
#define TFT_BROWN 0x38E0

// Pause in milliseconds between screens, change to 0 to time font rendering
#define WAIT 5000

#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
#include <SPI.h>

TFT_eSPI tft = TFT_eSPI();  // Invoke library, pins defined in User_Setup.h

unsigned long targetTime = 0; // Used for testing draw times

void setup(void) {
  tft.init();
  tft.setRotation(1);
}

void loop() {
  targetTime = millis();

  // First we test them with a background colour set
  tft.setTextSize(2);
  tft.fillScreen(TFT_BLACK);
  tft.setTextColor(TFT_GREEN, TFT_BLACK);

  tft.drawString(" !\"#$%&'()*+,-./0123456", 0, 0, 2);//int16_t drawString(const String &string, int32_t x, int32_t y, uint8_t font)
  tft.drawString("789:;<=>?@ABCDEFGHIJKL", 0, 16, 2);//int16_t drawString(const String &string, int32_t x, int32_t y)
  tft.drawString("MNOPQRSTUVWXYZ[\\]^_`", 0, 32, 2);
  tft.drawString("abcdefghijklmnopqrstuvw", 0, 48, 2);
  int xpos = 0;
  xpos += tft.drawString("xyz{|}~", 0, 64, 2);
  tft.drawChar(127, xpos, 64, 2);
  delay(WAIT);
//****************************************************************
  tft.fillScreen(TFT_BLACK);
  tft.setTextColor(TFT_GREEN, TFT_BLACK);

  tft.drawString(" !\"#$%&'()*+,-.", 0, 0, 4);
  tft.drawString("/0123456789:;", 0, 26, 4);
  tft.drawString("<=>?@ABCDE", 0, 52, 4);
  tft.drawString("FGHIJKLMNO", 0, 78, 4);
  tft.drawString("PQRSTUVWX", 0, 104, 4);
  delay(WAIT);

  tft.fillScreen(TFT_BLACK);
  tft.drawString("YZ[\\]^_`abc", 0, 0, 4);
  tft.drawString("defghijklmno", 0, 26, 4);
  tft.drawString("pqrstuvwxyz", 0, 52, 4);
  xpos = 0;
  xpos += tft.drawString("{|}~", 0, 78, 4);
  tft.drawChar(127, xpos, 78, 4);
  delay(WAIT);

  tft.fillScreen(TFT_BLACK);
  tft.setTextColor(TFT_BLUE, TFT_BLACK);

  tft.drawString("012345", 0, 0, 6);
  tft.drawString("6789", 0, 40, 6);
  tft.drawString("apm-:.", 0, 80, 6);
  delay(WAIT);

  tft.fillScreen(TFT_BLACK);
  tft.setTextColor(TFT_RED, TFT_BLACK);

  tft.drawString("0123", 0, 0, 7);
  tft.drawString("4567", 0, 60, 7);
  delay(WAIT);

  tft.fillScreen(TFT_BLACK);
  tft.drawString("890:.", 0, 0, 7);
  tft.drawString("", 0, 60, 7);
  delay(WAIT);

  tft.fillScreen(TFT_BLACK);
  tft.setTextColor(TFT_YELLOW, TFT_BLACK);

  tft.drawString("01", 0, 0, 8);
  delay(WAIT);
  
  tft.drawString("23", 0, 0, 8);
  delay(WAIT);

  tft.drawString("45", 0, 0, 8);
  delay(WAIT);
  
  tft.drawString("67", 0, 0, 8);
  delay(WAIT);

  tft.drawString("89", 0, 0, 8);
  delay(WAIT);
 
  tft.drawString("0:.", 0, 0, 8);
  delay(WAIT);

  tft.setTextColor(TFT_MAGENTA);
  tft.drawNumber(millis() - targetTime, 0, 100, 4);
  delay(4000);

  // Now test them with transparent background
  targetTime = millis();

  tft.setTextSize(1);
  tft.fillScreen(TFT_BROWN);
  tft.setTextColor(TFT_GREEN);

  tft.drawString(" !\"#$%&'()*+,-./0123456", 0, 0, 2);
  tft.drawString("789:;<=>?@ABCDEFGHIJKL", 0, 16, 2);
  tft.drawString("MNOPQRSTUVWXYZ[\\]^_`", 0, 32, 2);
  tft.drawString("abcdefghijklmnopqrstuvw", 0, 48, 2);
  xpos = 0;
  xpos += tft.drawString("xyz{|}~", 0, 64, 2);
  tft.drawChar(127, xpos, 64, 2);
  delay(WAIT);

  tft.fillScreen(TFT_BROWN);
  tft.setTextColor(TFT_GREEN);

  tft.drawString(" !\"#$%&'()*+,-.", 0, 0, 4);
  tft.drawString("/0123456789:;", 0, 26, 4);
  tft.drawString("<=>?@ABCDE", 0, 52, 4);
  tft.drawString("FGHIJKLMNO", 0, 78, 4);
  tft.drawString("PQRSTUVWX", 0, 104, 4);

  delay(WAIT);
  tft.fillScreen(TFT_BROWN);
  tft.drawString("YZ[\\]^_`abc", 0, 0, 4);
  tft.drawString("defghijklmno", 0, 26, 4);
  tft.drawString("pqrstuvwxyz", 0, 52, 4);
  xpos = 0;
  xpos += tft.drawString("{|}~", 0, 78, 4);
  tft.drawChar(127, xpos, 78, 4);
  delay(WAIT);

  tft.fillScreen(TFT_BROWN);
  tft.setTextColor(TFT_BLUE);

  tft.drawString("012345", 0, 0, 6);
  tft.drawString("6789", 0, 40, 6);
  tft.drawString("apm-:.", 0, 80, 6);
  delay(WAIT);

  tft.fillScreen(TFT_BROWN);
  tft.setTextColor(TFT_RED);

  tft.drawString("0123", 0, 0, 7);
  tft.drawString("4567", 0, 60, 7);
  delay(WAIT);

  tft.fillScreen(TFT_BROWN);
  tft.drawString("890:.", 0, 0, 7);
  tft.drawString("", 0, 60, 7);
  delay(WAIT);

  tft.fillScreen(TFT_BROWN);
  tft.setTextColor(TFT_YELLOW);

  tft.drawString("0123", 0, 0, 8);
  delay(WAIT);

  tft.fillScreen(TFT_BROWN);
  tft.drawString("4567", 0, 0, 8);
  delay(WAIT);

  tft.fillScreen(TFT_BROWN);
  tft.drawString("890:.", 0, 0, 8);
  delay(WAIT);

  tft.setTextColor(TFT_MAGENTA);

  tft.drawNumber(millis() - targetTime, 0, 100, 4);
  delay(4000);;
}

————————————————————————————————————————

3.显示图片

pushimage函数
————————————————————————————————————————

// Icon images are stored in tabs ^ e.g. Alert.h etc above this line
// more than one icon can be in a header file

// Arrays containing FLASH images can be created with UTFT library tool:
// (libraries\UTFT\Tools\ImageConverter565.exe)
// Convert to .c format then copy into a new tab

/*
 This sketch demonstrates loading images from arrays stored in program (FLASH) memory.

 Works with TFT_eSPI library here:
 https://github.com/Bodmer/TFT_eSPI

 This sketch does not use/need any fonts at all...

 Code derived from ILI9341_due library example

 Make sure all the display driver and pin connections are correct by
 editing the User_Setup.h file in the TFT_eSPI library folder.

 #########################################################################
 ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
 #########################################################################
*/

#include <TFT_eSPI.h>       // Hardware-specific library

TFT_eSPI tft = TFT_eSPI();  // Invoke custom library

// Include the header files that contain the icons
#include "Alert.h"
#include "Close.h"
#include "Info.h"

long count = 0; // Loop count

void setup()
{
  Serial.begin(115200);
  tft.begin();
  tft.setRotation(1);	// landscape

  tft.fillScreen(TFT_BLACK);

  // Swap the colour byte order when rendering
  tft.setSwapBytes(true);

  // Draw the icons
  tft.pushImage(100, 100, infoWidth, infoHeight, info);
  tft.pushImage(140, 100, alertWidth, alertHeight, alert);
  tft.pushImage(180, 100, closeWidth, closeHeight, closeX);

  // Pause here to admire the icons!
  delay(2000);

}

void loop()
{
  // Loop filling and clearing screen
  tft.pushImage(random(tft.width() -  infoWidth), random(tft.height() -  infoHeight),  infoWidth,  infoHeight, info);
  tft.pushImage(random(tft.width() - alertWidth), random(tft.height() - alertHeight), alertWidth, alertHeight, alert);
  tft.pushImage(random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight, closeX);

  // Clear screen after 100 x 3 = 300 icons drawn
  if (1000 == count++) {
    count = 1;
    tft.setRotation(2 * random(2)); // Rotate randomly to clear display left>right or right>left to reduce monotony!
    tft.fillScreen(TFT_BLACK);
    tft.setRotation(1);
  }
}
// We need this header file to use FLASH as storage with PROGMEM directive:

// Icon width and height
const uint16_t alertWidth = 32;
const uint16_t alertHeight = 32;

const unsigned short  alert[1024] PROGMEM={
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0840,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 0, 32 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1080,0xAC66,0xEDE8,0xFE69,0xC4C6,0x2901,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 1, 64 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xBCC6,0xFE68,0xFE68,0xFE6A,0xFE68,0xEDE8,0x18A1,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 2, 96 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x8344,0xFE48,0xFE8C,0xFFDD,0xFFFF,0xFEF0,0xFE48,0xB466,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 3, 128 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1880,0xEDC7,0xFE48,0xFF99,0xFFBC,0xFF9B,0xFFBD,0xFE6A,0xFE48,0x5A23,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 4, 160 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x9BE5,0xFE28,0xFED0,0xFFBC,0xFF7A,0xFF9A,0xFF9B,0xFF35,0xFE28,0xBCA6,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 5, 192 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3962,0xFE28,0xFE28,0xFF9A,0xFF79,0xFF9A,0xFF9B,0xFF9A,0xFFBD,0xFE6B,0xFE28,0x72E3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 6, 224 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xB465,0xFE28,0xFEF2,0xFF7A,0xFF79,0xFF7A,0xFF9A,0xFF7A,0xFF7A,0xFF78,0xFE28,0xDD67,0x0860,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 7, 256 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x5A22,0xFE07,0xFE29,0xFF9B,0xFF37,0xFF58,0xFF79,0xFF79,0xFF79,0xFF58,0xFF9B,0xFEAE,0xFE07,0x93A4,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 8, 288 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xC4A5,0xFE07,0xFF15,0xFF37,0xFF36,0xAD11,0x2965,0x2965,0xCDF4,0xFF37,0xFF37,0xFF79,0xFE07,0xFE07,0x2901,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 9, 320 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x7B03,0xFDE7,0xFE4B,0xFF79,0xFEF4,0xFF15,0xB552,0x2945,0x2945,0xDE55,0xFF16,0xFF15,0xFF58,0xFED1,0xFDE7,0xAC25,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 10, 352 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0840,0xDD26,0xFDE7,0xFF57,0xFED3,0xFED2,0xFEF4,0xBD93,0x2124,0x2124,0xDE75,0xFF14,0xFED3,0xFED3,0xFF7A,0xFE08,0xFDE7,0x49A2,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 11, 384 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x9BA4,0xFDC6,0xFE6E,0xFF36,0xFE90,0xFEB1,0xFED3,0xC592,0x2124,0x2124,0xE675,0xFED3,0xFEB2,0xFEB1,0xFEF3,0xFEF3,0xFDC6,0xBC45,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 12, 416 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3141,0xF5C6,0xF5C7,0xFF58,0xFE90,0xFE6F,0xFE8F,0xFEB1,0xCDB2,0x2104,0x2104,0xF6B4,0xFEB1,0xFE90,0xFE8F,0xFE90,0xFF58,0xFE0A,0xF5C6,0x72A3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 13, 448 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xABE4,0xF5A6,0xFEB1,0xFED3,0xFE4E,0xFE6E,0xFE6F,0xFE90,0xD5F2,0x18E3,0x18E3,0xFED4,0xFE90,0xFE6F,0xFE6F,0xFE6E,0xFE91,0xFF36,0xF5A6,0xCCA5,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // row 14, 480 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0x5202,0xF5A6,0xF5C7,0xFF58,0xFE4D,0xFE4D,0xFE4D,0xFE4E,0xFE6F,0xDE11,0x18C3,0x18C3,0xFED3,0xFE6F,0xFE6E,0xFE4E,0xFE4D,0xFE4D,0xFF16,0xFE2C,0xF5A6,0x9363,0x0000,0x0000,0x0000,0x0000,0x0000, // row 15, 512 pixels
0x0000,0x0000,0x0000,0x0000,0x0000,0xBC44,0xF585,0xFED3,0xFE6F,0xFE2C,0xFE2C,0xFE2D,0xFE4D,0xFE4E,0xE630,0x10A2,0x2104,0xFED1,0xFE4E,0xFE4D,0xFE4D,0xFE2D,0xFE2C,0xFE4D,0xFF37,0xF586,0xF585,0x28E1,0x0000,0x0000,0x0000,0x0000, // row 16, 544 pixels
0x0000,0x0000,0x0000,0x0000,0x7282,0xF565,0xF5EA,0xFF16,0xFE0B,0xFE0B,0xFE0B,0xFE2C,0xFE2C,0xFE4D,0xF670,0x1082,0x2924,0xFEB0,0xFE2D,0xFE2C,0xFE2C,0xFE2C,0xFE0B,0xFE0B,0xFEB2,0xFE6F,0xF565,0xA383,0x0000,0x0000,0x0000,0x0000, // row 17, 576 pixels
0x0000,0x0000,0x0000,0x0840,0xD4C4,0xF565,0xFEF5,0xFE0C,0xFDE9,0xFDEA,0xFE0A,0xFE0B,0xFE0B,0xFE2C,0xFE8F,0x0861,0x2964,0xFE8F,0xFE2C,0xFE0B,0xFE0B,0xFE0B,0xFE0A,0xFDEA,0xFE0B,0xFF37,0xF586,0xF565,0x4181,0x0000,0x0000,0x0000, // row 18, 608 pixels
0x0000,0x0000,0x0000,0x9343,0xF545,0xF60C,0xFED3,0xFDC8,0xFDC8,0xFDC9,0xFDE9,0xFDEA,0xFDEA,0xFE0B,0xFE8E,0x0861,0x3184,0xFE6D,0xFE0B,0xFE0A,0xFDEA,0xFDEA,0xFDE9,0xFDC9,0xFDC9,0xFE4E,0xFEB2,0xF545,0xB3E3,0x0000,0x0000,0x0000, // row 19, 640 pixels
0x0000,0x0000,0x28E0,0xF544,0xF545,0xFF17,0xFDC8,0xFDA7,0xFDA7,0xFDC8,0xFDC8,0xFDC9,0xFDC9,0xFDE9,0xFE6C,0x10A2,0x39C4,0xFE4C,0xFDEA,0xFDE9,0xFDC9,0xFDC9,0xFDC8,0xFDC8,0xFDA7,0xFDA8,0xFF16,0xF588,0xF544,0x6222,0x0000,0x0000, // row 20, 672 pixels
0x0000,0x0000,0xA383,0xF524,0xF64E,0xFE4E,0xFD86,0xFD86,0xFD87,0xFDA7,0xFDA7,0xFDA8,0xFDC8,0xFDC8,0xFE2A,0xA469,0xB4EA,0xFE2A,0xFDC9,0xFDC8,0xFDC8,0xFDA8,0xFDA7,0xFDA7,0xFD87,0xFD86,0xFDEA,0xFED3,0xF524,0xC443,0x0000,0x0000, // row 21, 704 pixels
0x0000,0x51C1,0xF504,0xF546,0xFF16,0xF565,0xFD65,0xFD65,0xFD86,0xFD86,0xFD86,0xFDA7,0xFDA7,0xFDA7,0xFDE8,0xFE6A,0xFE4A,0xFDE8,0xFDA7,0xFDA7,0xFDA7,0xFDA7,0xFD86,0xFD86,0xFD86,0xFD65,0xFD65,0xFEB2,0xF5CA,0xF504,0x8AE2,0x0000, // row 22, 736 pixels
0x0000,0xB3A2,0xED03,0xFE92,0xFDC9,0xF543,0xF544,0xFD44,0xFD65,0xFD65,0xFD65,0xFD86,0xFD86,0xFD86,0xFDA7,0xFDC7,0xFDC7,0xFDA7,0xFD86,0xFD86,0xFD86,0xFD86,0xFD65,0xFD65,0xFD65,0xFD44,0xF544,0xFD86,0xFEF5,0xED03,0xE4C3,0x1880, // row 23, 768 pixels
0x7241,0xECE3,0xF567,0xFED3,0xF523,0xF523,0xF523,0xF543,0xF544,0xF544,0xFD65,0xFD65,0xFD65,0xFD65,0xD4E6,0x39C5,0x39A5,0xD4E6,0xFD86,0xFD65,0xFD65,0xFD65,0xFD65,0xF544,0xF544,0xF543,0xF523,0xF523,0xFE2E,0xF5EC,0xECE3,0x9B42, // row 24, 800 pixels
0xD443,0xECE3,0xFED4,0xF565,0xF502,0xF502,0xF522,0xF523,0xF523,0xF543,0xF544,0xF544,0xF544,0xFD65,0x8B64,0x18C3,0x18C3,0x8344,0xFD85,0xFD44,0xF544,0xF544,0xF544,0xF543,0xF523,0xF523,0xF522,0xF502,0xF523,0xFEF5,0xED04,0xECE3, // row 25, 832 pixels
0xECC3,0xF5AB,0xFE6F,0xF501,0xF4E1,0xF501,0xF502,0xF502,0xF522,0xF522,0xF523,0xF523,0xF523,0xFD84,0xC504,0x20E1,0x18E1,0xC4E4,0xFD84,0xF543,0xF523,0xF523,0xF523,0xF522,0xF522,0xF502,0xF502,0xF501,0xF501,0xFDC9,0xF62F,0xECC3, // row 26, 864 pixels
0xECC2,0xFE92,0xF523,0xF4E0,0xF4E0,0xF4E1,0xF4E1,0xF501,0xF501,0xF502,0xF502,0xF522,0xF522,0xF543,0xFDE3,0xFEA5,0xF6A4,0xFE04,0xF543,0xF522,0xF522,0xF522,0xF502,0xF502,0xF501,0xF501,0xF4E1,0xF4E1,0xF4E0,0xF4E1,0xFED4,0xECC2, // row 27, 896 pixels
0xECA2,0xF5EC,0xF4E0,0xF4C0,0xF4E0,0xF4E0,0xF4E0,0xF4E1,0xF4E1,0xF501,0xF501,0xF501,0xF502,0xF502,0xF542,0xFDA2,0xFDA2,0xF542,0xF502,0xF502,0xF502,0xF501,0xF501,0xF501,0xF4E1,0xF4E1,0xF4E0,0xF4E0,0xF4E0,0xF4C0,0xF5A9,0xECA2, // row 28, 928 pixels
0xECA2,0xECA2,0xECC2,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4E1,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E2,0xF4E1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xF4C1,0xECC2,0xECC3,0xECA2, // row 29, 960 pixels
0x8AC1,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0xEC82,0x9B01, // row 30, 992 pixels
0x0000,0x1880,0x51A0,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x8AA1,0x61E0,0x28E0,0x0000}; // row 31, 1024 pixels

————————————————————————————————————————

4.显示图片

drawXBM
————————————————————————————————————————

// Example sketch to demonstrate the drawing of X BitMap (XBM)
// format image onto the display.

// Information on the X BitMap (XBM) format can be found here:
// https://en.wikipedia.org/wiki/X_BitMap

// This example is part of the TFT_eSPI library:
// https://github.com/Bodmer/TFT_eSPI

// Created by Bodmer 23/04/18

#include "xbm.h"             // Sketch tab header for xbm images

#include <TFT_eSPI.h>        // Hardware-specific library

TFT_eSPI tft = TFT_eSPI();   // Invoke library


void setup()
{
  tft.begin();               // Initialise the display
  tft.fillScreen(TFT_BLACK); // Black screen fill
}

void loop()
{

  // Example 1
  // =========
  // Random x and y coordinates
  int x = random(tft.width()  - logoWidth);
  int y = random(tft.height() - logoHeight);

  // Draw bitmap with top left corner at x,y with foreground only color
  // Bits set to 1 plot as the defined color, bits set to 0 are not plotted
  //              x  y  xbm   xbm width  xbm height  color
  tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_WHITE);

  delay(500);

  // Erase old one by drawing over with background colour
  tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_BLACK);


  // Example 2
  // =========
  // New random x and y coordinates
  x = random(tft.width()  - logoWidth);
  y = random(tft.height() - logoHeight);

  // Draw bitmap with top left corner at x,y with foreground and background colors
  // Bits set to 1 plot as the defined fg color, bits set to 0 are plotted as bg color
  //              x  y  xbm   xbm width  xbm height  fg color   bg color
  tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_WHITE, TFT_RED);

  delay(500);

  // Erase old one by drawing over with background colour
  tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_BLACK, TFT_BLACK);

}









// Images can be converted to XBM format by using the online converter here:
// https://www.online-utility.org/image/convert/to/XBM

// The output must be pasted in a header file, renamed and adjusted to appear
// as as a const unsigned char array in PROGMEM (FLASH program memory).

// The xbm format adds padding to pixel rows so they are a whole number of bytes
// In this example 50 pixel width means 56 bits = 7 bytes
// the 50 height then means array uses 50 x 7 = 350 bytes of FLASH
// The library ignores the padding bits when drawing the image on the display.

// Example of the correct format is shown below

// Espressif logo 50 x 50 pixel array in XBM format
#define logoWidth  50  // logo width
#define logoHeight 50  // logo height

// Image is stored in this array
PROGMEM const unsigned char logo[] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x00, 
  0x00, 0x00, 0x00, 0x07, 0xFC, 0x07, 0x00, 0x00, 0x00, 0x82, 0x7F, 0xF0, 
  0x1F, 0x00, 0x00, 0x00, 0xC6, 0xFF, 0xC3, 0x3F, 0x00, 0x00, 0x00, 0xE7, 
  0xFF, 0x8F, 0x7F, 0x00, 0x00, 0x80, 0xE3, 0xFF, 0x1F, 0xFE, 0x00, 0x00, 
  0x80, 0xE1, 0xFF, 0x7F, 0xFC, 0x01, 0x00, 0xC0, 0x00, 0xFF, 0xFF, 0xF8, 
  0x03, 0x00, 0xE0, 0x00, 0xE0, 0xFF, 0xF1, 0x03, 0x00, 0x60, 0xF0, 0x81, 
  0xFF, 0xE3, 0x07, 0x00, 0x60, 0xFC, 0x1F, 0xFE, 0xC7, 0x07, 0x00, 0x30, 
  0xFE, 0x7F, 0xF8, 0x8F, 0x0F, 0x00, 0x30, 0xFF, 0xFF, 0xF1, 0x9F, 0x0F, 
  0x00, 0xB0, 0xFF, 0xFF, 0xE3, 0x3F, 0x0F, 0x00, 0xB0, 0xFF, 0xFF, 0xC7, 
  0x3F, 0x1E, 0x00, 0xB8, 0xFF, 0xFF, 0x8F, 0x7F, 0x1E, 0x00, 0x98, 0x1F, 
  0xFC, 0x3F, 0xFF, 0x1C, 0x00, 0xB8, 0x3F, 0xE0, 0x3F, 0xFE, 0x1C, 0x00, 
  0x98, 0xFF, 0xC3, 0x7F, 0xFE, 0x19, 0x00, 0x98, 0xFF, 0x0F, 0xFF, 0xFC, 
  0x19, 0x00, 0x38, 0xFF, 0x3F, 0xFF, 0xFC, 0x01, 0x00, 0x30, 0xFE, 0x7F, 
  0xFE, 0xF9, 0x03, 0x00, 0x30, 0xFC, 0xFF, 0xFC, 0xF9, 0x03, 0x00, 0x30, 
  0xF8, 0xFF, 0xF8, 0xF3, 0x03, 0x00, 0x30, 0x00, 0xFF, 0xF9, 0xF3, 0x03, 
  0x00, 0x70, 0x00, 0xFC, 0xF9, 0xF3, 0x07, 0x00, 0x60, 0x00, 0xF8, 0xF3, 
  0xF3, 0x07, 0x00, 0xE0, 0xF8, 0xF8, 0xF3, 0xF7, 0x03, 0x00, 0xC0, 0xF8, 
  0xF1, 0xF3, 0xE3, 0x03, 0x00, 0xC0, 0xFD, 0xF1, 0xF3, 0xF7, 0x01, 0x00, 
  0x80, 0xFD, 0xF1, 0xF3, 0xE7, 0x00, 0x00, 0x00, 0xFF, 0xF1, 0xF3, 0x07, 
  0x00, 0x00, 0x00, 0xFF, 0xF8, 0xF3, 0x07, 0x00, 0x00, 0x00, 0x7E, 0xF8, 
  0xF3, 0x83, 0x03, 0x00, 0x00, 0x3C, 0xF8, 0xF3, 0xC3, 0x01, 0x00, 0x00, 
  0x70, 0xF8, 0xF9, 0xE3, 0x00, 0x00, 0x00, 0xE0, 0xE1, 0x41, 0x78, 0x00, 
  0x00, 0x00, 0xC0, 0x0F, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFD, 
  0x07, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 
  0x80, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
  0x00, 0x00, };


_________________________________________________________

二.nodeMCU 驱动SSD1306

本文中代码下载百度云
密码:
1111

1. 自定义字体的方法

1.首先,创建头文件并引用(下图中的DIYFont.h);
在这里插入图片描述
2.把代码放在头文件中,
在这里插入图片描述
在这里插入图片描述

注意事项

1.const uint8_t要和使用库中的一样

比如:

4355861.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MTM5NzIxNQ==,size_16,color_FFFFFF,t_70)

在这里插入图片描述

2.使用的库是ESP8266_and ESP32 OLED driver for SSD 1306 displays,不是adafruit SSD 1306库!!!

2.代码

1.主函数

#include "Wire.h"
#include "SSD1306.h"
#include"DIYFont.h"
#define SDA D2
#define SCL D1
SSD1306 display(0x3c, SDA, SCL);
void setup() {

  display.init();

  display.setFont(zidingyi_11);
  display.drawString(20, 20, "12354");

//  display.setFont(ArialMT_Plain_18);
//  display.drawString(0, 10, "35");

//  display.setFont(ArialMT_Plain_24);
//  display.drawString(0, 25, "Hello World");

  display.display();
}

void loop() {}

2.头文件


const uint8_t  zidingyi_11[] PROGMEM = {
  0x11, // Width: 17
  0x17, // Height: 23
  0x20, // First Char: 32
  0x1B, // Numbers of Chars: 27

  // Jump Table:
  0xFF, 0xFF, 0x00, 0x04,  // 32:65535
  0x00, 0x00, 0x15, 0x08,  // 33:0
  0x00, 0x15, 0x15, 0x08,  // 34:21
  0x00, 0x2A, 0x15, 0x08,  // 35:42
  0x00, 0x3F, 0x15, 0x08,  // 36:63
  0x00, 0x54, 0x15, 0x08,  // 37:84
  0x00, 0x69, 0x15, 0x08,  // 38:105
  0x00, 0x7E, 0x15, 0x08,  // 39:126
  0x00, 0x93, 0x15, 0x08,  // 40:147
  0x00, 0xA8, 0x15, 0x08,  // 41:168
  0x00, 0xBD, 0x15, 0x08,  // 42:189
  0x00, 0xD2, 0x15, 0x08,  // 43:210
  0x00, 0xE7, 0x15, 0x08,  // 44:231
  0x00, 0xFC, 0x26, 0x11,  // 45:252
  0xFF, 0xFF, 0x00, 0x00,  // 46:65535
  0x01, 0x22, 0x15, 0x08,  // 47:290
  0x01, 0x37, 0x2D, 0x11,  // 48:311
  0x01, 0x64, 0x2D, 0x11,  // 49:356
  0x01, 0x91, 0x2C, 0x11,  // 50:401
  0x01, 0xBD, 0x2D, 0x11,  // 51:445
  0x01, 0xEA, 0x2D, 0x11,  // 52:490
  0x02, 0x17, 0x2D, 0x11,  // 53:535
  0x02, 0x44, 0x2D, 0x11,  // 54:580
  0x02, 0x71, 0x2D, 0x11,  // 55:625
  0x02, 0x9E, 0x2D, 0x11,  // 56:670
  0x02, 0xCB, 0x2D, 0x11,  // 57:715
  0x02, 0xF8, 0x09, 0x04,  // 58:760

  // Font Data:
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 33
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 34
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 35
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 36
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 37
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 38
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 39
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 40
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 41
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 42
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 43
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 44
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x10,  // 45
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 47
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xEF,0x3F,0xF4,0xEF,0x5F,0xEC,0xC7,0x6F,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0xEC,0xC7,0x6F,0xF4,0xEF,0x5F,0xF8,0xEF,0x3F, // 48
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xC7,0x0F,0xF0,0xEF,0x1F,0xF8,0xEF,0x3F, // 49
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x3F,0x04,0xE0,0x5F,0x0C,0xD0,0x6F,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0xEC,0x17,0x60,0xF4,0x0F,0x40,0xF8,0x0F,  // 50
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x40,0x0C,0x10,0x60,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0xEC,0xD7,0x6F,0xF4,0xEF,0x5F,0xF8,0xEF,0x3F, // 51
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0x00,0xF0,0x0F,0x00,0xE0,0x17,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0xE0,0xD7,0x0F,0xF0,0xEF,0x1F,0xF8,0xEF,0x3F, // 52
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0x00,0xF4,0x0F,0x40,0xEC,0x17,0x60,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x0C,0xD0,0x6F,0x04,0xE0,0x5F,0x00,0xE0,0x3F, // 53
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xEF,0x3F,0xF4,0xEF,0x5F,0xEC,0xD7,0x6F,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x0C,0xD0,0x6F,0x04,0xE0,0x5F,0x00,0xE0,0x3F, // 54
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0x00,0xF4,0x0F,0x00,0xEC,0x07,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0xEC,0xC7,0x0F,0xF4,0xEF,0x1F,0xF8,0xEF,0x3F, // 55
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xEF,0x3F,0xF4,0xEF,0x5F,0xEC,0xD7,0x6F,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0xEC,0xD7,0x6F,0xF4,0xEF,0x5F,0xF8,0xEF,0x3F, // 56
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0x00,0xF4,0x0F,0x40,0xEC,0x17,0x60,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0x1C,0x38,0x70,0xEC,0xD7,0x6F,0xF4,0xEF,0x5F,0xF8,0xEF,0x3F, // 57
  0x00,0x00,0x00,0x80,0x03,0x03,0x80,0x03,0x03  // 58
};

// Created by http://oleddisplay.squix.ch/ Consider a donation
// In case of problems make sure that you are using the font file with the correct version!
const char DSEG7_Classic_Regular_21[] PROGMEM = {
  0x11, // Width: 17
  0x17, // Height: 23
  0x20, // First Char: 32
  0x1B, // Numbers of Chars: 27

  // Jump Table:
  0xFF, 0xFF, 0x00, 0x04,  // 32:65535
  0x00, 0x00, 0x15, 0x08,  // 33:0
  0x00, 0x15, 0x15, 0x08,  // 34:21
  0x00, 0x2A, 0x15, 0x08,  // 35:42
  0x00, 0x3F, 0x15, 0x08,  // 36:63
  0x00, 0x54, 0x15, 0x08,  // 37:84
  0x00, 0x69, 0x15, 0x08,  // 38:105
  0x00, 0x7E, 0x15, 0x08,  // 39:126
  0x00, 0x93, 0x15, 0x08,  // 40:147
  0x00, 0xA8, 0x15, 0x08,  // 41:168
  0x00, 0xBD, 0x15, 0x08,  // 42:189
  0x00, 0xD2, 0x15, 0x08,  // 43:210
  0x00, 0xE7, 0x15, 0x08,  // 44:231
  0x00, 0xFC, 0x29, 0x11,  // 45:252
  0xFF, 0xFF, 0x00, 0x00,  // 46:65535
  0x01, 0x25, 0x15, 0x08,  // 47:293
  0x01, 0x3A, 0x2D, 0x11,  // 48:314
  0x01, 0x67, 0x2D, 0x11,  // 49:359
  0x01, 0x94, 0x2C, 0x11,  // 50:404
  0x01, 0xC0, 0x2D, 0x11,  // 51:448
  0x01, 0xED, 0x2D, 0x11,  // 52:493
  0x02, 0x1A, 0x2D, 0x11,  // 53:538
  0x02, 0x47, 0x2D, 0x11,  // 54:583
  0x02, 0x74, 0x2D, 0x11,  // 55:628
  0x02, 0xA1, 0x2D, 0x11,  // 56:673
  0x02, 0xCE, 0x2D, 0x11,  // 57:718
  0x02, 0xFB, 0x09, 0x04,  // 58:763

  // Font Data:
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 33
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 34
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 35
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 36
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 37
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 38
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 39
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 40
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 41
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 42
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 43
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 44
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10, // 45
  0x00,0x00,0x00,0x00,0xFE,0x7F,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0x02,0x40,0x00,0xFE,0x7F, // 47
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xEF,0x3F,0xF4,0xC7,0x5F,0x0C,0x00,0x60,0x0C,0x00,0x60,0x0C,0x00,0x60,0x0C,0x00,0x60,0x0C,0x00,0x60,0x0C,0x00,0x60,0x0C,0x00,0x60,0x0C,0x00,0x60,0x0C,0x00,0x60,0xF4,0xC7,0x5F,0xF8,0xEF,0x3F, // 48
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xC7,0x1F,0xF8,0xEF,0x3F, // 49
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x3F,0x04,0xD0,0x5F,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0xF4,0x17,0x40,0xF8,0x0F,  // 50
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x10,0x40,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0xF4,0xD7,0x5F,0xF8,0xEF,0x3F, // 51
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0x00,0xF0,0x17,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0x00,0x10,0x00,0xF0,0xD7,0x1F,0xF8,0xEF,0x3F, // 52
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0x00,0xF4,0x17,0x40,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x04,0xD0,0x5F,0x00,0xE0,0x3F, // 53
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xEF,0x3F,0xF4,0xD7,0x5F,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x04,0xD0,0x5F,0x00,0xE0,0x3F, // 54
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0x00,0xF4,0x07,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0xF4,0xC7,0x1F,0xF8,0xEF,0x3F, // 55
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xEF,0x3F,0xF4,0xD7,0x5F,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0xF4,0xD7,0x5F,0xF8,0xEF,0x3F, // 56
  0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0x00,0xF4,0x17,0x40,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0x0C,0x10,0x60,0xF4,0xD7,0x5F,0xF8,0xEF,0x3F, // 57
  0x00,0x00,0x00,0x80,0x03,0x03,0x80,0x03,0x03  // 58
};



3.图片展示

1.代码展示

在这里插入图片描述
在这里插入图片描述

2.此程序烧录后的显示

在这里插入图片描述

_________________________________________________________

三.ESP8266无线配网 + 获取网络时间

1.串口显示

在这里插入图片描述

2.代码分享

#include <ESP8266WiFi.h>          //https://github.com/esp8266/Arduino

//needed for library
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <CustomWiFiManager.h>         //https://github.com/tzapu/WiFiManager
#include <NTPClient.h>
// change next line to use with another board/shield
#include <ESP8266WiFi.h>
//#include <WiFi.h> // for WiFi shield
//#include <WiFi101.h> // for WiFi 101 shield or MKR1000
#include <WiFiUdp.h>

WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "ntp1.aliyun.com",60*60*8, 30*60*1000);
void setup() {
    
    Serial.begin(115200);

    //WiFiManager
    //Local intialization. Once its business is done, there is no need to keep it around
    WiFiManager wifiManager;
    
 wifiManager.autoConnect("密码8个8", "88888888");

    
    //if you get here you have connected to the WiFi
    Serial.println("已经脸连上无线网啦!!");
    
    timeClient.begin();
}

void loop() {
    
    timeClient.update();

  Serial.println(timeClient.getFormattedTime());

  delay(1000);



  
}

_________________________________________________________

四. ARDUINO SSD1306 OLED

1.SSD1306其他学习链接

2.OLEDAnimations软件使用教程

3.字模提取取模方法详解

4.本篇百度云链接— 提取码: 301w

百度云内容:
在这里插入图片描述
接线 (nodeMCU : D1-----SCL, D2------SDA)
在这里插入图片描述

显示动画
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

部分代码(请下载百度云里面的代码,不然会报错)

***********************************显示图片***************************************************************
void draw_picture() {

  //画 枫叶
  display.clearDisplay();   // clears the screen and buffer
  display.drawBitmap(16, 16, fengye, 64, 64, WHITE);//参数为:x,y,名字,图像x轴像素,图像Y轴像素
  display.display();
  delay(2000);
  //画 猫咪
  display.clearDisplay();   // clears the screen and buffer
  display.drawBitmap(0, 0, maomi, 128, 64, WHITE);
  display.display();
  delay(2000);
  //画 尽我所能
  display.clearDisplay();   // clears the screen and buffer
  display.drawBitmap(0, 0, jinwosuoneng, 128, 64, WHITE);
  display.display();
  delay(2000);
}
***********************************动画***************************************************************

int xx = 10;//xx,yy 为动画的左上角坐标
int yy = 10;
int tt = 150;//tt为每一帧的时间间隔



void draw_animated_rabbit () {

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit0, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit1, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit2, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit3, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit4, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit5, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit6, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit7, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit8, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit9, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit10, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit11, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit12, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit13, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit14, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit15, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit16, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit17, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit18, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit19, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit20, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit21, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit22, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit23, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit24, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit25, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit26, 64, 64, 1);
  display.display();
  delay(tt);

  display.clearDisplay();
  display.drawBitmap(xx, yy, framerabbit27, 64, 64, 1);
  display.display();
  delay(tt);


}


//***********************************画矩形***************************************************************

void testdrawrect(void) {
  display.clearDisplay();

  for (int16_t i = 0; i < display.height() / 2; i += 2) {
    display.drawRect(i, i, display.width() - 2 * i, display.height() - 2 * i, SSD1306_WHITE);
    display.display(); // Update screen with each newly-drawn rectangle
    delay(1);
  }

  delay(2000);
}
//***********************************画填充矩形***************************************************************

void testfillrect(void) {
  display.clearDisplay();

  for (int16_t i = 0; i < display.height() / 2; i += 3) {
    // The INVERSE color is used so rectangles alternate white/black
    display.fillRect(i, i, display.width() - i * 2, display.height() - i * 2, SSD1306_INVERSE);
    display.display(); // Update screen with each newly-drawn rectangle
    delay(1);
  }

  delay(2000);}

  //*****************************************画圆***************************************************************

  void testdrawcircle(void) {
  display.clearDisplay();

  for (int16_t i = 0; i < max(display.width(), display.height()) / 2; i += 2) {
    display.drawCircle(display.width() / 2, display.height() / 2, i, SSD1306_WHITE);
    display.display();
    delay(1);
  }

  delay(2000);
}

//********************************************画填充圆*****************************************************************

void testfillcircle(void) {
  display.clearDisplay();

  for (int16_t i = max(display.width(), display.height()) / 2; i > 0; i -= 3) {
    // The INVERSE color is used so circles alternate white/black
    display.fillCircle(display.width() / 2, display.height() / 2, i, SSD1306_INVERSE);
    display.display(); // Update screen with each newly-drawn circle
    delay(1);
  }

  delay(2000);
}
//****************************************************圆角矩形******************************************************

void testdrawroundrect(void) {
  display.clearDisplay();

  for (int16_t i = 0; i < display.height() / 2 - 2; i += 2) {
    display.drawRoundRect(i, i, display.width() - 2 * i, display.height() - 2 * i,
                          display.height() / 4, SSD1306_WHITE);
    display.display();
    delay(1);
  }

  delay(2000);
}
//****************************************************填充圆角矩形************************************************************

void testfillroundrect(void) {
  display.clearDisplay();

  for (int16_t i = 0; i < display.height() / 2 - 2; i += 2) {
    // The INVERSE color is used so round-rects alternate white/black
    display.fillRoundRect(i, i, display.width() - 2 * i, display.height() - 2 * i,
                          display.height() / 4, SSD1306_INVERSE);
    display.display();
    delay(1);
  }

  delay(2000);
}
//********************************************************三角形***********************************

void testdrawtriangle(void) {
  display.clearDisplay();

  for (int16_t i = 0; i < max(display.width(), display.height()) / 2; i += 5) {
    display.drawTriangle(
      display.width() / 2  , display.height() / 2 - i,
      display.width() / 2 - i, display.height() / 2 + i,
      display.width() / 2 + i, display.height() / 2 + i, SSD1306_WHITE);
    display.display();
    delay(1);
  }

  delay(2000);
}
//***************************************填充的三角形***********************************

void testfilltriangle(void) {
  display.clearDisplay();

  for (int16_t i = max(display.width(), display.height()) / 2; i > 0; i -= 5) {
    // The INVERSE color is used so triangles alternate white/black
    display.fillTriangle(
      display.width() / 2  , display.height() / 2 - i,
      display.width() / 2 - i, display.height() / 2 + i,
      display.width() / 2 + i, display.height() / 2 + i, SSD1306_INVERSE);
    display.display();
    delay(1);
  }

  delay(2000);
}
//**************************************************************英文**************************************

void testdrawyingwen(void) {
   display.clearDisplay();
  display.setTextSize(1); //选择字号
  display.setTextColor(WHITE);  //字体颜色
  display.setCursor(0,8);
  display.print("setTextSize: 1");
  display.display();
  delay(2000);
  display.clearDisplay();
  display.setTextSize(2); //选择字号
  display.print("setTextSize: 2");
  display.display();
  delay(2000);

}
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值