CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

character lookup table access

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

character lookup table access
PostPosted: Tue Mar 14, 2006 2:44 pm     Reply with quote

How can i get a character in the character table

I would have a write routine that writes a string to a led board
This routine must get the character from this table

Code:
int const Font[96][5] = {
   {0x00, 0x00, 0x00, 0x00, 0x00 ,}   // 0x20, Space
   {0x00, 0x00, 0x5F, 0x00, 0x00 ,}   // 0x21, !
   {0x00, 0x07, 0x00, 0x07, 0x00 ,}   // 0x22, "
   {0x14, 0x7F, 0x14, 0x7F, 0x14 ,}   // 0x23, #
   {0x24, 0x2A, 0x7F, 0x2A, 0x12 ,}   // 0x24, 0x
   {0x23, 0x13, 0x08, 0x64, 0x62 ,}   // 0x25, %
   {0x36, 0x49, 0x55, 0x22, 0x50 ,}   // 0x26, &
   {0x00, 0x05, 0x03, 0x00, 0x00 ,}   // 0x27, '
   {0x00, 0x1C, 0x22, 0x41, 0x00 ,}   // 0x28, (
   {0x00, 0x41, 0x22, 0x1C, 0x00 ,}   // 0x29, )
   {0x08, 0x2A, 0x1C, 0x2A, 0x08 ,}   // 0x2a, *
   {0x08, 0x08, 0x3E, 0x08, 0x08 ,}   // 0x2b, +
   {0x00, 0x50, 0x30, 0x00, 0x00 ,}   // 0x2c, ,
   {0x08, 0x08, 0x08, 0x08, 0x08 ,}   // 0x2d, -
   {0x00, 0x60, 0x60, 0x00, 0x00 ,}   // 0x2e, .
   {0x20, 0x10, 0x08, 0x04, 0x02 ,}   // 0x2f, /
   {0x3E, 0x51, 0x49, 0x45, 0x3E ,}   // 0x30, 0
   {0x00, 0x42, 0x7F, 0x40, 0x00 ,}   // 0x31, 1
   {0x42, 0x61, 0x51, 0x49, 0x46 ,}   // 0x32, 2
   {0x21, 0x41, 0x45, 0x4B, 0x31 ,}   // 0x33, 3
   {0x18, 0x14, 0x12, 0x7F, 0x10 ,}   // 0x34, 4
   {0x27, 0x45, 0x45, 0x45, 0x39 ,}   // 0x35, 5
   {0x3C, 0x4A, 0x49, 0x49, 0x30 ,}   // 0x36, 6
   {0x01, 0x71, 0x09, 0x05, 0x03 ,}   // 0x37, 7
   {0x36, 0x49, 0x49, 0x49, 0x36 ,}   // 0x38, 8
   {0x06, 0x49, 0x49, 0x29, 0x1E ,}   // 0x39, 9
   };
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 15, 2006 12:30 am     Reply with quote

Study the C language topic of "two dimensional arrays":
http://www.eskimo.com/~scs/cclass/int/sx9.html
http://www.macdonald.egate.net/CompSci/harray2.html
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Mar 16, 2006 9:52 am     Reply with quote

Thx PCM,

Bot now i which to pass a string to the routine, and this string must be displayed.

How must i change below source?

Code:
void hcms2911_send_byte(int data) {
   int i;

   for(i=0;i<8;i++) {
      output_bit(HCMS2911_DIN,data & 0x80);
      output_high(HCMS2911_CLK);
      delay_cycles(2);
      output_low(HCMS2911_CLK);
      data=data<<1;
   }
}

void hcms2911_put(int data) {
   output_low(HCMS2911_RS);
   output_low(HCMS2911_CE);
   hcms2911_send_byte(data);
   output_high(HCMS2911_CE);
   output_low(HCMS2911_CLK);
}

void readfont(int ccode) {
   int cidx;

   if(Ccode>=0x20&&Ccode<0x80)
      Ccode-=0x20;
   
   for(cidx=0;cidx<5;cidx++)
      hcms2911_put(Font[Ccode][cidx]);
}


#include <18F4620.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,NOBROWNOUT,NOPUT,NOLVP,DEBUG,NOSTVREN,NOPROTECT

#include <hcms2911.h>

void main() {

   int i;

   hcms2911_init();

   while (1) {
      for(i=0x20;i<0x80;i++) {
      readfont(i);
      delay_ms(150);
      }
   }
}
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Mar 16, 2006 11:47 am     Reply with quote

Quote:
Bot now i which to pass a string to the routine, and this string must be displayed.
The CCS compiler has a nice addition to the printf command allowing you to assign a function for processing the data one character at a time.

This should do the trick
Code:
printf(readfont, "It works!");
The Puma



Joined: 23 Apr 2004
Posts: 227
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Mar 16, 2006 12:10 pm     Reply with quote

It displays the whole message.
But the message must routating from left to right
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Mar 16, 2006 12:47 pm     Reply with quote

How do you expect us to know you want a rotating message? We can't read your mind.

You have most pieces of the puzzle, just add a rotating mechanism. Shouldn't be very difficult to create such a thing but I'm not going to do it for you unless you have shown some effort yourself first.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group