1 /*****************************************************************************
\r
2 * (c) Copyright 2009 Actel Corporation. All rights reserved.
\r
4 * Author : Actel Application Team
\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
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
28 SECOND_LINE : The OLED cursor is set to line number 2 and only 1 line is
\r
30 BOTH_LINES : The OLED cursor is set to line number 1 and line 1 and line 2
\r
39 /*-------------------------------------------------------------------------*//**
\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
48 /* Represents line number, where String 1 has to be printed */
\r
50 /* Represents character offset within the line1, from where String 1 has to be
\r
52 uint8_t char_offset1;
\r
53 /* Represents line number, where String 2 has to be printed */
\r
55 /* Represents character offset within the line2, from where String 2 has to be
\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
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
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
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
78 /***************************************************************************//**
\r
79 The following defines can be used as parameter to the OLED_set_cursor()
\r
83 /***************************************************************************//**
\r
84 The OLED_init function initializes the OLED display.
\r
86 void vOLEDInit( void );
\r
87 void OLED_init( void );
\r
89 /***************************************************************************//**
\r
90 This function(OLED_clear_display) clears the content of the display RAM
\r
91 based on the LINES input.
\r
92 ------------------------------------------------------------------------------
\r
93 @param oled_no_of_line:
\r
94 The oled_no_of_line parameter enum that holds Number of lines.
\r
95 If FIRST_LINE is passed as parameter to this function thnen, this functions
\r
96 clears only First line that is 0
\r
97 If SECOND_LINE is passed as parameter to this function thnen, this functions
\r
98 clears only Second line that is 1
\r
99 If BOTH_LINE is passed as parameter to this function thnen, this functions
\r
100 clears entire OLED display.
\r
102 void OLED_clear_display( oled_no_of_line LINES );
\r
104 /*-------------------------------------------------------------------------*//**
\r
106 ------------------------------------------------------------------------------
\r
107 This function (OLED_write_data ) writes the data to OLED basedon the
\r
108 parameters passed to this function.
\r
109 ------------------------------------------------------------------------------
\r
111 The data parameter is a pointer to an oled_data structure, that holds
\r
112 different fields of data to be required for OLED (see the oled_data structure
\r
115 @param oled_no_of_line:
\r
116 The oled_no_of_line parameter enum that holds Number of lines.
\r
117 If FIRST_LINE is passed as parameter to this function thnen, this functions
\r
118 wtites string 1 at FIRST LINE
\r
119 If SECOND_LINE is passed as parameter to this function thnen, this functions
\r
120 wtites string 1 at SECOND LINE
\r
121 If BOTH_LINE is passed as parameter to this function thnen, this functions
\r
122 wtites string 1 and string 2 at FIRST LINE and SECOND LINE respectively.
\r
125 #include "drivers/mss_watchdog/mss_watchdog.h"
\r
127 #define FIRST_CHARACTER 0
\r
132 char *string1="SmartFusion";
\r
133 char *string2="INNOVATIVE ";
\r
134 struct oled_data write_data;
\r
136 write_data.line1 = FIRST_LINE;
\r
137 write_data.char_offset1 = FIRST_CHARACTER;
\r
138 write_data.string1 = string1;
\r
139 write_data.line2 = SECOND_LINE;
\r
140 write_data.char_offset2 = FIRST_CHARACTER;
\r
141 write_data.string2 = string2;
\r
142 write_data.contrast_val = 0x01;
\r
146 OLED_write_data(&write_data,BOTH_LINES);
\r
152 void OLED_write_data(struct oled_data * data, oled_no_of_line flag);
\r
154 /*-------------------------------------------------------------------------*//**
\r
155 OLED Horizontal scrolling.
\r
156 ------------------------------------------------------------------------------
\r
157 This function (OLED_horizontal_scroll ) enbles the Horizontal scrolling.
\r
158 ------------------------------------------------------------------------------
\r
160 The horiz_scroll parameter is a pointer to an oled_data structure, that holds
\r
161 different fields of data to be required for OLED (see the oled_data structure
\r
169 char *string1="SmartFusion";
\r
170 char *string2="INNOVATIVE ";
\r
171 struct oled_data write_data;
\r
173 write_data.line1 = FIRST_LINE;
\r
174 write_data.char_offset1 = FIRST_CHARACTER;
\r
175 write_data.string1 = string1;
\r
176 write_data.line2 = SECOND_LINE;
\r
177 write_data.char_offset2 = FIRST_CHARACTER;
\r
178 write_data.string2 = string2;
\r
179 write_data.contrast_val = 0x01;
\r
180 write_data.on_off = 0x01;
\r
181 write_data.column_scrool_per_step = 0x08;
\r
182 write_data.start_page = 0x01;
\r
183 write_data.time_intrval_btw_scroll_step = 0x00;
\r
184 write_data.end_page = 0x05;
\r
188 OLED_write_data(&write_data,BOTH_LINES);
\r
189 OLED_horizontal_scroll(&write_data);
\r
195 void OLED_horizontal_scroll(struct oled_data * horiz_scroll);
\r
197 /***************************************************************************//**
\r
198 This function(OLED_contrast) sets ths conrtast to the data displayed on the
\r
200 ------------------------------------------------------------------------------
\r
201 @param color_contrast:
\r
202 The color_contrast parameter that holds contrast value.
\r
203 The color_contrast values should be in the range of 1 to 256.
\r
205 void OLED_contrast(uint8_t color_contrast);
\r