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