BiDoU
Newbie level 6
Hello,
I made this function maybe rapidly, but I don't know if it's possible to optimise it. Because it takes a lot of program memory data... (like 200 bytes).
It's for a PIC16Fxxx...
I think it's the basic form for this function. The using of this function is like vAffichage('7');
I made this function maybe rapidly, but I don't know if it's possible to optimise it. Because it takes a lot of program memory data... (like 200 bytes).
It's for a PIC16Fxxx...
I think it's the basic form for this function. The using of this function is like vAffichage('7');
Code:
#include <pic.h>
#define SEGMENT_A RB0
#define SEGMENT_B RB1
#define SEGMENT_C RB2
#define SEGMENT_D RB3
#define SEGMENT_E RB4
#define SEGMENT_F RB5
#define SEGMENT_G RB6
#define ON 1
#define OFF 0
void vAffichage(unsigned char ucCharacter)
{
switch(ucCharacter)
{
case '0':
case 'O':
SEGMENT_A = ON;
SEGMENT_B = ON;
SEGMENT_C = ON;
SEGMENT_D = ON;
SEGMENT_E = ON;
SEGMENT_F = ON;
SEGMENT_G = OFF;
break;
case '1':
case 'l':
SEGMENT_A = OFF;
SEGMENT_B = ON;
SEGMENT_C = ON;
SEGMENT_D = OFF;
SEGMENT_E = OFF;
SEGMENT_F = OFF;
SEGMENT_G = OFF;
break;
case '2':
SEGMENT_A = ON;
SEGMENT_B = ON;
SEGMENT_C = OFF;
SEGMENT_D = ON;
SEGMENT_E = ON;
SEGMENT_F = OFF;
SEGMENT_G = ON;
break;
case '3':
SEGMENT_A = ON;
SEGMENT_B = ON;
SEGMENT_C = ON;
SEGMENT_D = ON;
SEGMENT_E = OFF;
SEGMENT_F = OFF;
SEGMENT_G = ON;
break;
case '4':
SEGMENT_A = OFF;
SEGMENT_B = ON;
SEGMENT_C = ON;
SEGMENT_D = OFF;
SEGMENT_E = OFF;
SEGMENT_F = ON;
SEGMENT_G = ON;
break;
case '5':
case 'S':
SEGMENT_A = ON;
SEGMENT_B = OFF;
SEGMENT_C = ON;
SEGMENT_D = ON;
SEGMENT_E = OFF;
SEGMENT_F = ON;
SEGMENT_G = ON;
break;
case '6':
SEGMENT_A = ON;
SEGMENT_B = OFF;
SEGMENT_C = ON;
SEGMENT_D = ON;
SEGMENT_E = ON;
SEGMENT_F = ON;
SEGMENT_G = ON;
break;
case '7':
SEGMENT_A = ON;
SEGMENT_B = ON;
SEGMENT_C = ON;
SEGMENT_D = OFF;
SEGMENT_E = OFF;
SEGMENT_F = OFF;
SEGMENT_G = OFF;
break;
case '8':
SEGMENT_A = ON;
SEGMENT_B = ON;
SEGMENT_C = ON;
SEGMENT_D = ON;
SEGMENT_E = ON;
SEGMENT_F = ON;
SEGMENT_G = ON;
break;
case '9':
SEGMENT_A = ON;
SEGMENT_B = ON;
SEGMENT_C = ON;
SEGMENT_D = OFF;
SEGMENT_E = OFF;
SEGMENT_F = ON;
SEGMENT_G = ON;
break;
case 'd':
SEGMENT_A = OFF;
SEGMENT_B = ON;
SEGMENT_C = ON;
SEGMENT_D = ON;
SEGMENT_E = ON;
SEGMENT_F = OFF;
SEGMENT_G = ON;
break;
case 'o':
SEGMENT_A = OFF;
SEGMENT_B = OFF;
SEGMENT_C = ON;
SEGMENT_D = ON;
SEGMENT_E = ON;
SEGMENT_F = OFF;
SEGMENT_G = ON;
break;
case 'A':
SEGMENT_A = ON;
SEGMENT_B = ON;
SEGMENT_C = ON;
SEGMENT_D = OFF;
SEGMENT_E = ON;
SEGMENT_F = ON;
SEGMENT_G = ON;
break;
case 'C':
SEGMENT_A = ON;
SEGMENT_B = OFF;
SEGMENT_C = OFF;
SEGMENT_D = ON;
SEGMENT_E = ON;
SEGMENT_F = ON;
SEGMENT_G = OFF;
break;
case 'F':
SEGMENT_A = ON;
SEGMENT_B = OFF;
SEGMENT_C = OFF;
SEGMENT_D = OFF;
SEGMENT_E = ON;
SEGMENT_F = ON;
SEGMENT_G = ON;
break;
case 'H':
SEGMENT_A = OFF;
SEGMENT_B = ON;
SEGMENT_C = ON;
SEGMENT_D = OFF;
SEGMENT_E = ON;
SEGMENT_F = ON;
SEGMENT_G = ON;
break;
case 'L':
SEGMENT_A = OFF;
SEGMENT_B = OFF;
SEGMENT_C = OFF;
SEGMENT_D = ON;
SEGMENT_E = ON;
SEGMENT_F = ON;
SEGMENT_G = OFF;
break;
case 'P':
SEGMENT_A = ON;
SEGMENT_B = ON;
SEGMENT_C = OFF;
SEGMENT_D = OFF;
SEGMENT_E = ON;
SEGMENT_F = ON;
SEGMENT_G = ON;
break;
case '_':
SEGMENT_A = OFF;
SEGMENT_B = OFF;
SEGMENT_C = OFF;
SEGMENT_D = ON;
SEGMENT_E = OFF;
SEGMENT_F = OFF;
SEGMENT_G = OFF;
break;
}//Fin switch(ucCharacter).
}