]> git.sur5r.net Git - freertos/blob - Demo/CORTEX_A2F200_SoftConsole/MicroSemi_Code/drivers/OLED/oled.h
35a82609857169467f2b27a965373e617801e801
[freertos] / Demo / CORTEX_A2F200_SoftConsole / MicroSemi_Code / drivers / OLED / oled.h
1 /*****************************************************************************\r
2  * (c) Copyright 2009 Actel Corporation.  All rights reserved.\r
3  *\r
4  * Author : Actel Application Team\r
5  * Rev    : 1.0.0.0\r
6  * Description: Device driver for the on-board OLED for SmartFusion KITS\r
7  *  API of sample basic driver for OLED display found on Actel SmartFusion\r
8  *  development boards.\r
9  *  This code is intended as an example of using the SmartFusion I2C driver.\r
10  *\r
11  */\r
12 #ifndef OLED_H_\r
13 #define OLED_H_\r
14 \r
15 #include "../BSP/i2c_driver/i2c.h"\r
16 \r
17 #define OLED_HORIZ_SCROLL_ON    0x01\r
18 #define OLED_HORIZ_SCROLL_OFF   0x00\r
19 #define OLED_HORIZ_SCROLL_STEP  0x08\r
20 #define OLED_CONTRAST_VAL       0xFF\r
21 #define OLED_START_PAGE         0x01\r
22 #define OLED_HORIZ_SCROLL_TINVL 0x00\r
23 #define OLED_END_PAGE           0x05\r
24 /*-------------------------------------------------------------------------*/\r
25 /*  The oled_no_of_line type represents number of lines to be written on OLED.\r
26     FIRST LINE  : The OLED cursor is set to line number 1 and only 1 line is\r
27                   printed on OLED\r
28     SECOND_LINE : The OLED cursor is set to line number 2 and only 1 line is\r
29                   printed on OLED\r
30     BOTH_LINES  : The OLED cursor is set to line number 1 and line 1 and line 2\r
31                   are printed on OLED\r
32 */\r
33 typedef enum {\r
34     FIRST_LINE = 0,\r
35     SECOND_LINE,\r
36     BOTH_LINES\r
37 } oled_no_of_line;\r
38 \r
39 /*-------------------------------------------------------------------------*//**\r
40   oled_data\r
41   ------------------------------------------------------------------------------\r
42   There is one instance of this structure for OLED data. Instances of this\r
43   structure is used to provide the data to OLED. A pointer to an instance of\r
44   the oled_data structure is passed as the parameter OLED driver functions.\r
45  */\r
46 struct oled_data\r
47 {\r
48     /* Represents line number, where String 1 has to be printed */\r
49     uint8_t line1;\r
50     /* Represents character offset within the line1, from where String 1 has to be\r
51      * printed */\r
52     uint8_t char_offset1;\r
53     /* Represents line number, where String 2 has to be printed */\r
54     uint8_t line2;\r
55     /* Represents character offset within the line2, from where String 2 has to be\r
56      * printed */\r
57     uint8_t char_offset2;\r
58     /* String 1 holds the data to be displayed on line 1 of OLED, It has to be\r
59      * less that 49 characters*/\r
60     char    *string1;\r
61     /* String 1 holds the data to be displayed on line 2 of OLED, It has to be\r
62      * less that 49 characters*/\r
63     char    *string2;\r
64     /* Holds the contrast value to be set for String 1 and String 2 */\r
65     uint8_t contrast_val;\r
66     /* Represents ON or OFF for horizontal scrolling  */\r
67     uint8_t on_off;\r
68     /* Represents  number of coumns scrolls per step for horizontal scroll*/\r
69     unsigned char column_scrool_per_step;\r
70     /* Represents  start page for horizontal scroll*/\r
71     unsigned char start_page;\r
72     /* Represents  time interval for horizontal scroll*/\r
73     unsigned char time_intrval_btw_scroll_step;\r
74     /* Represents  end page for horizontal scroll*/\r
75     unsigned char end_page;\r
76 \r
77 };\r
78 /***************************************************************************//**\r
79   The following defines can be used as parameter to the OLED_set_cursor()\r
80   function.\r
81  */\r
82 \r
83 /***************************************************************************//**\r
84   The OLED_init function initializes the OLED display.\r
85  */\r
86 void OLED_init( void );\r
87 \r
88 /***************************************************************************//**\r
89   This function(OLED_clear_display) clears the content of the display RAM\r
90   based on the LINES input.\r
91   ------------------------------------------------------------------------------\r
92   @param oled_no_of_line:\r
93       The oled_no_of_line parameter enum that holds Number of lines.\r
94       If FIRST_LINE is passed as parameter to this function thnen, this functions\r
95       clears only First line that is 0\r
96       If SECOND_LINE is passed as parameter to this function thnen, this functions\r
97       clears only Second line that is 1\r
98       If BOTH_LINE is passed as parameter to this function thnen, this functions\r
99       clears entire OLED display.\r
100  */\r
101 void OLED_clear_display( oled_no_of_line LINES );\r
102 \r
103 /*-------------------------------------------------------------------------*//**\r
104   OLED Write data.\r
105   ------------------------------------------------------------------------------\r
106   This function (OLED_write_data ) writes the data to OLED basedon the\r
107   parameters passed to this function.\r
108   ------------------------------------------------------------------------------\r
109   @param data:\r
110       The data parameter is a pointer to an oled_data structure, that holds\r
111       different fields of data to be required for OLED (see the oled_data structure\r
112       definition).\r
113 \r
114   @param oled_no_of_line:\r
115       The oled_no_of_line parameter enum that holds Number of lines.\r
116       If FIRST_LINE is passed as parameter to this function thnen, this functions\r
117       wtites string 1 at FIRST LINE\r
118       If SECOND_LINE is passed as parameter to this function thnen, this functions\r
119       wtites string 1 at SECOND LINE\r
120       If BOTH_LINE is passed as parameter to this function thnen, this functions\r
121       wtites string 1 and string 2 at FIRST LINE and SECOND LINE respectively.\r
122 Example:\r
123   @code\r
124 #include "drivers/mss_watchdog/mss_watchdog.h"\r
125 #include "oled.h"\r
126 #define FIRST_CHARACTER 0\r
127 \r
128 int main()\r
129 {\r
130 \r
131     char *string1="SmartFusion";\r
132     char *string2="INNOVATIVE ";\r
133     struct oled_data write_data;\r
134 \r
135     write_data.line1 = FIRST_LINE;\r
136     write_data.char_offset1 = FIRST_CHARACTER;\r
137     write_data.string1 = string1;\r
138     write_data.line2 = SECOND_LINE;\r
139     write_data.char_offset2 = FIRST_CHARACTER;\r
140     write_data.string2 = string2;\r
141     write_data.contrast_val = 0x01;\r
142 \r
143     MSS_WD_disable();\r
144     OLED_init();\r
145     OLED_write_data(&write_data,BOTH_LINES);\r
146     return 0;\r
147 }\r
148   @endcode\r
149  */\r
150 \r
151 void OLED_write_data(struct oled_data * data, oled_no_of_line flag);\r
152 \r
153 /*-------------------------------------------------------------------------*//**\r
154   OLED Horizontal scrolling.\r
155   ------------------------------------------------------------------------------\r
156   This function (OLED_horizontal_scroll ) enbles the Horizontal scrolling.\r
157   ------------------------------------------------------------------------------\r
158   @param data:\r
159       The horiz_scroll parameter is a pointer to an oled_data structure, that holds\r
160       different fields of data to be required for OLED (see the oled_data structure\r
161       definition).\r
162 Example:\r
163   @code\r
164 \r
165 int main()\r
166 {\r
167 \r
168     char *string1="SmartFusion";\r
169     char *string2="INNOVATIVE     ";\r
170     struct oled_data write_data;\r
171 \r
172     write_data.line1 = FIRST_LINE;\r
173     write_data.char_offset1 = FIRST_CHARACTER;\r
174     write_data.string1 = string1;\r
175     write_data.line2 = SECOND_LINE;\r
176     write_data.char_offset2 = FIRST_CHARACTER;\r
177     write_data.string2 = string2;\r
178     write_data.contrast_val = 0x01;\r
179     write_data.on_off = 0x01;\r
180     write_data.column_scrool_per_step = 0x08;\r
181     write_data.start_page = 0x01;\r
182     write_data.time_intrval_btw_scroll_step = 0x00;\r
183     write_data.end_page = 0x05;\r
184 \r
185     MSS_WD_disable();\r
186     OLED_init();\r
187     OLED_write_data(&write_data,BOTH_LINES);\r
188     OLED_horizontal_scroll(&write_data);\r
189     return 0;\r
190 }\r
191   @endcode\r
192  */\r
193 \r
194 void OLED_horizontal_scroll(struct oled_data * horiz_scroll);\r
195 \r
196 /***************************************************************************//**\r
197   This function(OLED_contrast) sets ths conrtast to the data displayed on the\r
198   OLED.\r
199   ------------------------------------------------------------------------------\r
200   @param color_contrast:\r
201   The color_contrast parameter that holds contrast value.\r
202   The color_contrast values should be in the range of 1 to 256.\r
203  */\r
204 void OLED_contrast(uint8_t color_contrast);\r
205 \r
206 #endif\r
207 \r
208 \r
209 \r