Psi Swarm robot library version 0.9

Dependents:   PsiSwarm_V9_Blank

Fork of PsiSwarmV9 by James Hilder

Committer:
richardredpath
Date:
Mon Jul 08 10:50:40 2019 +0000
Revision:
20:2b6ebe60929d
Parent:
16:50686c07ad07
Fixed deprecated warnings for callbacks throughout the library

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 8:6c92789d5f87 2 *
jah128 16:50686c07ad07 3 * Copyright 2017 University of York
jah128 6:b340a527add9 4 *
jah128 8:6c92789d5f87 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 8:6c92789d5f87 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 16:50686c07ad07 16 * PsiSwarm Library Version: 0.9
jah128 0:d6269d17c8cf 17 *
jah128 16:50686c07ad07 18 * June 2017
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 8:6c92789d5f87 25 */
jah128 8:6c92789d5f87 26
jah128 8:6c92789d5f87 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 8:6c92789d5f87 34 /**
jah128 8:6c92789d5f87 35 * Display class
jah128 8:6c92789d5f87 36 * Functions for use with the Midas 16x2 I2C LCD Display (MCCOG21605x6W) LCD
jah128 8:6c92789d5f87 37 * Farnell part 2218942 or 2063206
jah128 8:6c92789d5f87 38 *
jah128 8:6c92789d5f87 39 * Example:
jah128 8:6c92789d5f87 40 * @code
jah128 8:6c92789d5f87 41 * #include "psiswarm.h"
jah128 8:6c92789d5f87 42 *
jah128 8:6c92789d5f87 43 * int main() {
jah128 8:6c92789d5f87 44 * init();
jah128 8:6c92789d5f87 45 * display.clear_display; //Clears display
jah128 8:6c92789d5f87 46 * display.set_position(0,2); //Set cursor to row 0 column 2
jah128 8:6c92789d5f87 47 * display.write_string("YORK ROBOTICS");
jah128 8:6c92789d5f87 48 * display.set_position(1,3); //Set cursor to row 1 column 3
jah128 8:6c92789d5f87 49 * display.write_string("LABORATORY");
jah128 8:6c92789d5f87 50 * }
jah128 8:6c92789d5f87 51 * @endcode
jah128 8:6c92789d5f87 52 */
jah128 8:6c92789d5f87 53 class Display : public Stream
jah128 8:6c92789d5f87 54 {
jah128 0:d6269d17c8cf 55
jah128 0:d6269d17c8cf 56 // Public Functions
jah128 0:d6269d17c8cf 57
jah128 0:d6269d17c8cf 58 public:
jah128 0:d6269d17c8cf 59
jah128 8:6c92789d5f87 60 /** Create the LCD Display object connected to the default pins
jah128 8:6c92789d5f87 61 * (sda = p28, scl = p27, reset = p29, backlight = p30)
jah128 8:6c92789d5f87 62 */
jah128 8:6c92789d5f87 63 Display();
jah128 8:6c92789d5f87 64
jah128 8:6c92789d5f87 65 /** Create the LCD Display object connected to specific pins
jah128 0:d6269d17c8cf 66 *
jah128 0:d6269d17c8cf 67 * @param sda pin - default is p28
jah128 0:d6269d17c8cf 68 * @param scl pin - default is p27
jah128 0:d6269d17c8cf 69 * @param reset pin - default is p29
jah128 0:d6269d17c8cf 70 * @param backlight pin - default is p30
jah128 0:d6269d17c8cf 71 */
jah128 0:d6269d17c8cf 72 Display(PinName sda, PinName scl, PinName reset, PinName backlight);
jah128 0:d6269d17c8cf 73
jah128 8:6c92789d5f87 74 /** Clear the display
jah128 8:6c92789d5f87 75 */
jah128 8:6c92789d5f87 76 void clear_display(void);
jah128 0:d6269d17c8cf 77
jah128 8:6c92789d5f87 78 /** Set cursor to home position
jah128 8:6c92789d5f87 79 */
jah128 8:6c92789d5f87 80 void home(void);
jah128 0:d6269d17c8cf 81
jah128 8:6c92789d5f87 82 /** Print string message
jah128 8:6c92789d5f87 83 * @param message - The null-terminated message to print
jah128 8:6c92789d5f87 84 */
jah128 8:6c92789d5f87 85 void write_string(char * message);
jah128 0:d6269d17c8cf 86
jah128 8:6c92789d5f87 87 /** Print string message of given length
jah128 8:6c92789d5f87 88 * @param message - The message to print
jah128 8:6c92789d5f87 89 * @param length - The number of characters to display
jah128 8:6c92789d5f87 90 */
jah128 8:6c92789d5f87 91 void write_string(char * message, char length);
jah128 0:d6269d17c8cf 92
jah128 8:6c92789d5f87 93 /** Set the row and column of cursor position
jah128 8:6c92789d5f87 94 * @param row - The row of the display to set the cursor to (either 0 or 1)
jah128 8:6c92789d5f87 95 * @param column - The column of the display to set the cursor to (range 0 to 15)
jah128 8:6c92789d5f87 96 */
jah128 8:6c92789d5f87 97 void set_position(char row, char column);
jah128 0:d6269d17c8cf 98
jah128 8:6c92789d5f87 99 /** Enable or disable cursor
jah128 8:6c92789d5f87 100 * @param enable - Set to 1 to enable the cursor visibility
jah128 8:6c92789d5f87 101 */
jah128 8:6c92789d5f87 102 void set_cursor(char enable);
jah128 0:d6269d17c8cf 103
jah128 8:6c92789d5f87 104 /** Enable or disable cursor blink
jah128 8:6c92789d5f87 105 * @param enable - Set to 1 to enable the cursor blinking mode
jah128 8:6c92789d5f87 106 */
jah128 8:6c92789d5f87 107 void set_blink(char enable);
jah128 0:d6269d17c8cf 108
jah128 8:6c92789d5f87 109 /** Enable or disable display
jah128 8:6c92789d5f87 110 * @param enable - Set to 1 to enable the display output
jah128 8:6c92789d5f87 111 */
jah128 8:6c92789d5f87 112 void set_display(char enable);
jah128 0:d6269d17c8cf 113
jah128 8:6c92789d5f87 114 /** Set the brightness of the backlight
jah128 8:6c92789d5f87 115 * @param brightness - Sets the brightness of the display (range 0.0 to 1.0)
jah128 8:6c92789d5f87 116 */
jah128 8:6c92789d5f87 117 void set_backlight_brightness(float brightness);
jah128 0:d6269d17c8cf 118
jah128 15:66be5ec52c3b 119 /** Display the switch state at the current cursor position
jah128 15:66be5ec52c3b 120 * @param switch_state - The value of the cursor switch (range 0 to 31)
jah128 15:66be5ec52c3b 121 */
jah128 15:66be5ec52c3b 122 void show_switch_state(char switch_state);
jah128 15:66be5ec52c3b 123
jah128 8:6c92789d5f87 124 // Special function for when debug messages are sent to display
jah128 8:6c92789d5f87 125 void debug_page(char * message, char length);
jah128 0:d6269d17c8cf 126
jah128 8:6c92789d5f87 127 // Internal function used to restore display after debug messages
jah128 8:6c92789d5f87 128 void IF_restore_page(void);
jah128 0:d6269d17c8cf 129
jah128 8:6c92789d5f87 130 // Internal function used to show multi-page debug messages
jah128 8:6c92789d5f87 131 void IF_debug_multipage(void);
jah128 8:6c92789d5f87 132
jah128 8:6c92789d5f87 133 // Internal function used to toggle backlight
jah128 8:6c92789d5f87 134 void IF_backlight_toggle(void);
jah128 0:d6269d17c8cf 135
jah128 8:6c92789d5f87 136 //Parts of initialisation routine
jah128 8:6c92789d5f87 137 void post_init(void);
jah128 8:6c92789d5f87 138 void post_post_init(void);
jah128 0:d6269d17c8cf 139
jah128 8:6c92789d5f87 140 // Send a 1-byte control message to the display
jah128 8:6c92789d5f87 141 int i2c_message(char byte);
jah128 0:d6269d17c8cf 142
jah128 15:66be5ec52c3b 143 // Default initialisation sequence for the display (start of boot)
jah128 15:66be5ec52c3b 144 void init_display_start();
jah128 15:66be5ec52c3b 145
jah128 15:66be5ec52c3b 146 // Default initialisation sequence for the display (end of boot)
jah128 15:66be5ec52c3b 147 void init_display_end(char mode);
jah128 8:6c92789d5f87 148
jah128 8:6c92789d5f87 149 int disp_putc(int c);
jah128 0:d6269d17c8cf 150
jah128 0:d6269d17c8cf 151
jah128 0:d6269d17c8cf 152 private :
jah128 0:d6269d17c8cf 153
jah128 0:d6269d17c8cf 154 I2C _i2c;
jah128 0:d6269d17c8cf 155 DigitalOut _reset;
jah128 0:d6269d17c8cf 156 DigitalOut _backlight;
jah128 8:6c92789d5f87 157
jah128 0:d6269d17c8cf 158 char display_on;
jah128 0:d6269d17c8cf 159 char cursor_on;
jah128 0:d6269d17c8cf 160 char blink_on;
jah128 8:6c92789d5f87 161
jah128 0:d6269d17c8cf 162 void _set_display();
jah128 8:6c92789d5f87 163
jah128 0:d6269d17c8cf 164 virtual int _putc(int c);
jah128 0:d6269d17c8cf 165 virtual int _getc();
jah128 8:6c92789d5f87 166
jah128 0:d6269d17c8cf 167 };
jah128 0:d6269d17c8cf 168
jah128 0:d6269d17c8cf 169 #endif // DISPLAY_H