Orignal AVR Tiny USI Based I2C slave LCD Driver.
Dependents: MyLCD_OSARU MyLCD_printf
MyLCD.h@0:2ba6a6510880, 2013-12-11 (annotated)
- Committer:
- bant62
- Date:
- Wed Dec 11 11:58:45 2013 +0000
- Revision:
- 0:2ba6a6510880
- Child:
- 1:794acd9a0b9c
first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bant62 | 0:2ba6a6510880 | 1 | /** |
bant62 | 0:2ba6a6510880 | 2 | ***************************************************************************** |
bant62 | 0:2ba6a6510880 | 3 | * File Name : MyLCD.h |
bant62 | 0:2ba6a6510880 | 4 | * |
bant62 | 0:2ba6a6510880 | 5 | * Title : ORGINAL I2C LCD Display Claass Header File |
bant62 | 0:2ba6a6510880 | 6 | * Revision : 0.1 |
bant62 | 0:2ba6a6510880 | 7 | * Notes : |
bant62 | 0:2ba6a6510880 | 8 | * Target Board : mbed NXP LPC1768, mbed LPC1114FN28 etc |
bant62 | 0:2ba6a6510880 | 9 | * Tool Chain : ???? |
bant62 | 0:2ba6a6510880 | 10 | * |
bant62 | 0:2ba6a6510880 | 11 | * Revision History: |
bant62 | 0:2ba6a6510880 | 12 | * When Who Description of change |
bant62 | 0:2ba6a6510880 | 13 | * ----------- ----------- ----------------------- |
bant62 | 0:2ba6a6510880 | 14 | * 2012/12/06 Hiroshi M init |
bant62 | 0:2ba6a6510880 | 15 | ***************************************************************************** |
bant62 | 0:2ba6a6510880 | 16 | * |
bant62 | 0:2ba6a6510880 | 17 | * Copyright (C) 2013 Hiroshi M, MIT License |
bant62 | 0:2ba6a6510880 | 18 | * |
bant62 | 0:2ba6a6510880 | 19 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
bant62 | 0:2ba6a6510880 | 20 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
bant62 | 0:2ba6a6510880 | 21 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
bant62 | 0:2ba6a6510880 | 22 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
bant62 | 0:2ba6a6510880 | 23 | * furnished to do so, subject to the following conditions: |
bant62 | 0:2ba6a6510880 | 24 | * |
bant62 | 0:2ba6a6510880 | 25 | * The above copyright notice and this permission notice shall be included in all copies or |
bant62 | 0:2ba6a6510880 | 26 | * substantial portions of the Software. |
bant62 | 0:2ba6a6510880 | 27 | * |
bant62 | 0:2ba6a6510880 | 28 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
bant62 | 0:2ba6a6510880 | 29 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
bant62 | 0:2ba6a6510880 | 30 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
bant62 | 0:2ba6a6510880 | 31 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
bant62 | 0:2ba6a6510880 | 32 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
bant62 | 0:2ba6a6510880 | 33 | * |
bant62 | 0:2ba6a6510880 | 34 | **/ |
bant62 | 0:2ba6a6510880 | 35 | |
bant62 | 0:2ba6a6510880 | 36 | #ifndef __MYLCD_H_ |
bant62 | 0:2ba6a6510880 | 37 | #define __MYLCD_H_ |
bant62 | 0:2ba6a6510880 | 38 | |
bant62 | 0:2ba6a6510880 | 39 | /* Includes ----------------------------------------------------------------- */ |
bant62 | 0:2ba6a6510880 | 40 | #include "mbed.h" |
bant62 | 0:2ba6a6510880 | 41 | /* typedef ------------------------------------------------------------------ */ |
bant62 | 0:2ba6a6510880 | 42 | |
bant62 | 0:2ba6a6510880 | 43 | /* define ------------------------------------------------------------------- */ |
bant62 | 0:2ba6a6510880 | 44 | #define ESC 0x1B |
bant62 | 0:2ba6a6510880 | 45 | #define I2C_ADDR_MYLCD 0x32 |
bant62 | 0:2ba6a6510880 | 46 | #define _i2cSUCCESS 0 |
bant62 | 0:2ba6a6510880 | 47 | #define _i2cFAILURE 1 |
bant62 | 0:2ba6a6510880 | 48 | |
bant62 | 0:2ba6a6510880 | 49 | /* macro -------------------------------------------------------------------- */ |
bant62 | 0:2ba6a6510880 | 50 | /* variables ---------------------------------------------------------------- */ |
bant62 | 0:2ba6a6510880 | 51 | /* class -------------------------------------------------------------------- */ |
bant62 | 0:2ba6a6510880 | 52 | class MyLCD : public Stream |
bant62 | 0:2ba6a6510880 | 53 | { |
bant62 | 0:2ba6a6510880 | 54 | private: |
bant62 | 0:2ba6a6510880 | 55 | static const int i2c_addr = I2C_ADDR_MYLCD << 1; |
bant62 | 0:2ba6a6510880 | 56 | static const int i2c_bit_wait_us = 20; |
bant62 | 0:2ba6a6510880 | 57 | static const int i2c_command_wait_ms = 4; |
bant62 | 0:2ba6a6510880 | 58 | static const int display_columns = 16; |
bant62 | 0:2ba6a6510880 | 59 | static const int display_rows = 2; |
bant62 | 0:2ba6a6510880 | 60 | |
bant62 | 0:2ba6a6510880 | 61 | I2C *_i2c; |
bant62 | 0:2ba6a6510880 | 62 | int _column, _row; |
bant62 | 0:2ba6a6510880 | 63 | int writeBytes(const char *data, int length, bool repeated=false); |
bant62 | 0:2ba6a6510880 | 64 | |
bant62 | 0:2ba6a6510880 | 65 | protected: |
bant62 | 0:2ba6a6510880 | 66 | virtual int _putc(int value); |
bant62 | 0:2ba6a6510880 | 67 | virtual int _getc(); |
bant62 | 0:2ba6a6510880 | 68 | |
bant62 | 0:2ba6a6510880 | 69 | void character(int column, int row, int c); |
bant62 | 0:2ba6a6510880 | 70 | int columns(); |
bant62 | 0:2ba6a6510880 | 71 | int rows(); |
bant62 | 0:2ba6a6510880 | 72 | |
bant62 | 0:2ba6a6510880 | 73 | public: |
bant62 | 0:2ba6a6510880 | 74 | MyLCD(I2C *i2c); |
bant62 | 0:2ba6a6510880 | 75 | #if DOXYGEN_ONLY |
bant62 | 0:2ba6a6510880 | 76 | int putc(int value); |
bant62 | 0:2ba6a6510880 | 77 | int printf(const char* format, ...); |
bant62 | 0:2ba6a6510880 | 78 | #endif |
bant62 | 0:2ba6a6510880 | 79 | |
bant62 | 0:2ba6a6510880 | 80 | int gotoCursor( int x, int y ); |
bant62 | 0:2ba6a6510880 | 81 | int home(void); |
bant62 | 0:2ba6a6510880 | 82 | int clear(void); |
bant62 | 0:2ba6a6510880 | 83 | int offDisplay(void); |
bant62 | 0:2ba6a6510880 | 84 | int onDisplay(void); |
bant62 | 0:2ba6a6510880 | 85 | int blinkCharacter(void); |
bant62 | 0:2ba6a6510880 | 86 | int dispCursor(void); |
bant62 | 0:2ba6a6510880 | 87 | int blinkCursor(void); |
bant62 | 0:2ba6a6510880 | 88 | int hideCursor(void); |
bant62 | 0:2ba6a6510880 | 89 | int moveLeftCursor(void); |
bant62 | 0:2ba6a6510880 | 90 | int moveRightCursor(void); |
bant62 | 0:2ba6a6510880 | 91 | int moveLeftDisplay(void); |
bant62 | 0:2ba6a6510880 | 92 | int moveRightDisplay(void); |
bant62 | 0:2ba6a6510880 | 93 | int printChar(char chr); |
bant62 | 0:2ba6a6510880 | 94 | int printStr(const char *s); |
bant62 | 0:2ba6a6510880 | 95 | |
bant62 | 0:2ba6a6510880 | 96 | int saveCustomCharacter(int romCharNum, char lcdCharData[]); |
bant62 | 0:2ba6a6510880 | 97 | int mapCustomCharacter(int romCharNum, int lcdCharNum); |
bant62 | 0:2ba6a6510880 | 98 | }; |
bant62 | 0:2ba6a6510880 | 99 | |
bant62 | 0:2ba6a6510880 | 100 | #endif /* __MYLCD_H_ */ |