Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
155 Kevin 1
#ifndef OLED_SSD1331_H
2
#define	OLED_SSD1331_H
3
 
4
#define SSD1331_LCDWIDTH        96
5
#define SSD1331_LCDHEIGHT       64
6
//#define SSD1331_STRING_BUFFER_SIZE          64
7
 
8
// Select one of these defines to set the pixel color order
9
#define SSD1331_COLORORDER_RGB
10
// #define SSD1331_COLORORDER_BGR
11
 
12
// SSD1331 Commands
13
#define SSD1331_CMD_DRAWLINE 		0x21
14
#define SSD1331_CMD_DRAWRECT 		0x22
15
#define SSD1331_CMD_CLEARWINDOW         0x25
16
#define SSD1331_CMD_FILL                0x26
17
#define SSD1331_CMD_SETCOLUMN 		0x15
18
#define SSD1331_CMD_SETROW    		0x75
19
#define SSD1331_CMD_CONTRASTA 		0x81
20
#define SSD1331_CMD_CONTRASTB 		0x82
21
#define SSD1331_CMD_CONTRASTC		0x83
22
#define SSD1331_CMD_MASTERCURRENT 	0x87
23
#define SSD1331_CMD_SETREMAP 		0xA0
24
#define SSD1331_CMD_STARTLINE 		0xA1
25
#define SSD1331_CMD_DISPLAYOFFSET 	0xA2
26
#define SSD1331_CMD_NORMALDISPLAY 	0xA4
27
#define SSD1331_CMD_DISPLAYALLON  	0xA5
28
#define SSD1331_CMD_DISPLAYALLOFF 	0xA6
29
#define SSD1331_CMD_INVERTDISPLAY 	0xA7
30
#define SSD1331_CMD_SETMULTIPLEX  	0xA8
31
#define SSD1331_CMD_SETMASTER 		0xAD
32
#define SSD1331_CMD_DISPLAYOFF 		0xAE
33
#define SSD1331_CMD_DISPLAYON     	0xAF
34
#define SSD1331_CMD_POWERMODE 		0xB0
35
#define SSD1331_CMD_PRECHARGE 		0xB1
36
#define SSD1331_CMD_CLOCKDIV 		0xB3
37
#define SSD1331_CMD_PRECHARGEA 		0x8A
38
#define SSD1331_CMD_PRECHARGEB 		0x8B
39
#define SSD1331_CMD_PRECHARGEC 		0x8C
40
#define SSD1331_CMD_PRECHARGELEVEL 	0xBB
41
#define SSD1331_CMD_VCOMH 		0xBE
42
 
43
// Color definitions
44
#define	SSD1331_BLACK           0x0000
45
#define	SSD1331_BLUE            0x001F
46
#define	SSD1331_RED             0xF800
47
#define	SSD1331_GREEN           0x07E0
48
#define SSD1331_CYAN            0x07FF
49
#define SSD1331_MAGENTA         0xF81F
50
#define SSD1331_YELLOW          0xFFE0
51
#define SSD1331_WHITE           0xFFFF
52
 
53
typedef struct {
54
    int WIDTH, HEIGHT; // raw display size
55
    int _width, _height; // size depending on rotation
56
    int cursor_x, cursor_y;
57
    unsigned int textcolor, textbgcolor;
58
    char textsize;
59
    char rotation;
60
    char wrap; // If set, wrap text at right side
61
} SSD1331_DATA;
62
 
63
// Misc functions
64
int SSD1331_Abs(int i);
65
void SSD1331_Swap(int *a, int *b);
66
unsigned int SSD1331_Color565(char r, char g, char b);
67
 
68
// Core functions
69
void SSD1331_Init(SSD1331_DATA *data);
70
void SSD1331_Begin(void);
71
void SSD1331_GoTo(int x, int y);
72
 
73
void SSD1331_Command(char c);
74
void SSD1331_Data(char d);
75
 
76
// Display functions
77
void SSD1331_Clear_Display(void);
78
 
79
void SSD1331_Draw_Pixel(int x, int y, unsigned int color);
80
void SSD1331_Draw_Line(int x0, int y0, int x1, int y1, unsigned int color);
81
void SSD1331_Draw_Fast_VLine(int x, int y, int h, unsigned int color);
82
void SSD1331_Draw_Fast_HLine(int x, int y, int w, unsigned int color);
83
void SSD1331_Draw_Rect(int x0, int y0, int x1, int y1, unsigned int color);
84
void SSD1331_Fill_Rect(int x0, int y0, int x1, int y1, unsigned int color);
85
 
86
void SSD1331_Draw_Circle(int x0, int y0, int r, unsigned int color);
87
void SSD1331_Draw_Circle_Helper(int x0, int y0, int r, char cornername, unsigned int color);
88
void SSD1331_Fill_Circle(int x0, int y0, int r, unsigned int color);
89
void SSD1331_Fill_Circle_Helper(int x0, int y0, int r, char cornername, int delta, unsigned int color);
90
 
91
void SSD1331_Draw_Triangle(int x0, int y0, int x1, int y1, int x2, int y2, unsigned int color);
92
void SSD1331_Fill_Triangle(int x0, int y0, int x1, int y1, int x2, int y2, unsigned int color);
93
void SSD1331_Draw_Round_Rect(int x0, int y0, int w, int h, int radius, unsigned int color);
94
void SSD1331_Fill_Round_Rect(int x0, int y0, int w, int h, int radius, unsigned int color);
95
 
96
void SSD1331_Draw_Bitmap(int x, int y, const char *bitmap, int w, int h, unsigned int color);
97
void SSD1331_Draw_Char(int x, int y, char c, unsigned int color, unsigned int bg, char size);
98
 
99
void SSD1331_Write(char c);
100
void SSD1331_Write_String(char *msg, char length);
101
//void SSD1331_Write_String(const rom char *fmt, ...);
102
//void SSD1331_Append_String(const rom char *fmt, ...);
103
 
104
void SSD1331_Set_Cursor(int x, int y);
105
void SSD1331_Set_Text_Color(unsigned int c);
106
void SSD1331_Set_Text_Color_BG(unsigned int c, unsigned int bg);
107
void SSD1331_Set_Text_Size(char s);
108
void SSD1331_Set_Text_Wrap(char w);
109
void SSD1331_Set_Rotation(char r);
110
 
111
// Test functions
112
void SSD1331_Test_DrawLines(unsigned int color);
113
void SSD1331_Test_DrawRect(unsigned int color);
114
void SSD1331_Test_FillRect(unsigned int color1, unsigned int color2);
115
void SSD1331_Test_DrawCircle(unsigned int radius, unsigned int color);
116
void SSD1331_Test_FillCircle(unsigned int radius, unsigned int color);
117
void SSD1331_Test_DrawTria(void);
118
void SSD1331_Test_DrawRoundRect(void);
119
void SSD1331_Test_MediaButtons(void);
120
void SSD1331_Test_Pattern(void);
121
 
122
#endif	/* OLED_SSD1331_H */
123