kd5uzz
Joined: 28 May 2006 Posts: 56
|
Font for 14seg LED display (binary notation?) |
Posted: Mon Apr 14, 2008 10:31 am |
|
|
Hello,
I just recieved a part from allelectronics (CAT# DSY-1) that includes a 7 char 14seg display. I need to create a font for this device. I plan on storing the bit pattern array in rom via the CONST statement. The elements of this array are to be 'long'. I would like to use binary notation, but I have at few questions:
1. I've never used binary notation before, would it be acceptible in this situation? Or is there a better option?
2. Does CCS support binary notation? I can't find any mention of it in the help file. Can I even use binary notation for a long?
3. Can someone give me an example of binary notation?
Here is my code so far. Display.A[] is what the program will modify to change the display, BA[] holds the bit pattern that is to be sent to the display. SetupDisplay() will be called to perform the conversion from the char Display.A[] to the bit pattern in Display.BA[]. The bit pattern will be pulled from the ALPHAFont. Same goes for Display.N[] except its a 7seg display. The display will be updated 100 times a second, and the contents of the display will be updated 8 times a second.
Any suggestions are welcome. I've never done this type of program before.
I should mention that
Code: |
#include <16F877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000) //clock speed
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,ERRORS)
#define TIMER2PERIOD 250
#define MAIL 0
#define PHONE 1
#define STORAGE 2
#define NETWORK 3
#define AC1 4
#define AC2 5
#define NC1 6
#define NC2 7
int DoDSYSetup,QuarterSecondPassed,HalfSecondPassed,SecondPassed,Timer2Count;
LONG CONST ALPHAFont[90] = {};
INT CONST NUMERICFont[10] = {};
struct typeserialpacket {
char A[7];
char N[4];
long BA[7];
int BN[4];
int Icons;
} Display;
#int_TIMER2
void TIMER2_ISR(){
//this function should be called X times a second
static int TIMER2Counter;
static int DSYSetup;
int i;
TIMER2Counter++;
DSYSetup++;
if (DSYSetup == TIMER2PERIOD/8){
DoDSYSetup = TRUE;
DSYSetup = 0;
}
if ((Timer2Counter == TIMER2PERIOD/4) || (Timer2Counter == TIMER2PERIOD/4*2) || (Timer2Counter == TIMER2PERIOD/4*3) || (Timer2Counter == TIMER2PERIOD/4*4)){
QuarterSecondPassed = TRUE;
}
if ((Timer2Counter == TIMER2PERIOD/2) || (Timer2Counter == TIMER2PERIOD/2*2)){
HalfSecondPassed = TRUE;
}
if (Timer2Counter == TIMER2PERIOD){
SecondPassed = TRUE;
Timer2Counter = 0;
}
}
void SetupDisplay(){
int i;
for (i=0;i<=6;++i){
}
}
void main(){
printf("DSY-1 from All Electronics Test");
enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
setup_timer_2(T2_DIV_BY_16,250,5);
while(TRUE){
if (DoDSYSetup == TRUE){
DoDSYSetup = !DoDSYSetup;
SetupDisplay();
}
}
}
|
|
|