The driver library uses the more universal software (simulated) IIC method to drive the OLED, but the Yahboom Self-balancing Robot V2 supports hardware IIC in the hardware circuit.
The content of this chapter only introduces OLED related methods, and does not introduce the implementation of software IIC
method
void OLED_I2C_Init()
Initialize OLED module
void OLED_Clear()
Clear the screen
void OLED_Refresh()
Refresh the screen
void OLED_Draw_Stringg(char *str, uint8_t x, uint8_t y, bool clear, bool refresh)
Write into the string at the specified location
| parameter | type | Annotation |
| str | char * | Want the string displayed by OLED |
| x | uint8_t | Draw the starting coordinates in the direction of string X |
| y | uint8_t | Draw the starting coordinates in the direction of the string y |
| clear | bool | Whether to empty the screen |
| refresh | uint8_t | Whether to screen immediately |
| After drawing is completed, you need to call the refresh method to display |
void OLED_Draw_Line(char *str, uint8_t line, bool clear, bool refresh)
Write a string in a designated line
/* Write a line of characters */
| parameter | type | Annotation |
| str | char * | Want the string displayed by OLED |
| line | uint8_t | Display string in the first line |
| clear | bool | Whether to empty the screen |
| refresh | uint8_t | Whether to screen immediately |
| The default line height is 10 |
The following method is provided for driving chip SSD1306, which can be used for more detailed drawing operations
SSD1306_UpdateScreen()
The unit updates the OLED display content
| Return value | type |
| none | void |
SSD1306_ToggleInvert()
Switch the color reversal of the OLED display
| Return value | type |
| none | void |
SSD1306_Fill(SSD1306_COLOR_t Color)
Fill in the color of the screen
| parameter | type | Annotation |
| Color | SSD1306_COLOR_t | Fill color |
| Return value | type |
| none | void |
SSD1306_DrawPixel(uint16_t x, uint16_t y, SSD1306_COLOR_t color)
Draw a pixel in the specified coordinate
| parameter | type | Annotation |
| x | uint16_t | X coordinate |
| y | uint16_t | y coordinate |
| color | SSD1306_COLOR_t | Pixel color |
| Return value | type |
| none | void |
SSD1306_GotoXY(uint16_t x, uint16_t y)
Set the drawing coordinates of the next character
| parameter | type | Annotation |
| x | uint16_t | X coordinate |
| y | uint16_t | y coordinate |
| Return value | type |
| none | void |
SSD1306_Putc(char ch, FontDef_t *Font, SSD1306_COLOR_t color)
Draw a single character
| parameter | type | Annotation |
| ch | char | Characters to be drawn |
| Font | FontDef_t* | Font structure used |
| color | SSD1306_COLOR_t | Character color |
| Return value | type |
| none | char |
SSD1306_Puts(char *str, FontDef_t *Font, SSD1306_COLOR_t color)
Draw a string
| parameter | type | Annotation |
| str | char* | String to draw |
| Font | FontDef_t* | Font structure used |
| color | SSD1306_COLOR_t | String color |
| Return value | type |
| none | char |
SSD1306_DrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, SSD1306_COLOR_t c)
Draw a line
| parameter | type | Annotation |
| x0 | uint16_t | Starting point x coordinates |
| y0 | uint16_t | Starting point y coordinate |
| x1 | uint16_t | Ending point x coordinates |
| y1 | uint16_t | Ending point y coordinates |
| c | SSD1306_COLOR_t | Line color |
SSD1306_DrawRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h, SSD1306_COLOR_t c)
Drawing rectangle
| parameter | type | Annotation |
| x | uint16_t | X coordinates in the upper left corner |
| y | uint16_t | Y coordinate in the upper left corner |
| w | uint16_t | Rectangular width |
| h | uint16_t | Rectangular height |
| c | SSD1306_COLOR_t | Rectangular color |
| Return value | type |
| none | void |
SSD1306_DrawFilledRectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h, SSD1306_COLOR_t c)
Draw a rectangle
| parameter | type | Annotation |
| x | uint16_t | X coordinates in the upper left corner |
| y | uint16_t | Y coordinate in the upper left corner |
| w | uint16_t | Rectangular width |
| h | uint16_t | Rectangular height |
| c | SSD1306_COLOR_t | Rectangular color |
| Return value | type |
| none | void |
SSD1306_DrawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, SSD1306_COLOR_t color)
Draw a triangle
| parameter | type | Annotation |
| x1 | uint16_t | The first point X coordinates |
| y1 | uint16_t | The first point y coordinates |
| x2 | uint16_t | The second point x coordinates |
| y2 | uint16_t | The second point y coordinates |
| x3 | uint16_t | Third point X coordinates |
| y3 | uint16_t | The third point y coordinate |
| color | SSD1306_COLOR_t | Triangular color |
| Return value | type |
| none | void |
SSD1306_DrawCircle(int16_t x0, int16_t y0, int16_t r, SSD1306_COLOR_t c)
Draw a circle
| parameter | type | Annotation |
| x0 | int16_t | The x coordinate of the center of the circle |
| y0 | int16_t | Y coordinate of the center of the circle |
| r | int16_t | radius |
| c | SSD1306_COLOR_t | Round color |
| Return value | type |
| none | void |
SSD1306_DrawFilledCircle(int16_t x0, int16_t y0, int16_t r, SSD1306_COLOR_t c)
Draw a circle
| parameter | type | Annotation |
| x0 | int16_t | The x coordinate of the center of the circle |
| y0 | int16_t | Y coordinate of the center of the circle |
| r | int16_t | radius |
| c | SSD1306_COLOR_t | Fill in round colors |
| Return value | type |
| none | void |
ssd1306_I2C_Init()
Initialize I2C interface
| Return value | type |
| none | void |
ssd1306_I2C_Write(uint8_t address, uint8_t reg, uint8_t data)
Write data to the specified address and register
| parameter | type | Annotation |
| address | uint8_t | I2C device address |
| reg | uint8_t | Register address |
| data | uint8_t | Data to be written |
| Return value | type |
| none | void |
ssd1306_I2C_WriteMulti(uint8_t address, uint8_t reg, uint8_t *data, uint16_t count)
Write multiple data to the specified address and register
| parameter | type | Annotation |
| address | uint8_t | I2C device address |
| reg | uint8_t | Register address |
| data | uint8_t* | Pointing to data pointer |
| count | uint16_t | Number of data to be written |
| Return value | type |
| none | void |