/* Trixel.h - Liquid Crystal Display 1x3 character graphics Trixel *PRELIMINARY* Arduino header Copyright (c) 2011 Devon Sean McCullough Licensed under the GPL (GNU Public License) Trixel(lcd) // LCD (Liquid Crystal Display) for trixel window begin(width, height) // trixel window size in LCD characters begin(width, height, buffer) // ... (width * height) byte trixel buffer moveWindow(column, row) // position window in LCD coordinates show() // render trixel buffer to trixel window on physical LCD clear() // buffer to all white setDot(x, y) // buffer trixel at x,y to black setDot(x, y, color) // ... to color setDot(x, y, color, operator) // ... combine old/new colors by operator setChar(x, y, character) // buffer byte at trixel x,y to character getDot(x, y) // buffer trixel at x,y getChar(x, y) // trixel buffer character at (and nearby) x,y macro IS_TRIXEL(character) // true = character is trixel graphic type trixel_color trixel_white = 0 // LCD background trixel_black = 1 // LCD ink type boolean_operator boole_* // all sixteen boolean two-input operators, e.g., boole_2 // default: ignore old color, use new color boole_c2 // ... complement (reverse) new color boole_ior // inclusive or: like ink on paper boole_xor // exclusive or: easily reversed boole_andc2 // and complement of new color, like white paint boole_clr // use white, ignore both colors LCD upper left corner in LCD character coordinates = 0,0 window upper left corner in trixel coordinates = 0,0 in full screen case where upper left corners coincide one character at c,r = three trixels at x,y = c,3r ... c,3r+2 LCD characteristics wired in Trixel version 0.0 font 5x8 font RAM at codes 0 ... 5 font ROM code 128 all white font ROM code 255 all black */ #ifndef Trixel_h #define Trixel_h #include "WProgram.h" #ifndef LiquidCrystal_h #error LiquidCrystal.h must appear before Trixel.h #endif typedef enum {trixel_white = 0, trixel_black = 1} trixel_color; typedef enum { boole_clr = B0000, boole_nor = B0001, boole_andc2 = B0010, boole_c2 = B0011, boole_andc1 = B0100, boole_c1 = B0101, boole_xor = B0110, boole_nand = B0111, boole_and = B1000, boole_eqv = B1001, boole_1 = B1010, boole_orc2 = B1011, boole_2 = B1100, boole_orc1 = B1101, boole_ior = B1110, boole_set = B1111 } boolean_operator; class Trixel { public: Trixel(LiquidCrystal *lcd); void begin(byte width, byte height, byte *buffer = 0); void moveWindow(byte column, byte row); void clear(); void setDot(byte x, byte y, trixel_color color = trixel_black, boolean_operator op = boole_2); void setChar(byte x, byte y, byte character); trixel_color getDot(byte x, byte y); byte getChar(byte x, byte y); void show(); #ifdef DESTRUCTOR ~Trixel(); #endif private: LiquidCrystal *_lcd; byte _x, _y, _width, _height; byte *_matrix; }; #define IS_TRIXEL(character) ((character) < 8) /* character is trixel graphic not plain */ #endif // end Trixel.h