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