| Line 14... |
Line 14... |
| 14 |
|
14 |
|
| 15 |
You also need to set the LCDWIDTH and LCDHEIGHT defines to an
|
15 |
You also need to set the LCDWIDTH and LCDHEIGHT defines to an
|
| 16 |
appropriate size
|
16 |
appropriate size
|
| 17 |
|
17 |
|
| 18 |
-----------------------------------------------------------------------*/
|
18 |
-----------------------------------------------------------------------*/
|
| 19 |
// #define SSD1306_128_64
|
19 |
#define SSD1306_128_64
|
| 20 |
#define SSD1306_128_32
|
20 |
// #define SSD1306_128_32
|
| 21 |
/*=========================================================================*/
|
21 |
/*=========================================================================*/
|
| 22 |
|
22 |
|
| 23 |
#if defined SSD1306_128_64
|
23 |
#if defined SSD1306_128_64
|
| 24 |
#define SSD1306_LCDWIDTH 128
|
24 |
#define SSD1306_LCDWIDTH 128
|
| 25 |
#define SSD1306_LCDHEIGHT 64
|
25 |
#define SSD1306_LCDHEIGHT 64
|
| Line 27... |
Line 27... |
| 27 |
#if defined SSD1306_128_32
|
27 |
#if defined SSD1306_128_32
|
| 28 |
#define SSD1306_LCDWIDTH 128
|
28 |
#define SSD1306_LCDWIDTH 128
|
| 29 |
#define SSD1306_LCDHEIGHT 32
|
29 |
#define SSD1306_LCDHEIGHT 32
|
| 30 |
#endif
|
30 |
#endif
|
| 31 |
|
31 |
|
| - |
|
32 |
#define SSD1306_STRING_BUFFER_SIZE 32
|
| - |
|
33 |
|
| 32 |
#define SSD1306_BLACK 0
|
34 |
#define SSD1306_BLACK 0
|
| 33 |
#define SSD1306_WHITE 1
|
35 |
#define SSD1306_WHITE 1
|
| 34 |
|
36 |
|
| 35 |
#define SSD1306_I2C_ADDRESS 0x3D // 011110+SA0+RW
|
37 |
#define SSD1306_I2C_ADDRESS 0x3D // 011110+SA0+RW
|
| 36 |
|
38 |
|
| Line 56... |
Line 58... |
| 56 |
#define SSD1306_SEGREMAP 0xA0
|
58 |
#define SSD1306_SEGREMAP 0xA0
|
| 57 |
#define SSD1306_CHARGEPUMP 0x8D
|
59 |
#define SSD1306_CHARGEPUMP 0x8D
|
| 58 |
#define SSD1306_EXTERNALVCC 0x1
|
60 |
#define SSD1306_EXTERNALVCC 0x1
|
| 59 |
#define SSD1306_SWITCHCAPVCC 0x2
|
61 |
#define SSD1306_SWITCHCAPVCC 0x2
|
| 60 |
|
62 |
|
| - |
|
63 |
typedef struct __SSD1306_DATA {
|
| - |
|
64 |
int WIDTH, HEIGHT; // raw display size
|
| - |
|
65 |
int _width, _height; // size depending on rotation
|
| - |
|
66 |
int cursor_x, cursor_y;
|
| - |
|
67 |
unsigned int textcolor, textbgcolor;
|
| - |
|
68 |
unsigned char textsize;
|
| - |
|
69 |
unsigned char rotation;
|
| - |
|
70 |
unsigned char wrap; // If set, wrap text at right side
|
| - |
|
71 |
} SSD1306_DATA;
|
| - |
|
72 |
|
| - |
|
73 |
// Misc functions
|
| - |
|
74 |
int SSD1306_Abs(int i);
|
| - |
|
75 |
void SSD1306_Swap(int *a, int *b);
|
| - |
|
76 |
|
| - |
|
77 |
// Core functions
|
| 61 |
void SSD1306_Init(void);
|
78 |
void SSD1306_Init(void);
|
| 62 |
void SSD1306_Begin(unsigned char vcc);
|
79 |
void SSD1306_Begin(unsigned char vcc);
|
| 63 |
void SSD1306_Command(unsigned char cmd);
|
80 |
void SSD1306_Command(unsigned char cmd);
|
| 64 |
void SSD1306_Data(unsigned char data);
|
81 |
void SSD1306_Data(unsigned char data);
|
| 65 |
|
82 |
|
| 66 |
void SSD1306_Clear_Display(void);
|
83 |
void SSD1306_Clear_Display(void);
|
| 67 |
void SSD1306_Invert_Display(unsigned char);
|
84 |
void SSD1306_Invert_Display(unsigned char);
|
| 68 |
void SSD1306_Display(void);
|
85 |
void SSD1306_Display(void);
|
| 69 |
|
86 |
|
| - |
|
87 |
// Drawing functions
|
| 70 |
void SSD1306_Draw_Pixel(int x, int y, unsigned int color);
|
88 |
void SSD1306_Draw_Pixel(int x, int y, unsigned int color);
|
| - |
|
89 |
void SSD1306_Draw_Line(int x0, int y0, int x1, int y1, unsigned int color);
|
| - |
|
90 |
void SSD1306_Draw_Fast_VLine(int x, int y, int h, unsigned int color);
|
| - |
|
91 |
void SSD1306_Draw_Fast_HLine(int x, int y, int w, unsigned int color);
|
| - |
|
92 |
void SSD1306_Draw_Rect(int x, int y, int w, int h, unsigned int color);
|
| - |
|
93 |
void SSD1306_Fill_Rect(int x, int y, int w, int h, unsigned int color);
|
| - |
|
94 |
|
| - |
|
95 |
void SSD1306_Draw_Circle(int x0, int y0, int r, unsigned int color);
|
| - |
|
96 |
void SSD1306_Draw_Circle_Helper(int x0, int y0, int r, unsigned char cornername, unsigned int color);
|
| - |
|
97 |
void SSD1306_Fill_Circle(int x0, int y0, int r, unsigned int color);
|
| - |
|
98 |
void SSD1306_Fill_Circle_Helper(int x0, int y0, int r, unsigned char cornername, int delta, unsigned int color);
|
| - |
|
99 |
|
| - |
|
100 |
void SSD1306_Draw_Triangle(int x0, int y0, int x1, int y1, int x2, int y2, unsigned int color);
|
| - |
|
101 |
void SSD1306_Fill_Triangle(int x0, int y0, int x1, int y1, int x2, int y2, unsigned int color);
|
| - |
|
102 |
void SSD1306_Draw_Round_Rect(int x0, int y0, int w, int h, int radius, unsigned int color);
|
| - |
|
103 |
void SSD1306_Fill_Round_Rect(int x0, int y0, int w, int h, int radius, unsigned int color);
|
| - |
|
104 |
|
| - |
|
105 |
void SSD1306_Draw_Bitmap(int x, int y, const unsigned char *bitmap, int w, int h, unsigned int color);
|
| - |
|
106 |
void SSD1306_Draw_Char(int x, int y, unsigned char c, unsigned int color, unsigned int bg, unsigned char size);
|
| - |
|
107 |
|
| - |
|
108 |
void SSD1306_Write(unsigned char c);
|
| - |
|
109 |
void SSD1306_Write_String(const rom char *fmt, ...);
|
| - |
|
110 |
//void SSD1306_Append_String(const rom char *fmt, ...);
|
| - |
|
111 |
|
| - |
|
112 |
void SSD1306_Set_Cursor(int x, int y);
|
| - |
|
113 |
void SSD1306_Set_Text_Color(unsigned int c);
|
| - |
|
114 |
void SSD1306_Set_Text_Color_BG(unsigned int c, unsigned int bg);
|
| - |
|
115 |
void SSD1306_Set_Text_Size(unsigned char s);
|
| - |
|
116 |
void SSD1306_Set_Text_Wrap(unsigned char w);
|
| - |
|
117 |
void SSD1306_Set_Rotation(unsigned char r);
|
| 71 |
|
118 |
|
| - |
|
119 |
// Test functions
|
| 72 |
void SSD1306_Test_DrawChar(void);
|
120 |
void SSD1306_Test_DrawChar(void);
|
| 73 |
void SSD1306_Test_DrawCircle(void);
|
121 |
void SSD1306_Test_DrawCircle(void);
|
| 74 |
void SSD1306_Test_DrawRect(void);
|
122 |
void SSD1306_Test_DrawRect(void);
|
| 75 |
void SSD1306_Test_FillRect(void);
|
123 |
void SSD1306_Test_FillRect(void);
|
| 76 |
void SSD1306_Test_DrawTriangle(void);
|
124 |
void SSD1306_Test_DrawTriangle(void);
|