#ifndef LiquidCrystal_t6a34_h #define LiquidCrystal_t6a34_h #include #include "Print.h" // commands #define LCD_CLEARDISPLAY 0x01 #define LCD_RETURNHOME 0x02 #define LCD_ENTRYMODESET 0x04 #define LCD_DISPLAYCONTROL 0x08 #define LCD_CURSORSHIFT 0x10 #define LCD_FUNCTIONSET 0x20 #define LCD_SETCGRAMADDR 0x40 #define LCD_SETDDRAMADDR 0x80 // flags for display entry mode. t6a34 datasheet has these sets of bits swapped, ie increment/decrement is 0x02 // have left this as the hitachi default until confirmed #define LCD_ENTRYRIGHT 0x00 #define LCD_ENTRYLEFT 0x02 #define LCD_ENTRYSHIFTINCREMENT 0x01 #define LCD_ENTRYSHIFTDECREMENT 0x00 // flags for display on/off control #define LCD_DISPLAYON 0x04 #define LCD_DISPLAYOFF 0x00 #define LCD_CURSORON 0x02 #define LCD_CURSOROFF 0x00 #define LCD_BLINKON 0x01 #define LCD_BLINKOFF 0x00 // flags for display/cursor shift #define LCD_DISPLAYMOVE 0x08 #define LCD_CURSORMOVE 0x00 #define LCD_MOVERIGHT 0x04 #define LCD_MOVELEFT 0x00 // flags for function set #define LCD_BLINKMODE 0x10 //determines whether blink does reverse video or all on of pixels for t6a34 #define LCD_NOBLINKMODE 0x00 #define LCD_2LINE 0x08 #define LCD_1LINE 0x00 #define LCD_5x10DOTS 0x04 #define LCD_5x7DOTS 0x00 // flags for register select #define IR_WRITE 0x00 #define DR_WRITE 0x02 #define LER1_WRITE 0x01 #define LER2_WRITE 0x03 #define LED3 0x0001 #define LED4 0x0002 #define LED6 0x0004 #define LED2 0x0100 #define pwmRegister OCR1B //the logical pin, can be set to OCR1A or B #define clk_period 8 class LiquidCrystal : public Print { public: LiquidCrystal(uint8_t data_in, uint8_t clk); LiquidCrystal(uint8_t data_in, uint8_t data_out, uint8_t clk); void init(uint8_t data_in, uint8_t data_out, uint8_t clk); void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x7DOTS); void clear(); void home(); void noDisplay(); void display(); void noBlink(); void blink(); void noCursor(); void cursor(); void scrollDisplayLeft(); void scrollDisplayRight(); void leftToRight(); void rightToLeft(); void autoscroll(); void noAutoscroll(); void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); virtual size_t write(uint8_t); void command(uint8_t); void setLeds(uint16_t); private: void send(uint8_t, uint8_t); uint8_t _sid_pin; // data in to t6a34. uint8_t _sod_pin; // data out from t6a34. uint8_t _sclk_pin; // data valid on rising edge. uint8_t _displayfunction; uint8_t _displaycontrol; uint8_t _displaymode; uint8_t _initialized; uint8_t _numlines,_currline; //settings for pwm clock pin long period = clk_period; //the LCD clock period in microseconds (1=1MHz, 2=500kHz) int duty = 512; //duty as a range from 0 to 1024, 512 is 50% duty cycle int prescale[6] = {0, 1, 8, 64, 256, 1024}; //the range of prescale values const int clear_delay = 410*clk_period; const int home_delay = 410*clk_period; const int cmd_delay = 20*clk_period; }; #endif