//Application or test code LCD_ROM_Class.ino
#include "LCD_ROM_Class.h"LCD_ROM_Class LCD; //No ( ) if no parameters
byte pattern[6];
void DumpCharPat(char pattern);void DumpByte(byte cc);void DumpHex(byte cc);
void setup(void){ Serial.begin(115200); // pinMode(2,OUTPUT);}
void loop(void){ int ptr; for (ptr=0x20; ptr < 0x80; ptr++){ Serial.print(char(ptr)); Serial.print(' '); //digitalWrite(2,HIGH); LCD.char_pat(ptr,pattern); //digitalWrite(2,LOW); DumpCharPat(pattern,6); delay(500); }}
void DumpCharPat(byte pattern[6], int ss){ for (int i = 0; i<ss; i++) DumpByte(pattern[i]); Serial.println( ); }
void DumpByte(byte cc) { DumpHex(cc/16); DumpHex(cc%16); Serial.print(" "); } void DumpHex(byte cc){ if (cc <10) Serial.print(char(cc+'0')); else Serial.print(char('A'+ cc-10)); }
//Implementation file
#include "LCD_ROM_Class.h"
LCD_ROM_Class::LCD_ROM_Class ( ){ };
void LCD_ROM_Class::char_pat(char c, byte pat[6]){ if((c > 127)||(c < 32)) c = "^"; //out of range pat[0] = 0; for (int index = 0; index < 5; index++) { // pat[index+1] = ((&ASCII[c - 0x20][index])); pat[index+1] = (pgm_read_byte(&ASCII[c - 0x20][index])); //pattern in ROM // pat[index+1] = (pgm_read_byte(&ASCII[c ][index])); //big pattern in ROM }}; //static const byte LCD_ROM_Class::ASCII[96][5] = //load patterns into RAM static const byte LCD_ROM_Class::ASCII[96][5] PROGMEM = //use patterns in ROM//static const byte LCD_ROM_Class::ASCII[128][5] PROGMEM ={/* {0x77,0x41,0x07,0x70,0x00}, //null {0x17,0x1D,0x70,0x20,0x70}, //SOT {0x17,0x1D,0x20,0xA0,0x20}, //STX {0x1F,0x15,0x20,0xA0,0x20}, //ETX {0x1F,0x15,0x60,0x90,0x60}, //EOT {0x1F,0x15,0xE0,0x20,0E0}, //ENQ {0x0E,0x05,0x0E,0x70,0x50}, //ACK {0x1F,0x14,0x1C,0x00,0x7C}, //BEL {0x5F,0xF4,0x5C,0x40,0x40}, //Back Sp {0x07,0x20,0x17,0x70,0x10}, //Hor Tab {0x1F,0x10,0x00,0x7C,0x14}, //Line feed {0x03,0x04,0x13,0x70,0x10}, //vert Tab {0x1F,0x05,0x00,0x3C,0x14}, //Form Feed {0x0F,0x09,0x00,0x70,0x10}, //CR {0x17,0x15,0x5D,0xA0,0x40}, //SO {0x17,0x15,0x17,0x00,0x78}, //Si {0x0E,0x0A,0x0F,0x70,0x40}, //DLE {0x0E,0x0A,0x0F,0x00,0x70}, //DC1 {0x0E,0x0A,0x6F,0x00,0x60}, //DC2 {0x6E,0x0A,0x6F,0x00,0x60}, //DC3 {0x0E,0x6A,0x4F,0xE0,0x40}, //DC4 {0x1D,0x0B,0x1D,0x71,0x51}, //NAK {0x9C,0x54,0x75,0x02,0x0F}, //SYN {0x1F,0x15,0x20,0xD0,0x20}, //ETB {0x0F,0x90,0x70,0x28,0x70}, //CAN {0x1F,0x15,0x60,0x20,0x60}, //EM {0x5C,0x54,0x75,0x02,0x01}, //SUB {0x5F,0x55,0x40,0x5F,0x51}, //ESC {0x1F,0x05,0x59,0x54,0x74}, //FS {0x0F,0x09,0x0D,0x70,0x10}, //GS {0x1F,0x01,0x01,0x7C,0x54}, //RS {0x07,0x04,0x77,0x10,0x70}, //US*/ {0,0,0,0,0}, // space {0,95,95,0,0}, //! {3,3,0,3,3}, //" {60,60,36,60,60}, //# {36,46,127,58,18}, //$ {99,19,8,100,99}, //% {54,127,73,127,126}, //& {0,3,3,0,0}, // {0,28,62,99,65}, //( {65,99,62,28,0}, //) {84,56,56,84,0}, //* {16,124,124,16,0}, //+ {0,128,224,96,0}, //, {16,16,16,16,0}, //- {0,0,96,96,0}, //. {112,120,12,7,3}, /// {62,127,65,127,62}, //0 {0,66,127,127,64}, //1 {98,115,89,79,70}, //2 {34,107,73,127,54}, //3 {60,34,127,127,32}, //4 {79,79,73,121,49}, //5 {60,126,75,121,48}, //6 {1,97,121,31,7}, //7 {54,127,73,127,54}, //8 {6,79,105,63,30}, //9 {0,108,108,0,0}, //: {128,236,108,0,0}, //; {8,28,54,34,0}, //< {40,40,40,40,0}, //= {34,54,28,8,0}, //> {2,107,105,15,6}, //? {60,126,66,94,92}, //@ {126,127,17,127,126}, //A {127,127,73,127,54}, //B {62,127,65,99,34}, //C {127,127,65,127,62}, //D {127,127,73,73,65}, //E {127,127,9,9,1}, //F {62,127,65,113,113}, //G {127,127,8,127,127}, //H {65,127,127,65,0}, //I {64,64,64,127,63}, //J {127,127,28,119,99}, //K {127,127,64,64,64}, //L {127,126,12,126,127}, //M {127,127,30,127,127}, //N {62,127,65,127,62}, //O {127,127,9,15,6}, //P {62,127,97,127,94}, //Q {127,127,25,127,102}, //R {38,111,73,123,50}, //S {1,127,127,1,0}, //T {63,127,64,127,63}, //U {31,63,96,63,31}, //V {127,63,112,63,127}, //W {119,127,8,127,119}, //X {71,111,56,31,7}, //Y {113,121,77,71,67}, //Z {127,127,65,65,0}, //[ {3,15,60,112,64}, //backslash {65,65,127,127,0}, //] {4,6,3,6,4}, //^ {64,64,64,64,64}, //_ {1,3,2,0,0}, //` {32,116,84,124,120}, //a {127,127,72,120,48}, //b {56,124,68,68,68}, //c {48,120,72,127,127}, //d {56,124,84,92,88}, //e {126,127,17,1,0}, //f {152,188,164,252,124}, //g {127,127,8,120,112}, //h {72,122,122,64,0}, //i {128,128,128,250,122}, //j {127,127,56,108,68}, //k {0,127,127,0,0}, //l {120,8,120,8,112}, //m {120,120,8,120,112}, //n {48,120,72,120,48}, //o {248,248,72,120,48}, //p {48,120,72,248,248}, //q {112,120,8,8,8}, //r {72,92,84,116,36}, //s {0,60,124,72,0}, //t {56,120,64,120,120}, //u {24,56,96,56,24}, //v {120,96,16,96,120}, //w {72,120,48,120,72}, //x {152,184,160,248,120}, //y {72,104,120,88,72}, //z {8,62,119,65,65}, //{ {0,0,127,0,0}, //| {65,65,119,62,8}, //} {2,3,1,2,3}, //~ {64,0,64,0,64} //…};
//Header file LCD_ROM_Class.h
#ifndef LCD_ROM_Class_H#define LCD_ROM_Class_H
#include "Arduino.h" //includes defn of byte
class LCD_ROM_Class { public: LCD_ROM_Class( ); void char_pat(char c, byte pat[6]); private: static const byte ASCII[96][5]; // private: static const byte ASCII[128][5]; };#endif