This repository tells you how to interface a 128 x 64 Dot Matrix OLED Display on STM32F4xx MCU (I am using STM32F407 Discovery Kit) using I2C Protocol. Here 4 wires are used for interfacing the OLED display Ground(GND), VCC(3.3V), Serial Data Line (PB7), and Serial Clock line (PB6). The code is written very systematically and it's easy to understand. This driver can be ported for other microcontrollers by simply replacing few functions with MCU-specific APIs. An example project using Kiel µVision 5 is also included.
Code is written without using STM32CubeMX tool, however you can also use CubeMX to generat I2C and MCU basic initialization code.
This driver provides following functionalities.
- Send Command
- Send Data
- Fill the Screen
- Draw a Pixel
- Put a Character
- Put a String
- Draw the Line
- Draw Rectangle & Filled Rectangle
- Draw Triangle & Filled Triangle
- Draw Circle & Filled Circle
Only the following functions in the driver contains the STM23F407 MCU Specific code for initializing the Microcontroller and SPI Peripheral and these can be replaced by other MCU specific codes for porting.
- static void GPIO_Config(void) - Configure the GPIO
- static void I2C_Config(void) - Configure I2C Peripheral
- void OLED_SSD1306_Send_Command(uint8_t cmd) - Send Command to OLED
- void OLED_SSD1306_Send_Data(uint8_t data) - Send Data to OLED
- HAL_Delay() and void SysTick_Handler(void) - For time delay (from HAL library).