Library for the PsiSwarm Robot - Version 0.4
display.h@2:c6986ee3c7c5, 2016-03-11 (annotated)
- Committer:
- jah128
- Date:
- Fri Mar 11 13:51:24 2016 +0000
- Revision:
- 2:c6986ee3c7c5
- Parent:
- 0:d6269d17c8cf
Added Alex' IR functions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jah128 | 0:d6269d17c8cf | 1 | /* University of York Robotics Laboratory PsiSwarm Library: Display Driver Header File |
jah128 | 0:d6269d17c8cf | 2 | * |
jah128 | 0:d6269d17c8cf | 3 | * File: display.h |
jah128 | 0:d6269d17c8cf | 4 | * |
jah128 | 0:d6269d17c8cf | 5 | * (C) Dept. Electronics & Computer Science, University of York |
jah128 | 0:d6269d17c8cf | 6 | * James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis |
jah128 | 0:d6269d17c8cf | 7 | * |
jah128 | 2:c6986ee3c7c5 | 8 | * PsiSwarm Library Version: 0.41 |
jah128 | 0:d6269d17c8cf | 9 | * |
jah128 | 2:c6986ee3c7c5 | 10 | * March 2016 |
jah128 | 0:d6269d17c8cf | 11 | * |
jah128 | 0:d6269d17c8cf | 12 | * |
jah128 | 0:d6269d17c8cf | 13 | * Driver for the Midas 16x2 I2C LCD Display (MCCOG21605x6W) LCD |
jah128 | 0:d6269d17c8cf | 14 | * |
jah128 | 0:d6269d17c8cf | 15 | * Farnell part 2218942 or 2063206 |
jah128 | 0:d6269d17c8cf | 16 | * |
jah128 | 0:d6269d17c8cf | 17 | */ |
jah128 | 0:d6269d17c8cf | 18 | |
jah128 | 0:d6269d17c8cf | 19 | |
jah128 | 0:d6269d17c8cf | 20 | #ifndef DISPLAY_H |
jah128 | 0:d6269d17c8cf | 21 | #define DISPLAY_H |
jah128 | 0:d6269d17c8cf | 22 | |
jah128 | 0:d6269d17c8cf | 23 | #define PAGE_TIME 0.4 |
jah128 | 0:d6269d17c8cf | 24 | #define CLEAR_TIME 0.8 |
jah128 | 0:d6269d17c8cf | 25 | |
jah128 | 0:d6269d17c8cf | 26 | class Display : public Stream { |
jah128 | 0:d6269d17c8cf | 27 | |
jah128 | 0:d6269d17c8cf | 28 | // Public Functions |
jah128 | 0:d6269d17c8cf | 29 | |
jah128 | 0:d6269d17c8cf | 30 | public: |
jah128 | 0:d6269d17c8cf | 31 | |
jah128 | 0:d6269d17c8cf | 32 | /** Create the LCD Display object connected to the default pins |
jah128 | 0:d6269d17c8cf | 33 | * |
jah128 | 0:d6269d17c8cf | 34 | * @param sda pin - default is p28 |
jah128 | 0:d6269d17c8cf | 35 | * @param scl pin - default is p27 |
jah128 | 0:d6269d17c8cf | 36 | * @param reset pin - default is p29 |
jah128 | 0:d6269d17c8cf | 37 | * @param backlight pin - default is p30 |
jah128 | 0:d6269d17c8cf | 38 | */ |
jah128 | 0:d6269d17c8cf | 39 | |
jah128 | 0:d6269d17c8cf | 40 | Display(); |
jah128 | 0:d6269d17c8cf | 41 | |
jah128 | 0:d6269d17c8cf | 42 | /** Create the LCD Display object connected to specific pins |
jah128 | 0:d6269d17c8cf | 43 | * |
jah128 | 0:d6269d17c8cf | 44 | */ |
jah128 | 0:d6269d17c8cf | 45 | Display(PinName sda, PinName scl, PinName reset, PinName backlight); |
jah128 | 0:d6269d17c8cf | 46 | |
jah128 | 0:d6269d17c8cf | 47 | //Print string message |
jah128 | 0:d6269d17c8cf | 48 | void write_string(char * message); |
jah128 | 0:d6269d17c8cf | 49 | |
jah128 | 0:d6269d17c8cf | 50 | //Print string message of given length |
jah128 | 0:d6269d17c8cf | 51 | void write_string(char * message, char length); |
jah128 | 0:d6269d17c8cf | 52 | |
jah128 | 0:d6269d17c8cf | 53 | //Set the row and column of cursor position |
jah128 | 0:d6269d17c8cf | 54 | void set_position(char row, char column); |
jah128 | 0:d6269d17c8cf | 55 | |
jah128 | 0:d6269d17c8cf | 56 | // Enable or disable cursor |
jah128 | 0:d6269d17c8cf | 57 | void set_cursor(char enable); |
jah128 | 0:d6269d17c8cf | 58 | |
jah128 | 0:d6269d17c8cf | 59 | // Enable or disable cursor blink |
jah128 | 0:d6269d17c8cf | 60 | void set_blink(char enable); |
jah128 | 0:d6269d17c8cf | 61 | |
jah128 | 0:d6269d17c8cf | 62 | // Enable or disable display |
jah128 | 0:d6269d17c8cf | 63 | void set_display(char enable); |
jah128 | 0:d6269d17c8cf | 64 | |
jah128 | 0:d6269d17c8cf | 65 | // Set the brightness of the backlight |
jah128 | 0:d6269d17c8cf | 66 | void set_backlight_brightness(float brightness); |
jah128 | 0:d6269d17c8cf | 67 | |
jah128 | 0:d6269d17c8cf | 68 | // Special function for when debug messages are sent to display |
jah128 | 0:d6269d17c8cf | 69 | void debug_page(char * message, char length); |
jah128 | 0:d6269d17c8cf | 70 | |
jah128 | 0:d6269d17c8cf | 71 | void IF_restore_page(void); |
jah128 | 0:d6269d17c8cf | 72 | |
jah128 | 0:d6269d17c8cf | 73 | void IF_debug_multipage(void); |
jah128 | 0:d6269d17c8cf | 74 | |
jah128 | 0:d6269d17c8cf | 75 | void IF_backlight_toggle(void); |
jah128 | 0:d6269d17c8cf | 76 | |
jah128 | 0:d6269d17c8cf | 77 | //Parts of initialisation routine |
jah128 | 0:d6269d17c8cf | 78 | void post_init(void); |
jah128 | 0:d6269d17c8cf | 79 | void post_post_init(void); |
jah128 | 0:d6269d17c8cf | 80 | |
jah128 | 0:d6269d17c8cf | 81 | |
jah128 | 0:d6269d17c8cf | 82 | // Clear display |
jah128 | 0:d6269d17c8cf | 83 | void clear_display(); |
jah128 | 0:d6269d17c8cf | 84 | |
jah128 | 0:d6269d17c8cf | 85 | //Set cursor to home position |
jah128 | 0:d6269d17c8cf | 86 | void home(); |
jah128 | 0:d6269d17c8cf | 87 | |
jah128 | 0:d6269d17c8cf | 88 | // Send a 1-byte control message to the display |
jah128 | 0:d6269d17c8cf | 89 | int i2c_message(char byte); |
jah128 | 0:d6269d17c8cf | 90 | |
jah128 | 0:d6269d17c8cf | 91 | // Default initialisation sequence for the display |
jah128 | 0:d6269d17c8cf | 92 | void init_display(char mode); |
jah128 | 0:d6269d17c8cf | 93 | |
jah128 | 0:d6269d17c8cf | 94 | int disp_putc(int c); |
jah128 | 0:d6269d17c8cf | 95 | |
jah128 | 0:d6269d17c8cf | 96 | |
jah128 | 0:d6269d17c8cf | 97 | private : |
jah128 | 0:d6269d17c8cf | 98 | |
jah128 | 0:d6269d17c8cf | 99 | I2C _i2c; |
jah128 | 0:d6269d17c8cf | 100 | DigitalOut _reset; |
jah128 | 0:d6269d17c8cf | 101 | DigitalOut _backlight; |
jah128 | 0:d6269d17c8cf | 102 | |
jah128 | 0:d6269d17c8cf | 103 | char display_on; |
jah128 | 0:d6269d17c8cf | 104 | char cursor_on; |
jah128 | 0:d6269d17c8cf | 105 | char blink_on; |
jah128 | 0:d6269d17c8cf | 106 | |
jah128 | 0:d6269d17c8cf | 107 | void _set_display(); |
jah128 | 0:d6269d17c8cf | 108 | |
jah128 | 0:d6269d17c8cf | 109 | virtual int _putc(int c); |
jah128 | 0:d6269d17c8cf | 110 | virtual int _getc(); |
jah128 | 0:d6269d17c8cf | 111 | |
jah128 | 0:d6269d17c8cf | 112 | }; |
jah128 | 0:d6269d17c8cf | 113 | |
jah128 | 0:d6269d17c8cf | 114 | #endif // DISPLAY_H |