Mithun_K_Das
Advanced Member level 3
- Joined
- Apr 24, 2010
- Messages
- 899
- Helped
- 24
- Reputation
- 48
- Reaction score
- 26
- Trophy points
- 1,318
- Location
- Dhaka, Bangladesh, Bangladesh
- Activity points
- 8,254
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
// LCD module connections
sbit LCD_RS at RC0_bit;
sbit LCD_EN at RC1_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;
sbit LCD_RS_Direction at TRISC1_bit;
sbit LCD_EN_Direction at TRISC0_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
// End LCD module connections
char stringOutput[5];
short i=0;
const char segments[8][8]=
{
{3,3,3,3,3,3,3,3}, // segmento 0
{3,3,3,3,3,3,31,31}, // segmento 1
{31,31,3,3,3,3,3,3}, // segmento 2
{31,31,3,3,3,3,31,31},// segmento 3
{31,31,24,24,24,24,31,31},// segmento 4
{27,27,27,27,27,27,31,31},// segmento 5
{31,31,27,27,27,27,27,27},// segmento 6
{31,31,27,27,27,27,31,31} // segmento 7
};
void writeCGRAM() {
char i,j=0;
for (i=0; i<=7; i++) {
LCD_Cmd(64+i*8); //write CGRAM address
for (j = 0; j<=7; j++) {
LCD_Chr_Cp(segments[i][j]);
}
LCD_Cmd(_LCD_RETURN_HOME);
}
}
void writeBigChar(short column, char character) {
switch(character){
case 0: {
LCD_Chr(1,column,6);
LCD_Chr(2,column,5);
break;
}
case 1: {
LCD_Chr(1,column,0);
LCD_Chr(2,column,0);
break;
}
case 2: {
LCD_Chr(1,column,2);
LCD_Chr(2,column,4);
break;
}
case 3: {
LCD_Chr(1,column,3);
LCD_Chr(2,column,1);
break;
}
case 4: {
LCD_Chr(1,column,5);
LCD_Chr(2,column,0);
break;
}
case 5: {
LCD_Chr(1,column,4);
LCD_Chr(2,column,1);
break;
}
case 6: {
LCD_Chr(1,column,4);
LCD_Chr(2,column,5);
break;
}
case 7: {
LCD_Chr(1,column,2);
LCD_Chr(2,column,0);
break;
}
case 8: {
LCD_Chr(1,column,7);
LCD_Chr(2,column,5);
break;
}
case 9: {
LCD_Chr(1,column,7);
LCD_Chr(2,column,1);
break;
}
case 10:{
LCD_Out(2,column,".");
}
}
}
void ASCIItoDec(char *string, short size) {
short i=0;
for(i=0; i<=size; i++) {
if ( (string[i]==46 || (string[i]==0))) { //dot character
string[i]=10;
}
else if (string[i]!=32){
string[i] = string[i]-48;
}
}
}
void writeBigFloat(short column, float floatNumber)
{
char size[] = sprintf(stringOutput,"%4.1f",floatNumber);//string generator
ASCIItoDec(stringOutput,size)
{
for (i=0; i<=size-1; i++)
{
if(stringOutput[i]!=32) { //Display string generator
writeBigChar(column,stringOutput[i]);
if(stringOutput[i]==10) { // dot
writeBigChar(column,10);
}
}
}
void main()
{
TRISA = 0xFF;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
writeCGRAM();
do
{
writeBigChar(2,10);
} while(1);
}
// LCD module connections
sbit LCD_RS at RC0_bit;
sbit LCD_EN at RC1_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;
sbit LCD_RS_Direction at TRISC1_bit;
sbit LCD_EN_Direction at TRISC0_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
// End LCD module connections
char stringOutput[5];
short i=0;
const char segments[8][8]=
{
{3,3,3,3,3,3,3,3}, // segmento 0
{3,3,3,3,3,3,31,31}, // segmento 1
{31,31,3,3,3,3,3,3}, // segmento 2
{31,31,3,3,3,3,31,31},// segmento 3
{31,31,24,24,24,24,31,31},// segmento 4
{27,27,27,27,27,27,31,31},// segmento 5
{31,31,27,27,27,27,27,27},// segmento 6
{31,31,27,27,27,27,31,31} // segmento 7
};
void writeCGRAM() {
char i,j=0;
for (i=0; i<=7; i++) {
LCD_Cmd(64+i*8); //write CGRAM address
for (j = 0; j<=7; j++) {
LCD_Chr_Cp(segments[i][j]);
}
LCD_Cmd(_LCD_RETURN_HOME);
}
}
void writeBigChar(short column, char character) {
switch(character){
case 0: {
LCD_Chr(1,column,6);
LCD_Chr(2,column,5);
break;
}
case 1: {
LCD_Chr(1,column,0);
LCD_Chr(2,column,0);
break;
}
case 2: {
LCD_Chr(1,column,2);
LCD_Chr(2,column,4);
break;
}
case 3: {
LCD_Chr(1,column,3);
LCD_Chr(2,column,1);
break;
}
case 4: {
LCD_Chr(1,column,5);
LCD_Chr(2,column,0);
break;
}
case 5: {
LCD_Chr(1,column,4);
LCD_Chr(2,column,1);
break;
}
case 6: {
LCD_Chr(1,column,4);
LCD_Chr(2,column,5);
break;
}
case 7: {
LCD_Chr(1,column,2);
LCD_Chr(2,column,0);
break;
}
case 8: {
LCD_Chr(1,column,7);
LCD_Chr(2,column,5);
break;
}
case 9: {
LCD_Chr(1,column,7);
LCD_Chr(2,column,1);
break;
}
case 10:{
LCD_Out(2,column,".");
}
}
}
void ASCIItoDec(char *string, short size) {
short i=0;
for(i=0; i<=size; i++) {
if ( (string[i]==46 || (string[i]==0))) { //dot character
string[i]=10;
}
else if (string[i]!=32){
string[i] = string[i]-48;
}
}
}
void writeBigFloat(short column, float floatNumber)
{
char size = sprintf(stringOutput,"%4.1f",floatNumber);//string generator
ASCIItoDec(stringOutput,size)
{
for (i=0; i<=size-1; i++)
{
if(stringOutput[i]!=32) { //Display string generator
writeBigChar(column,stringOutput[i]);
if(stringOutput[i]==10) { // dot
writeBigChar(column,10);
}
}
}
void main()
{
TRISA = 0xFF;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
writeCGRAM();
do
{
writeBigChar(2,10);
} while(1);
}
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 // LCD module connections sbit LCD_RS at LATC0_bit; sbit LCD_EN at LATC1_bit; sbit LCD_D4 at LATC4_bit; sbit LCD_D5 at LATC5_bit; sbit LCD_D6 at LATC6_bit; sbit LCD_D7 at LATC7_bit; sbit LCD_RS_Direction at TRISC0_bit; sbit LCD_EN_Direction at TRISC1_bit; sbit LCD_D4_Direction at TRISC4_bit; sbit LCD_D5_Direction at TRISC5_bit; sbit LCD_D6_Direction at TRISC6_bit; sbit LCD_D7_Direction at TRISC7_bit; // End LCD module connections char stringOutput[5]; short i = 0; const char segments[8][8]= { {3,3,3,3,3,3,3,3}, // segmento 0 {3,3,3,3,3,3,31,31}, // segmento 1 {31,31,3,3,3,3,3,3}, // segmento 2 {31,31,3,3,3,3,31,31},// segmento 3 {31,31,24,24,24,24,31,31},// segmento 4 {27,27,27,27,27,27,31,31},// segmento 5 {31,31,27,27,27,27,27,27},// segmento 6 {31,31,27,27,27,27,31,31} // segmento 7 }; void writeCGRAM() { char i,j=0; for (i=0; i<=7; i++) { LCD_Cmd(64+i*8); //write CGRAM address for (j = 0; j<=7; j++) { LCD_Chr_Cp(segments[i][j]); } LCD_Cmd(_LCD_RETURN_HOME); } } void writeBigChar(short column, char character) { switch(character){ case 0: { LCD_Chr(1,column,6); LCD_Chr(2,column,5); break; } case 1: { LCD_Chr(1,column,0); LCD_Chr(2,column,0); break; } case 2: { LCD_Chr(1,column,2); LCD_Chr(2,column,4); break; } case 3: { LCD_Chr(1,column,3); LCD_Chr(2,column,1); break; } case 4: { LCD_Chr(1,column,5); LCD_Chr(2,column,0); break; } case 5: { LCD_Chr(1,column,4); LCD_Chr(2,column,1); break; } case 6: { LCD_Chr(1,column,4); LCD_Chr(2,column,5); break; } case 7: { LCD_Chr(1,column,2); LCD_Chr(2,column,0); break; } case 8: { LCD_Chr(1,column,7); LCD_Chr(2,column,5); break; } case 9: { LCD_Chr(1,column,7); LCD_Chr(2,column,1); break; } case 10:{ LCD_Out(2,column,"."); } } } void ASCIItoDec(char *string, char size) { short i=0; for(i=0; i<=size; i++) { if ( (string[i]==46 || (string[i]==0))) { //dot character string[i]=10; } else if (string[i]!=32){ string[i] = string[i]-48; } } } void writeBigFloat(short column, float floatNumber) { char size = sprintf(stringOutput, "%4.1f", floatNumber);//string generator ASCIItoDec(stringOutput, size); for (i=0; i<=size-1; i++) { if(stringOutput[i]!=32) { //Display string generator writeBigChar(column,stringOutput[i]); if(stringOutput[i]==10) { // dot writeBigChar(column,10); } } } } void main() { TRISA = 0xFF; TRISC = 0x00; PORTC = 0x00; Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); writeCGRAM(); do{ writeBigChar(2,10); } while(1); }