PsiSwarm Library  0.8
display.h
1 /* University of York Robotics Laboratory PsiSwarm Library: Display Driver Header File
2  *
3  * Copyright 2016 University of York
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS
8  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9  * See the License for the specific language governing permissions and limitations under the License.
10  *
11  * File: display.h
12  *
13  * (C) Dept. Electronics & Computer Science, University of York
14  * James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis
15  *
16  * PsiSwarm Library Version: 0.8
17  *
18  * October 2016
19  *
20  *
21  * Driver for the Midas 16x2 I2C LCD Display (MCCOG21605x6W) LCD
22  *
23  * Farnell part 2218942 or 2063206
24  *
25  */
26 
27 
28 #ifndef DISPLAY_H
29 #define DISPLAY_H
30 
31 #define PAGE_TIME 0.4
32 #define CLEAR_TIME 0.8
33 
53 class Display : public Stream
54 {
55 
56 // Public Functions
57 
58 public:
59 
63  Display();
64 
72  Display(PinName sda, PinName scl, PinName reset, PinName backlight);
73 
76  void clear_display(void);
77 
80  void home(void);
81 
85  void write_string(char * message);
86 
91  void write_string(char * message, char length);
92 
97  void set_position(char row, char column);
98 
102  void set_cursor(char enable);
103 
107  void set_blink(char enable);
108 
112  void set_display(char enable);
113 
117  void set_backlight_brightness(float brightness);
118 
119  // Special function for when debug messages are sent to display
120  void debug_page(char * message, char length);
121 
122  // Internal function used to restore display after debug messages
123  void IF_restore_page(void);
124 
125  // Internal function used to show multi-page debug messages
126  void IF_debug_multipage(void);
127 
128  // Internal function used to toggle backlight
129  void IF_backlight_toggle(void);
130 
131  //Parts of initialisation routine
132  void post_init(void);
133  void post_post_init(void);
134 
135  // Send a 1-byte control message to the display
136  int i2c_message(char byte);
137 
138  // Default initialisation sequence for the display
139  void init_display(char mode);
140 
141  int disp_putc(int c);
142 
143 
144 private :
145 
146  I2C _i2c;
147  DigitalOut _reset;
148  DigitalOut _backlight;
149 
150  char display_on;
151  char cursor_on;
152  char blink_on;
153 
154  void _set_display();
155 
156  virtual int _putc(int c);
157  virtual int _getc();
158 
159 };
160 
161 #endif // DISPLAY_H
void write_string(char *message)
Definition: display.cpp:131
void set_position(char row, char column)
Definition: display.cpp:174
void set_display(char enable)
Definition: display.cpp:193
void home(void)
Definition: display.cpp:238
void clear_display(void)
Definition: display.cpp:230
void set_cursor(char enable)
Definition: display.cpp:183
void set_backlight_brightness(float brightness)
Definition: display.cpp:198
Display()
Definition: display.cpp:47
void set_blink(char enable)
Definition: display.cpp:188