#ifndef NokiaLCD_h #define NokiaLCD_h #include "WProgram.h" #include //# define bigfonts //# define hugefonts // Define Software SPI Pin Signal #define BL 2 // Digital 2 --> BL #define CS 3 // Digital 3 --> #CS #define CLK 4 // Digital 4 --> SCLK #define SDA 5 // Digital 5 --> SDATA #define RESET 6 // Digital 6 --> #RESET #define actinicPWMPin 9 #define daylightPWMPin 10 // Phillips PCF8833 Command Set #define NOP 0x00 // nop #define SWRESET 0x01 // software reset #define BSTROFF 0x02 // booster voltage OFF #define BSTRON 0x03 // booster voltage ON #define RDDIDIF 0x04 // read display identification #define RDDST 0x09 // read display status #define SLEEPIN 0x10 // sleep in #define SLEEPOUT 0x11 // sleep out #define PTLON 0x12 // partial display mode #define NORON 0x13 // display normal mode #define INVOFF 0x20 // inversion OFF #define INVON 0x21 // inversion ON #define DALO 0x22 // all pixel OFF #define DAL 0x23 // all pixel ON #define SETCON 0x25 // write contrast #define DISPOFF 0x28 // display OFF #define DISPON 0x29 // display ON #define CASET 0x2A // column address set #define PASET 0x2B // page address set #define RAMWR 0x2C // memory write #define RGBSET 0x2D // colour set #define PTLAR 0x30 // partial area #define VSCRDEF 0x33 // vertical scrolling definition #define TEOFF 0x34 // test mode #define TEON 0x35 // test mode #define MADCTL 0x36 // memory access control #define SEP 0x37 // vertical scrolling start address #define IDMOFF 0x38 // idle mode OFF #define IDMON 0x39 // idle mode ON #define COLMOD 0x3A // interface pixel format #define SETVOP 0xB0 // set Vop #define BRS 0xB4 // bottom row swap #define TRS 0xB6 // top row swap #define DISCTR 0xB9 // display control //#define DAOR 0xBA // data order(DOR) #define TCDFE 0xBD // enable/disable DF temperature compensation #define TCVOPE 0xBF // enable/disable Vop temp comp #define EC 0xC0 // internal or external oscillator #define SETMUL 0xC2 // set multiplication factor #define TCVOPAB 0xC3 // set TCVOP slopes A and B #define TCVOPCD 0xC4 // set TCVOP slopes c and d #define TCDF 0xC5 // set divider frequency #define DF8COLOR 0xC6 // set divider frequency 8-color mode #define SETBS 0xC7 // set bias system #define RDTEMP 0xC8 // temperature read back #define NLI 0xC9 // n-line inversion #define RDID1 0xDA // read ID1 #define RDID2 0xDB // read ID2 #define RDID3 0xDC // read ID3 //a few basic colors #define RED 0xE0 #define GREEN 0x1C #define BLUE 0x03 #define YELLOW 0xFC #define MAGENTA 0xE3 #define CYAN 0x1F #define BLACK 0x00 #define WHITE 0xFF #define WaterTempColor 0xE0 #define LightsTempColor 0xCC #define AmbientTempColor 0xAA #define PHColor 0x34 #define DPColor 0x88 #define APColor 0x49 #define cbi(reg, bit) (reg&=~(1< 0x02 , 0x01 , 0x59 , 0x09 , 0x06 , // ? 0x3E , 0x41 , 0x5D , 0x55 , 0x1E , // @ 0x7E , 0x09 , 0x09 , 0x09 , 0x7E , // A 0x7F , 0x49 , 0x49 , 0x49 , 0x36 , // B 0x3E , 0x41 , 0x41 , 0x41 , 0x22 , // C 0x7F , 0x41 , 0x41 , 0x41 , 0x3E , // D 0x7F , 0x49 , 0x49 , 0x49 , 0x41 , // E 0x7F , 0x09 , 0x09 , 0x09 , 0x01 , // F 0x3E , 0x41 , 0x49 , 0x49 , 0x7A , // G 0x7F , 0x08 , 0x08 , 0x08 , 0x7F , // H 0x00 , 0x41 , 0x7F , 0x41 , 0x00 , // I 0x30 , 0x40 , 0x40 , 0x40 , 0x3F , // J 0x7F , 0x08 , 0x14 , 0x22 , 0x41 , // K 0x7F , 0x40 , 0x40 , 0x40 , 0x40 , // L 0x7F , 0x02 , 0x04 , 0x02 , 0x7F , // M 0x7F , 0x02 , 0x04 , 0x08 , 0x7F , // N 0x3E , 0x41 , 0x41 , 0x41 , 0x3E , // O 0x7F , 0x09 , 0x09 , 0x09 , 0x06 , // P 0x3E , 0x41 , 0x51 , 0x21 , 0x5E , // Q 0x7F , 0x09 , 0x09 , 0x19 , 0x66 , // R 0x26 , 0x49 , 0x49 , 0x49 , 0x32 , // S 0x01 , 0x01 , 0x7F , 0x01 , 0x01 , // T 0x3F , 0x40 , 0x40 , 0x40 , 0x3F , // U 0x1F , 0x20 , 0x40 , 0x20 , 0x1F , // V 0x3F , 0x40 , 0x3C , 0x40 , 0x3F , // W 0x63 , 0x14 , 0x08 , 0x14 , 0x63 , // X 0x07 , 0x08 , 0x70 , 0x08 , 0x07 , // Y 0x71 , 0x49 , 0x45 , 0x43 , 0x00 , // Z 0x00 , 0x7F , 0x41 , 0x41 , 0x00 , // [ 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , // Back slash 0x00 , 0x41 , 0x41 , 0x7F , 0x00 , // ] 0x04 , 0x02 , 0x01 , 0x02 , 0x04 , // ^ 0x80 , 0x80 , 0x80 , 0x80 , 0x80 , // _ //0x00 , 0x03 , 0x07 , 0x00 , 0x00 , // ` 0x20 , 0x40 , 0x80 , 0x40 , 0x20 , // ` 0x20 , 0x54 , 0x54 , 0x54 , 0x78 , // a 0x7F , 0x44 , 0x44 , 0x44 , 0x38 , // b 0x38 , 0x44 , 0x44 , 0x44 , 0x28 , // c 0x38 , 0x44 , 0x44 , 0x44 , 0x7F , // d 0x38 , 0x54 , 0x54 , 0x54 , 0x18 , // e 0x08 , 0x7E , 0x09 , 0x09 , 0x00 , // f 0x18 , 0xA4 , 0xA4 , 0xA4 , 0x7C , // g 0x7F , 0x04 , 0x04 , 0x78 , 0x00 , // h 0x00 , 0x00 , 0x7D , 0x00 , 0x00 , // i 0x40 , 0x80 , 0x84 , 0x7D , 0x00 , // j 0x7F , 0x10 , 0x28 , 0x44 , 0x00 , // k 0x00 , 0x00 , 0x7F , 0x40 , 0x00 , // l 0x7C , 0x04 , 0x18 , 0x04 , 0x78 , // m 0x7C , 0x04 , 0x04 , 0x78 , 0x00 , // n 0x38 , 0x44 , 0x44 , 0x44 , 0x38 , // o 0xFC , 0x44 , 0x44 , 0x44 , 0x38 , // p 0x38 , 0x44 , 0x44 , 0x44 , 0xFC , // q 0x44 , 0x78 , 0x44 , 0x04 , 0x08 , // r 0x08 , 0x54 , 0x54 , 0x54 , 0x20 , // s 0x04 , 0x3E , 0x44 , 0x24 , 0x00 , // t 0x3C , 0x40 , 0x20 , 0x7C , 0x00 , // u 0x1C , 0x20 , 0x40 , 0x20 , 0x1C , // v 0x3C , 0x60 , 0x30 , 0x60 , 0x3C , // w 0x6C , 0x10 , 0x10 , 0x6C , 0x00 , // x 0x9C , 0xA0 , 0x60 , 0x3C , 0x00 , // y 0x64 , 0x54 , 0x54 , 0x4C , 0x00 , // z //0x08 , 0x3E , 0x41 , 0x41 , 0x00 , // { 0x33 , 0x66 , 0xCC , 0x66 , 0x33 , // { 0x00 , 0x00 , 0x7F , 0x00 , 0x00 , // | //0x00 , 0x41 , 0x41 , 0x3E , 0x08 , // } 0xCC , 0x66 , 0x33 , 0x66 , 0xCC , // } 0x02 , 0x01 , 0x02 , 0x01 , 0x00 // ~ }; #ifdef bigfonts const prog_uchar big_font[] PROGMEM = { //0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00, // columns, rows, num_bytes_per 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // space 0x20 0x30,0x78,0x78,0x30,0x30,0x00,0x30,0x00, // ! 0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00, // " 0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00, // # 0x18,0x3E,0x60,0x3C,0x06,0x7C,0x18,0x00, // $ 0x00,0x63,0x66,0x0C,0x18,0x33,0x63,0x00, // % 0x1C,0x36,0x1C,0x3B,0x6E,0x66,0x3B,0x00, // & 0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00, // ' 0x0C,0x18,0x30,0x30,0x30,0x18,0x0C,0x00, // ( 0x30,0x18,0x0C,0x0C,0x0C,0x18,0x30,0x00, // ) 0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00, // * 0x00,0x30,0x30,0xFC,0x30,0x30,0x00,0x00, // + 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30, // , 0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00, // - 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00, // . 0x03,0x06,0x0C,0x18,0x30,0x60,0x40,0x00, // / (forward slash) 0x3E,0x63,0x63,0x6B,0x63,0x63,0x3E,0x00, // 0 0x30 0x18,0x38,0x58,0x18,0x18,0x18,0x7E,0x00, // 1 0x3C,0x66,0x06,0x1C,0x30,0x66,0x7E,0x00, // 2 0x3C,0x66,0x06,0x1C,0x06,0x66,0x3C,0x00, // 3 0x0E,0x1E,0x36,0x66,0x7F,0x06,0x0F,0x00, // 4 0x7E,0x60,0x7C,0x06,0x06,0x66,0x3C,0x00, // 5 0x1C,0x30,0x60,0x7C,0x66,0x66,0x3C,0x00, // 6 0x7E,0x66,0x06,0x0C,0x18,0x18,0x18,0x00, // 7 0x3C,0x66,0x66,0x3C,0x66,0x66,0x3C,0x00, // 8 0x3C,0x66,0x66,0x3E,0x06,0x0C,0x38,0x00, // 9 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00, // : 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x30, // ; 0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x00, // < 0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00, // = 0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x00, // > 0x3C,0x66,0x06,0x0C,0x18,0x00,0x18,0x00, // ? 0x3E,0x63,0x6F,0x69,0x6F,0x60,0x3E,0x00, // @ 0x40 0x18,0x3C,0x66,0x66,0x7E,0x66,0x66,0x00, // A 0x7E,0x33,0x33,0x3E,0x33,0x33,0x7E,0x00, // B 0x1E,0x33,0x60,0x60,0x60,0x33,0x1E,0x00, // C 0x7C,0x36,0x33,0x33,0x33,0x36,0x7C,0x00, // D 0x7F,0x31,0x34,0x3C,0x34,0x31,0x7F,0x00, // E 0x7F,0x31,0x34,0x3C,0x34,0x30,0x78,0x00, // F 0x1E,0x33,0x60,0x60,0x67,0x33,0x1F,0x00, // G 0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00, // H 0x3C,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // I 0x0F,0x06,0x06,0x06,0x66,0x66,0x3C,0x00, // J 0x73,0x33,0x36,0x3C,0x36,0x33,0x73,0x00, // K 0x78,0x30,0x30,0x30,0x31,0x33,0x7F,0x00, // L 0x63,0x77,0x7F,0x7F,0x6B,0x63,0x63,0x00, // M 0x63,0x73,0x7B,0x6F,0x67,0x63,0x63,0x00, // N 0x3E,0x63,0x63,0x63,0x63,0x63,0x3E,0x00, // O 0x7E,0x33,0x33,0x3E,0x30,0x30,0x78,0x00, // P 0x50 0x3C,0x66,0x66,0x66,0x6E,0x3C,0x0E,0x00, // Q 0x7E,0x33,0x33,0x3E,0x36,0x33,0x73,0x00, // R 0x3C,0x66,0x30,0x18,0x0C,0x66,0x3C,0x00, // S 0x7E,0x5A,0x18,0x18,0x18,0x18,0x3C,0x00, // T 0x66,0x66,0x66,0x66,0x66,0x66,0x7E,0x00, // U 0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00, // V 0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00, // W 0x63,0x63,0x36,0x1C,0x1C,0x36,0x63,0x00, // X 0x66,0x66,0x66,0x3C,0x18,0x18,0x3C,0x00, // Y 0x7F,0x63,0x46,0x0C,0x19,0x33,0x7F,0x00, // Z 0x3C,0x30,0x30,0x30,0x30,0x30,0x3C,0x00, // [ 0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00, // \ (back slash) 0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00, // ] 0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00, // ^ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, // _ 0x18,0x18,0x0C,0x00,0x00,0x00,0x00,0x00, // ` 0x60 0x00,0x00,0x3C,0x06,0x3E,0x66,0x3B,0x00, // a 0x70,0x30,0x3E,0x33,0x33,0x33,0x6E,0x00, // b 0x00,0x00,0x3C,0x66,0x60,0x66,0x3C,0x00, // c 0x0E,0x06,0x3E,0x66,0x66,0x66,0x3B,0x00, // d 0x00,0x00,0x3C,0x66,0x7E,0x60,0x3C,0x00, // e 0x1C,0x36,0x30,0x78,0x30,0x30,0x78,0x00, // f 0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x7C, // g 0x70,0x30,0x36,0x3B,0x33,0x33,0x73,0x00, // h 0x18,0x00,0x38,0x18,0x18,0x18,0x3C,0x00, // i 0x06,0x00,0x06,0x06,0x06,0x66,0x66,0x3C, // j 0x70,0x30,0x33,0x36,0x3C,0x36,0x73,0x00, // k 0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // l 0x00,0x00,0x66,0x7F,0x7F,0x6B,0x63,0x00, // m 0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x00, // n 0x00,0x00,0x3C,0x66,0x66,0x66,0x3C,0x00, // o 0x00,0x00,0x6E,0x33,0x33,0x3E,0x30,0x78, // p 0x70 0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x0F, // q 0x00,0x00,0x6E,0x3B,0x33,0x30,0x78,0x00, // r 0x00,0x00,0x3E,0x60,0x3C,0x06,0x7C,0x00, // s 0x08,0x18,0x3E,0x18,0x18,0x1A,0x0C,0x00, // t 0x00,0x00,0x66,0x66,0x66,0x66,0x3B,0x00, // u 0x00,0x00,0x66,0x66,0x66,0x3C,0x18,0x00, // v 0x00,0x00,0x63,0x6B,0x7F,0x7F,0x36,0x00, // w 0x00,0x00,0x63,0x36,0x1C,0x36,0x63,0x00, // x 0x00,0x00,0x66,0x66,0x66,0x3E,0x06,0x7C, // y 0x00,0x00,0x7E,0x4C,0x18,0x32,0x7E,0x00, // z 0x0E,0x18,0x18,0x70,0x18,0x18,0x0E,0x00, // { 0x0C,0x0C,0x0C,0x00,0x0C,0x0C,0x0C,0x00, // | 0x70,0x18,0x18,0x0E,0x18,0x18,0x70,0x00, // } 0x3B,0x6E,0x00,0x00,0x00,0x00,0x00,0x00, // ~ 0x1C,0x36,0x36,0x1C,0x00,0x00,0x00,0x00}; // DEL #endif #ifdef hugefonts const prog_uint16_t num_16x16[] PROGMEM = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7000, 0x7000, 0x7000, 0x7000, 0x0000, 0x0000, // . 0xC000, 0xC000, 0x3000, 0x3000, 0x0C00, 0x0C00, 0x0300, 0x0300, 0x00C0, 0x00C0, 0x0030, 0x0030, 0x000C, 0x000C, 0x0003, 0x0003, // / 0x0000, 0x1FF8, 0x3FFC, 0x6006, 0xC003, 0xC003, 0xC003, 0xC3C3, 0xC3C3, 0xC003, 0xC003, 0xC003, 0x6006, 0x3FFC, 0x1FF8, 0x0000, // 0 0x0000, 0xC020, 0xC030, 0xC038, 0xC03C, 0xC03E, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xC000, 0xC000, 0xC000, 0xC000, 0xC000, 0x0000, // 1 0x0000, 0xF008, 0xFC0C, 0xDE0E, 0xC707, 0xC303, 0xC183, 0xC183, 0xC183, 0xC1C3, 0xC0C3, 0xC0C7, 0xE0FE, 0xE07C, 0xE038, 0x0000, // 2 0x0000, 0x1008, 0x300C, 0x700E, 0xE007, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xE3C7, 0x77EE, 0x3E7C, 0x1C38, 0x0000, // 3 0x0000, 0x0780, 0x07C0, 0x07E0, 0x0670, 0x0638, 0x061C, 0xC60E, 0xC607, 0xFFFF, 0xFFFF, 0xFFFF, 0xC600, 0xC600, 0x0000, 0x0000, // 4 0x0000, 0x607F, 0xE0FF, 0xC1FF, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xE383, 0x7703, 0x3E03, 0x1C03, 0x0000, // 5 0x0000, 0x1FC0, 0x3FF0, 0x77F8, 0xE3BC, 0xC19E, 0xC18E, 0xC187, 0xC183, 0xC183, 0xC183, 0xE383, 0x7700, 0x3E00, 0x1C00, 0x0000, // 6 0x0000, 0x0002, 0x0003, 0x0003, 0x0003, 0xFE03, 0xFF03, 0xFF83, 0x01C3, 0x00E3, 0x0073, 0x003B, 0x001F, 0x000F, 0x0006, 0x0000, // 7 0x0000, 0x1C38, 0x3E7C, 0x77EE, 0xE3C7, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xC183, 0xE3C7, 0x77EE, 0x3E7C, 0x1C38, 0x0000, // 8 0x0000, 0x0038, 0x007C, 0x00EE, 0xC1C7, 0xC183, 0xC183, 0xC183, 0xE183, 0x7183, 0x7983, 0x3DC7, 0x1FEE, 0x0FFC, 0x03F8, 0x0000, // 9 }; #endif typedef struct { int Temp1; int Temp2; int Temp3; int PH; int Sal; int ORP; } ParamsStruct; class NokiaLCD { public: NokiaLCD(); void Init(); void Sleep(); void Wake(); void BacklightOn(); void BacklightOff(); void Clear(byte color, byte x1, byte y1, byte x2, byte y2); void DrawText(byte fcolor, byte bcolor, byte x, byte y, char *text); #ifdef bigfonts void DrawLargeText(byte fcolor, byte bcolor, byte x, byte y, char *text); #endif #ifdef hugefonts void DrawHugeText(byte fcolor, byte bcolor, byte x, byte y, char *text); #endif void DrawText(byte fcolor, byte bcolor, byte x, byte y, int text); void DrawText(byte fcolor, byte bcolor, byte x, byte y, byte text); void DrawText(byte fcolor, byte bcolor, byte x, byte y, long text); void PutPixel(byte color, byte x, byte y); void SetContrast(byte Contrast); void DrawDate(byte x, byte y); void DrawOutletBox(byte x, byte y,byte RelayData); void DrawMonitor(byte x, byte y, ParamsStruct Params, byte DaylightPWMValue, byte ActinicPWMValue); void DrawGraph(byte x, byte y, int I2CAddr, int pointer); void DrawEEPromImage(int swidth, int sheight, byte x, byte y, int I2CAddr, int EEaddr); private: void SetBox(byte x1, byte y1, byte x2, byte y2); void SendCMD(byte data); void SendData(byte data); void ShiftBits(byte b); void DrawTextLine(byte fcolor, byte bcolor,byte x, byte y,char c); #ifdef bigfonts void DrawLargeTextLine(byte fcolor, byte bcolor,byte x, byte y,char c); #endif #ifdef hugefonts void DrawHugeTextLine(byte fcolor, byte bcolor, byte x, byte y, uint16_t c); #endif void DrawSingleMonitor(int Temp, byte fcolor, byte x, byte y, byte decimal); void DrawSingleGraph(byte color, byte x, byte y, int I2CAddr, int EEaddr); }; #endif