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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778
|
#include "Wire.h"
//#include "LiquidCrystal.h"
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h> // include i/o class header
#include "math.h"
#include "EEPROM.h"
#define DS1307_I2C_ADDRESS 0x68
#define PIN_STG 8
#define PIN_MENU 2
#define PIN_DR 10
#define PIN_COMMAND_A A1 //relais A
#define PIN_COMMAND_B A2 //relais B
#define PIN_COMMAND_C A3 //relais C
#define PIN_COMMAND_D A0 //relais D
#define PIN_COMMAND_E 7 //relais E
#define PIN_COMMAND_F 9 //relais F
#define PIN_COMMAND_G 13 //relais G
#define DESCHIS LOW
#define INCHIS HIGH
#define NR_ALARME 6
#define MAX_MENU_POS NR_ALARME*4+3 //doit être NR_ALARMS*4+3
hd44780_I2Cexp lcd; // auto locate and autoconfig interface pins
#define HD44780_LCDOBJECT
byte menuPos=0;
byte subMenuPos = 0;
byte cursorPos = -1;
char ligne1[17];
char ligne2[17];
char ligne[17];
boolean dataDirthy = false;
boolean oraDirthy = false;
long lastMillis=0;
boolean bAlarma = false;
typedef struct alarm{
byte hour;
byte minute;
byte days;
byte duration;
byte relee;
byte unitAlarma;
};
typedef struct ds1307_time{
byte second;
byte minute;
byte hour;
byte dayOfWeek;
byte dayOfMonth;
byte month;
byte year;
};
struct ds1307_time time;
alarm* alarme = (alarm*) malloc(sizeof(alarm) * NR_ALARME);
byte relee[]={PIN_COMMAND_G, PIN_COMMAND_F,PIN_COMMAND_E,PIN_COMMAND_D,PIN_COMMAND_C,PIN_COMMAND_B,PIN_COMMAND_A};
byte decToBcd(byte val){
return ((val/10*16)+(val%10));
}
byte bcdToDec(byte val){
return ((val/16*10)+(val%16));
}
void setDateDs1307(struct ds1307_time time)
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(0);
Wire.write(decToBcd(time.second));
Wire.write(decToBcd(time.minute));
Wire.write(decToBcd(time.hour));
Wire.write(decToBcd(time.dayOfWeek));
Wire.write(decToBcd(time.dayOfMonth));
Wire.write(decToBcd(time.month));
Wire.write(decToBcd(time.year));
Wire.endTransmission();
}
void getDateDs1307(struct ds1307_time *time)
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.write(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS,7);
(*time).second = bcdToDec(Wire.read() & 0x7f);
(*time).minute = bcdToDec(Wire.read());
(*time).hour = bcdToDec(Wire.read() & 0x3f);
(*time).dayOfWeek = bcdToDec(Wire.read());
(*time).dayOfMonth = bcdToDec(Wire.read());
(*time).month = bcdToDec(Wire.read());
(*time).year = bcdToDec(Wire.read());
}
void showMenu(){
char *zile[7];
zile[0]="L\0";
zile[1]="M\0";
zile[2]="M\0";
zile[3]="J\0";
zile[4]="V\0";
zile[5]="S\0";
zile[6]="D\0";
if(menuPos==1){ // Menu Date
strcpy(ligne1,"Date\0");
strcpy(ligne2,getDate(time));
strcat(ligne2," ");
strcat(ligne2,getZiuaSaptamaniiShort(time.dayOfWeek));
}else if(menuPos==2){ // Menu Heure
strcpy(ligne1,"Heure\0");
strcpy(ligne2,getTime(time));
}else if((menuPos+1)%4==0){ // Menu Alarme Heure
strcpy(ligne1,"Alarme ");
ligne1[7] = 48+(byte)((menuPos+1)/4)/10;
ligne1[8] = 48+(byte)(((menuPos+1)/4)-((menuPos+1)/4)/10*10);
ligne1[9]='\0';
strcat(ligne1," Heure\0");
strcpy(ligne2,getFmt2Char((alarme[(menuPos+1)/4-1]).hour)); // Alarme Heure
strcat(ligne2,":");
strcat(ligne2,getFmt2Char((alarme[(menuPos+1)/4-1]).minute)); // Alarme Minute
strcat(ligne2,"");
}else if((menuPos)%4==0){ // Jour de l'Alarme
strcpy(ligne1,"Alarme ");
ligne1[7] = 48+(byte)((menuPos)/4)/10;
ligne1[8] = 48+(byte)((menuPos)/4-(menuPos)/4/10*10);
ligne1[9]='\0';
strcat(ligne1," Jour\0");
strcpy(ligne2,"L");
for(int i=6;i>=0;i--){
if((alarme[(menuPos)/4-1]).days & (byte)ceil(pow(2,i))){
strcat(ligne2,"<");
}else{
strcat(ligne2," ");
}
if(i>0)strcat(ligne2,zile[7-i]);
}
}else if((menuPos-1)%4==0){ // Duree de l'Alarme
strcpy(ligne1,"Alarme ");
ligne1[7] = 48+(byte)((menuPos-1)/4)/10;
ligne1[8] = 48+(byte)((menuPos-1)/4-(menuPos-1)/4/10*10);
ligne1[9]='\0';
strcat(ligne1," duree\0");
itoa(alarme[(menuPos-1)/4-1].duration,ligne2,10);
if(alarme[(menuPos-1)/4-1].unitAlarma){
strcat(ligne2," min");
}else{
strcat(ligne2," sec");
}
}else if((menuPos-2)%4==0){ // Relais de l'Alarme
strcpy(ligne1,"Relais Alarme");
ligne1[13]= 48+(byte)((menuPos-2)/4)/10;
ligne1[14]= 48+(byte)((menuPos-2)/4-(menuPos-2)/4/10*10);
ligne1[15]='\0';
strcpy(ligne2,"");
for(int i=6;i>=0;i--){
char chBuff[2];
chBuff[0]=6-i+65;
chBuff[1]='\0';
strcat(ligne2,chBuff);
if((alarme[(menuPos-2)/4-1]).relee & (byte)ceil(pow(2,i))){
strcat(ligne2,"<");
}else{
strcat(ligne2," ");
}
//if(i>0)strcat(ligne2,zile[7-i]);
}
}
}
//nous plaçons le curseur en fonction de notre position dans submenu
void showSubMenu(){
if(menuPos==1 || menuPos==2){ //la date ou l'heure
switch(subMenuPos){
case 1://jour
cursorPos = 1;
break;
case 2://Lundi
cursorPos = 4;
break;
case 3://année
cursorPos = 7;
break;
case 4://jour de la semaine
if(menuPos==1){//seulement dans le cas de la date, nous avons le jour de la semaine
cursorPos=12;
break;
}
default:
subMenuPos = 0;
cursorPos = -1;
break;
}
}else if((menuPos+1)%4==0){ //heure d'alarme
switch(subMenuPos){
case 1: //ora
cursorPos = 1;
break;
case 2: //minutul
cursorPos = 4;
break;
default:
subMenuPos = 0;
cursorPos = -1;
break;
}
}else if((menuPos)%4==0){ //jours d'alarme
if(subMenuPos>0 && subMenuPos<8){
cursorPos = subMenuPos*2-1;
}else{
subMenuPos = 0;
cursorPos = -1;
}
}else if((menuPos-1)%4==0){ //durée de l'alarme
if(subMenuPos==1){
cursorPos = 0;
}else if(subMenuPos==2){
cursorPos=4;
}else{
subMenuPos=0;
cursorPos = -1;
}
}else if((menuPos-2)%4==0){ //relais d'alarme
if(subMenuPos>0 && subMenuPos<8){
cursorPos = subMenuPos*2-1;
}else{
subMenuPos = 0;
cursorPos = -1;
}
}
}
void menu(){
if((millis()-lastMillis)>150){
if(digitalRead(PIN_MENU)==LOW && menuPos==0){
menuPos=(menuPos+1)%(MAX_MENU_POS);
showMenu();
}else if(digitalRead(PIN_MENU)==LOW){
subMenuPos++;
showSubMenu();
}
}
lastMillis=millis();
}
void readValues(){
//nous lisons les valeurs initiales de l'eeprom.
//si rien n'est écrit dans l'EEPROM, nous considérons également que les heures et la durée sont égales à 0 et nous écrivons dans l'EEPROM.
for(int i=0;i<NR_ALARME;i++){
byte b = EEPROM.read(i*5+1);
if(b==0xFF){
b = 0;
EEPROM.write(i*5+1,b);
}
(alarme[i]).hour = b & 31; //pointeurs 1, 6, 11 etc.
(alarme[i]).unitAlarma = b >> 6;
b = EEPROM.read(i*5+2);
if(b==0xFF){
b = 0;
EEPROM.write(i*5+2,b);
}
(alarme[i]).minute = b; //pointeurs 2, 7, 12 etc.
b = EEPROM.read(i*5+3);
if(b==0xFF){
b = 0;
EEPROM.write(i*5+3,b);
}
(alarme[i]).days = b; //pointeurs 3, 8, 13 etc.
b = EEPROM.read(i*5+4);
if(b==0xFF){
b = 0;
EEPROM.write(i*5+4,b);
}
(alarme[i]).duration = b; //pointeurs 4, 9, 14 etc.
b = EEPROM.read(i*5+5);
if(b==0xFF){
b = 0;
EEPROM.write(i*5+5,b);
}
(alarme[i]).relee = b; //pointeurs 5, 10, 15 etc.
}
}
void setup(){
pinMode(PIN_MENU,INPUT); //btn menu
pinMode(PIN_DR,INPUT); //btn droit
pinMode(PIN_STG,INPUT); //btn gauche
for(int i=0;i<7;i++){
pinMode(relee[i],OUTPUT);
digitalWrite(relee[i],DESCHIS);
}
digitalWrite(PIN_MENU,HIGH);
digitalWrite(PIN_STG,HIGH);
digitalWrite(PIN_DR,HIGH);
attachInterrupt(0,menu,CHANGE);
//alarmes
readValues();
//initializam DS_1307
Wire.begin();
//lcd.begin(16, 2);
lcd.init();
lcd.backlight();
lcd.home();
Serial.begin(9600);
struct ds1307_time time;
time.second = 00;
time.minute = 33;
time.hour = 15;
time.dayOfWeek = 4;
time.dayOfMonth = 03;
time.month = 8;
time.year = 23;
//setDateDs1307(time);
}
char* getFmt2Char(byte val){
char *buf = "00\0";
buf[0] = 48+val/10;
buf[1] = 48+val%10;
return buf;
}
char* getDate(struct ds1307_time time){
char *buf=" \0";
buf[0]=48+time.dayOfMonth/10;
buf[1]=48+time.dayOfMonth%10;
buf[2]='.';
buf[3]=48+time.month/10;
buf[4]=48+time.month%10;
buf[5]='.';
buf[6]=48+time.year/10;
buf[7]=48+time.year%10;
return buf;
}
char* getTime(struct ds1307_time time){
char *buf=" \0";
buf[0]=48+time.hour/10;
buf[1]=48+time.hour%10;
buf[2]=':';
buf[3]=48+time.minute/10;
buf[4]=48+time.minute%10;
buf[5]=':';
buf[6]=48+time.second/10;
buf[7]=48+time.second%10;
return buf;
}
char* getZiuaSaptamaniiShort(byte val){
switch(val){
case 1:
return "Lun\0"; //Mon
break;
case 2:
return "Mar\0"; //Tue
break;
case 3:
return "Mer\0"; //Wen
break;
case 4:
return "Jeu\0"; //Thu
break;
case 5:
return "Ven\0"; //Fri
break;
case 6:
return "Sam\0"; //Sat
break;
case 7:
return "Dim\0"; //Sun
break;
default:
return "?\0";
break;
}
}
char* getZiuaSaptamanii(byte val){
switch(val){
case 1:
return "Lundi\0"; //replace with Monday if you want
break;
case 2:
return "Mardi\0"; //replace with Tuesday if you want
break;
case 3:
return "Mercredi\0"; //replace with Wednesday if you want
break;
case 4:
return "Jeudi\0"; //replace with Thursday if you want
break;
case 5:
return "Vendredi\0"; //replace with Friday if you want
break;
case 6:
return "Samedi\0"; //replace with Saturday if you want
break;
case 7:
return "Dimanche\0"; //replace with Sunday if you want
break;
default:
return "?\0";
break;
}
}
void minusData(){
if(subMenuPos==1 && time.dayOfMonth>1){ //jours
time.dayOfMonth--;
}else if(subMenuPos==2 && time.month>1){
time.month--;
}else if(subMenuPos==3 && time.year>1){
time.year--;
}else if(subMenuPos==4 && time.dayOfWeek>1){
time.dayOfWeek--;
}
dataDirthy=true;
showMenu();
}
void plusData(){
if(subMenuPos==1){ //jours ici l'utilisateur doit faire attention à ne pas mettre plus de jours qu'il n'a de mois, je l'ai limité à 31 seulement
time.dayOfMonth=(time.dayOfMonth+1)%32;
if(time.dayOfMonth==0){
time.dayOfMonth=1;
}
}else if(subMenuPos==2){
time.month=(time.month+1)%13;
if(time.month==0){
time.month=1;
}
}else if(subMenuPos==3){
time.year=(time.year+1)%99;
}else if(subMenuPos==4){
time.dayOfWeek=(time.dayOfWeek+1)%8;
if(time.dayOfWeek==0){
time.dayOfWeek=1;
}
}
dataDirthy=true;
showMenu();
}
void minusOra(){
if(subMenuPos==1 && time.hour>0){ //zilele
time.hour=time.hour-1;
}else if(subMenuPos==2 && time.minute>0){
time.minute=time.minute-1;
}else if(subMenuPos==3 && time.second>1){
time.second=time.second-1;
}
oraDirthy = true;
showMenu();
}
void plusOra(){
if(subMenuPos==1){ //zilele
time.hour=(time.hour+1)%24;
}else if(subMenuPos==2){
time.minute=(time.minute+1)%60;
}else if(subMenuPos==3){
time.second=(time.second+1)%60;
}
oraDirthy = true;
showMenu();
}
void minusAlarma(byte pos){
alarme[pos-1];
if(subMenuPos==1) {
if (alarme[pos-1].hour>0){
alarme[pos-1].hour--;
}
}else if(subMenuPos==2) {
if (alarme[pos-1].minute>0){
alarme[pos-1].minute--;
}
}
showMenu();
}
void plusAlarma(byte pos){
alarme[pos-1];
if(subMenuPos==1){
alarme[pos-1].hour=(alarme[pos-1].hour+1)%24;
} else if(subMenuPos==2){
alarme[pos-1].minute=(alarme[pos-1].minute+1)%60;
}
showMenu();
}
void minusZileAlarma(byte pos){
Serial.println(alarme[pos-1].days);
alarme[pos-1].days =alarme[pos-1].days ^ (byte)ceil(pow(2,(7-subMenuPos)));
Serial.println(alarme[pos-1].days);
showMenu();
}
void plusReleeAlarma(byte pos){
minusReleeAlarma(pos);
}
void minusReleeAlarma(byte pos){
Serial.println(alarme[pos-1].relee);
alarme[pos-1].relee = alarme[pos-1].relee ^ (byte)ceil(pow(2,(7-subMenuPos)));
Serial.println(alarme[pos-1].relee);
showMenu();
}
void plusZileAlarma(byte pos){
minusZileAlarma(pos);
}
void minusUnitAlarma(byte pos){
plusUnitAlarma(pos);
}
void plusUnitAlarma(byte pos){
if(subMenuPos==2){
alarme[pos-1].unitAlarma=(alarme[pos-1].unitAlarma+1)%2;
}
}
void minusDurataAlarma(byte pos){
if(alarme[pos-1].duration>0 && subMenuPos==1){
alarme[pos-1].duration--;
}else if(subMenuPos==2){
minusUnitAlarma(pos);
}
showMenu();
}
void plusDurataAlarma(byte pos){
if(subMenuPos==1){
alarme[pos-1].duration=(alarme[pos-1].duration+1)%240;
}else if(subMenuPos==2){
plusUnitAlarma(pos);
}
showMenu();
}
void saveValues(){
for(int i=0;i<NR_ALARME;i++){
EEPROM.write(i*5+1,(alarme[i]).hour | (alarme[i].unitAlarma << 6));
EEPROM.write(i*5+2,(alarme[i]).minute);
EEPROM.write(i*5+3,(alarme[i]).days);
EEPROM.write(i*5+4,(alarme[i]).duration);
EEPROM.write(i*5+5,(alarme[i]).relee);
}
}
void applyNewDateHour(){
if(dataDirthy || oraDirthy){
if(oraDirthy){
Serial.println("Avec l'heure");
setDateDs1307(time);
}else{ //si l'heure n'a pas changé, nous la laisserons telle quelle
Serial.println("Pas d'heure");
struct ds1307_time tmp;
getDateDs1307(&tmp);
tmp.dayOfMonth = time.dayOfMonth;
tmp.dayOfWeek = time.dayOfWeek;
tmp.month = time.month;
tmp.year = time.year;
setDateDs1307(tmp);
}
dataDirthy=false;
oraDirthy = false;
}
saveValues();
}
long valAlarmaMin(byte index){
return (alarme[index]).hour*3600L+(alarme[index]).minute*60L;
}
long valAlarmaMax(byte index){
byte multipl = (alarme[index]).unitAlarma?60:1;
return (alarme[index]).hour*3600L+(alarme[index]).minute*60L+multipl*(alarme[index]).duration;
}
void checkAlarms(){
long valComp = time.hour*3600L+time.minute*60L+time.second;
bAlarma=false;
strcpy(ligne,getTime(time));
strcat(ligne,";A");
char cAl[4];
long timeToFinish=0,vAlMax=0;
boolean tipTimp=0;
byte statusRelee[7];
for(int i=0;i<7;i++){
statusRelee[i]=0;
}
for(int i=0;i<NR_ALARME;i++){
struct alarm alarma = alarme[i];
vAlMax=valAlarmaMax(i);
if(valComp>=valAlarmaMin(i) && valComp<=vAlMax){ //comparam valorile minime si maxime ale fiecarei alarme cu timpul actual
if((byte)ceil(pow(2,7-time.dayOfWeek)) & (alarma).days){
bAlarma=true;
if((timeToFinish==0 && vAlMax-valComp>timeToFinish) || (vAlMax-valComp<timeToFinish)){//setam durata pana la sf primei alarme
tipTimp = alarma.unitAlarma;
if(tipTimp && vAlMax-valComp>=60){
timeToFinish=(vAlMax-valComp)/60;
}else{
timeToFinish=vAlMax-valComp;
tipTimp=0;
}
}
for(int j=6;j>=0;j--){
if((alarma).relee & (byte)(ceil(pow(2,j)))){
statusRelee[j]=statusRelee[j] | 1;
}
}
itoa((i+1),cAl,10);
if(strlen(ligne)<11){
strcat(ligne,cAl);
}
}
}
}
for(int i=0;i<7;i++){
if(statusRelee[i]){
digitalWrite(relee[i],INCHIS);
}else{
digitalWrite(relee[i],DESCHIS);
}
}
if(bAlarma){
itoa(timeToFinish,cAl,10);
strcat(ligne," ");
strcat(ligne,cAl);
if(tipTimp){
strcat(ligne,"m");
}else{
strcat(ligne,"s");
}
}
}
void loop(){
//si nous cliquons sur le menu, nous affichons ce dont nous avons besoin et nous n'affichons plus la date et l'heure actuelles
if(menuPos>0){
lcd.clear();
lcd.setCursor(0,0);
lcd.print(ligne1);
lcd.setCursor(0,1);
lcd.print(ligne2);
if(digitalRead(PIN_STG)==LOW && menuPos){ //avem apasat minus
delay(100);
if(subMenuPos){
if(menuPos==1){ //data
minusData();
}else if(menuPos==2){
minusOra();
}else if((menuPos+1)%4==0){
minusAlarma((menuPos+1)/4);
}else if((menuPos)%4==0){ //Jour alarme
minusZileAlarma((menuPos)/4);
}else if((menuPos-1)%4==0){ //Duree alarme
minusDurataAlarma((menuPos-1)/4);
}else if((menuPos-2)%4==0){ //Relais alarme
minusReleeAlarma((menuPos-2)/4);
}
}
else{
if(menuPos==1){
applyNewDateHour();
}
menuPos--;
showMenu();
}
}else if(digitalRead(PIN_DR)==LOW && menuPos){ //nous avons appuyé sur plus
delay(200);
if(subMenuPos){
if(menuPos==1){ //data
plusData();
}else if(menuPos==2){
plusOra();
}else if((menuPos+1)%4==0){ //heure d'alarme
plusAlarma((menuPos+1)/4);
}else if((menuPos)%4==0){ //jours d'alarme
plusZileAlarma((menuPos)/4);
}else if((menuPos-1)%4==0){ //durée de l'alarme
plusDurataAlarma((menuPos-1)/4);
}else if((menuPos-2)%4==0){ // relais de l'alarme
plusReleeAlarma((menuPos-2)/4);
}
}
else if(menuPos<MAX_MENU_POS-1){
++menuPos;
Serial.print("Menu pos: ");
Serial.print(menuPos);
showMenu();
}else{
applyNewDateHour();
menuPos=0;
}
}else if(subMenuPos>0 && cursorPos>-1){
// Serial.println(cursorPos);
lcd.cursor();
lcd.setCursor(cursorPos,1);
}else{
lcd.noCursor();
}
delay(100);
return;
}
lcd.clear();
char buf[3];
getDateDs1307(&time);
Serial.print(getTime(time));
Serial.print(" ");
Serial.print(getDate(time));
Serial.print(":");
Serial.print("Jour de la semaine : ");
Serial.println(time.dayOfWeek, DEC);
lcd.setCursor(0, 0);
lcd.print(getZiuaSaptamanii(time.dayOfWeek));
lcd.setCursor(8,0);
lcd.print(getDate(time));
if(bAlarma){
lcd.setCursor(0,1);
lcd.print(ligne);
}else{
lcd.setCursor(4,1);
lcd.print(getTime(time));
lcd.setCursor(12,1);
lcd.print(" ");
lcd.noCursor();
}
checkAlarms();
delay(1000);
} |
Partager