Library for the PsiSwarm Robot - Version 0.7

Dependents:   PsiSwarm_V7_Blank

Fork of PsiSwarmLibrary by James Hilder

Committer:
jah128
Date:
Sat Oct 15 13:51:39 2016 +0000
Revision:
6:b340a527add9
Parent:
5:3cdd1a37cdd7
Added Apache license to files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jah128 0:d6269d17c8cf 1 /* University of York Robotics Laboratory PsiSwarm Library: Display Driver Header File
jah128 0:d6269d17c8cf 2 *
jah128 6:b340a527add9 3 * Copyright 2016 University of York
jah128 6:b340a527add9 4 *
jah128 6:b340a527add9 5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
jah128 6:b340a527add9 6 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
jah128 6:b340a527add9 7 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS
jah128 6:b340a527add9 8 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jah128 6:b340a527add9 9 * See the License for the specific language governing permissions and limitations under the License.
jah128 6:b340a527add9 10 *
jah128 0:d6269d17c8cf 11 * File: display.h
jah128 0:d6269d17c8cf 12 *
jah128 0:d6269d17c8cf 13 * (C) Dept. Electronics & Computer Science, University of York
jah128 0:d6269d17c8cf 14 * James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis
jah128 0:d6269d17c8cf 15 *
jah128 5:3cdd1a37cdd7 16 * PsiSwarm Library Version: 0.7
jah128 0:d6269d17c8cf 17 *
jah128 5:3cdd1a37cdd7 18 * October 2016
jah128 0:d6269d17c8cf 19 *
jah128 0:d6269d17c8cf 20 *
jah128 0:d6269d17c8cf 21 * Driver for the Midas 16x2 I2C LCD Display (MCCOG21605x6W) LCD
jah128 0:d6269d17c8cf 22 *
jah128 0:d6269d17c8cf 23 * Farnell part 2218942 or 2063206
jah128 0:d6269d17c8cf 24 *
jah128 0:d6269d17c8cf 25 */
jah128 0:d6269d17c8cf 26
jah128 0:d6269d17c8cf 27
jah128 0:d6269d17c8cf 28 #ifndef DISPLAY_H
jah128 0:d6269d17c8cf 29 #define DISPLAY_H
jah128 0:d6269d17c8cf 30
jah128 0:d6269d17c8cf 31 #define PAGE_TIME 0.4
jah128 0:d6269d17c8cf 32 #define CLEAR_TIME 0.8
jah128 0:d6269d17c8cf 33
jah128 0:d6269d17c8cf 34 class Display : public Stream {
jah128 0:d6269d17c8cf 35
jah128 0:d6269d17c8cf 36 // Public Functions
jah128 0:d6269d17c8cf 37
jah128 0:d6269d17c8cf 38 public:
jah128 0:d6269d17c8cf 39
jah128 0:d6269d17c8cf 40 /** Create the LCD Display object connected to the default pins
jah128 0:d6269d17c8cf 41 *
jah128 0:d6269d17c8cf 42 * @param sda pin - default is p28
jah128 0:d6269d17c8cf 43 * @param scl pin - default is p27
jah128 0:d6269d17c8cf 44 * @param reset pin - default is p29
jah128 0:d6269d17c8cf 45 * @param backlight pin - default is p30
jah128 0:d6269d17c8cf 46 */
jah128 0:d6269d17c8cf 47
jah128 0:d6269d17c8cf 48 Display();
jah128 0:d6269d17c8cf 49
jah128 0:d6269d17c8cf 50 /** Create the LCD Display object connected to specific pins
jah128 0:d6269d17c8cf 51 *
jah128 0:d6269d17c8cf 52 */
jah128 0:d6269d17c8cf 53 Display(PinName sda, PinName scl, PinName reset, PinName backlight);
jah128 0:d6269d17c8cf 54
jah128 0:d6269d17c8cf 55 //Print string message
jah128 0:d6269d17c8cf 56 void write_string(char * message);
jah128 0:d6269d17c8cf 57
jah128 0:d6269d17c8cf 58 //Print string message of given length
jah128 0:d6269d17c8cf 59 void write_string(char * message, char length);
jah128 0:d6269d17c8cf 60
jah128 0:d6269d17c8cf 61 //Set the row and column of cursor position
jah128 0:d6269d17c8cf 62 void set_position(char row, char column);
jah128 0:d6269d17c8cf 63
jah128 0:d6269d17c8cf 64 // Enable or disable cursor
jah128 0:d6269d17c8cf 65 void set_cursor(char enable);
jah128 0:d6269d17c8cf 66
jah128 0:d6269d17c8cf 67 // Enable or disable cursor blink
jah128 0:d6269d17c8cf 68 void set_blink(char enable);
jah128 0:d6269d17c8cf 69
jah128 0:d6269d17c8cf 70 // Enable or disable display
jah128 0:d6269d17c8cf 71 void set_display(char enable);
jah128 0:d6269d17c8cf 72
jah128 0:d6269d17c8cf 73 // Set the brightness of the backlight
jah128 0:d6269d17c8cf 74 void set_backlight_brightness(float brightness);
jah128 0:d6269d17c8cf 75
jah128 0:d6269d17c8cf 76 // Special function for when debug messages are sent to display
jah128 0:d6269d17c8cf 77 void debug_page(char * message, char length);
jah128 0:d6269d17c8cf 78
jah128 0:d6269d17c8cf 79 void IF_restore_page(void);
jah128 0:d6269d17c8cf 80
jah128 0:d6269d17c8cf 81 void IF_debug_multipage(void);
jah128 0:d6269d17c8cf 82
jah128 0:d6269d17c8cf 83 void IF_backlight_toggle(void);
jah128 0:d6269d17c8cf 84
jah128 0:d6269d17c8cf 85 //Parts of initialisation routine
jah128 0:d6269d17c8cf 86 void post_init(void);
jah128 0:d6269d17c8cf 87 void post_post_init(void);
jah128 0:d6269d17c8cf 88
jah128 0:d6269d17c8cf 89
jah128 0:d6269d17c8cf 90 // Clear display
jah128 0:d6269d17c8cf 91 void clear_display();
jah128 0:d6269d17c8cf 92
jah128 0:d6269d17c8cf 93 //Set cursor to home position
jah128 0:d6269d17c8cf 94 void home();
jah128 0:d6269d17c8cf 95
jah128 0:d6269d17c8cf 96 // Send a 1-byte control message to the display
jah128 0:d6269d17c8cf 97 int i2c_message(char byte);
jah128 0:d6269d17c8cf 98
jah128 0:d6269d17c8cf 99 // Default initialisation sequence for the display
jah128 0:d6269d17c8cf 100 void init_display(char mode);
jah128 0:d6269d17c8cf 101
jah128 0:d6269d17c8cf 102 int disp_putc(int c);
jah128 0:d6269d17c8cf 103
jah128 0:d6269d17c8cf 104
jah128 0:d6269d17c8cf 105 private :
jah128 0:d6269d17c8cf 106
jah128 0:d6269d17c8cf 107 I2C _i2c;
jah128 0:d6269d17c8cf 108 DigitalOut _reset;
jah128 0:d6269d17c8cf 109 DigitalOut _backlight;
jah128 0:d6269d17c8cf 110
jah128 0:d6269d17c8cf 111 char display_on;
jah128 0:d6269d17c8cf 112 char cursor_on;
jah128 0:d6269d17c8cf 113 char blink_on;
jah128 0:d6269d17c8cf 114
jah128 0:d6269d17c8cf 115 void _set_display();
jah128 0:d6269d17c8cf 116
jah128 0:d6269d17c8cf 117 virtual int _putc(int c);
jah128 0:d6269d17c8cf 118 virtual int _getc();
jah128 0:d6269d17c8cf 119
jah128 0:d6269d17c8cf 120 };
jah128 0:d6269d17c8cf 121
jah128 0:d6269d17c8cf 122 #endif // DISPLAY_H