--- Quote Start ---
originally posted by jmarshall@Aug 16 2006, 08:52 PM
for the seven segment displays, here are the hex codes:
static unsigned char hex_digits = {
0x01, 0x4f, 0x12, 0x06, 0x4c, /* 0-4 */
0x24, 0x20, 0x0f, 0x00, 0x04, /* 5-9 */
0x08, 0x60, 0x72, 0x42, 0x30, 0x38 /* a-f */
};
static unsigned char hex_alphabet = {
0x88, 0xe0, 0xf2, 0xc2, 0xb0, 0xb8, 0x84, /* a,b,c,d,e,f,g */
0xe8, 0xfb, 0xc7, 0xf0, 0xf1, 0xb6, 0xea, /* h,i,j,k,l,m,n (m is 3 horizontal bars)*/
0xe2, 0x98, 0x8c, 0xfa, 0xa4, 0xb9, 0xe3, /* o,p,q,r,s,t,u */
0xff, 0xc8, 0xc4, 0x92 /* w,x,y,z */
};
note that not all the characters can be represented, particularly m, v, w. s & z end up like 2 and 5.
then i have the following two functions:
vuint16 *led_7seg_address = (vuint16*) na_seven_seg_pio;
char getsevensegmentrep(char c, int decimalpoint) {
int dp = 0;
if (decimalpoint) dp = 0xff;
else dp = 0x7f;
if (c >= 0 && c <= 0xf) {
return (hex_digits | 0x80) & dp;
}
else if (c >= '0' && c <= '9') {
return (hex_digits | 0x80) & dp;
}
else if (c >= 'a' && c <= 'z') {
return (hex_alphabet | 0x80) & dp;
}
else if (c >= 'a' && c <= 'z') {
return (hex_alphabet | 0x80) & dp;
}
else
return 0xdd;
}
void puttoled(char char1, char char2, int decimalpoint1, int decimalpoint2) {
*led_7seg_address = getsevensegmentrep(char1, decimalpoint1) << 8
| getsevensegmentrep(char2, decimalpoint2);
}
then use like so:
puttoled('a','c', 0, 0);
someone else asked about the makefile. i have set this up as part of the user build, changing the config definition file as described in the wiki.
the makefile itself looks like this, again as described in wiki:
exec = app
objc = app.o
all: $(exec)
$(exec): $(objs)
$(cc) $(ldflags) -o $@ $(objs) $(ldlibs)
romfs:
$(romfsinst) /bin$(exec)
clean:
rm -rf $(exec) *.elf *.gdb *.o
note that you can't just copy and paste this, as it needs a tab instead of those spaces as indents.
hope this helps.
- josh
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=17661)</div> --- Quote End ---
Jmarshall,
Thanks. I can now get the hang of looking at devices , and map them to hardware.
I am still fiddling around with some code ...
Once I am done, I will post this on the wiki for everyone ...