Hi all,
well i've made a small prog base on the LCD Display tuto.
The soft is quite simple, it's like a calendar.
it write on the LCD a date like "lundi dix-sept janvier deux mille deux" (it's in french, but this is not really important)
strangely, the word "fevrier" doesn't appear in the sentence.
the soft write the month only at "mars" and other month but not february !!!!
if i delete "sAnnee" declaration, the prog doesn't work any more. (it's not in use in the prog)
have you an idea ?
i add a printString() by the serialport to debugg.
would you try my prog and tell me if there is the same prob (with "fevrier") on your board.
I suppose there is an init prob with the vars... but why ! not enough memory ?
or have made a bad declaration ?
oh, it delete "janvier" too !
best regards
eric
:-[
//boolean b;
int RS = 12;
int RW = 11;
int DB[] = {3, 4, 5, 6, 7, 8, 9, 10};
int Enable = 2;
// init poeme
int jour = 0;
int nJour = 17;
int mois = 2;
int an = 2;
char chaine[65] = " ";
char ligne[0x10] = "";
int jMax[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
const char *sNomJour[7] = {"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"};
const char *sJour[33] = {"", " premier", " deux", " trois", " quatre", " cinq", " six", " sept", " huit", " neuf", " dix", " onze", " douze", " treize", " quatorze", " quinze", " seize", " dix-sept", " dix-huit", " dix-neuf", " vingt", " vingt-et-un", " vingt-deux", " vingt-trois", " vingt-quatre", " vingt-cinq", " vingt-six", " vingt-sept", " vingt-huit", " vingt-neuf", " trente", " trente-et-un", " mille"};
const char *sMois[13] = {"", " janvier", " fevrier", " mars", " avril", " mai", " juin", " juillet", " aout", " septembre", " octobre", " novembre", " decembre"};
const char *sAnnee[8] = {"", ""," deux mille deux", " deux mille trois", " deux mille quatre", " deux mille cinq", " deux mille six"};
void LcdCommandWrite(int value) {
int i = 0;
for (i=DB[0]; i <= RS; i++) {
digitalWrite(i,value & 01);
value >>= 1;
}
digitalWrite(Enable,LOW);
delayMicroseconds(1);
// send a pulse to enable
digitalWrite(Enable,HIGH);
delayMicroseconds(1);
digitalWrite(Enable,LOW);
delayMicroseconds(1);
}
void LcdDataWrite(int value) {
// poll all the pins
int i = 0;
//delay(25);
//printInteger(value);
//printNewline();
digitalWrite(RS, HIGH);
digitalWrite(RW, LOW);
for (i=DB[0]; i <= DB[7]; i++) {
digitalWrite(i,value & 01);
value >>= 1;
}
digitalWrite(Enable,LOW);
delayMicroseconds(1);
// send a pulse to enable
digitalWrite(Enable,HIGH);
delayMicroseconds(1);
digitalWrite(Enable,LOW);
delayMicroseconds(1);
}
void lcdGotoXY (int x, int y) {
// depend of your LCD datasheet DDRAM adress
int DDRAMadresses[]={0x80, 0xC0, 0x90, 0xD0}; // it's a 4X16 LCD DISPLAY
int i, value;
digitalWrite(RS, LOW);
digitalWrite(RW, LOW);
value = DDRAMadresses[x-1]+y;
for (i=DB[0]; i <= DB[7]; i++) {
digitalWrite(i,value & 01);
value >>= 1;
}
digitalWrite(Enable,LOW);
delayMicroseconds(1);
// send a pulse to enable
digitalWrite(Enable,HIGH);
delayMicroseconds(1);
digitalWrite(Enable,LOW);
delayMicroseconds(1);
}
void printStringLCD(unsigned char *s)
{
while (*s)
LcdDataWrite(*s++);
}
void setup (void) {
int i = 0;
beginSerial(115200);
for (i=Enable; i <= RS; i++) {
pinMode(i,OUTPUT);
}
delay(100);
LcdCommandWrite(0x30);
delay(64);
LcdCommandWrite(0x30);
delay(50);
LcdCommandWrite(0x30);
delay(20);
LcdCommandWrite(0x38);
delay(20);
LcdCommandWrite(0x6);
//LcdCommandWrite(0x07);
delay(20);
LcdCommandWrite(0xE);
delay(20);
LcdCommandWrite(0x1);
delay(100);
LcdCommandWrite(0x80);
delay(20);
}
void loop (void) {
int i = 0;
int j = 0;
delay(4000);
LcdCommandWrite(0x1);
delay(10);
LcdCommandWrite(0x2);
delay(10);
if (jour > 6) {jour = 0;}
if (nJour > jMax[mois]) {nJour = 1; mois++;}
if (mois == 2 && an == 3) { jMax[2] = 29;} else { jMax[2] = 28;}
if (mois > 12) {mois = 1; an++;}
// concatenation des chaines
chaine[64] = " ";
strcpy(chaine, sNomJour[jour]); // dimanche
strcat(chaine, sJour[nJour]); // dix-sept
strcat(chaine, sMois[mois]); // Février
strcat(chaine, sJour[2]); // deux
strcat(chaine, sJour[32]);// mille
strcat(chaine, sJour[an]); // deux
printString(chaine);
printNewline();
jour++;
nJour++;
// ecriture des lignes
lcdGotoXY(1, 0);
strncpy(ligne,chaine,16);
if (strlen(ligne) >= 16) {
ligne[16] = '\0';
}
// ecrit la ligne
printStringLCD(ligne);
delay(100);
/*printInteger(an);
printNewline();*/
*ligne=" ";
for (i=2; i<=4;i++) {
lcdGotoXY(i, 0);
strncpy(ligne,&chaine[16*(i-1)],16);
if (strlen(ligne) >= 16) {
ligne[16] = '\0';
}
// ecrit la ligne
printStringLCD(ligne);
delay(100);
*ligne=" ";
}
}