Stduino UNO mini and 7-line oled display for Message Box

What are you developing?
Post Reply
jacobli
Posts: 42
Joined: Fri Jun 11, 2021 3:40 am

Stduino UNO mini and 7-line oled display for Message Box

Post by jacobli »

I have a 7-line Oled display that has been trying to use stm32 to drive under, just now through the Stduino UNO mini and Arduino framework for testing.
Material
Software: Stduino IDE 1.10.7
Hardware: Stduino UNO mini (STM32F103C6 main control)
Others: 7-wire OLED display (other displays such as LCD can also be used) and Dupont wire
1. Oled 7-wire line sequence
Oled 7 lines are GND, VCC, D0, D1, RES, DC, CS, here only D0 refers to Clock, D1 refers to Data, the line sequence is shown in the figure below.
Image
2. Line sequence-specific connection
according to the following line of code to connect the line that will be ok
U8X8_SSD1306_128X64_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
3. Download and install the library u8g24. Test the output Hello world code example, the display effect is shown in the figure above.

Code: Select all

#include <Arduino.h>
#include <U8x8lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
U8X8_SSD1306_128X64_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
void setup(void)
{
  u8x8.begin();
  u8x8.setPowerSave(0);
}
void loop(void)
{
  u8x8.setFont(u8x8_font_chroma48medium8_r);
  u8x8.drawString(0,1,"Hello World!");
  u8x8.refreshDisplay();
  delay(2000);
}
5. Testing the Message Box function
It should be noted here that the Message Box has two select boxes that can be controlled, so here is a customization based on the pinout of the Stduino UNO mini board.
u8x8.begin(/*Select=*/ 7, /*Right/Next=*/ A1, /*Left/Prev=*/ A2, /*Up=*/ A0, /*Down=*/ A3, /*Home/Cancel=*/ 6); // Stduino
5.1 Message Box initialization display effect
Image
Image
Image
The Message Box code is as follows

Code: Select all

#include <Arduino.h>
#include <U8x8lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
U8X8_SSD1306_128X64_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
void setup(void)
{
  u8x8.begin(/*Select=*/ 7, /*Right/Next=*/ A1, /*Left/Prev=*/ A2, /*Up=*/ A0, /*Down=*/ A3, /*Home/Cancel=*/ 6); // Stduino
  u8x8.setPowerSave(0);
}
void loop(void)
{
  uint8_t r;
  u8x8.setFont(u8x8_font_chroma48medium8_r);
  r = u8x8_UserInterfaceMessage(u8x8.getU8x8(), "Message", "Box", NULL, " Ok \n Cancel ");
  if ( r == 0 )
  {
    u8x8.userInterfaceMessage("You pressed the", "Home/Quit", "Button", " Ok ");
  }
  else if ( r == 1 )
  {
    u8x8.userInterfaceMessage("You selected the", "Ok", "Button", " Ok ");
  }
  else if ( r == 2 )
  {
    u8x8.userInterfaceMessage("You selected the", "Cancel", "Button", " Ok ");
  }
}
Post Reply

Return to “Projects”