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 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072
| #include "Nextion.h"
//#define Serial2;
#define RXD2 16 // port de commnication nextion
#define TXD2 17 // port de commnication nextion
#define RXD1 4 // port de commnication rs485
#define TXD1 2 // port de commnication rs485
#define NETXION_END_PATTERN 0xff
#define NETXION_BEGIN_TOUCH_EVENT 0x65
#define NETXION_BEGIN_NUMERIC_VALUE 0x71
long variable1 = 0; // Create a variable to have a counter going up by one on each cycle
long selection_seance = 1; //defilement incrément des seance dans la page seance
long selection_visu=1; //defilement incrément décrement des variables dans la page visu
long temp_aff_visu_var=0; //temp variable visu pour nextion
long comp_selection_seance = 0; //comparaison defilement incrément des seance dans la page seance
long counter = 0; // Create a variable to have a counter for the + and - buttons
long CurrentPage = 0; // Create a variable to store which page is currently loaded
byte rot_A=0;
long rot_init=0; // boucle pour init variable setup
int ctrl_flux_rs485=19;//controle flux forcer par shunt sur carte
String reception = "";//reception rs485
String reception_nextion = "";//reception nextion
String $menu="";
String decoupage[11]; //le mot lu sur la liaison série 2
String decoupage_nextion[3]; //le mot lu sur la liaison série 2
int i = 0; //variable locale pour l'incrémentation des données dutableau
byte memo_seance; // utiliser pour memoriser modification variable
//byte _byte;
// Le buffer contenant le message complet, en cours de construction,
// avant émission.
//byte byteBuffer[32];
// Index du prochain byte attendu, dans le buffer.
// int byteIndex = 0;
byte nextByte=0;
//Variable touche pupitre commune avec carte mere
long Touche_BP[6];
long Comp_Touche_BP[6];
long SeanceON_heure[17] ; //champs pour les séances de chauffage(0à8)et programme(9à16)
long SeanceOFF_heure[17]; //champs pour les séances de chauffage(0à8)et programme(9à16)
long SeanceON_min[17]; //champs pour les séances de chauffage(0à8)et programme(9à16)
long SeanceOFF_min[17]; //champs pour les séances de chauffage(0à8)et programme(9à16)
long Input_[5];
long Output_[5];
//Variable ESP pour échange communication carte mère
long Echange_info=0;
long Messages=0;
long Adresse_ser=0; //gestion de trame RS485
long attente_trame_apres_init=0;
long temp_echange_info= 0;
//Variables pour ESP (identique à celle de carte mère)
long Memo_0=0;
long Login=0; // état de la touche BP(5),6
long Temp_login=0;
long Alarme=0; // état de la touche BP(5),3
long Econo=0;
// Declare Variable Nextion PAGE 0 INIT
NexButton p0_b0 = NexButton(0,1,"b0");
//NexNumber p0_n0 = NexNumber(0,5,"n0");
NexText p0_t1 = NexText(0,6,"t1");
NexButton p0_b1 = NexButton(0,7,"b1");
// Declare Variable Nextion PAGE 1 MAIN
NexButton p1_b0 = NexButton(1,1,"b0");
NexButton p1_bt0 = NexButton(1,7,"bt0");//touche ballon eau chaude
NexButton p1_bt1 = NexButton(1,9,"bt1");// touche Alarme
NexButton p1_bt3 = NexButton(1,6,"bt3");// touche LOGIN
// Declare Variable Nextion PAGE 2 CAVE
NexButton p2_bt0 = NexButton(2,18,"bt0"); //touche escalier cave
NexButton p2_bt1 = NexButton(2,19,"bt1"); //touche local technique
NexButton p2_bt2 = NexButton(2,20,"bt2"); // touche cave
NexButton p2_bt3 = NexButton(2,21,"bt3"); //Grotte
// Declare Variable Nextion PAGE 3 RDC
NexButton p3_bt0 = NexButton(3,14,"bt0"); //touche escalier cave
NexButton p3_bt1 = NexButton(3,15,"bt1"); //descente volet
NexButton p3_bt2 = NexButton(3,16,"bt2"); // montee volet
NexButton p3_bt3 = NexButton(3,17,"bt3"); //Buanderie
NexButton p3_bt4 = NexButton(3,18,"bt4"); //piece 2
NexButton p3_bt5 = NexButton(3,19,"bt5"); //exterieur
NexButton p3_bt6 = NexButton(3,20,"bt6"); // escalier rdc
NexButton p3_bt7 = NexButton(3,21,"bt7"); // libre
// Declare Variable Nextion PAGE 4 RDR
NexButton p4_bt0 = NexButton(4,17,"bt0"); //touche escalier RdC
NexButton p4_bt1 = NexButton(4,18,"bt1"); //sejour
NexButton p4_bt2 = NexButton(4,19,"bt2"); // cuisine
NexButton p4_bt3 = NexButton(4,20,"bt3"); //lumiere ambiance
NexButton p4_bt4 = NexButton(4,21,"bt4"); //entrée
NexButton p4_bt5 = NexButton(4,22,"bt5"); //escalier niV
NexButton p4_bt6 = NexButton(4,23,"bt6"); // libre
NexButton p4_bt7 = NexButton(4,24,"bt7"); // libre
// Declare Variable Nextion PAGE 5 NIV1
NexButton p5_bt0 = NexButton(5,17,"bt0"); //touche escalier NIV 1
NexButton p5_bt1 = NexButton(5,18,"bt1"); //prise CH
NexButton p5_bt2 = NexButton(5,19,"bt2"); // prise CH
NexButton p5_bt3 = NexButton(5,20,"bt3"); //lumiere chambre
NexButton p5_bt4 = NexButton(5,21,"bt4"); //SdB
NexButton p5_bt5 = NexButton(5,22,"bt5"); //Couloir
NexButton p5_bt6 = NexButton(5,23,"bt6"); // Escalier Niv 2
NexButton p5_bt7 = NexButton(5,24,"bt7"); // libre
// Declare Variable Nextion PAGE 6 NIV2
NexButton p6_bt0 = NexButton(6,17,"bt0"); //touche escalier NIV 2
NexButton p6_bt1 = NexButton(6,18,"bt1"); //chambre 2
NexButton p6_bt2 = NexButton(6,19,"bt2"); // chambre 3
NexButton p6_bt3 = NexButton(6,20,"bt3"); // SdB
NexButton p6_bt4 = NexButton(6,21,"bt4"); // libre
NexButton p6_bt5 = NexButton(6,22,"bt5"); // libre
NexButton p6_bt6 = NexButton(6,23,"bt6"); // libre
NexButton p6_bt7 = NexButton(6,24,"bt7"); // libre
// Declare Variable Nextion PAGE 11 Clavier
NexButton p11_p1 = NexButton(11,22,"p1"); //touche droite selection variable
NexButton p11_p2 = NexButton(11,23,"p2"); //touche gauche selection variable
NexButton p11_b9 = NexButton(11,11,"b9"); //touche enter
// Declare Variable Nextion PAGE 8 seance
NexButton p8_bt0 = NexButton(8,24,"bt0"); //touche escalier NIV 2
NexButton p8_p3 = NexButton(8,10,"p3"); //touche droite selection variable
NexButton p8_p4 = NexButton(8,11,"p4"); //touche gauche selection variable
NexButton p8_n0 = NexButton(8,12,"n0"); //touche selection debut heure seance
NexButton p8_n2 = NexButton(8,14,"n2"); //touche selection debut min seance
NexButton p8_n3 = NexButton(8,18,"n3"); //touche selection fin heure seance
NexButton p8_n4 = NexButton(8,21,"n4"); //touche selection fin min seance
// Declare Variable Nextion PAGE 9 Visualisation
NexButton p9_p3 = NexButton(9,10,"p3"); //touche droite selection variable
NexButton p9_p4 = NexButton(9,11,"p4"); //touche gauche selection variable
// Declare pages:
// Sending data to the display to nonexistent objects on the current page creates an error code sent by the display.
// Any error sent by the display creates lag on the arduino loop because arduino tries to read it, thinking it's a touch event.
// So to avoid this, I am only going to send data depending on the page the display is on.
// That's the reason I want the arduino to know which page is loaded on the display.
// To let arduino know what page is currently loaded, we are creating a touch event for each page.
// On the nextion project, each page most send a simulated "Touch Press Event" in the "Preinitialize Event" section so
// we can register that a new page was loaded.
NexPage page0 = NexPage(0, 0, "page0"); // Page added as a touch event PAGE INIT
NexPage page1 = NexPage(1, 0, "page1"); // Page added as a touch event PAGE MAIN
NexPage page2 = NexPage(2, 0, "page2"); // Page added as a touch event PAGE CAVE
NexPage page3 = NexPage(3, 0, "page3"); // Page added as a touch event PAGE RDC
NexPage page4 = NexPage(4, 0, "page4"); // Page added as a touch event PAGE RdR
NexPage page5 = NexPage(5, 0, "page5"); // Page added as a touch event PAGE NIV1
NexPage page6 = NexPage(6, 0, "page6"); // Page added as a touch event PAGE NIV2
NexPage page7 = NexPage(7, 0, "page7"); // Page added as a touch event PAGE SETTINGS
NexPage page8 = NexPage(8, 0, "page8"); // Page added as a touch event PAGE SEANCE REGLAGE
NexPage page9 = NexPage(9, 0, "page9"); // Page added as a touch event PAGE VISUALISATION
NexPage page10 = NexPage(10,0,"page10"); // Page added as a touch event PAGE REGLAGE
NexPage page11 = NexPage(11,0,"page11"); // Page added as a touch event PAGE CLAVIER
//Variable boutton nextion à lire
NexTouch *nex_listen_list[] = {
&p0_b0,//touche b0 page 0
&p0_b1,//touche b1 page 0
&p1_b0,//touche b2 page 0
&p1_bt0,//touche bt0 page 1
&p1_bt1,//touche bt1 page 1
&p1_bt3,//touche bt3 page 1
&p2_bt0,//touche bt0 page 2
&p2_bt1,//touche bt1 page 2
&p2_bt2,//touche bt2 page 2
&p2_bt3,//touche bt3 page 2
&p3_bt0,//touche bt0 page 3
&p3_bt1,//touche bt1 page 3
&p3_bt2,//touche bt2 page 3
&p3_bt3,//touche bt3 page 3
&p3_bt4,//touche bt4 page 3
&p3_bt5,//touche bt5 page 3
&p3_bt6,//touche bt6 page 3
&p3_bt7,//touche bt7 page 3
&p4_bt0,//touche bt0 page 4
&p4_bt1,//touche bt1 page 4
&p4_bt2,//touche bt2 page 4
&p4_bt3,//touche bt3 page 4
&p4_bt4,//touche bt4 page 4
&p4_bt5,//touche bt5 page 4
&p4_bt6,//touche bt6 page 4
&p4_bt7,//touche bt7 page 4
&p5_bt0,//touche bt0 page 5
&p5_bt1,//touche bt1 page 5
&p5_bt2,//touche bt2 page 5
&p5_bt3,//touche bt3 page 5
&p5_bt4,//touche bt4 page 5
&p5_bt5,//touche bt5 page 5
&p5_bt6,//touche bt6 page 5
&p5_bt7,//touche bt7 page 5
&p6_bt0,//touche bt0 page 6
&p6_bt1,//touche bt1 page 6
&p6_bt2,//touche bt2 page 6
&p6_bt3,//touche bt3 page 6
&p6_bt4,//touche bt4 page 6
&p6_bt5,//touche bt5 page 6
&p6_bt6,//touche bt6 page 6
&p6_bt7,//touche bt7 page 6
&p11_p1,//touche p1 page 11 clavier défilement
&p11_p2,//touche p2 page 11 clavier défilement
&p8_bt0,//touche login logout page seance
&p8_p3,//touche p3 page 8 seance défilement -
&p8_p4,//touche p4 page 8 seance défilement +
&p8_n0, //touche selection debut heure seance
&p8_n2, //touche selection debut min seance
&p8_n3, //touche selection fin heure seance
&p8_n4, //touche selection fin min seance
&p9_p3,//touche p3 page 9 visualisation
&p9_p4,//touche p4 page 9 visualisation
&p11_b9,//touche b9 Enter page clavier
&page0, // Page added as a touch event PAGE INIT
&page1, // Page added as a touch event PAGE MAIN
&page2, // Page added as a touch event PAGE CAVE
&page3, // Page added as a touch event PAGE RDC
&page4, // Page added as a touch event PAGE RdR
&page5, // Page added as a touch event PAGE NIV1
&page6, // Page added as a touch event PAGE NIV2
&page7, // Page added as a touch event PAGE SETTING
&page8, // Page added as a touch event PAGE reglage des seances
&page9, // Page added as a touch event PAGE VISUALISATION
&page10, // Page added as a touch event PAGE REGLAGE pas de retour serial ATTENTION NE FONCTIONNE PAS ??????parceque c'est au dessus de 9?
&page11, // Page added as a touch event PAGE CLAVIER pas de retour serial ATTENTION NE FONCTIONNE PAS ??????parceque c'est au dessus de 9?
NULL
};
uint32_t next, myInt = 0;
#define ledPin0 25
#define ledPin1 26
#define ledPin2 27
#define ledPin3 14
#define ledPin4 12
#define ledPin5 13
#define ledPin6 15
#define ledPin7 18
//DEBUT DES VOID
// PAGE 0 INIT
void p0_b1_Press(void *ptr) {
digitalWrite(ledPin0, HIGH);
}
void p0_b1_Release(void *ptr) {
// digitalWrite(ledPin, LOW);
}
void p0_b0_Release(void *ptr) {
// p1.show();
}
void p1_b0_Release(void *ptr) {
//p0.show();
}
//FIN PAGE 0
//PAGE 1 MAIN
void p1_bt0_Press(void *ptr) { //touche ballon eau chaude/econo
byte memo;
memo=0;
if (Econo==0&&memo==0){
memo=1;
Econo=1;
if (Login==1){
Adresse_ser=8;//encoi la trame 8 sur RS485
Serial.println("void econo=1");
Serial.println(String(Adresse_ser)+" "+String(Echange_info)+" "+String(Messages));
envoi_data();//appel fonction envoi
//Serial.println(String(Adresse_ser)+" "+String(Echange_info)+" "+String(Messages));
digitalWrite(ledPin0, HIGH);
}//fin login =1
}
// else {
if (Econo==1&&memo==0){
Econo=0;
memo=1;
if (Login==1){
Serial.println("void econo=0");
Serial.println(String(Adresse_ser)+" "+String(Echange_info)+" "+String(Messages));
Adresse_ser=8;//encoi la trame 8 sur RS485
envoi_data();//appel fonction envoi
}//fin login =1
digitalWrite(ledPin0, LOW);
}
//jump0:
}//fin void
void p1_bt1_Press(void *ptr) { //touche alarme
byte memo_1;
memo_1=0;
if (Alarme==0) { // = 0
memo_1=1;
bitSet(Touche_BP[5], 3);
digitalWrite(ledPin1, HIGH);
Alarme=1;
if (Login==1){
Adresse_ser=8;//encoi la trame 8 sur RS485
//Serial.println(String(Adresse_ser)+" "+String(Echange_info)+" "+String(Messages));
envoi_data();//appel fonction envoi
//digitalWrite(ledPin1, HIGH);
}//fin login =1
}
if (Alarme==1==1&&memo_1==0) {
bitClear(Touche_BP[5], 3);
Alarme=0;
digitalWrite(ledPin1,LOW);
if (Login==1){
Adresse_ser=8;//encoi la trame 8 sur RS485
// Serial.println(Echange_info,BIN);
// Serial.println(Touche_BP[5],BIN);
// Serial.println(String(Adresse_ser)+" "+String(Echange_info)+" "+String(Messages));
envoi_data();//appel fonction envoi
}//fin login =1
// digitalWrite(ledPin1, LOW);
}
//jump:
//return;
}//fin void
void p1_bt3_Press(void *ptr) { //touche login
byte memo_0;
memo_0=0;
if (Login==0) { // = 0
memo_0=1;
bitSet(Touche_BP[5], 6);
//bitSet(Echange_info, 0); //vérification de la trame RS485
//bitSet(Echange_info, 8); //vérification de la trame RS485
Login=1;
Adresse_ser=8; //encoi la trame 8 sur RS485
// Serial.println(Echange_info,BIN);
// Serial.println(Touche_BP[5],BIN);
//Serial.println(String(Adresse_ser)+" "+String(Echange_info)+" "+String(Messages));
envoi_data();//appel fonction envoi
digitalWrite(ledPin2, HIGH);
}
if (Login==1&memo_0==0) {
bitClear(Touche_BP[5], 6);
// bitClear(Echange_info,0); //vérification de la trame RS485
// bitClear(Echange_info,8);//vérification de la trame RS485
Login=0;
Adresse_ser=8;//encoi la trame 8 sur RS485
// Serial.println(Echange_info,BIN);
// Serial.println(Touche_BP[5],BIN);
Serial.println(String(Adresse_ser)+" "+String(Echange_info)+" "+String(Messages));
envoi_data();//appel fonction envoi
digitalWrite(ledPin2, LOW);
}
}//fin void
void p1_bt0_Release(void *ptr) {
// digitalWrite(ledPin,LOW);
}
//FIN PAGE 1 MAIN
//PAGE 2 CAVE
void p2_bt0_Press(void *ptr) { //touche Esclier cave
//if (bit(variable1)==0){ //fonctionne
if (bitRead(Touche_BP[0],0)==0) { // = 0
bitSet(Touche_BP[0], 0);
Serial.println(Touche_BP[0],BIN);//;Touche_BP[rot_port]!=Comp_Touche_BP[rot_port])
Serial.println(Comp_Touche_BP[0],BIN);
}
else {
bitClear(Touche_BP[0],0);
Serial.println(Touche_BP[0],BIN);//;Touche_BP[rot_port]!=Comp_Touche_BP[rot_port])
Serial.println(Comp_Touche_BP[0],BIN);
}
}//fin void
void p2_bt1_Press(void *ptr) { //touche Local technique
if (bitRead(Touche_BP[0],1)==0) { // = 0
bitSet(Touche_BP[0], 1);
}
else {
bitClear(Touche_BP[0],1);
}
}//fin void
void p2_bt2_Press(void *ptr) { //touche Cave
if (bitRead(Touche_BP[0],2)==0) { // = 0
bitSet(Touche_BP[0], 2);
}
else {
bitClear(Touche_BP[0],2);
}
}//fin void
void p2_bt3_Press(void *ptr) { //touche Passage/grotte
if (bitRead(Touche_BP[0],3)==0) { // = 0
bitSet(Touche_BP[0], 3);
}
else {
bitClear(Touche_BP[0],3);
}
}//fin void
//FIN PAGE 2 CAVE
//PAGE 3 RDC
void p3_bt0_Press(void *ptr) { //touche escalier cave
if (bitRead(Touche_BP[1],0)==0) { // = 0
bitSet(Touche_BP[1], 0);
}
else {
bitClear(Touche_BP[1],0);
}
}//fin void
void p3_bt1_Press(void *ptr) { //touche descente volet
if (bitRead(Touche_BP[1],1)==0) { // = 0
bitSet(Touche_BP[1], 1);
}
else {
bitClear(Touche_BP[1],1);
}
}//fin void
void p3_bt2_Press(void *ptr) { //touche montée volet
if (bitRead(Touche_BP[1],2)==0) { // = 0
bitSet(Touche_BP[1], 2);
}
else {
bitClear(Touche_BP[1],2);
}
}//fin void
void p3_bt3_Press(void *ptr) { //touche Buanderie
if (bitRead(Touche_BP[1],3)==0) { // = 0
bitSet(Touche_BP[1], 3);
}
else {
bitClear(Touche_BP[1],3);
}
}//fin void
void p3_bt4_Press(void *ptr) { //touche pièce 2
if (bitRead(Touche_BP[1],4)==0) { // = 0
bitSet(Touche_BP[1], 4);
}
else {
bitClear(Touche_BP[1],4);
}
}//fin void
void p3_bt5_Press(void *ptr) { //touche Extérieur
if (bitRead(Touche_BP[1],5)==0) { // = 0
bitSet(Touche_BP[1], 5);
}
else {
bitClear(Touche_BP[1],5);
}
}//fin void
void p3_bt6_Press(void *ptr) { //touche Escelier RdC
if (bitRead(Touche_BP[1],6)==0) { // = 0
bitSet(Touche_BP[1], 6);
}
else {
bitClear(Touche_BP[1],6);
}
}//fin void
void p3_bt7_Press(void *ptr) { //touche
if (bitRead(Touche_BP[1],7)==0) { // = 0
bitSet(Touche_BP[1], 7);
}
else {
bitClear(Touche_BP[1],7);
}
}//fin void
//FIN PAGE 3 RDC
//..................................................
//PAGE 4 RDR
void p4_bt0_Press(void *ptr) { //touche escalier RdC
if (bitRead(Touche_BP[2],0)==0) { // = 0
bitSet(Touche_BP[2], 0);
}
else {
bitClear(Touche_BP[2],0);
}
}//fin void
void p4_bt1_Press(void *ptr) { //sejour
if (bitRead(Touche_BP[2],1)==0) { // = 0
bitSet(Touche_BP[2], 1);
}
else {
bitClear(Touche_BP[2],1);
}
}//fin void
void p4_bt2_Press(void *ptr) { //cuisine
if (bitRead(Touche_BP[2],2)==0) { // = 0
bitSet(Touche_BP[2], 2);
}
else {
bitClear(Touche_BP[2],2);
}
}//fin void
void p4_bt3_Press(void *ptr) { //lumière Ambiance
if (bitRead(Touche_BP[2],3)==0) { // = 0
bitSet(Touche_BP[2], 3);
}
else {
bitClear(Touche_BP[2],3);
}
}//fin void
void p4_bt4_Press(void *ptr) { //entrée
if (bitRead(Touche_BP[2],4)==0) { // = 0
bitSet(Touche_BP[2], 4);
}
else {
bitClear(Touche_BP[2],4);
}
}//fin void
void p4_bt5_Press(void *ptr) { //touche Extérieur
if (bitRead(Touche_BP[2],5)==0) { // = 0
bitSet(Touche_BP[2], 5);
}
else {
bitClear(Touche_BP[2],5);
}
}//fin void
void p4_bt6_Press(void *ptr) { //touche Escelier RdC
if (bitRead(Touche_BP[2],6)==0) { // = 0
bitSet(Touche_BP[2], 6);
}
else {
bitClear(Touche_BP[2],6);
}
}//fin void
void p4_bt7_Press(void *ptr) { //touche
if (bitRead(Touche_BP[2],7)==0) { // = 0
bitSet(Touche_BP[2], 7);
}
else {
bitClear(Touche_BP[2],7);
}
}//fin void
//FIN PAGE 4 RDR
//..................................................
//PAGE 5 NIV 1
void p5_bt0_Press(void *ptr) { //touche escalier RdC
if (bitRead(Touche_BP[3],0)==0) { // = 0
bitSet(Touche_BP[3], 0);
}
else {
bitClear(Touche_BP[3],0);
}
}//fin void
void p5_bt1_Press(void *ptr) { //prise cH D
if (bitRead(Touche_BP[3],1)==0) { // = 0
bitSet(Touche_BP[3], 1);
}
else {
bitClear(Touche_BP[3],1);
}
}//fin void
void p5_bt2_Press(void *ptr) { //prise cH G
if (bitRead(Touche_BP[3],2)==0) { // = 0
bitSet(Touche_BP[3], 2);
}
else {
bitClear(Touche_BP[3],2);
}
}//fin void
void p5_bt3_Press(void *ptr) { //lumière chambre
if (bitRead(Touche_BP[3],3)==0) { // = 0
bitSet(Touche_BP[3], 3);
}
else {
bitClear(Touche_BP[3],3);
}
}//fin void
void p5_bt4_Press(void *ptr) { //SdB
if (bitRead(Touche_BP[3],4)==0) { // = 0
bitSet(Touche_BP[3], 4);
}
else {
bitClear(Touche_BP[3],4);
}
}//fin void
void p5_bt5_Press(void *ptr) { //Couloir
if (bitRead(Touche_BP[3],5)==0) { // = 0
bitSet(Touche_BP[3], 5);
}
else {
bitClear(Touche_BP[3],5);
}
}//fin void
void p5_bt6_Press(void *ptr) { //touche Escelier NIV2
if (bitRead(Touche_BP[3],6)==0) { // = 0
bitSet(Touche_BP[3], 6);
}
else {
bitClear(Touche_BP[3],6);
}
}//fin void
void p5_bt7_Press(void *ptr) { //touche libre
if (bitRead(Touche_BP[3],7)==0) { // = 0
bitSet(Touche_BP[3], 7);
}
else {
bitClear(Touche_BP[3],7);
}
}//fin void
//FIN PAGE 5 NIV1
//..................................................
//PAGE 6 NIV 2
void p6_bt0_Press(void *ptr) { //touche escalier NIV2
if (bitRead(Touche_BP[4],0)==0) { // = 0
bitSet(Touche_BP[4], 0);
}
else {
bitClear(Touche_BP[4],0);
}
}//fin void
void p6_bt1_Press(void *ptr) { //chambre 2
if (bitRead(Touche_BP[4],1)==0) { // = 0
bitSet(Touche_BP[4], 1);
}
else {
bitClear(Touche_BP[4],1);
}
}//fin void
void p6_bt2_Press(void *ptr) { //chambre 3
if (bitRead(Touche_BP[4],2)==0) { // = 0
bitSet(Touche_BP[4], 2);
}
else {
bitClear(Touche_BP[4],2);
}
}//fin void
void p6_bt3_Press(void *ptr) { //sdB
if (bitRead(Touche_BP[4],3)==0) { // = 0
bitSet(Touche_BP[4], 3);
}
else {
bitClear(Touche_BP[4],3);
}
}//fin void
void p6_bt4_Press(void *ptr) { //libre
if (bitRead(Touche_BP[4],4)==0) { // = 0
bitSet(Touche_BP[4], 4);
}
else {
bitClear(Touche_BP[4],4);
}
}//fin void
void p6_bt5_Press(void *ptr) { //libre
if (bitRead(Touche_BP[4],5)==0) { // = 0
bitSet(Touche_BP[4], 5);
}
else {
bitClear(Touche_BP[4],5);
}
}//fin void
void p6_bt6_Press(void *ptr) { //libre
if (bitRead(Touche_BP[4],6)==0) { // = 0
bitSet(Touche_BP[4], 6);
}
else {
bitClear(Touche_BP[4],6);
}
}//fin void
void p6_bt7_Press(void *ptr) { //touche libre
if (bitRead(Touche_BP[4],7)==0) { // = 0
bitSet(Touche_BP[4], 7);
}
else {
bitClear(Touche_BP[4],7);
}
}//fin void
//FIN PAGE 6 NIV2
//page seance
void p8_bt0_Press(void *ptr) { //touche login logout page seance
}
void p8_p3_Press(void *ptr) { //incremente
if (selection_seance<17){
selection_seance++;
}
}//fin void
void p8_p4_Press(void *ptr) { //décrémente
if (selection_seance>=1){
selection_seance--;
}
}//fin void
void p8_n0_Press(void *ptr) { //touche selection debut heure seance
//memo_seance=1;
bitSet(memo_seance, 1);
//bitClear(Touche_BP[4],6);
Serial.println("set bit memo_seance=1");
}//fin void
void p8_n2_Press(void *ptr) { //touche selection debut min seance
bitSet(memo_seance, 2);
Serial.println(" set bit memo_seance=2");
}//fin void
void p8_n3_Press(void *ptr) { //touche selection fin heure seance
bitSet(memo_seance, 3);
Serial.println("set bit memo_seance=3");
}//fin void
void p8_n4_Press(void *ptr) { //touche selection fin min seance
bitSet(memo_seance, 4);
Serial.println("set bit memo_seance=4");
}//fin void
//FIN PAGE SEANCE
//PAGE VISUALISATION
void p9_p3_Press(void *ptr) { //incremente
if (selection_visu<=23){
selection_visu++;
}
}//fin void
void p9_p4_Press(void *ptr) { //décrémente
if (selection_visu>=1){
selection_visu--;
}
}//fin void
//FIN PAGE VISUALISATION
//PAGE CLAVIER
void p11_b9_Press(void *ptr) { //touche selection debut heure seance
bitSet(memo_seance, 5); //info touche enter clavier
Serial.println("touche enter clavier,set bit memo_seance=5");
// Lecture d'un nouveau message de la Nextion.
}//fin void
//Information des pages du Nextion en cours
void page0PushCallback(void *ptr) // If page 0 is loaded on the display, the following is going to execute:
{
CurrentPage = 0; // variable page init
} // End of press event
// Page change event:
void page1PushCallback(void *ptr) // If page 1 is loaded on the display, the following is going to execute:
{
CurrentPage = 1; // variable page main
} // End of press event
// Page change event:
void page2PushCallback(void *ptr) // If page 2 is loaded on the display, the following is going to execute:
{
CurrentPage = 2; // variable page cave
} //Fin Information des pages du Nextion en cours
// Page change event:
void page3PushCallback(void *ptr) // If page 3 is loaded on the display, the following is going to execute:
{
CurrentPage = 3; // variable page rdc
} //Fin Information des pages du Nextion en cours
// Page change event:
void page4PushCallback(void *ptr) // If page 4 is loaded on the display, the following is going to execute:
{
CurrentPage = 4; // variable page rdr
} //Fin Information des pages du Nextion en cours
// Page change event:
void page5PushCallback(void *ptr) // If page 5 is loaded on the display, the following is going to execute:
{
CurrentPage = 5; // variable page niv1
} //Fin Information des pages du Nextion en cours
// Page change event:
void page6PushCallback(void *ptr) // If page 6 is loaded on the display, the following is going to execute:
{
CurrentPage = 6; // variable page niv2
} //Fin Information des pages du Nextion en cours
// Page change event:
void page7PushCallback(void *ptr) // If page 7 is loaded on the display, the following is going to execute:
{
CurrentPage = 7; // variable page CLAVIER
} //Fin Information des pages du Nextion en cours
void page8PushCallback(void *ptr) // If page 8 is loaded on the display, the following is going to execute:
{
CurrentPage = 8; // variable page REGLAGE
} //Fin Information des pages du Nextion en cours
void page9PushCallback(void *ptr) // If page 9 is loaded on the display, the following is going to execute:
{
CurrentPage = 9; // variable page visualisation
} //Fin Information des pages du Nextion en cours
void page10PushCallback(void *ptr) // If page 10 is loaded on the display, the following is going to execute:
{
CurrentPage = 10; // variable page setting
} //Fin Information des pages du Nextion en cours
void page11PushCallback(void *ptr) // If page 11 is loaded on the display, the following is going to execute:
{
CurrentPage = 11; // variable page reglage des seances
} //Fin Information des pages du Nextion en cours
////////////////////////// End of touch events
void do_every_so_often() {
myInt = (myInt + 1) % 101;
// p0_n0.setValue(myInt);
}
void setup() { //A FINIR DE DECLARER
nexInit();
pinMode(ctrl_flux_rs485, OUTPUT);
pinMode(ledPin0,OUTPUT);
pinMode(ledPin1,OUTPUT);
pinMode(ledPin2,OUTPUT);
pinMode(ledPin3,OUTPUT);
pinMode(ledPin4,OUTPUT);
pinMode(ledPin5,OUTPUT);
pinMode(ledPin6,OUTPUT);
pinMode(ledPin7,OUTPUT);
digitalWrite(ledPin0,LOW);
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin3,LOW);
digitalWrite(ledPin4,LOW);
digitalWrite(ledPin5,LOW);
digitalWrite(ledPin6,LOW);
digitalWrite(ledPin7,LOW);
digitalWrite(ctrl_flux_rs485,LOW);
//Pour fonction VOID
//page init
p0_b1.attachPush(p0_b1_Press, &p0_b1);
p0_b0.attachPop(p0_b0_Release, &p0_b0);
p0_b1.attachPop(p0_b1_Release, &p0_b1);
p0_t1.setText("Arduino Text");
// fin page init
//page 1 Main
p1_bt0.attachPush(p1_bt0_Press, &p1_bt0);//touche ballon eau chaude/econo
p1_bt1.attachPush(p1_bt1_Press, &p1_bt1); // touche Alarme
// p1_bt2.attachPush(p1_bt2_Press, &p1_bt2);
p1_bt3.attachPush(p1_bt3_Press, &p1_bt3);// touche LOGIN
p1_bt0.attachPop(p1_bt0_Release, &p1_bt0);
p1_b0.attachPop(p1_b0_Release, &p1_b0);
//Fin page 1 Main
//page 2 Cave
p2_bt0.attachPush(p2_bt0_Press, &p2_bt0);//touche escalier cave
p2_bt1.attachPush(p2_bt1_Press, &p2_bt1); // touche Local technique
p2_bt2.attachPush(p2_bt2_Press, &p2_bt2); //touche cave
p2_bt3.attachPush(p2_bt3_Press, &p2_bt3);// touche passage /grotte
//Fin page 2 Cave
//page 3 RDC
p3_bt0.attachPush(p3_bt0_Press, &p3_bt0);//touche Escalier Cave
p3_bt1.attachPush(p3_bt1_Press, &p3_bt1); // touche Descente Volet
p3_bt2.attachPush(p3_bt2_Press, &p3_bt2);//montee Volet
p3_bt3.attachPush(p3_bt3_Press, &p3_bt3);// touche Buanderie
p3_bt4.attachPush(p3_bt4_Press, &p3_bt4);//touche Pièce 2
p3_bt5.attachPush(p3_bt5_Press, &p3_bt5); // touche extérieur
p3_bt6.attachPush(p3_bt6_Press, &p3_bt6); // escalier RdC
p3_bt7.attachPush(p3_bt7_Press, &p3_bt7);// touche Libre
//Fin page 3 RDC
//page 4 RDR
p4_bt0.attachPush(p4_bt0_Press, &p4_bt0);//touche Escalier RdC
p4_bt1.attachPush(p4_bt1_Press, &p4_bt1); // touche Séjour
p4_bt2.attachPush(p4_bt2_Press, &p4_bt2);//cuisine
p4_bt3.attachPush(p4_bt3_Press, &p4_bt3);// touche Lumière Ambiance
p4_bt4.attachPush(p4_bt4_Press, &p4_bt4);//touche entrée
p4_bt5.attachPush(p4_bt5_Press, &p4_bt5); // touche escalier niveau 1
p4_bt6.attachPush(p4_bt6_Press, &p4_bt6); // Libre
p4_bt7.attachPush(p4_bt7_Press, &p4_bt7);// touche Libre
//Fin page 4 RDR
//page 5 NIV 1
p5_bt0.attachPush(p5_bt0_Press, &p5_bt0);//touche Escalier NiV1
p5_bt1.attachPush(p5_bt1_Press, &p5_bt1); // prise CH D
p5_bt2.attachPush(p5_bt2_Press, &p5_bt2);//prise CH G
p5_bt3.attachPush(p5_bt3_Press, &p5_bt3);// touche Chambre
p5_bt4.attachPush(p5_bt4_Press, &p5_bt4);//touche SdB
p5_bt5.attachPush(p5_bt5_Press, &p5_bt5); // couloir
p5_bt6.attachPush(p5_bt6_Press, &p5_bt6); // touche Escalier NiV2
p5_bt7.attachPush(p5_bt7_Press, &p5_bt7);//touche libre
//Fin page 5 NIV 1
//page 5 NIV 2
p6_bt0.attachPush(p6_bt0_Press, &p6_bt0);//touche Escalier NiV2
p6_bt1.attachPush(p6_bt1_Press, &p6_bt1); // chambre 2
p6_bt2.attachPush(p6_bt2_Press, &p6_bt2);//chambre 3
p6_bt3.attachPush(p6_bt3_Press, &p6_bt3);// touche SdB
p6_bt4.attachPush(p6_bt4_Press, &p6_bt4);//libre
p6_bt5.attachPush(p6_bt5_Press, &p6_bt5); // libre
p6_bt6.attachPush(p6_bt6_Press, &p6_bt6); // libre
p6_bt7.attachPush(p6_bt7_Press, &p6_bt7);//touche libre
//Fin page 5 NIV 2
//page seance
p8_bt0.attachPush(p8_bt0_Press, &p8_bt0);//touche login logout page seance
p8_p3.attachPush(p8_p3_Press, &p8_p3);//defilement +
p8_p4.attachPush(p8_p4_Press, &p8_p4);//defilement -
p8_n0.attachPush(p8_n0_Press, &p8_n0);//touche selection debut heure seance
p8_n2.attachPush(p8_n2_Press, &p8_n2);//touche selection debut heure seance
p8_n3.attachPush(p8_n3_Press, &p8_n3);//touche selection debut heure seance
p8_n4.attachPush(p8_n4_Press, &p8_n4);//touche selection debut heure seance
//Page Visualisation
p9_p3.attachPush(p9_p3_Press, &p9_p3);//defilement +
p9_p4.attachPush(p9_p4_Press, &p9_p4);//defilement -
//page clavier
p11_b9.attachPush(p11_b9_Press, &p11_b9);//touche Enter
//touche selection fin min seance
//page
page0.attachPush(page0PushCallback); // Page press event
page1.attachPush(page1PushCallback); // Page press event
page2.attachPush(page2PushCallback); // Page press event
page3.attachPush(page3PushCallback); // Page press event
page4.attachPush(page4PushCallback); // Page press event
page5.attachPush(page5PushCallback); // Page press event
page6.attachPush(page6PushCallback); // Page press event
page7.attachPush(page7PushCallback); // Page press event
page8.attachPush(page8PushCallback); // Page press event
page9.attachPush(page9PushCallback); // Page press event
page10.attachPush(page10PushCallback); // Page press event
page11.attachPush(page11PushCallback); // Page press event
//page
next = millis();
digitalWrite(ledPin0,HIGH);
delay (2000);
digitalWrite(ledPin0,LOW);
Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2); // port de communication nextion
Serial1.begin(19200, SERIAL_8N1, RXD1, TXD1);// port rs 485
Serial.begin(115200);// port de visualisation usb |
Partager