1680 views|0 replies

85

Posts

0

Resources
The OP
 

[Zero-knowledge ESP8266 tutorial] Quick start 22 Re-exploration of OLED module [Copy link]

Quote:
After making the world clock, we have to return to our original intention. We found that, like the previous electronic works, the extended use of OLED modules will use different related software libraries. The use of these software libraries enriches the practical scope of OLED, making the electronic products we make more diverse and the scope of use in life more extensive. This also promotes our understanding of the electronic world. Now you should have a general outline of the electronic world.

Similarly, the use of other modules, like the ones mentioned in this sharing, has greater development potential, which depends on our imagination as developers.

Next, we will continue to share and learn.
This sharing will continue to use OLED on Zero Knowledge ESP8266 to deepen our understanding of OLED modules.
1. Hardware
Computer, Windows system
Zero Knowledge ESP8266 development board
OLED SSD1306 module
micro-usb cable

2. Connection

3. Software Library
(1) This time we use the OLED related software library, so you need to install the following two libraries:
Tip: If your computer has installed the latest Zero Knowledge Development Tools in the "Software Download" section of Zero Knowledge Lab, you can skip this step.

1. Adafruit_SSD1306
2. Adafruit-GFX

(2) Installation
Search for "local library" on the official website of Zero Knowledge Lab to install it.

You can also leave me a message and we can communicate and learn together.

(3) Burning program
Here we just need to select the SSD1306 example.

The complete code is as follows:

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define NUMFLAKES 10 // Number of snowflakes in the animation example

#define LOGO_HEIGHT 16
#define LOGO_WIDTH 16
static const unsigned char PROGMEM logo_bmp[] =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000 };

void setup() {
Serial.begin(9600);

Serial.println("SSD1306 i2c example");

// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c)) { // Address 0x3D for 128x64
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();
delay(2000); // Pause for 2 seconds

// Clear the buffer
display.clearDisplay();

// Draw a single pixel in white
display.drawPixel(10, 10, WHITE);

// Show the display buffer on the screen. You MUST call display() after
// drawing commands to make them visible on screen!
display.display();
delay(2000);
// display.display() is NOT necessary after every single drawing command,
// unless that's what you want...rather, you can batch up a bunch of
// drawing operations and then update the screen all at once by calling
// display.display(). These examples demonstrate both approaches...

testdrawline(); // Draw many lines

testdrawrect(); // Draw rectangles (outlines)

testfillrect(); // Draw rectangles (filled)

testdrawcircle(); // Draw circles (outlines)

testfillcircle(); // Draw circles (filled)

testdrawroundrect(); // Draw rounded rectangles (outlines)

testfillroundrect(); // Draw rounded rectangles (filled)

testdrawtriangle(); // Draw triangles (outlines)

testfilltriangle(); // Draw triangles (filled)

testdrawchar(); // Draw characters of the default font

testdrawstyles(); // Draw 'stylized' characters

testscrolltext(); // Draw scrolling text

testdrawbitmap(); // Draw a small bitmap image

// Invert and restore display, pausing in-between
display.invertDisplay(true);
delay(1000);
display.invertDisplay(false);
delay(1000);

testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); // Animate bitmaps
}

void loop() {
}

(4) Verify the code and upload it

4. Results
Effect video link: Click my whisk and go

The demonstration is great, come and try it out!

This post is from stm32/stm8
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list