Psi Swarm robot library version 0.9
Fork of PsiSwarmV9 by
Diff: display.h
- Revision:
- 8:6c92789d5f87
- Parent:
- 6:b340a527add9
- Child:
- 12:878c6e9d9e60
diff -r aa5a4a257895 -r 6c92789d5f87 display.h --- a/display.h Sun Oct 16 11:11:21 2016 +0000 +++ b/display.h Sun Oct 16 12:54:33 2016 +0000 @@ -1,11 +1,11 @@ /* University of York Robotics Laboratory PsiSwarm Library: Display Driver Header File - * + * * Copyright 2016 University of York * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and limitations under the License. * * File: display.h @@ -22,84 +22,123 @@ * * Farnell part 2218942 or 2063206 * - */ - - + */ + + #ifndef DISPLAY_H #define DISPLAY_H #define PAGE_TIME 0.4 #define CLEAR_TIME 0.8 -class Display : public Stream { +/** + * Display class + * Functions for use with the Midas 16x2 I2C LCD Display (MCCOG21605x6W) LCD + * Farnell part 2218942 or 2063206 + * + * Example: + * @code + * #include "psiswarm.h" + * + * int main() { + * init(); + * display.clear_display; //Clears display + * display.set_position(0,2); //Set cursor to row 0 column 2 + * display.write_string("YORK ROBOTICS"); + * display.set_position(1,3); //Set cursor to row 1 column 3 + * display.write_string("LABORATORY"); + * } + * @endcode +*/ +class Display : public Stream +{ // Public Functions public: - /** Create the LCD Display object connected to the default pins + /** Create the LCD Display object connected to the default pins + * (sda = p28, scl = p27, reset = p29, backlight = p30) + */ + Display(); + + /** Create the LCD Display object connected to specific pins * * @param sda pin - default is p28 * @param scl pin - default is p27 * @param reset pin - default is p29 * @param backlight pin - default is p30 */ - - Display(); - - /** Create the LCD Display object connected to specific pins - * - */ Display(PinName sda, PinName scl, PinName reset, PinName backlight); -//Print string message -void write_string(char * message); - -//Print string message of given length -void write_string(char * message, char length); + /** Clear the display + */ + void clear_display(void); -//Set the row and column of cursor position -void set_position(char row, char column); + /** Set cursor to home position + */ + void home(void); -// Enable or disable cursor -void set_cursor(char enable); + /** Print string message + * @param message - The null-terminated message to print + */ + void write_string(char * message); -// Enable or disable cursor blink -void set_blink(char enable); - -// Enable or disable display -void set_display(char enable); + /** Print string message of given length + * @param message - The message to print + * @param length - The number of characters to display + */ + void write_string(char * message, char length); -// Set the brightness of the backlight -void set_backlight_brightness(float brightness); + /** Set the row and column of cursor position + * @param row - The row of the display to set the cursor to (either 0 or 1) + * @param column - The column of the display to set the cursor to (range 0 to 15) + */ + void set_position(char row, char column); -// Special function for when debug messages are sent to display -void debug_page(char * message, char length); + /** Enable or disable cursor + * @param enable - Set to 1 to enable the cursor visibility + */ + void set_cursor(char enable); -void IF_restore_page(void); - -void IF_debug_multipage(void); + /** Enable or disable cursor blink + * @param enable - Set to 1 to enable the cursor blinking mode + */ + void set_blink(char enable); -void IF_backlight_toggle(void); + /** Enable or disable display + * @param enable - Set to 1 to enable the display output + */ + void set_display(char enable); -//Parts of initialisation routine -void post_init(void); -void post_post_init(void); + /** Set the brightness of the backlight + * @param brightness - Sets the brightness of the display (range 0.0 to 1.0) + */ + void set_backlight_brightness(float brightness); + // Special function for when debug messages are sent to display + void debug_page(char * message, char length); -// Clear display -void clear_display(); + // Internal function used to restore display after debug messages + void IF_restore_page(void); -//Set cursor to home position -void home(); + // Internal function used to show multi-page debug messages + void IF_debug_multipage(void); + + // Internal function used to toggle backlight + void IF_backlight_toggle(void); -// Send a 1-byte control message to the display -int i2c_message(char byte); + //Parts of initialisation routine + void post_init(void); + void post_post_init(void); -// Default initialisation sequence for the display -void init_display(char mode); + // Send a 1-byte control message to the display + int i2c_message(char byte); -int disp_putc(int c); + // Default initialisation sequence for the display + void init_display(char mode); + + int disp_putc(int c); private : @@ -107,16 +146,16 @@ I2C _i2c; DigitalOut _reset; DigitalOut _backlight; - + char display_on; char cursor_on; char blink_on; - + void _set_display(); - + virtual int _putc(int c); virtual int _getc(); - + }; #endif // DISPLAY_H \ No newline at end of file