Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Code design for maintaining database

Status
Not open for further replies.

scorrpeio

Full Member level 5
Joined
Dec 26, 2006
Messages
286
Helped
10
Reputation
20
Reaction score
9
Trophy points
1,298
Activity points
3,496
The hardware is something like this....

MCU - 128x64 GLCD
The interface may be serial(3 wire spi) or parallel.

Now, I have a set of messages which MCU should display on the LCD regularly or based on the keypad events.

My Design approach is....

1. Save the char codes of A, B...Z; a,b...z; 0,1...9; and special symbols(%,$,*,&,^) on to the Code memory in the form of const char A[] = {code bytes for A}
const char B[] = {code bytes for B} ...and so on

2. Save all the required messages to be displayed on LCD as strings in code memory.
For ex. const char Msg1[] = "The Overflow Count: -"
const char Msg2[] = "Currency Value: - "

3. In program, based on the keypad event or timer event, I would call the Msg1, Msg2 etc using pointer.
Further each character from that string is copied into a variable. This variable will compare the char with the char code database and get the char code for that char.
For ex, in Msg1[], the first char is 'T'
So,
Code:
TempVar = 'T'; 
Switch (TempVar)
{
   case 'A':
   CharCodePtr = &A[0];
   break;
   .
   .
   .
   .
   case 'T':
   CharCodePtr = &T[0];
   break;
   .
   .
   .


}

The Data in the CharCodePtr is transmitted to GLCD.

Kindly Let me know if my approach is correct or it will lead to disaster.
I am in state of design, so didnt actually try it on code yet.
 
Last edited:

mmmm...

i think your aproach is a little... more difficult...
as the ascii codes for numbers and letters can be also sorted
if you can make all the characters 7x5 dots (for example)
the common approach is to use an array of (127x5) bytes (or 80x5 bytes)

for example, i choose tu use 128 ASCII characters... but the first 32 characters (from 0x00 to 0x1F) are something like control characters, and not printable characters... so mi table will begin from ASCII character 0x20 (space) and so on (a ommited all the table for explanation )
Code:
const char glcd_cg[][5]={
	{0x00,0x00,0x00,0x00,0x00},	//(space)
	{0x00,0x00,0x4f,0x00,0x00},	//!
	{0x00,0x07,0x00,0x07,0x00},	//"
	{0x14,0x7f,0x14,0x7f,0x14},	//#
	{0x24,0x2a,0x7f,0x2a,0x12},	//$
	{0x23,0x13,0x08,0x64,0x62},	//%
	{0x36,0x49,0x55,0x22,0x50},	//&
	{0x00,0x00,0x07,0x00,0x00},	//'
	{0x00,0x1c,0x22,0x41,0x00},	//(
	{0x00,0x41,0x22,0x1c,0x00},	//)
	{0x14,0x08,0x3e,0x08,0x14},	//*
	{0x08,0x08,0x3e,0x08,0x08},	//+
	{0x00,0x50,0x30,0x00,0x00},	//,
	{0x08,0x08,0x08,0x08,0x08},	//-
	{0x00,0x60,0x60,0x00,0x00},	//.
	{0x20,0x10,0x08,0x04,0x02},	///
	{0x3e,0x51,0x49,0x45,0x3e},	//0 ASCII character 0x30
	{0x00,0x42,0x7f,0x40,0x00},	//1
	{0x62,0x51,0x49,0x45,0x42},	//2
...
	{0x06,0x49,0x49,0x29,0x1e},	//9
	{0x00,0x36,0x36,0x00,0x00},	//:
	{0x00,0x76,0x36,0x00,0x00},	//;
	{0x08,0x14,0x22,0x41,0x00},	//<
	{0x14,0x14,0x14,0x14,0x14},	//=
	{0x00,0x41,0x22,0x14,0x08},	//>
	{0x02,0x01,0x51,0x09,0x06},	//?
	{0x3e,0x41,0x5d,0x55,0x1e},	//@
	{0x7e,0x11,0x11,0x11,0x7e},	//A ascii character 0x41
	{0x7f,0x49,0x49,0x49,0x36},	//B
...
...
	{0x1c,0x20,0x40,0x20,0x1c},	//v
	{0x3c,0x40,0x30,0x40,0x3c},	//w
	{0x44,0x28,0x10,0x28,0x44},	//x
	{0x0c,0x50,0x50,0x50,0x3c},	//y
	{0x44,0x64,0x54,0x4C,0x44},	//z
	{0x08,0x36,0x41,0x41,0x00},	//{
	{0x00,0x00,0x77,0x00,0x00},	//|
	{0x00,0x41,0x41,0x36,0x08},	//}
	{0x08,0x04,0x08,0x10,0x08},	//~
	{0x3E,0x22,0x22,0x22,0x3E},	//127
};

now, my messages are strings in variables

const char Msg1[] = "The Overflow Count: -"
const char Msg2[] = "Currency Value: - "

and (if i don't want to use printf or something like that) you can implement a print string function something like:
Code:
void print_string(const char *message){
 unsigned char i;
 char c;
 while(*message){ //until end of message string...
  c=(*message);
  if (c<0x20) c=0; //if control character, then lets print an space only! you can use the control characters to do more cool stuff here!
 else c = c - 0x20; ///// could be c-=0x20; make the ascii character to point in our table.
  for(i=0;i<5;i++){ //lets print all the columns for the desired character...
    glcd_byte(glcd_cg[c][i]); //assuming the glcd_byte function writes on the glcd a column of 8 dots... and advance to the next column...()
  }
  glcd_byte(0); //write one space to separate characters!...
  message++; //next character on message string
 }
}


...
...
//in application
if (button1) print_string(Msg1);
if (button2) print_string(Msg2); //etc..
...

or something like that...

---------- Post added at 09:38 ---------- Previous post was at 09:33 ----------

mmm...

just in case you need... my GLCD CG table: use at your own risk.... (not fully checked... may have displaced dots...)
Code:
const char glcd_cg[][5]={
	{0x00,0x00,0x00,0x00,0x00},	//
	{0x00,0x00,0x4f,0x00,0x00},	//!
	{0x00,0x07,0x00,0x07,0x00},	//"
	{0x14,0x7f,0x14,0x7f,0x14},	//#
	{0x24,0x2a,0x7f,0x2a,0x12},	//$
	{0x23,0x13,0x08,0x64,0x62},	//%
	{0x36,0x49,0x55,0x22,0x50},	//&
	{0x00,0x00,0x07,0x00,0x00},	//'
	{0x00,0x1c,0x22,0x41,0x00},	//(
	{0x00,0x41,0x22,0x1c,0x00},	//)
	{0x14,0x08,0x3e,0x08,0x14},	//*
	{0x08,0x08,0x3e,0x08,0x08},	//+
	{0x00,0x50,0x30,0x00,0x00},	//,
	{0x08,0x08,0x08,0x08,0x08},	//-
	{0x00,0x60,0x60,0x00,0x00},	//.
	{0x20,0x10,0x08,0x04,0x02},	///
	{0x3e,0x51,0x49,0x45,0x3e},	//0
	{0x00,0x42,0x7f,0x40,0x00},	//1
	{0x62,0x51,0x49,0x45,0x42},	//2
	{0x21,0x41,0x45,0x4b,0x31},	//3
	{0x18,0x14,0x12,0x7f,0x10},	//4
	{0x27,0x45,0x45,0x45,0x39},	//5
	{0x3c,0x4a,0x49,0x49,0x30},	//6
	{0x01,0x71,0x09,0x05,0x03},	//7
	{0x36,0x49,0x49,0x49,0x36},	//8
	{0x06,0x49,0x49,0x29,0x1e},	//9
	{0x00,0x36,0x36,0x00,0x00},	//:
	{0x00,0x76,0x36,0x00,0x00},	//;
	{0x08,0x14,0x22,0x41,0x00},	//<
	{0x14,0x14,0x14,0x14,0x14},	//=
	{0x00,0x41,0x22,0x14,0x08},	//>
	{0x02,0x01,0x51,0x09,0x06},	//?
	{0x3e,0x41,0x5d,0x55,0x1e},	//@
	{0x7e,0x11,0x11,0x11,0x7e},	//A
	{0x7f,0x49,0x49,0x49,0x36},	//B
	{0x3e,0x41,0x41,0x41,0x22},	//C
	{0x7f,0x41,0x41,0x22,0x1C},	//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
	{0x20,0x40,0x41,0x3f,0x01},	//J
	{0x7f,0x08,0x14,0x22,0x41},	//K
	{0x7f,0x40,0x40,0x40,0x40},	//L
	{0x7f,0x02,0x0c,0x02,0x7f},	//M
	{0x7f,0x04,0x08,0x10,0x7f},	//N
	{0x3e,0x41,0x41,0x41,0x3e},	//O
	{0x7f,0x09,0x09,0x09,0x06},	//P
	{0x3e,0x41,0x51,0x21,0x5e},	//Q
	{0x7f,0x09,0x19,0x29,0x46},	//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,0x38,0x40,0x3f},	//W
	{0x63,0x14,0x08,0x14,0x63},	//X
	{0x07,0x08,0x70,0x08,0x07},	//Y
	{0x61,0x51,0x49,0x45,0x43},	//Z
	{0x00,0x7f,0x41,0x41,0x00},	//[
	{0x02,0x04,0x08,0x10,0x20},	// /invertido
	{0x00,0x41,0x41,0x7f,0x00},	//]
	{0x04,0x02,0x01,0x02,0x04},	//^
	{0x40,0x40,0x40,0x40,0x40},	//_
	{0x00,0x00,0x03,0x05,0x00},	//`
	{0x20,0x54,0x54,0x54,0x78},	//a
	{0x7f,0x44,0x44,0x44,0x38},	//b
	{0x38,0x44,0x44,0x44,0x44},	//c
	{0x38,0x44,0x44,0x44,0x3F},	//d
	{0x38,0x54,0x54,0x54,0x18},	//e
	{0x04,0x04,0x7e,0x05,0x05},	//f
	{0x08,0x54,0x54,0x54,0x3c},	//g
	{0x7f,0x08,0x04,0x04,0x78},	//h
	{0x00,0x44,0x7d,0x40,0x00},	//i
	{0x40,0x40,0x44,0x3d,0x00},	//j
	{0x7f,0x10,0x28,0x44,0x00},	//k
	{0x00,0x41,0x7f,0x40,0x00},	//l
	{0x7c,0x04,0x7c,0x04,0x78},	//m
	{0x7c,0x08,0x04,0x04,0x78},	//n
	{0x38,0x44,0x44,0x44,0x38},	//o
	{0x7c,0x24,0x24,0x24,0x18},	//p
	{0x18,0x24,0x24,0x24,0x7C},	//q
	{0x7c,0x08,0x04,0x04,0x00},	//r
	{0x48,0x54,0x54,0x54,0x24},	//s
	{0x04,0x04,0x3F,0x44,0x44},	//t
	{0x3c,0x40,0x40,0x7c,0x40},	//u
	{0x1c,0x20,0x40,0x20,0x1c},	//v
	{0x3c,0x40,0x30,0x40,0x3c},	//w
	{0x44,0x28,0x10,0x28,0x44},	//x
	{0x0c,0x50,0x50,0x50,0x3c},	//y
	{0x44,0x64,0x54,0x4C,0x44},	//z
	{0x08,0x36,0x41,0x41,0x00},	//{
	{0x00,0x00,0x77,0x00,0x00},	//|
	{0x00,0x41,0x41,0x36,0x08},	//}
	{0x08,0x04,0x08,0x10,0x08},	//~
	{0x3E,0x22,0x22,0x22,0x3E},	//127
	{0x3e,0x55,0x55,0x41,0x22},	//?
	{0x3E,0x22,0x22,0x22,0x3E},	//
	{0x00,0xA0,0x60,0x00,0x00},	//?
	{0x44,0x44,0x3e,0x05,0x05},	//?
	{0x20,0x10,0x20,0x40,0x20},	//?
	{0x00,0x40,0x40,0x40,0x00},	//?
	{0x00,0x40,0x7F,0x40,0x00},	//?
	{0x00,0x24,0xFF,0x24,0x00},	//?
	{0x00,0x02,0x01,0x02,0x00},	//?
	{0x13,0x6B,0x64,0x62,0x61},	//?
	{0x58,0x55,0x56,0x55,0x68},	//?
	{0x00,0x08,0x14,0x22,0x00},	//?
	{0x3E,0x41,0x7f,0x49,0x41},	//?
	{0x3E,0x22,0x22,0x22,0x3E},	//
	{0x3E,0x22,0x22,0x22,0x3E},	//
	{0x3E,0x22,0x22,0x22,0x3E},	//
	{0x3E,0x22,0x22,0x22,0x3E},	//
	{0x00,0x00,0x01,0x02,0x00},	//?
	{0x00,0x02,0x01,0x00,0x00},	//?
	{0x00,0x01,0x02,0x01,0x02},	//?
	{0x02,0x01,0x02,0x01,0x00},	//?
	{0x00,0x1c,0x1c,0x1c,0x00},	//?
	{0x00,0x08,0x08,0x08,0x00},	//-
	{0x08,0x08,0x08,0x08,0x08},	//-
	{0x07,0x07,0x00,0x07,0x07},	//?
	{0x01,0x07,0x01,0x07,0x07},	//?
	{0x48,0x55,0x56,0x55,0x24},	//?
	{0x00,0x22,0x14,0x08,0x00},	//?
	{0x3C,0x44,0x78,0x54,0x58},	//?
	{0x3E,0x22,0x22,0x22,0x3E},	//
	{0x3E,0x22,0x22,0x22,0x3E},	//
	{0x0E,0x09,0x70,0x09,0x0E},	//?
	{0x00,0x00,0x00,0x00,0x00},	//*
	{0x00,0x00,0x79,0x00,0x00},	//¡
	{0x38,0x44,0xc6,0x44,0x44},	//¢
	{0x4f,0x60,0x50,0x40,0x60},	//£
	{0x44,0x28,0x28,0x28,0x44},	//¤
	{0x07,0x28,0x70,0x28,0x07},	//¥
	{0x00,0x00,0x77,0x00,0x00},	//¦
	{0x26,0x55,0x55,0x55,0x32},	//§
	{0x00,0x01,0x00,0x01,0x00},	//¨
	{0x3E,0x49,0x55,0x55,0x3E},	//©
	{0x08,0x15,0x15,0x1E,0x00},	//ª
	{0x08,0x14,0x2A,0x14,0x22},	//«
	{0x00,0x08,0x08,0x38,0x00},	//¬
	{0x00,0x08,0x08,0x08,0x00},	//*
	{0x3E,0x5D,0x4D,0x55,0x3E},	//®
	{0x01,0x01,0x01,0x01,0x01},	//¯
	{0x00,0x02,0x05,0x02,0x00},	//°
	{0x28,0x28,0x3e,0x28,0x28},	//±
	{0x00,0x0D,0x0D,0x0a,0x00},	//²
	{0x00,0x09,0x0B,0x07,0x00},	//³
	{0x00,0x00,0x02,0x01,0x00},	//´
	{0x40,0x7c,0x40,0x40,0x3c},	//µ
	{0x06,0x09,0x7f,0x09,0x7F},	//¶
	{0x00,0x1c,0x1c,0x1c,0x00},	//·
	{0x40,0xa8,0xa8,0xF0,0x00},	//¸
	{0x00,0x09,0x0F,0x08,0x00},	//¹
	{0x00,0x06,0x09,0x06,0x00},	//º
	{0x22,0x14,0x2a,0x14,0x08},	//»
	{0x24,0x17,0x38,0x24,0x07},	//¼
	{0x24,0x17,0x58,0x74,0x52},	//½
	{0x25,0x17,0x38,0x24,0x07},	//¾
	{0x30,0x48,0x45,0x40,0x20},	//¿
	{0x78,0x25,0x26,0x24,0x78},	//
	{0x78,0x24,0x26,0x25,0x78},	//M
	{0x78,0x26,0x25,0x26,0x78},	//
	{0x78,0x25,0x25,0x25,0x78},	//Í
	{0x78,0x25,0x24,0x25,0x78},	//c
	{0x78,0x24,0x25,0x24,0x78},	//o
	{0x7E,0x09,0x7F,0x49,0x41},	//?
	{0x1e,0x21,0x61,0x21,0x12},	//A
	{0xFC,0x95,0x96,0x94,0x84},	//?
	{0xFC,0x94,0x96,0x95,0x84},	//?
	{0xFC,0x96,0x95,0x96,0x84},	//?
	{0xFC,0x95,0x94,0x95,0x84},	//_
	{0x00,0x45,0x7E,0x44,0x00},	//?
	{0x00,0x44,0x7E,0x45,0x00},	//?
	{0x00,0x46,0x7D,0x46,0x00},	//?
	{0x00,0x45,0x7C,0x45,0x00},	//?
	{0x7f,0x49,0x49,0x22,0x28},	//?
	{0x7C,0x09,0x11,0x21,0x7C},	//?
	{0x78,0x85,0x86,0x84,0x78},	//?
	{0x78,0x84,0x86,0x85,0x78},	//?
	{0x78,0x86,0x85,0x86,0x78},	//?
	{0x78,0x85,0x85,0x85,0x78},	//?
	{0x78,0x85,0x84,0x85,0x78},	//?
	{0x00,0x05,0x02,0x05,0x00},	//?
	{0x3e,0x71,0x49,0x43,0x3e},	//?
	{0x7C,0x81,0x82,0x80,0x7C},	//?
	{0x7C,0x80,0x82,0x81,0x7C},	//?
	{0x7C,0x82,0x81,0x82,0x7C},	//?
	{0x7C,0x81,0x80,0x81,0x7C},	//?
	{0x0E,0x08,0x72,0x09,0x0E},	//?
	{0x41,0x7F,0x55,0x55,0x08},	//?
	{0x40,0x7f,0x41,0x49,0x36},	//?
	{0x20,0x55,0x56,0x54,0x78},	//J
	{0x20,0x54,0x56,0x55,0x78},	//?
	{0x20,0x56,0x55,0x56,0x78},	//?
	{0x20,0x55,0x55,0x55,0x78},	//?
	{0x20,0x55,0x54,0x55,0x78},	//?
	{0x20,0x54,0x56,0x56,0x78},	//?	
	{0x35,0x54,0x78,0x54,0x58},	//?	
	{0x1C,0x22,0x62,0x22,0x22},	//?
	{0x38,0x55,0x56,0x54,0x18},	//?
	{0x38,0x56,0x55,0x54,0x18},	//?
	{0x38,0x56,0x55,0x56,0x18},	//?
	{0x38,0x55,0x54,0x55,0x18},	//?
	{0x00,0x45,0x7A,0x40,0x00},	//?
	{0x00,0x44,0x7A,0x41,0x00},	//?
	{0x00,0x46,0x7d,0x42,0x00},	//?
	{0x00,0x45,0x7C,0x41,0x00},	//?
	{0x38,0x47,0x45,0x47,0x38},	//J
	{0x7c,0x09,0x05,0x05,0x78},	//?
	{0x38,0x45,0x46,0x44,0x38},	//?
	{0x38,0x44,0x46,0x45,0x38},	//?
	{0x38,0x46,0x45,0x46,0x38},	//?
	{0x38,0x45,0x45,0x45,0x38},	//?
	{0x38,0x45,0x44,0x45,0x38},	//?
	{0x00,0x08,0x2A,0x08,0x00},	//?
	{0x38,0x64,0x54,0x4C,0x38},	//?
	{0x3c,0x41,0x42,0x7c,0x40},	//?
	{0x3c,0x40,0x42,0x7D,0x40},	//?
	{0x3c,0x42,0x41,0x7E,0x40},	//?
	{0x3D,0x40,0x40,0x7D,0x40},	//?
	{0x0c,0x50,0x52,0x51,0x3c},	//?
	{0x41,0x7F,0x14,0x14,0x08},	//?
	{0x0c,0x51,0x50,0x51,0x3c}		//?
};

many lost characters beyond 128 ASCII...
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top