Hotboards_SpiLcd.cpp - Library for write and control and lcd with spi interfaces and the ST7032 controller. Base on Arduino's Liquid Cristal library
Dependents: Hotboards_SpiLcd-Hello_World Hotboards_SpiLcd-Writing_In_Diferent_Rows Hotboards_SpiLcd_Scrolling_Text Hotboards_SpiLcd_AutoScroll ... more
Hotboards_SpiLcd.h@1:b777b6147d99, 2016-01-29 (annotated)
- Committer:
- Hotboards
- Date:
- Fri Jan 29 01:08:33 2016 +0000
- Revision:
- 1:b777b6147d99
- Parent:
- 0:1d03652e9f7a
- Child:
- 2:9673849ef2e9
update description
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Hotboards | 0:1d03652e9f7a | 1 | /* |
Hotboards | 1:b777b6147d99 | 2 | Hotboards_SpiLcd.cpp - Library to control and write an lcd with spi interface and ST7032 controller. |
Hotboards | 0:1d03652e9f7a | 3 | base on Arduino's Liquid Cristal library |
Hotboards | 0:1d03652e9f7a | 4 | Library ported by diego from Hotboards January 16, 2016. |
Hotboards | 0:1d03652e9f7a | 5 | and originally cretaed by |
Hotboards | 0:1d03652e9f7a | 6 | by David A. Mellis |
Hotboards | 0:1d03652e9f7a | 7 | library modified 5 Jul 2009 |
Hotboards | 0:1d03652e9f7a | 8 | by Limor Fried (http://www.ladyada.net) |
Hotboards | 0:1d03652e9f7a | 9 | example added 9 Jul 2009 |
Hotboards | 0:1d03652e9f7a | 10 | by Tom Igoe |
Hotboards | 0:1d03652e9f7a | 11 | modified 22 Nov 2010 |
Hotboards | 0:1d03652e9f7a | 12 | by Tom Igoe |
Hotboards | 0:1d03652e9f7a | 13 | Released into the public domain. |
Hotboards | 0:1d03652e9f7a | 14 | */ |
Hotboards | 0:1d03652e9f7a | 15 | |
Hotboards | 0:1d03652e9f7a | 16 | #ifndef Hotboards_SpiLcd_h |
Hotboards | 0:1d03652e9f7a | 17 | #define Hotboards_SpiLcd_h |
Hotboards | 0:1d03652e9f7a | 18 | |
Hotboards | 0:1d03652e9f7a | 19 | #include "mbed.h" |
Hotboards | 0:1d03652e9f7a | 20 | |
Hotboards | 0:1d03652e9f7a | 21 | // commands |
Hotboards | 0:1d03652e9f7a | 22 | #define HT_SPILCD_CLEARDISPLAY 0x01 |
Hotboards | 0:1d03652e9f7a | 23 | #define HT_SPILCD_RETURNHOME 0x02 |
Hotboards | 0:1d03652e9f7a | 24 | #define HT_SPILCD_ENTRYMODESET 0x04 |
Hotboards | 0:1d03652e9f7a | 25 | #define HT_SPILCD_DISPLAYCONTROL 0x08 |
Hotboards | 0:1d03652e9f7a | 26 | #define HT_SPILCD_CURSORSHIFT 0x10 |
Hotboards | 0:1d03652e9f7a | 27 | #define HT_SPILCD_FUNCTIONSET 0x20 |
Hotboards | 0:1d03652e9f7a | 28 | #define HT_SPILCD_SETCGRAMADDR 0x40 |
Hotboards | 0:1d03652e9f7a | 29 | #define HT_SPILCD_SETDDRAMADDR 0x80 |
Hotboards | 0:1d03652e9f7a | 30 | |
Hotboards | 0:1d03652e9f7a | 31 | // flags for display entry mode |
Hotboards | 0:1d03652e9f7a | 32 | #define HT_SPILCD_ENTRYRIGHT 0x00 |
Hotboards | 0:1d03652e9f7a | 33 | #define HT_SPILCD_ENTRYLEFT 0x02 |
Hotboards | 0:1d03652e9f7a | 34 | #define HT_SPILCD_ENTRYSHIFTINCREMENT 0x01 |
Hotboards | 0:1d03652e9f7a | 35 | #define HT_SPILCD_ENTRYSHIFTDECREMENT 0x00 |
Hotboards | 0:1d03652e9f7a | 36 | |
Hotboards | 0:1d03652e9f7a | 37 | // flags for display on/off control |
Hotboards | 0:1d03652e9f7a | 38 | #define HT_SPILCD_DISPLAYON 0x04 |
Hotboards | 0:1d03652e9f7a | 39 | #define HT_SPILCD_DISPLAYOFF 0x00 |
Hotboards | 0:1d03652e9f7a | 40 | #define HT_SPILCD_CURSORON 0x02 |
Hotboards | 0:1d03652e9f7a | 41 | #define HT_SPILCD_CURSOROFF 0x00 |
Hotboards | 0:1d03652e9f7a | 42 | #define HT_SPILCD_BLINKON 0x01 |
Hotboards | 0:1d03652e9f7a | 43 | #define HT_SPILCD_BLINKOFF 0x00 |
Hotboards | 0:1d03652e9f7a | 44 | |
Hotboards | 0:1d03652e9f7a | 45 | // flags for display/cursor shift |
Hotboards | 0:1d03652e9f7a | 46 | #define HT_SPILCD_DISPLAYMOVE 0x08 |
Hotboards | 0:1d03652e9f7a | 47 | #define HT_SPILCD_CURSORMOVE 0x00 |
Hotboards | 0:1d03652e9f7a | 48 | #define HT_SPILCD_MOVERIGHT 0x04 |
Hotboards | 0:1d03652e9f7a | 49 | #define HT_SPILCD_MOVELEFT 0x00 |
Hotboards | 0:1d03652e9f7a | 50 | |
Hotboards | 0:1d03652e9f7a | 51 | // flags for function set |
Hotboards | 0:1d03652e9f7a | 52 | #define HT_SPILCD_8BITMODE 0x10 |
Hotboards | 0:1d03652e9f7a | 53 | #define HT_SPILCD_4BITMODE 0x00 |
Hotboards | 0:1d03652e9f7a | 54 | #define HT_SPILCD_2LINE 0x08 |
Hotboards | 0:1d03652e9f7a | 55 | #define HT_SPILCD_1LINE 0x00 |
Hotboards | 0:1d03652e9f7a | 56 | #define HT_SPILCD_5x16DOTS 0x04 |
Hotboards | 0:1d03652e9f7a | 57 | #define HT_SPILCD_5x8DOTS 0x00 |
Hotboards | 0:1d03652e9f7a | 58 | #define HT_SPILCD_EXTINST 0x01 |
Hotboards | 0:1d03652e9f7a | 59 | #define HT_SPILCD_NORMINST 0x00 |
Hotboards | 0:1d03652e9f7a | 60 | |
Hotboards | 0:1d03652e9f7a | 61 | |
Hotboards | 0:1d03652e9f7a | 62 | class Hotboards_SpiLcd : public Stream |
Hotboards | 0:1d03652e9f7a | 63 | { |
Hotboards | 0:1d03652e9f7a | 64 | public: |
Hotboards | 0:1d03652e9f7a | 65 | |
Hotboards | 0:1d03652e9f7a | 66 | Hotboards_SpiLcd( SPI &spi, PinName cs, PinName rs, PinName rst ); |
Hotboards | 0:1d03652e9f7a | 67 | void init( void ); |
Hotboards | 0:1d03652e9f7a | 68 | void clear( void ); |
Hotboards | 0:1d03652e9f7a | 69 | void home( void ); |
Hotboards | 0:1d03652e9f7a | 70 | |
Hotboards | 0:1d03652e9f7a | 71 | void noDisplay( void ); |
Hotboards | 0:1d03652e9f7a | 72 | void display( void ); |
Hotboards | 0:1d03652e9f7a | 73 | void noBlink( void ); |
Hotboards | 0:1d03652e9f7a | 74 | void blink( void ); |
Hotboards | 0:1d03652e9f7a | 75 | void noCursor( void ); |
Hotboards | 0:1d03652e9f7a | 76 | void cursor( void ); |
Hotboards | 0:1d03652e9f7a | 77 | void scrollDisplayLeft( void ); |
Hotboards | 0:1d03652e9f7a | 78 | void scrollDisplayRight( void ); |
Hotboards | 0:1d03652e9f7a | 79 | void leftToRight( void ); |
Hotboards | 0:1d03652e9f7a | 80 | void rightToLeft( void ); |
Hotboards | 0:1d03652e9f7a | 81 | void autoscroll( void ); |
Hotboards | 0:1d03652e9f7a | 82 | void noAutoscroll( void ); |
Hotboards | 0:1d03652e9f7a | 83 | |
Hotboards | 0:1d03652e9f7a | 84 | //void setRowOffsets( int row1, int row2 ); |
Hotboards | 0:1d03652e9f7a | 85 | //void createChar( uint8_t, uint8_t[] ); |
Hotboards | 0:1d03652e9f7a | 86 | void setCursor( uint8_t, uint8_t ); |
Hotboards | 0:1d03652e9f7a | 87 | void command( uint8_t ); |
Hotboards | 0:1d03652e9f7a | 88 | #if DOXYGEN_ONLY |
Hotboards | 0:1d03652e9f7a | 89 | int putc(int c); |
Hotboards | 0:1d03652e9f7a | 90 | int printf(const char* format, ...); |
Hotboards | 0:1d03652e9f7a | 91 | #endif |
Hotboards | 0:1d03652e9f7a | 92 | |
Hotboards | 0:1d03652e9f7a | 93 | |
Hotboards | 0:1d03652e9f7a | 94 | protected: |
Hotboards | 0:1d03652e9f7a | 95 | |
Hotboards | 0:1d03652e9f7a | 96 | void send( uint8_t, uint8_t ); |
Hotboards | 0:1d03652e9f7a | 97 | |
Hotboards | 0:1d03652e9f7a | 98 | // redirection for the printf and putc functions |
Hotboards | 0:1d03652e9f7a | 99 | virtual int _putc( int value ); |
Hotboards | 0:1d03652e9f7a | 100 | virtual int _getc( void ); |
Hotboards | 0:1d03652e9f7a | 101 | |
Hotboards | 0:1d03652e9f7a | 102 | // internal objects |
Hotboards | 0:1d03652e9f7a | 103 | SPI _spi; |
Hotboards | 0:1d03652e9f7a | 104 | |
Hotboards | 0:1d03652e9f7a | 105 | DigitalOut _cs_pin; |
Hotboards | 0:1d03652e9f7a | 106 | DigitalOut _rs_pin; |
Hotboards | 0:1d03652e9f7a | 107 | DigitalOut _rst_pin; |
Hotboards | 0:1d03652e9f7a | 108 | |
Hotboards | 0:1d03652e9f7a | 109 | uint8_t _displayfunction; |
Hotboards | 0:1d03652e9f7a | 110 | uint8_t _displaycontrol; |
Hotboards | 0:1d03652e9f7a | 111 | uint8_t _displaymode; |
Hotboards | 0:1d03652e9f7a | 112 | }; |
Hotboards | 0:1d03652e9f7a | 113 | |
Hotboards | 0:1d03652e9f7a | 114 | #endif /* Hotboards_SpiLcd_h */ |