Handheld controller (RF) for Pi Swarm system
Fork of Pi_Swarm_Handheld_Controller by
display.h@0:d63a63feb104, 2014-06-10 (annotated)
- Committer:
- jah128
- Date:
- Tue Jun 10 11:05:23 2014 +0000
- Revision:
- 0:d63a63feb104
Handheld controller for Pi Swarm (old code)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jah128 | 0:d63a63feb104 | 1 | /* University of York Robotics Laboratory MBED Library: Display Driver |
jah128 | 0:d63a63feb104 | 2 | * |
jah128 | 0:d63a63feb104 | 3 | * File: display.h |
jah128 | 0:d63a63feb104 | 4 | * |
jah128 | 0:d63a63feb104 | 5 | * (C) Dr James Hilder, Dept. Electronics & Computer Science, University of York |
jah128 | 0:d63a63feb104 | 6 | * |
jah128 | 0:d63a63feb104 | 7 | * October 2013 |
jah128 | 0:d63a63feb104 | 8 | * |
jah128 | 0:d63a63feb104 | 9 | * Driver for the Midas 20x4 I2C LCD Display (MCCOG42005A6W-BNMLWI) LCD |
jah128 | 0:d63a63feb104 | 10 | * |
jah128 | 0:d63a63feb104 | 11 | * Farnell part 2218946 |
jah128 | 0:d63a63feb104 | 12 | * |
jah128 | 0:d63a63feb104 | 13 | */ |
jah128 | 0:d63a63feb104 | 14 | |
jah128 | 0:d63a63feb104 | 15 | #ifndef DISPLAY_H |
jah128 | 0:d63a63feb104 | 16 | #define DISPLAY_H |
jah128 | 0:d63a63feb104 | 17 | |
jah128 | 0:d63a63feb104 | 18 | // |
jah128 | 0:d63a63feb104 | 19 | // Defines |
jah128 | 0:d63a63feb104 | 20 | // |
jah128 | 0:d63a63feb104 | 21 | |
jah128 | 0:d63a63feb104 | 22 | #define LCD_ADDRESS 0x78 |
jah128 | 0:d63a63feb104 | 23 | |
jah128 | 0:d63a63feb104 | 24 | class Display : public Stream { |
jah128 | 0:d63a63feb104 | 25 | |
jah128 | 0:d63a63feb104 | 26 | // Public Functions |
jah128 | 0:d63a63feb104 | 27 | |
jah128 | 0:d63a63feb104 | 28 | public: |
jah128 | 0:d63a63feb104 | 29 | |
jah128 | 0:d63a63feb104 | 30 | /** Create the LCD Display object connected to the default pins |
jah128 | 0:d63a63feb104 | 31 | * |
jah128 | 0:d63a63feb104 | 32 | * @param sda pin - default is p9 |
jah128 | 0:d63a63feb104 | 33 | * @param scl pin - default is p10 |
jah128 | 0:d63a63feb104 | 34 | * @param reset pin - default is p12 |
jah128 | 0:d63a63feb104 | 35 | */ |
jah128 | 0:d63a63feb104 | 36 | |
jah128 | 0:d63a63feb104 | 37 | Display(); |
jah128 | 0:d63a63feb104 | 38 | |
jah128 | 0:d63a63feb104 | 39 | /** Create the LCD Display object connected to specific pins |
jah128 | 0:d63a63feb104 | 40 | * |
jah128 | 0:d63a63feb104 | 41 | */ |
jah128 | 0:d63a63feb104 | 42 | Display(PinName sda, PinName scl, PinName reset); |
jah128 | 0:d63a63feb104 | 43 | |
jah128 | 0:d63a63feb104 | 44 | //Print string message of given length |
jah128 | 0:d63a63feb104 | 45 | void write_string(char * message, char length); |
jah128 | 0:d63a63feb104 | 46 | |
jah128 | 0:d63a63feb104 | 47 | //Set the row and column of cursor position |
jah128 | 0:d63a63feb104 | 48 | void set_position(char row, char column); |
jah128 | 0:d63a63feb104 | 49 | |
jah128 | 0:d63a63feb104 | 50 | // Enable or disable cursor |
jah128 | 0:d63a63feb104 | 51 | void set_cursor(char enable); |
jah128 | 0:d63a63feb104 | 52 | |
jah128 | 0:d63a63feb104 | 53 | // Enable or disable cursor blink |
jah128 | 0:d63a63feb104 | 54 | void set_blink(char enable); |
jah128 | 0:d63a63feb104 | 55 | |
jah128 | 0:d63a63feb104 | 56 | // Enable or disable display |
jah128 | 0:d63a63feb104 | 57 | void set_display(char enable); |
jah128 | 0:d63a63feb104 | 58 | |
jah128 | 0:d63a63feb104 | 59 | |
jah128 | 0:d63a63feb104 | 60 | // Clear display |
jah128 | 0:d63a63feb104 | 61 | void clear_display(); |
jah128 | 0:d63a63feb104 | 62 | |
jah128 | 0:d63a63feb104 | 63 | //Set cursor to home position |
jah128 | 0:d63a63feb104 | 64 | void home(); |
jah128 | 0:d63a63feb104 | 65 | |
jah128 | 0:d63a63feb104 | 66 | |
jah128 | 0:d63a63feb104 | 67 | // Send a 1-byte control message to the display |
jah128 | 0:d63a63feb104 | 68 | int i2c_message(char byte); |
jah128 | 0:d63a63feb104 | 69 | |
jah128 | 0:d63a63feb104 | 70 | // Default initialisation sequence for the display |
jah128 | 0:d63a63feb104 | 71 | void init_display(); |
jah128 | 0:d63a63feb104 | 72 | |
jah128 | 0:d63a63feb104 | 73 | int disp_putc(int c); |
jah128 | 0:d63a63feb104 | 74 | |
jah128 | 0:d63a63feb104 | 75 | |
jah128 | 0:d63a63feb104 | 76 | private : |
jah128 | 0:d63a63feb104 | 77 | |
jah128 | 0:d63a63feb104 | 78 | I2C _i2c; |
jah128 | 0:d63a63feb104 | 79 | DigitalOut _reset; |
jah128 | 0:d63a63feb104 | 80 | |
jah128 | 0:d63a63feb104 | 81 | char display_on; |
jah128 | 0:d63a63feb104 | 82 | char cursor_on; |
jah128 | 0:d63a63feb104 | 83 | char blink_on; |
jah128 | 0:d63a63feb104 | 84 | |
jah128 | 0:d63a63feb104 | 85 | void _set_display(); |
jah128 | 0:d63a63feb104 | 86 | |
jah128 | 0:d63a63feb104 | 87 | virtual int _putc(int c); |
jah128 | 0:d63a63feb104 | 88 | virtual int _getc(); |
jah128 | 0:d63a63feb104 | 89 | |
jah128 | 0:d63a63feb104 | 90 | }; |
jah128 | 0:d63a63feb104 | 91 | |
jah128 | 0:d63a63feb104 | 92 | #endif // DISPLAY_H |
jah128 | 0:d63a63feb104 | 93 | |
jah128 | 0:d63a63feb104 | 94 | |
jah128 | 0:d63a63feb104 | 95 | |
jah128 | 0:d63a63feb104 | 96 | /* Permission is hereby granted, free of charge, to any person obtaining a copy |
jah128 | 0:d63a63feb104 | 97 | * of this software and associated documentation files (the "Software"), to deal |
jah128 | 0:d63a63feb104 | 98 | * in the Software without restriction, including without limitation the rights |
jah128 | 0:d63a63feb104 | 99 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
jah128 | 0:d63a63feb104 | 100 | * copies of the Software, and to permit persons to whom the Software is |
jah128 | 0:d63a63feb104 | 101 | * furnished to do so, subject to the following conditions: |
jah128 | 0:d63a63feb104 | 102 | * |
jah128 | 0:d63a63feb104 | 103 | * The above copyright notice and this permission notice shall be included in |
jah128 | 0:d63a63feb104 | 104 | * all copies or substantial portions of the Software. |
jah128 | 0:d63a63feb104 | 105 | * |
jah128 | 0:d63a63feb104 | 106 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
jah128 | 0:d63a63feb104 | 107 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
jah128 | 0:d63a63feb104 | 108 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
jah128 | 0:d63a63feb104 | 109 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
jah128 | 0:d63a63feb104 | 110 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
jah128 | 0:d63a63feb104 | 111 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
jah128 | 0:d63a63feb104 | 112 | * THE SOFTWARE. |
jah128 | 0:d63a63feb104 | 113 | */ |