欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 【零知ESP8266教程】快速入門22 OLED模塊的再探索 [打印本頁]

作者: roc2    時間: 2019-11-6 16:23
標題: 【零知ESP8266教程】快速入門22 OLED模塊的再探索
引述:
制作完世界時鐘之后,最終還是要回歸本心。我們發現,和之前的電子作品一樣,OLED模塊的拓展使用會用到不同相關的軟件庫,這些軟件庫的使用是豐富了OLED的實用范圍,使得我們制作的電子產品也更加的多樣化,在生活中的使用范圍也更加廣泛。這同時也推動了我們了解電子世界的進程,現在的你,應該對電子世界有一個大概的輪廓了吧。

同理,其他模塊的使用也和本次分享的引述一樣,擁有更大的發展潛力,這就取決于我們作為開發者的想象力了。

接下來,我們繼續分享學習。
本次分享則繼續在零知ESP8266上使用OLED,加深我們對OLED模塊的認識。
一、硬件
電腦,windows系統
零知ESP8266開發板
OLED SSD1306模塊
micro-usb線

二、連線




三、軟件庫
(1)本次使用了OLED相關的軟件庫,因此需要安裝如下兩個庫:
Tip:如果你的電腦已在零知實驗室“軟件下載”處安裝了最新的零知開發工具(如下圖),即可跳過此步驟。

1. Adafruit_SSD1306
2. Adafruit-GFX

(2)安裝
在零知實驗室官網搜索:本地庫,即可安裝。

同時也可以給我留言,我們一起交流學習。

(3)燒錄程序
在這里我們選中SSD1306的示例即可。


其完整代碼如下:
  1. <font size="3">#include <SPI.h>
  2. #include <Wire.h>
  3. #include <Adafruit_GFX.h>
  4. #include <Adafruit_SSD1306.h>
  5.   
  6. #define SCREEN_WIDTH 128 // OLED display width, in pixels
  7. #define SCREEN_HEIGHT 64 // OLED display height, in pixels
  8.   
  9. // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
  10. #define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
  11. Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
  12.   
  13. #define NUMFLAKES     10 // Number of snowflakes in the animation example
  14.   
  15. #define LOGO_HEIGHT   16
  16. #define LOGO_WIDTH    16
  17. static const unsigned char PROGMEM logo_bmp[] =
  18. { B00000000, B11000000,
  19.   B00000001, B11000000,
  20.   B00000001, B11000000,
  21.   B00000011, B11100000,
  22.   B11110011, B11100000,
  23.   B11111110, B11111000,
  24.   B01111110, B11111111,
  25.   B00110011, B10011111,
  26.   B00011111, B11111100,
  27.   B00001101, B01110000,
  28.   B00011011, B10100000,
  29.   B00111111, B11100000,
  30.   B00111111, B11110000,
  31.   B01111100, B11110000,
  32.   B01110000, B01110000,
  33.   B00000000, B00110000 };
  34.   
  35. void setup() {
  36.   Serial.begin(9600);//設置打印波特率
  37.    
  38.   Serial.println("SSD1306 i2c example");
  39.   
  40.   // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  41.   if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c)) { // Address 0x3D for 128x64
  42.     Serial.println(F("SSD1306 allocation failed"));
  43.     for(;;); // Don't proceed, loop forever
  44.   }
  45.   
  46.   // Show initial display buffer contents on the screen --
  47.   // the library initializes this with an Adafruit splash screen.
  48.   display.display();
  49.   delay(2000); // Pause for 2 seconds
  50.   
  51.   // Clear the buffer
  52.   display.clearDisplay();
  53.   
  54.   // Draw a single pixel in white
  55.   display.drawPixel(10, 10, WHITE);
  56.   
  57.   // Show the display buffer on the screen. You MUST call display() after
  58.   // drawing commands to make them visible on screen!
  59.   display.display();
  60.   delay(2000);
  61.   // display.display() is NOT necessary after every single drawing command,
  62.   // unless that's what you want...rather, you can batch up a bunch of
  63.   // drawing operations and then update the screen all at once by calling
  64.   // display.display(). These examples demonstrate both approaches...
  65.   
  66.   testdrawline();      // Draw many lines
  67.   
  68.   testdrawrect();      // Draw rectangles (outlines)
  69.   
  70.   testfillrect();      // Draw rectangles (filled)
  71.   
  72.   testdrawcircle();    // Draw circles (outlines)
  73.   
  74.   testfillcircle();    // Draw circles (filled)
  75.   
  76.   testdrawroundrect(); // Draw rounded rectangles (outlines)
  77.   
  78.   testfillroundrect(); // Draw rounded rectangles (filled)
  79.   
  80.   testdrawtriangle();  // Draw triangles (outlines)
  81.   
  82.   testfilltriangle();  // Draw triangles (filled)
  83.   
  84.   testdrawchar();      // Draw characters of the default font
  85.   
  86.   testdrawstyles();    // Draw 'stylized' characters
  87.   
  88.   testscrolltext();    // Draw scrolling text
  89.   
  90.   testdrawbitmap();    // Draw a small bitmap image
  91.   
  92.   // Invert and restore display, pausing in-between
  93.   display.invertDisplay(true);
  94.   delay(1000);
  95.   display.invertDisplay(false);
  96.   delay(1000);
  97.   
  98.   testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); // Animate bitmaps
  99. }
  100.   
  101. void loop() {
  102. }
  103. </font>
復制代碼


(4)驗證代碼,并且上傳

四、結果
效果視頻:親自實現是極好的,小主


演示效果極佳,快來動手試試吧!





歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1