-
Notifications
You must be signed in to change notification settings - Fork 55
/
ssd1306.h
68 lines (57 loc) · 1.59 KB
/
ssd1306.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* This Library is written and optimized by Olivier Van den Eede(4ilo) in 2016
* for Stm32 Uc and HAL-i2c lib's.
*
* To use this library with ssd1306 oled display you will need to customize the defines below.
*
* This library uses 2 extra files (fonts.c/h).
* In this files are 3 different fonts you can use:
* - Font_7x10
* - Font_11x18
* - Font_16x26
*
*/
#ifndef _SSD1306_H
#define _SSD1306_H
#include "stm32f4xx_hal.h"
#include "fonts.h"
// I2c address
#ifndef SSD1306_I2C_ADDR
#define SSD1306_I2C_ADDR 0x78
#endif // SSD1306_I2C_ADDR
// SSD1306 width in pixels
#ifndef SSD1306_WIDTH
#define SSD1306_WIDTH 128
#endif // SSD1306_WIDTH
// SSD1306 LCD height in pixels
#ifndef SSD1306_HEIGHT
#define SSD1306_HEIGHT 64
#endif // SSD1306_HEIGHT
//
// Enumeration for screen colors
//
typedef enum {
Black = 0x00, // Black color, no pixel
White = 0x01, // Pixel is set. Color depends on LCD
} SSD1306_COLOR;
//
// Struct to store transformations
//
typedef struct {
uint16_t CurrentX;
uint16_t CurrentY;
uint8_t Inverted;
uint8_t Initialized;
} SSD1306_t;
//
// Function definitions
//
uint8_t ssd1306_Init(I2C_HandleTypeDef *hi2c);
void ssd1306_UpdateScreen(I2C_HandleTypeDef *hi2c);
void ssd1306_Fill(SSD1306_COLOR color);
void ssd1306_DrawPixel(uint8_t x, uint8_t y, SSD1306_COLOR color);
char ssd1306_WriteChar(char ch, FontDef Font, SSD1306_COLOR color);
char ssd1306_WriteString(char* str, FontDef Font, SSD1306_COLOR color);
void ssd1306_SetCursor(uint8_t x, uint8_t y);
void ssd1306_InvertColors(void);
#endif // _SSD1306_H