NXP PCF8576 Universal LCD driver for low multiplex rates + GH08172 LCD library
Dependents: PCF8576_GH08172_test
PCF8576.h@1:427ffdda29a3, 2016-03-28 (annotated)
- Committer:
- MACRUM
- Date:
- Mon Mar 28 12:47:02 2016 +0000
- Revision:
- 1:427ffdda29a3
- Parent:
- 0:e62c6477b73b
Add comment
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MACRUM | 0:e62c6477b73b | 1 | /* Copyright (c) 2016 ARM Ltd., MIT License |
MACRUM | 0:e62c6477b73b | 2 | * |
MACRUM | 0:e62c6477b73b | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
MACRUM | 0:e62c6477b73b | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
MACRUM | 0:e62c6477b73b | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
MACRUM | 0:e62c6477b73b | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
MACRUM | 0:e62c6477b73b | 7 | * Software is furnished to do so, subject to the following conditions: |
MACRUM | 0:e62c6477b73b | 8 | * |
MACRUM | 0:e62c6477b73b | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
MACRUM | 0:e62c6477b73b | 10 | * substantial portions of the Software. |
MACRUM | 0:e62c6477b73b | 11 | * |
MACRUM | 0:e62c6477b73b | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
MACRUM | 0:e62c6477b73b | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
MACRUM | 0:e62c6477b73b | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
MACRUM | 0:e62c6477b73b | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
MACRUM | 0:e62c6477b73b | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
MACRUM | 0:e62c6477b73b | 17 | * |
MACRUM | 0:e62c6477b73b | 18 | * |
MACRUM | 0:e62c6477b73b | 19 | * PCF8576 Universal LCD driver library |
MACRUM | 0:e62c6477b73b | 20 | * |
MACRUM | 0:e62c6477b73b | 21 | * @author Toyomasa Watarai |
MACRUM | 0:e62c6477b73b | 22 | * @version 1.0 |
MACRUM | 0:e62c6477b73b | 23 | * @date 28-March-2016 |
MACRUM | 0:e62c6477b73b | 24 | * |
MACRUM | 0:e62c6477b73b | 25 | * Library for "PCF8576 Universal LCD driver for low multiplex rates" |
MACRUM | 0:e62c6477b73b | 26 | * |
MACRUM | 0:e62c6477b73b | 27 | */ |
MACRUM | 0:e62c6477b73b | 28 | |
MACRUM | 0:e62c6477b73b | 29 | #ifndef PCF8576_H |
MACRUM | 0:e62c6477b73b | 30 | #define PCF8576_H |
MACRUM | 0:e62c6477b73b | 31 | |
MACRUM | 0:e62c6477b73b | 32 | #include "mbed.h" |
MACRUM | 0:e62c6477b73b | 33 | #include "char_pattern.h" |
MACRUM | 0:e62c6477b73b | 34 | |
MACRUM | 0:e62c6477b73b | 35 | #define PCF8576_CMD_MODE_SET 0x40 |
MACRUM | 0:e62c6477b73b | 36 | #define PCF8576_CMD_LOAD_DATA 0x00 |
MACRUM | 0:e62c6477b73b | 37 | #define PCF8576_CMD_DEVICE_SEL 0x60 |
MACRUM | 0:e62c6477b73b | 38 | #define PCF8576_CMD_BANK_SEL 0x78 |
MACRUM | 0:e62c6477b73b | 39 | #define PCF8576_CMD_BINK 0x70 |
MACRUM | 0:e62c6477b73b | 40 | |
MACRUM | 0:e62c6477b73b | 41 | #define PCF8576_DEFAULT_SLAVE_ADDRESS 0x70 |
MACRUM | 0:e62c6477b73b | 42 | |
MACRUM | 0:e62c6477b73b | 43 | /** |
MACRUM | 0:e62c6477b73b | 44 | * PCF8576 Universal LCD driver library example |
MACRUM | 0:e62c6477b73b | 45 | * |
MACRUM | 0:e62c6477b73b | 46 | * @code |
MACRUM | 0:e62c6477b73b | 47 | * #include "PCF8576.h" |
MACRUM | 0:e62c6477b73b | 48 | * PCF8576 lcd(D14, D15); |
MACRUM | 0:e62c6477b73b | 49 | * |
MACRUM | 0:e62c6477b73b | 50 | * int main() { |
MACRUM | 0:e62c6477b73b | 51 | * lcd.print("mbed"); |
MACRUM | 0:e62c6477b73b | 52 | * while(1) { |
MACRUM | 0:e62c6477b73b | 53 | * } |
MACRUM | 0:e62c6477b73b | 54 | * } |
MACRUM | 0:e62c6477b73b | 55 | * @endcode |
MACRUM | 0:e62c6477b73b | 56 | */ |
MACRUM | 0:e62c6477b73b | 57 | class PCF8576 { |
MACRUM | 0:e62c6477b73b | 58 | public: |
MACRUM | 0:e62c6477b73b | 59 | /** |
MACRUM | 0:e62c6477b73b | 60 | * PCF8576 constructor |
MACRUM | 0:e62c6477b73b | 61 | * |
MACRUM | 0:e62c6477b73b | 62 | * @param sda SDA pin |
MACRUM | 0:e62c6477b73b | 63 | * @param sdl SCL pin |
MACRUM | 1:427ffdda29a3 | 64 | * @param addr Slave address of the I2C peripheral (default: 0x70) |
MACRUM | 0:e62c6477b73b | 65 | */ |
MACRUM | 0:e62c6477b73b | 66 | PCF8576(PinName sda, PinName scl, int addr = PCF8576_DEFAULT_SLAVE_ADDRESS); |
MACRUM | 0:e62c6477b73b | 67 | |
MACRUM | 0:e62c6477b73b | 68 | /** |
MACRUM | 0:e62c6477b73b | 69 | * Create a PCF8576 instance which is connected to specified I2C pins |
MACRUM | 0:e62c6477b73b | 70 | * with specified address |
MACRUM | 0:e62c6477b73b | 71 | * |
MACRUM | 0:e62c6477b73b | 72 | * @param i2c_obj I2C object (instance) |
MACRUM | 1:427ffdda29a3 | 73 | * @param addr Slave address of the I2C-bus peripheral (default: 0x70) |
MACRUM | 0:e62c6477b73b | 74 | */ |
MACRUM | 0:e62c6477b73b | 75 | PCF8576(I2C &i2c_obj, int addr = PCF8576_DEFAULT_SLAVE_ADDRESS); |
MACRUM | 0:e62c6477b73b | 76 | |
MACRUM | 0:e62c6477b73b | 77 | /** |
MACRUM | 0:e62c6477b73b | 78 | * PCF8576 destructor |
MACRUM | 0:e62c6477b73b | 79 | */ |
MACRUM | 0:e62c6477b73b | 80 | ~PCF8576(); |
MACRUM | 0:e62c6477b73b | 81 | |
MACRUM | 0:e62c6477b73b | 82 | /** Initializa PCF8576 device |
MACRUM | 0:e62c6477b73b | 83 | * |
MACRUM | 0:e62c6477b73b | 84 | * Configure LCD setting |
MACRUM | 0:e62c6477b73b | 85 | * |
MACRUM | 0:e62c6477b73b | 86 | */ |
MACRUM | 0:e62c6477b73b | 87 | void initialize(void); |
MACRUM | 0:e62c6477b73b | 88 | |
MACRUM | 0:e62c6477b73b | 89 | /** |
MACRUM | 0:e62c6477b73b | 90 | * Print string |
MACRUM | 0:e62c6477b73b | 91 | * |
MACRUM | 1:427ffdda29a3 | 92 | * @param str Poiner to print string |
MACRUM | 0:e62c6477b73b | 93 | */ |
MACRUM | 0:e62c6477b73b | 94 | void print(char *str); |
MACRUM | 0:e62c6477b73b | 95 | |
MACRUM | 0:e62c6477b73b | 96 | /** |
MACRUM | 1:427ffdda29a3 | 97 | * Print level-bar pictogram icon |
MACRUM | 0:e62c6477b73b | 98 | * |
MACRUM | 1:427ffdda29a3 | 99 | * @param icon Level-bar pictogram icon from 0 (all off) to 0xF (all on) |
MACRUM | 0:e62c6477b73b | 100 | */ |
MACRUM | 0:e62c6477b73b | 101 | void icon(uint32_t icon); |
MACRUM | 0:e62c6477b73b | 102 | |
MACRUM | 0:e62c6477b73b | 103 | private: |
MACRUM | 0:e62c6477b73b | 104 | I2C m_i2c; |
MACRUM | 0:e62c6477b73b | 105 | int m_addr; |
MACRUM | 0:e62c6477b73b | 106 | char m_lcd_buf[14]; |
MACRUM | 0:e62c6477b73b | 107 | char m_C5_mask; |
MACRUM | 0:e62c6477b73b | 108 | char m_C6_mask; |
MACRUM | 0:e62c6477b73b | 109 | |
MACRUM | 0:e62c6477b73b | 110 | }; |
MACRUM | 0:e62c6477b73b | 111 | |
MACRUM | 0:e62c6477b73b | 112 | #endif |