#ifndef LiquidCrystal_mx300N2_h #define LiquidCrystal_mx300N2_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 #define LCD_NORMAL 0x38 #define LCD_MIRVERT 0x39 #define LCD_MIRHORZ 0x3a #define LCD_ROTATE 0x3b // flags for display entry mode #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_8BITMODE 0x10 #define LCD_4BITMODE 0x00 #define LCD_2LINE 0x08 #define LCD_1LINE 0x00 #define LCD_5x10DOTS 0x04 #define LCD_5x8DOTS 0x00 // Double height numeric character set static uint8_t _digitsUpper[10][8] = { {0x00, 0x0e, 0x11, 0x11, 0x11, 0x13, 0x13, 0x15}, //0 {0x00, 0x04, 0x0c, 0x1c, 0x04, 0x04, 0x04, 0x04}, //1 {0x00, 0x0e, 0x11, 0x11, 0x01, 0x01, 0x02, 0x02}, //2 {0x00, 0x1f, 0x01, 0x02, 0x02, 0x04, 0x08, 0x0e}, //3 {0x00, 0x10, 0x10, 0x10, 0x14, 0x14, 0x14, 0x1f}, //4 {0x00, 0x1f, 0x11, 0x10, 0x10, 0x10, 0x10, 0x1e}, //5 {0x00, 0x06, 0x04, 0x08, 0x08, 0x10, 0x10, 0x1e}, //6 {0x00, 0x1f, 0x01, 0x01, 0x01, 0x02, 0x02, 0x04}, //7 {0x00, 0x0e, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0e}, //8 {0x00, 0x0e, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0f} //9 }; static uint8_t _digitsLower[10][8] = { {0x15, 0x19, 0x19, 0x11, 0x11, 0x11, 0x0e, 0x00}, //0 {0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0e, 0x00}, //1 {0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x1f, 0x00}, //2 {0x01, 0x01, 0x01, 0x01, 0x11, 0x11, 0x0e, 0x00}, //3 {0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00}, //4 {0x01, 0x01, 0x01, 0x11, 0x11, 0x11, 0x0e, 0x00}, //5 {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0e, 0x00}, //6 {0x04, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00}, //7 {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0e, 0x00}, //8 {0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x00} //9 }; class LiquidCrystal_mx300N2 : public Print { public: LiquidCrystal_mx300N2(uint8_t rs, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); LiquidCrystal_mx300N2(uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); LiquidCrystal_mx300N2(uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); LiquidCrystal_mx300N2(uint8_t rs, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3); void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); 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 clearBigfont(); void setBigfont(); void mirrorHorz(); void mirrorVert(); void rotate180(); void noMirror(); void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t i, uint8_t j, bool k = true); virtual size_t write(uint8_t); void command(uint8_t); private: void send(uint8_t, uint8_t); void write4bits(uint8_t); void write8bits(uint8_t); void pulseEnable(); uint8_t _rs_pin; // LOW: command. HIGH: character. uint8_t _rw_pin; // LOW: write to LCD. HIGH: read from LCD. uint8_t _enable_pin; // activated by a HIGH pulse. uint8_t _data_pins[8]; uint8_t _displayfunction; uint8_t _displaycontrol; uint8_t _displaymode; uint8_t _numlines, _currline; uint8_t _numcols, _currcol; bool _autoscroll; // auto scroll left if writing beyond column 19 bool _shifted; // we have reached column 20 bool _writebig; // LCD writes will be as tallfont characters }; #endif