-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssd1306.h
58 lines (46 loc) · 1.44 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
/**
* This Library was originally written by Olivier Van den Eede (4ilo) in 2016.
* Some refactoring was done and SPI support was added by Aleksander Alekseev (afiskon) in 2018.
*
* https://github.com/afiskon/stm32-ssd1306
*/
#ifndef __SSD1306_H__
#define __SSD1306_H__
#include "ft4222_hal.h"
#include "ssd1306_fonts.h"
//#define SSD1306_MIRROR_VERT
//#define SSD1306_MIRROR_HORIZ
#ifndef SSD1306_I2C_ADDR
#define SSD1306_I2C_ADDR 0x3C
#endif
// SSD1306 OLED height in pixels
#ifndef SSD1306_HEIGHT
#define SSD1306_HEIGHT 64
#endif
// SSD1306 width in pixels
#ifndef SSD1306_WIDTH
#define SSD1306_WIDTH 128
#endif
// Enumeration for screen colors
typedef enum {
Black = 0x00, // Black color, no pixel
White = 0x01 // Pixel is set. Color depends on OLED
} SSD1306_COLOR;
// Struct to store transformations
typedef struct {
uint16_t CurrentX;
uint16_t CurrentY;
uint8_t Inverted;
uint8_t Initialized;
} SSD1306_t;
// Procedure definitions
void ssd1306_Init(void);
void ssd1306_Fill(SSD1306_COLOR color);
void ssd1306_UpdateScreen(void);
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(const char* str, FontDef Font, SSD1306_COLOR color);
void ssd1306_SetCursor(uint8_t x, uint8_t y);
char ssd1306_WriteString_with_length(const char* str, uint32_t length,
FontDef Font, SSD1306_COLOR color);
#endif // __SSD1306_H__