k og / HT1621

Dependents:   Demo_HT1621

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HT1621.h Source File

HT1621.h

00001 /* HT1621 - Holtek RAM Mapping 32x4 LCD Controller */
00002 /**
00003  * TEST
00004  * TS119-3
00005  * TS119-5  http://www.aitendo.com/product/5152
00006  * TS174    http://www.aitendo.com/product/5153
00007  * http://www.holtek.com.tw/documents/10179/a33bf4b4-f0ef-4b77-94e4-3dd5d0c35f16
00008  * 
00009  * HT1621 Library
00010  * https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/wirejungle/source-archive.zip
00011  * 
00012  * reference
00013  * http://jr4pdp.blog.enjoy.jp/myblog/2016/01/lcd-ts174nblpic-da92.html
00014  * http://morecatlab.akiba.coocan.jp/lab/index.php/2015/10/segment-lcd/
00015 */
00016 #ifndef MBED_HT1621_H
00017 #define MBED_HT1621_H
00018 #include "mbed.h"
00019 
00020 class HT1621 {
00021 public:
00022     enum {
00023         SYS_DIS   = 0b00000000,
00024         SYS_EN    = 0b00000001,
00025         LCD_OFF   = 0b00000010,
00026         LCD_ON    = 0b00000011,
00027         TIMER_DIS = 0b00000100,
00028         WDT_DIS   = 0b00000101,
00029         TIMER_EN  = 0b00000110,
00030         WDT_EN    = 0b00000111,
00031         TONE_OFF  = 0b00001000,
00032         TONE_ON   = 0b00001001,
00033         
00034         //Set bias to 1/2 or 1/3 cycle
00035         //Set to 2,3 or 4 connected COM lines
00036         BIAS_HALF_2_COM  = 0b00100000,
00037         BIAS_HALF_3_COM  = 0b00100100,
00038         BIAS_HALF_4_COM  = 0b00101000,
00039         BIAS_THIRD_2_COM = 0b00100001,
00040         BIAS_THIRD_3_COM = 0b00100101,
00041         BIAS_THIRD_4_COM = 0b00101001,
00042         
00043         //Don't use
00044         TEST_ON   = 0b11100000,
00045         TEST_OFF  = 0b11100011
00046     } Commands;
00047 
00048     HT1621(
00049         PinName data, PinName wr, PinName rd, PinName cs
00050         );
00051     ~HT1621(){}
00052 
00053 
00054     void sendCommand(uint8_t cmd, bool first = true, bool last = true);
00055 
00056     void write(uint8_t address, uint8_t *data, uint8_t cnt);
00057     void read(uint8_t address, uint8_t *data, uint8_t cnt);
00058 
00059     void writeMem(uint8_t address, uint8_t data);
00060     uint8_t readMem(uint8_t address);
00061 
00062     void memset(uint8_t address, uint8_t data, uint8_t cnt);
00063 
00064 private:
00065     DigitalInOut _data;
00066     DigitalOut _wr, _rd, _cs;
00067     void writeBits(uint8_t data, uint8_t cnt);
00068     uint8_t readBits(uint8_t cnt);
00069 
00070     inline void initControlBus();
00071     inline bool testMem();
00072     
00073 };
00074 
00075 #endif //HT1621_H