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 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826
| #include <Rotary.h>
/*--------------------------------------------------------------
Program: Synthesizer on Mega 2560 v2.f modifié pour le projet 14HAM-DK2
Description: Synthesizer Mega 2560, Si5351
Hardware: Arduino Mega . 3.2 TFT display for rduino Mega connected to standard pins used in
Arduino example sketches from IDE.
Software: Developed using Arduino 1.6.11 software on WINDOWS 7x86
Date: May.......... 2018 8 :)
Modifié le 19/01/2025
Author: UB7KPV
Modificateur: F4JGL
--------------------------------------------------------------*/
//******************** CONNECTER LES BIBLIOTHÈQUES ****************
#include "Rotary.h"
Rotary r = Rotary(2, 3);//Setup a RoraryEncoder for pins 2 and 3:
//*************************************************************
#include <EEPROM.h>
// POUR UN TRAVAIL CORRECT DE ROTATION DE L'ÉCRAN, IL FAUT ALLER DANS LE DOSSIER AVEC LA BIBLIOTHÈQUE TFT_HX8357
//( C:\Users\desktop\Documents\Arduino\libraries\TFT_HX8357-master )
//ET MODIFIEZ LE FICHIER User_Setup EN COMMENTANT #define ILI9481 (#define HX8357B COMMENT OUT)
//*************************************************************
#include "TFT_HX8357.h" // Hardware-specific library
TFT_HX8357 tft = TFT_HX8357(); // Invoke custom library
#include "z_Free_Fonts.h" // Include the header file attached to this sketch
//#define TFT_GREY1 0x8410 // New colour // ICI ON CORRIGE LA COULEUR GRIS !!!!! 11 0x8410 - LABEL VERT 0x39E7 - LABEL JAUNE
//*************************************************************
#include "Wire.h"
#include "si5351.h"
Si5351 si5351;
//*************************** RTC ********************************************************
#include <DS3231.h>
// Init the DS3231 using the hardware interface
DS3231 rtc(SDA,SCL);
// Init a Time-data structure
Time t;
//*************************************************************
//************************************************ SI570 *******************************
/*
* A lean version of the Si570 sketch to test an si570
* Wiring details on <a href="http://blog.riyas.org" target="_blank">http://blog.riyas.org</a>
*
* Modified from Radiono - The Minima's Main Arduino Sketch (from : <a href="http://github.com/afarhan/radiono" target="_blank">http://github.com/afarhan/radiono</a> )
* Copyright (C) 2013 Ashar Farhan
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/ // <a href="https://www.riyas.org/2015/10/simple-arduino-sketch-and-pcb-to-test-Si570-from-silab.html" target="_blank">https://www.riyas.org/2015/10/simple...rom-silab.html</a>
#define __ASSERT_USE_STDERR
#include <assert.h>
/*
* Wire is only used from the Si570 module but we need to list it here so that
* the Arduino environment knows we need it.
*/
#include <Wire.h>
#include <avr/io.h>
#include "Si570.h"
#define SI570_I2C_ADDRESS 0x55
Si570 *vfo;
//int count = 0;
//char b[20], c[20], printBuff[32];
#define clock 4 // retour aux ports de gestion des registres
#define data 14
#define latch 5
//******************** FIXER LES VARIABLES ********************
uint32_t VFO_A ;
uint32_t VFO_B ;
uint32_t VFO_temp ;
uint32_t VFO_temp_output;
uint32_t VFO_opp_prev;
uint32_t VFO_chanel_1 ;
uint32_t VFO_chanel_2 ;
uint32_t VFO_chanel_3 ;
uint32_t VFO_chanel_4 ;
uint32_t VFO_chanel_5 ;
uint32_t VFO_chanel_6 ;
uint32_t VFO_chanel_7 ;
uint32_t VFO_chanel_8 ;
uint32_t VFO_chanel_9 ;
uint32_t VFO_chanel_10;
uint32_t VFO_chanel_11;
uint32_t VFO_chanel_12;
uint32_t VFO_chanel_13;
uint32_t VFO_chanel_14;
uint32_t VFO_chanel_15;
uint32_t VFO_chanel_16;
long Mode_A;
long Mode_B;
long Mode_temp = 1; // bit: 0-ATT; 1- PRE; 2-fast; 3- flag for calibration Smetr; 4/5/6 - MODE; 7- rit;
long Mode_temp_prev ;
byte modulation;
byte modulation_prev;
long Mode_chanel_1;
long Mode_chanel_2;
long Mode_chanel_3;
long Mode_chanel_4;
long Mode_chanel_5;
long Mode_chanel_6;
long Mode_chanel_7;
long Mode_chanel_8;
long Mode_chanel_9;
long Mode_chanel_10;
long Mode_chanel_11;
long Mode_chanel_12;
long Mode_chanel_13;
long Mode_chanel_14;
long Mode_chanel_15;
long Mode_chanel_16;
byte VFO_prev= 11;
byte VFO;
byte VFO_picked = 0;
byte VFO_picked_flag = 0;
boolean A_copy_B;
//*************************************
byte chanel_counter_prev = 3;
byte chanel_counter = 3;
byte load_chanel_for_VFO_A = 3;
byte load_chanel_for_VFO_B = 3;
boolean flag_key_0;
boolean flag_key_1;
boolean flag_key_2;
boolean flag_key_3;
boolean flag_key_4;
boolean flag_key_5;
boolean flag_key_6;
boolean flag_key_7;
boolean flag_key_8;
boolean flag_key_9;
boolean flag_key_10;
boolean flag_key_11;
boolean flag_key_12;
boolean flag_key_13;
boolean flag_key_14;
boolean flag_key_15;
boolean flag_key_16;
//******************** keyboard
int keyboard_pin = 5; // on mesure la tension au port 5 keyboard_pin
byte keyboard_cycle_counter;
long keyboard_value;
long keyboard_value_1;
long keyboard_value_2;
long keyboard_value_3;
long currentMillisB;
long previousMillisB;
//******************** Encoder
boolean lock = false;
boolean lock_prev = true;
byte Encoder_divider_couter;
byte Encoder_divider;
long increment;
long first_speed_step;
long currentMillis;
long previousMillis;
long En_speed_2;
long Step_int_2;
long En_speed_1;
long Step_int_1;
//********************************
//************************ CAT
long serial_temp0;
byte comand_1;
byte comand_2;
byte Terminator;
byte serial_temp2;
byte serial_temp3;
byte serial_temp4;
byte serial_temp5;
byte serial_temp6;
byte serial_temp7;
byte serial_temp8;
byte serial_temp9;
byte serial_temp10;
byte serial_temp11;
byte flag_CAT_write_A;
byte flag_CAT_write_B;
//***************** variables pour la décomposition en dizaines ?????????????????????????????
byte millions1000 ;
byte millions100 ;
byte millions10 ;
byte millions1 ;
byte thousands100 ;
byte thousands10;
byte thousands1 ;
byte hundreds ;
byte tens ;
long result0 ;
byte prev_millions1000= 11 ;
byte prev_millions100=11 ;
byte prev_millions10=11 ;
byte prev_millions1=11 ;
byte prev_thousands100 =11 ;// 11 à imprimer au début 0
byte prev_thousands10 =11 ; // définir les noms des registres pour le résultat précédent sur les affichages
byte prev_thousands1 =11;
byte prev_hundreds =11;
byte prev_tens =11;
int X_coordinate;
int Y_coordinate;
//*****************************
uint32_t S_level_1;
uint32_t S_level_5;
uint32_t S_level_7;
uint32_t S_level_9;
uint32_t S_level_10;
uint32_t S_level_20;
uint32_t S_level_30;
uint32_t S_level_40;
uint32_t S_level_50;
uint32_t S_level_60;
uint32_t S_level_1_ATT;
uint32_t S_level_5_ATT;
uint32_t S_level_7_ATT;
uint32_t S_level_9_ATT;
uint32_t S_level_10_ATT;
uint32_t S_level_20_ATT;
uint32_t S_level_30_ATT;
uint32_t S_level_40_ATT;
uint32_t S_level_50_ATT;
uint32_t S_level_1_PRE;
uint32_t S_level_5_PRE;
uint32_t S_level_7_PRE;
uint32_t S_level_9_PRE;
uint32_t S_level_10_PRE;
uint32_t S_level_20_PRE;
uint32_t S_level_30_PRE;
uint32_t S_level_40_PRE;
uint32_t S_level_50_PRE;
uint32_t S_level_1_TEMP;
uint32_t S_level_5_TEMP;
uint32_t S_level_7_TEMP;
uint32_t S_level_9_TEMP;
uint32_t S_level_10_TEMP;
uint32_t S_level_20_TEMP;
uint32_t S_level_30_TEMP;
uint32_t S_level_40_TEMP;
uint32_t S_level_50_TEMP;
uint32_t S_level_temp;
uint32_t valueS_temp;
uint32_t S_level_temp2;
uint32_t Start_point;
uint32_t End_point;
uint32_t S_meter_pick;
uint32_t S_meter_pick2;
uint32_t S_meter_pick3;
int pick_time;
uint32_t P_meter_pick;
uint32_t P_meter_pick2;
uint32_t P_meter_pick3;
int P_pick_time;
uint32_t SWR_meter_pick;
uint32_t SWR_meter_pick2;
uint32_t SWR_meter_pick3;
int SWR_pick_time;
byte S_P_meter_counter;
//************************ divers
byte RTC_enable;
byte prev_time = 100; /// pour afficher l'heure au début du programme. écrivez 100 car il n'y a pas de valeur pendant plus de 60min
byte Hours = 100;
byte Minutes = 100;
byte BFO_drive_strength;
byte VFO_drive_strength;
byte time_S = 0 ; // registre de temps
uint32_t valueS;
boolean flag_RX_TX = true ;
byte Step_temp_prev;
byte Step_temp;
long temp2;
byte flag_M;
uint32_t temp_reg_24_1;
boolean Split;
boolean Split_prev_state=11;
boolean XFC;
uint32_t temp_4bit_reg_1;
byte Band_Filter;
uint32_t r_1st_filter_switch_freq ;
uint32_t r_2nd_filter_switch_freq ;
uint32_t r_3rd_filter_switch_freq ;
uint32_t r_4th_filter_switch_freq ;
uint32_t r_5th_filter_switch_freq ;
uint32_t r_6th_filter_switch_freq ;
uint32_t r_7th_filter_switch_freq ;
uint32_t r_8th_filter_switch_freq ;
uint32_t r_9th_filter_switch_freq ;
uint32_t r_10th_filter_switch_freq ;
uint32_t r_11th_filter_switch_freq ;
uint32_t r_12th_filter_switch_freq ;
uint32_t r_13th_filter_switch_freq ;
uint32_t r_14th_filter_switch_freq ;
uint32_t r_15th_filter_switch_freq ;
uint32_t r_1st_transverter_freq;
uint32_t r_1st_transverter_LO_freq;
uint32_t r_2nd_transverter_freq;
uint32_t r_2nd_transverter_LO_freq;
uint32_t r_3rd_transverter_freq;
uint32_t r_3rd_transverter_LO_freq;
uint32_t r_4th_transverter_freq;
uint32_t r_4th_transverter_LO_freq;
uint32_t r_5th_transverter_freq;
uint32_t r_5th_transverter_LO_freq;
long oscillator_freq ; // étalonnage de la souris
long Si570_oscillator_freq ; // étalonnage de la souris
long USB_IF;
long LSB_IF;
long CW_IF;
long FM_IF;
long AM_IF;
long temp_IF;
long USB_BFO;
long LSB_BFO;
long CW_BFO;
long FM_BFO;
long AM_BFO;
long temp_BFO;
long CW_tone ;
byte FM_Mode;
byte AM_Mode;
//***************** variables pour les registres à décalage
byte reg1=0; // 1 majuscule pour le décalage
byte reg2=0;
byte reg3=0;
byte reg4=0;
//*************
byte multiplier;
byte Screen_rotation;
byte Screen_negative;
byte Grey_color_correction;
byte Syn_config;
//long Color_1 ;
//long Color_2 ;
long TFT_GREY1 = 0x8410 ; //#define TFT_GREY1 0x8410 // New colour // ICI ON CORRIGE LA COULEUR GRIS !!!!! 11 0x8410 - LABEL VERT 0x39E7 - LABEL JAUNE
long TFT_GREY2;
byte flag_plus_or_minus_IF;
byte number_of_channels = 9;
byte Reverse_side_signal;
byte Reverse_side_command;
byte rit_by_resistor;
long rit = 0 ; // registre de réglage
int rit0 = 0 ; // réglage du registre pour étendre en dizaines
byte thousands_rit ;
byte hundreds_rit ; // registres à prendre en compte par 10 pour le réglage
byte tens_rit ;
int prev_thousands_rit=11;//ancienne valeur affichée
boolean negativ_rit=false; // indicateur de valeur de réglage négative
long Freq_BFO_prev;
long Freq_VFO_prev;
uint64_t Syn_freq = 0 ; // registre pour la sortie fréquence fréquence uint64_t !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
long temp1;
//long temp2;
long temp3;
byte Sequence;
byte Synthesizer_chip;
//********************************
int Voltmter =0; // nous mesurons la tension au port 0
int old_volt = 2000; // de sorte que s'il y a 0 au début, alors les lectures sont mises à jour
byte temp_volt;
//******shift ???????????
//int Mode_temp_prev;
unsigned long prev ; //
long sift_prev = 1000;
long sift;
int Shift = 6; // on mesure la tension au port 6 Shift
boolean shift_tx ;
long sift_tx;
//********
//************* SWR
byte SWR_On_Off;
byte SWR_flag_1;
byte P_SWR_cycle_counter;
long SWR_forward= 200;
long SWR_reflected= 50;
long SWR_result;
byte SWR_pick;
long P_result;
byte one;
byte decimal;
byte one_prev = 11;
byte decimal_prev = 11;
//************************ inputs/outputs
int tx_out = A10; // port de gestion tx/rx
int tx = A9; // port de contrôle d'état rx/tx
int S_metr = 8; // mesurer la tension au port 8 S_metr
int SWR_forward_pin= 3;
int SWR_reflected_pin = 4;
int RIT_pin = A7;
//*************************************************************
void setup() {
delay (100);
Serial.begin(57600); // régler la vitesse du système CAT sur 57600
//Wire.begin();
//Wire.setClock(10000);
rtc.begin();
//************* bouton d'interruption *************
attachInterrupt(digitalPinToInterrupt(2), interrupt, CHANGE);
attachInterrupt(digitalPinToInterrupt(3), interrupt, CHANGE);
//***************** réglage de l'affichage ************************
tft.init();
tft.setRotation(1);//3
tft.fillScreen(0x0000); // стираем всё
//************************ inputs/outputs settings
pinMode(tx, INPUT); // définit le mode de fonctionnement - entrée pour le port rx / tx
digitalWrite(tx, HIGH); // activer la résistance de rappel
pinMode(tx_out, OUTPUT); //port de contrôle de transmission
digitalWrite(tx_out, LOW);
//************** configuration des ports pour les registres
pinMode(data, OUTPUT);
pinMode(clock, OUTPUT);
pinMode(latch, OUTPUT);
digitalWrite(clock, HIGH);
default_settings ();
menu (); // aller au menu des services
//**************** PROGRAMME D'AFFICHAGE D'INFO PERMANENT
tft.setTextColor(TFT_WHITE );
temp1= 64; // coordonnée x
temp2= 292; //coordonnée y pour les tirets
temp3= 318;// coordonnée y pour les nombres
tft.fillRect(temp1+72, temp2, 3, 9, TFT_WHITE); tft.setCursor(127, temp3); tft.println("25");// tracer des lignes et des nombres à partir d'un mètre
tft.fillRect(temp1+144, temp2, 3, 9, TFT_WHITE); tft.setCursor(198, temp3); tft.println("50");// tracer des lignes et des nombres à partir d'un mètre
tft.fillRect(temp1+216, temp2, 3, 9, TFT_WHITE); tft.setCursor(270, temp3); tft.println("75");// tracer des lignes et des nombres à partir d'un mètre
tft.fillRect(temp1+288, temp2, 3, 9, TFT_WHITE); tft.setCursor(337, temp3); tft.println("100");// tracer des lignes et des nombres à partir d'un mètre
tft.fillRect(temp1, temp2, 355, 3, TFT_WHITE);// ligne P mètres
tft.fillRect(temp1 , 265, 355, 3, TFT_WHITE);// ligne swr mètre
temp1= 56; // coordonnée x
tft.setTextColor(TFT_WHITE);
tft.setFreeFont(FF33);//21
tft.fillRect(temp1+70 , 265, 21, 3, TFT_BLACK); //effacer la ligne pour les nombres
tft.fillRect(temp1+150 , 265, 21, 3, TFT_BLACK);
tft.fillRect(temp1+230 , 265, 21, 3, TFT_BLACK);
tft.fillRect(temp1+310 , 265, 21, 3, TFT_BLACK);
tft.setCursor(temp1+76, 271); tft.println("2");// tracer des lignes et des nombres à partir d'un mètre
tft.setCursor(temp1+156, 271); tft.println("3");// tracer des lignes et des nombres à partir d'un mètre
tft.setCursor(temp1+236, 271); tft.println("4");// tracer des lignes et des nombres à partir d'un mètre
tft.setCursor(temp1+316, 271); tft.println("5");// tracer des lignes et des nombres à partir d'un mètre
// 284 227 57 28 27
temp1= 64; // coordonnée x
temp2= 227; //coordonnée y pour les tirets
temp3= 224;// coordonnée y pour les chiffres par mètre
tft.setTextColor(TFT_WHITE );
tft.setFreeFont(FF29);
tft.setCursor(443, 315); tft.println("%");
//tft.setFreeFont(FF34);// FF30 FSSB12 38
tft.setFreeFont(FF41); // 41
tft.setCursor(26, 312); tft.println("P");
tft.setCursor(26, 233); tft.println("S");
tft.setCursor(8, 272); tft.println("SWR");
tft.setFreeFont(FF33);//21
tft.setCursor(440, temp3); tft.println("dB");
tft.setCursor(443, 269); tft.println("o"); // ∞
tft.setCursor(443+8, 269); tft.println("o");
tft.fillRect(temp1, 237, 195, 3, TFT_WHITE);// ligne p mètre
tft.fillRect(temp1+ 200, 237, 155, 3, TFT_RED);// ligne s mètres
tft.fillRect(temp1, temp2+5, 3, 7, TFT_WHITE); tft.setCursor(60, temp3); tft.println("1");// рисуем чёрточки и цыфры с метра tracer des lignes et des nombres à partir d'un mètre
temp1= temp1+24;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_WHITE);
temp1= temp1+24;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_WHITE); tft.setCursor(109, temp3); tft.println("3");// tracer des lignes et des nombres à partir d'un mètre
temp1= temp1+24;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_WHITE);
temp1= temp1+24;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_WHITE); tft.setCursor(158, temp3); tft.println("5");// tracer des lignes et des nombres à partir d'un mètre
temp1= temp1+24;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_WHITE);
temp1= temp1+24;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_WHITE); tft.setCursor(205, temp3); tft.println("7");// tracer des lignes et des nombres à partir d'un mètre
temp1= temp1+24;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_WHITE);
temp1= temp1+24;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_WHITE); tft.setCursor(253, temp3); tft.println("9");// tracer des lignes et des nombres à partir d'un mètre
temp1= temp1+32;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_RED);
temp1= temp1+32;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_RED); tft.setCursor(305, temp3); tft.println("+20");// tracer des lignes et des nombres à partir d'un mètre
temp1= temp1+32;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_RED);
temp1= temp1+32;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_RED); tft.setCursor(367, temp3); tft.println("+40");// tracer des lignes et des nombres à partir d'un mètre
temp1= temp1+32;
tft.fillRect(temp1, temp2+5, 3, 7, TFT_RED);
//************************************************************
//tft.setTextColor(TFT_WHITE );
//tft.setFreeFont(FF30);
//tft.setCursor(416, 68); tft.println("MHz");
//***************
tft.setFreeFont(FF6);
tft.setCursor(285, 139, 1);
tft.println("MODE");
tft.setCursor(60, 17, 1);
tft.setCursor(292, 106, 1);
tft.println("RIT ");
tft.setFreeFont(FF41); // 21
tft.setCursor(10, 182, 1);
tft.println("VCC - V");
//tft.setFreeFont(FF26);//6
tft.drawRoundRect(140, 15, 334, 143, 5,TFT_GREY1 ); //x y width high radius color rectangle A
//***************************** SI 570 ******************************
// The library automatically reads the factory calibration settings of your Si570
// but it needs to know for what frequency it was calibrated for.
// Looks like most HAM Si570 are calibrated for 56.320 Mhz.
// If yours was calibrated for another frequency, you need to change that here
vfo = new Si570(SI570_I2C_ADDRESS, 56320000);
}
//******************* PROGRAMME PRINCIPAL ********************
void loop() {
//Wire.setClock(10000);
//********************* TEST **////////////////////
//tft.setTextColor(TFT_RED);
//tft.setFreeFont(FF1);
//tft.fillRect(10, 182, 100, 20, TFT_BLACK); // nous effaçons l'ancien x y width hight avec une longueur de 20 ne veut pas compiler
//tft.setCursor(10,200, 1);
//tft.println(temp_IF);//currentMillisB
tft.setTextColor(TFT_RED);
tft.setFreeFont(FF1);
//tft.fillRect(10, 182, 100, 20, TFT_BLACK); // nous effaçons l'ancien x y width hight avec une longueur de 20 ne veut pas compiler
//tft.setCursor(10,200, 1);
//tft.println(rtc.getTimeStr());//
//*****************************
CAT ();
keyboard_check (); // allez au SOUS-PROGRAMME DE DETERMINATION DE LA VALEUR ADC SUR LE CLAVIER
//*************************************************************
if (chanel_counter < 1) {chanel_counter = number_of_channels;}
if (chanel_counter > number_of_channels) {chanel_counter = 1;}
//*************************************************************
if (chanel_counter_prev != chanel_counter) { // si nous avons changé de canal, nous sauvegardons la valeur de fréquence et chargeons la nouvelle fréquence
if (flag_CAT_write_A == 1 & VFO_picked == 0 || flag_CAT_write_B == 1 & VFO_picked == 1) { goto skip_save; }
if ( chanel_counter_prev == 1 ){VFO_chanel_1 = VFO_temp; Mode_chanel_1 = Mode_temp;} // enregistrer la fréquence
if ( chanel_counter_prev == 2 ){VFO_chanel_2 = VFO_temp; Mode_chanel_2 = Mode_temp;}
if ( chanel_counter_prev == 3 ){VFO_chanel_3 = VFO_temp; Mode_chanel_3 = Mode_temp;}
if ( chanel_counter_prev == 4 ){VFO_chanel_4 = VFO_temp; Mode_chanel_4 = Mode_temp;}
if ( chanel_counter_prev == 5 ){VFO_chanel_5 = VFO_temp; Mode_chanel_5 = Mode_temp;}
if ( chanel_counter_prev == 6 ){VFO_chanel_6 = VFO_temp; Mode_chanel_6 = Mode_temp;}
if ( chanel_counter_prev == 7 ){VFO_chanel_7 = VFO_temp; Mode_chanel_7 = Mode_temp;}
if ( chanel_counter_prev == 8 ){VFO_chanel_8 = VFO_temp; Mode_chanel_8 = Mode_temp;}
if ( chanel_counter_prev == 9 ){VFO_chanel_9 = VFO_temp; Mode_chanel_9 = Mode_temp;}
if ( chanel_counter_prev == 10 ){VFO_chanel_10 = VFO_temp; Mode_chanel_10 = Mode_temp;}
if ( chanel_counter_prev == 11 ){VFO_chanel_11 = VFO_temp; Mode_chanel_11 = Mode_temp;}
if ( chanel_counter_prev == 12 ){VFO_chanel_12 = VFO_temp; Mode_chanel_12 = Mode_temp;}
if ( chanel_counter_prev == 13 ){VFO_chanel_13 = VFO_temp; Mode_chanel_13 = Mode_temp;}
if ( chanel_counter_prev == 14 ){VFO_chanel_14 = VFO_temp; Mode_chanel_14 = Mode_temp;}
if ( chanel_counter_prev == 15 ){VFO_chanel_15 = VFO_temp; Mode_chanel_15 = Mode_temp;}
if ( chanel_counter_prev == 16 ){VFO_chanel_16 = VFO_temp; Mode_chanel_16 = Mode_temp;}
skip_save:;
if ( chanel_counter == 1 ){VFO_temp = VFO_chanel_1; Mode_temp = Mode_chanel_1;} //
if ( chanel_counter == 2 ){VFO_temp = VFO_chanel_2; Mode_temp = Mode_chanel_2;}
if ( chanel_counter == 3 ){VFO_temp = VFO_chanel_3; Mode_temp = Mode_chanel_3;}
if ( chanel_counter == 4 ){VFO_temp = VFO_chanel_4; Mode_temp = Mode_chanel_4;}
if ( chanel_counter == 5 ){VFO_temp = VFO_chanel_5; Mode_temp = Mode_chanel_5;}
if ( chanel_counter == 6 ){VFO_temp = VFO_chanel_6; Mode_temp = Mode_chanel_6;}
if ( chanel_counter == 7 ){VFO_temp = VFO_chanel_7; Mode_temp = Mode_chanel_7;}
if ( chanel_counter == 8 ){VFO_temp = VFO_chanel_8; Mode_temp = Mode_chanel_8;}
if ( chanel_counter == 9 ){VFO_temp = VFO_chanel_9; Mode_temp = Mode_chanel_9;}
if ( chanel_counter == 10 ){VFO_temp = VFO_chanel_10; Mode_temp = Mode_chanel_10;}
if ( chanel_counter == 11 ){VFO_temp = VFO_chanel_11; Mode_temp = Mode_chanel_11;}
if ( chanel_counter == 12 ){VFO_temp = VFO_chanel_12; Mode_temp = Mode_chanel_12;}
if ( chanel_counter == 13 ){VFO_temp = VFO_chanel_13; Mode_temp = Mode_chanel_13;}
if ( chanel_counter == 14 ){VFO_temp = VFO_chanel_14; Mode_temp = Mode_chanel_14;}
if ( chanel_counter == 15 ){VFO_temp = VFO_chanel_15; Mode_temp = Mode_chanel_15;}
if ( chanel_counter == 16 ){VFO_temp = VFO_chanel_16; Mode_temp = Mode_chanel_16;}
chanel_counter_prev = chanel_counter;
if ( VFO_picked == 0){ load_chanel_for_VFO_A = chanel_counter; // nous enregistrons à partir de quel canal nous chargeons le VFO A/B afin de l'enregistrer plus tard
flag_CAT_write_A = 0;} // et réinitialiser le drapeau d'enregistrement CAT pour VFO_A
else { load_chanel_for_VFO_B = chanel_counter;
flag_CAT_write_B = 0;} // on remet à zéro le drapeau d'enregistrement par CAT pour VFO_B
}
//************************** A=B ***********************************
if ( A_copy_B == true){
A_copy_B = false;// on efface le bit A = B pour ne plus répéter ce programme
VFO_A = VFO_temp; Mode_A = Mode_temp;
VFO_B = VFO_temp; Mode_B = Mode_temp;
load_chanel_for_VFO_A = chanel_counter;
load_chanel_for_VFO_B = chanel_counter;
}
//********************* SOUS-PROGRAMME DE SÉLECTION VFO A/B *************************
if ( VFO == 1 & VFO != VFO_picked_flag) { // on passe de A à B
VFO_picked_flag = VFO ;
VFO_temp = VFO_B; Mode_temp = Mode_B;
chanel_counter = load_chanel_for_VFO_B;
chanel_counter_prev = load_chanel_for_VFO_B;
}
//*******************
if ( VFO == 0 & VFO != VFO_picked_flag) { // on passe de B à A
VFO_picked_flag = VFO ;
VFO_temp = VFO_A; Mode_temp = Mode_A;
chanel_counter = load_chanel_for_VFO_A;
chanel_counter_prev = load_chanel_for_VFO_A;
}
//*************************************************************
bitWrite(modulation, 0, bitRead(Mode_temp, 4));
bitWrite(modulation, 1, bitRead(Mode_temp, 5));
bitWrite(modulation, 2, bitRead(Mode_temp, 6));
//*************************************************************
// cat !!!!
if (VFO == false) { VFO_A = VFO_temp; Mode_A = Mode_temp; }
else { VFO_B = VFO_temp; Mode_B = Mode_temp; }
//*************************************************************
//*********************** SOUS-PROGRAMME SPLIT !!!!
if ( Split==true & digitalRead(tx) == LOW ){
if (VFO_picked==true){VFO = false;}
if (VFO_picked==false){VFO = true;} } // si la division et le transfert sont activés alors nous inversons A et B
else {VFO = VFO_picked;} // sinon le VFO est égal à celui sélectionné
//*********sous-programme XFC
if ( XFC==true ){ //allumé si le bouton est enfoncé pendant plus de 130 ms et le mode de réception
if (VFO_picked==true){VFO = false;} // si XFC est activé alors nous inversons A et B
if (VFO_picked==false){VFO = true;}
tft.setTextColor(TFT_RED);
tft.setFreeFont(FF41);//6
tft.setCursor(140, 182, 1); // afficher l'inscription XFC
tft.println("XFC"); }
else {tft.fillRect(135, 165, 45, 20, TFT_BLACK);}// ou effacer
XFC=false; //nous réinitialisons le drapeau si le bouton est toujours enfoncé il s'installera
//*********************** Commutation des filtres passe-bande ***********************
Band_Filter = 0; // ZERO_filter_switch_freq
if (VFO_temp > r_1st_filter_switch_freq ) {Band_Filter = 1;}
if (VFO_temp > r_2nd_filter_switch_freq ) {Band_Filter = 2;}
if (VFO_temp > r_3rd_filter_switch_freq ) {Band_Filter = 3;}
if (VFO_temp > r_4th_filter_switch_freq ) {Band_Filter = 4;}
if (VFO_temp > r_5th_filter_switch_freq ) {Band_Filter = 5;}
if (VFO_temp > r_6th_filter_switch_freq ) {Band_Filter = 6;}
if (VFO_temp > r_7th_filter_switch_freq ) {Band_Filter = 7;}
if (VFO_temp > r_8th_filter_switch_freq ) {Band_Filter = 8;}
if (VFO_temp > r_9th_filter_switch_freq ) {Band_Filter = 9;}
if (VFO_temp > r_10th_filter_switch_freq ) {Band_Filter = 10;}
if (VFO_temp > r_11th_filter_switch_freq ) {Band_Filter = 11;}
if (VFO_temp > r_12th_filter_switch_freq ) {Band_Filter = 12;}
if (VFO_temp > r_13th_filter_switch_freq ) {Band_Filter = 13;}
if (VFO_temp > r_14th_filter_switch_freq ) {Band_Filter = 14;}
if (VFO_temp > r_15th_filter_switch_freq ) {Band_Filter = 15;}
//************* SOUS-PROGRAMME DE SORTIE DE 2 OCTETS VERS LES REGISTRES
bitClear(reg1,0);// nous réinitialisons les anciens bits pour contrôler la bande
bitClear(reg1,1);
bitClear(reg1,2);
bitClear(reg1,3);
reg1 = reg1 + Band_Filter ; // écrire de nouveaux bits pour contrôler la bande
//****** АТТ PRE
if ( digitalRead(tx) == LOW ){bitClear(reg1,4);bitClear(reg1,5);} // si tx, désactivez ATT et PRE
else {
// si la réception, alors nous réglons les battements en fonction des modes Mode_temp; // bit: 0-ATT; 1- PRE; 2-fast; 3- flag for calibration Smetr; 4/5/6 - MODE; 7- rit;
if ( bitRead(Mode_temp,0)==1 ){bitSet(reg1,4);} // ATT
else {bitClear(reg1,4);}
if ( bitRead(Mode_temp,1)==1 ){bitSet(reg1,5);} //PRE
else {bitClear(reg1,5);}
}
//*****************
if (modulation == 3){bitSet(reg1,6);} // CW
else {bitClear(reg1,6);}
//**************************
if (Reverse_side_signal == 1 && Reverse_side_command == 1){bitSet(reg2,2);} // nous émettons un signal pour contrôler le côté réversible.
else if (Reverse_side_signal == 1) {bitClear(reg2,2);}
//**************************
if (modulation == 4 && FM_Mode == 1){bitSet(reg2,3);} // FM
else if (FM_Mode == 1) {bitClear(reg2,3);}
//**************************
if (modulation == 5 && AM_Mode == 1){bitSet(reg2,4);} // AM
else if (AM_Mode == 1) {bitClear(reg2,4);}
//******************* Р399 **************************
temp_reg_24_1 = VFO_temp; // étendre la fréquence actuelle
//************* SOUS-PROGRAMME DECOMPOSITION DES DIZAINES
millions100 =((temp_reg_24_1/100000000)%10);
millions10 = ((temp_reg_24_1/10000000)%10);
millions1 = ((temp_reg_24_1/1000000)%10);
thousands100 = ((temp_reg_24_1/100000)%10);
thousands10 = ((temp_reg_24_1/10000)%10);
reg3 = thousands10 + (thousands100 * 256);
reg4 = millions1 + (millions10 * 256);
if (millions10 >= 4) { bitSet(reg4,7); bitClear(reg4,6);}
else { bitSet(reg4,6); bitClear(reg4,7);}
//***********************************************************
//****** sortie 4 octets
digitalWrite(latch, LOW);
shiftOut(data, clock, MSBFIRST, reg4);
shiftOut(data, clock, MSBFIRST, reg3);//
shiftOut(data, clock, MSBFIRST, reg2);
shiftOut(data, clock, MSBFIRST, reg1);//
digitalWrite(latch, HIGH);
//*******************
// VFO_freq_out ();
//************* SOUS-PROGRAMME DE RETRAIT POUR SI 5351
if (Syn_config == 0 && VFO_temp > 12000000) {flag_plus_or_minus_IF = 0;} //si la configuration est pour + - IF et que la fréquence est supérieure à 12 MHz, alors on soustrait le IF
else {flag_plus_or_minus_IF = 1;} // sinon, on aditionne
if ( digitalRead(tx) == HIGH & shift_tx == true ){goto skip2;}//si la réception et la correction shift_tx sont activées, ignorer l'ajout de décalage
if ( flag_plus_or_minus_IF == 0 && modulation == 2 || flag_plus_or_minus_IF == 1 && modulation == 1 ){temp_IF = temp_IF + sift;} //- si la bande est inversée, alors nous inversons la valeur de décalage
else { temp_IF = temp_IF - sift;}
skip2:
//************************** Transverter OFFSET **********************************
VFO_temp_output = VFO_temp;
if (VFO_temp_output >= r_5th_transverter_freq ) { VFO_temp_output = VFO_temp_output - r_5th_transverter_LO_freq; goto OFFSET_out;}
if (VFO_temp_output >= r_4th_transverter_freq ) { VFO_temp_output = VFO_temp_output - r_4th_transverter_LO_freq; goto OFFSET_out;}
if (VFO_temp_output >= r_3rd_transverter_freq ) { VFO_temp_output = VFO_temp_output - r_3rd_transverter_LO_freq; goto OFFSET_out;}
if (VFO_temp_output >= r_2nd_transverter_freq ) { VFO_temp_output = VFO_temp_output - r_2nd_transverter_LO_freq; goto OFFSET_out;}
if (VFO_temp_output >= r_1st_transverter_freq ) { VFO_temp_output = VFO_temp_output - r_1st_transverter_LO_freq;}
OFFSET_out:;
//**********************************************************************************
if ( flag_plus_or_minus_IF == 0 ){Syn_freq = VFO_temp_output - temp_IF;} // ajouter ou soustraire l'oscillateur temp_IF
else { Syn_freq = VFO_temp_output + temp_IF;}
//************** routine de configuration 1.1 ( Si-шная часть часть Si partie partie )
if (bitRead(Mode_temp,7)==1 & digitalRead(tx) == HIGH ){ // si la rastérisation et le mode réception sont activés
Syn_freq = Syn_freq + rit ; } // ajouter rit à la fréquence de sortie
//**************
if (VFO_drive_strength == 0) {si5351.drive_strength(SI5351_CLK1, SI5351_DRIVE_2MA);}
if (VFO_drive_strength == 1) {si5351.drive_strength(SI5351_CLK1, SI5351_DRIVE_4MA);}
if (VFO_drive_strength == 2) {si5351.drive_strength(SI5351_CLK1, SI5351_DRIVE_6MA);}
if (VFO_drive_strength == 3) {si5351.drive_strength(SI5351_CLK1, SI5351_DRIVE_8MA);}
if (Freq_VFO_prev != Syn_freq){ // vérifier la fréquence précédente pour ne plus la restituer
Freq_VFO_prev = Syn_freq;
if ( Synthesizer_chip == 1) { // IF SI570
Syn_freq = Syn_freq*multiplier; // multiplier par 10 et sortir la fréquence
vfo->setFrequency(Syn_freq);
}
else { // IF SI5351
Syn_freq = Syn_freq*100ULL*multiplier; // multiplier par 100 et sortir la fréquence SI5351_PLL_FIXED
si5351.set_freq(Syn_freq,SI5351_PLL_FIXED, SI5351_CLK1);
}
}
else { delay (4);}/// on compense le temps si on ne change pas la fréquence pour que le cycle du programme soit approximativement le même
//********************************************************************
//************************** RIT by Resistor ***********************
if (rit_by_resistor == 1) {
// rit = u/((10230000-u)/1060) où 1060 est + -530, u est la valeur ADC
// u*10000 ! se débarrasser de la virgule dans les calculs
// cette complication est nécessaire pour que la résistance rit puisse être connectée via 2 fils
//***************************** partie commune ******************
if (temp_volt == 0 || temp_volt == 10 ) { // nous mesurons tous les 10 cycles à l'aide d'un compteur de cycles pour un voltmètre
rit = analogRead(RIT_pin); // lire
rit = analogRead(RIT_pin); // lire
if (rit > 600){rit = 340;} //
rit = rit*10000;
temp1 = (10230000 - rit)/1060; // où 1060 est + -530
rit = rit/temp1;
rit = rit - 530 ; // on soustrait la moitié pour que la position moyenne soit 0
rit = ((rit/10)%300);// on le décompose en dizaines pour que le décalage change après 10 Hz
rit = rit*10;
if (rit>0){rit = rit-10;} // étendre la zone zéro pour le décalage. 0 à + -30 équivaudra à 0*! pour qu'il soit plus facile d'attraper 0*!
if (rit>0){rit = rit-10;}
if (rit>0){rit = rit-10;}
if (rit<0){rit = rit+10;}
if (rit<0){rit = rit+10;}
if (rit<0){rit = rit+10;}
if (rit>500){rit = 500;}// on le limite pour qu'il ne dépasse pas 500 Hz au bord
}
}
//************** routine de configuration 1.2 ( décomposition en dizaines )
if (rit < -9999){ rit = -9999; } // limiteurs
if (rit > 9999){ rit = 9999; }
rit0 = rit; // copier vers rit0 pour l'expansion
if (rit0 < 0){ rit0=rit0*-1; } ; // si l'affichage est dans le rouge, alors on l'inverse !
thousands_rit = ((rit0/1000)%10);
hundreds_rit = ((rit0/100)%10);
tens_rit = ((rit0/10)%10);
//************************** SHIFT *****************************
// shif = u/((10230000-u)/1060) où 1060 est + -530, u est la valeur ADC
// u*10000 ! se débarrasser de la virgule dans les calculs
// cette complication est nécessaire pour que la résistance de décalage puisse être connectée via 2 fils
//***************************** partie commune ******************
if (temp_volt == 0 || temp_volt == 10 ) { // nous mesurons tous les 10 cycles à l'aide d'un compteur de cycles pour un voltmètre
sift = analogRead(Shift); // lire
sift = analogRead(Shift); // lire
if (sift > 600){sift = 340;} //si la résistance shift n'est pas connectée alors on fait shift = 0
sift = sift*10000;
temp1 = (10230000 - sift)/1060; // où 1060 est + -530
sift = sift/temp1;
sift = sift - 530 ; // on soustrait la moitié pour que la position moyenne soit 0
sift = ((sift/10)%300);// on le décompose en dizaines pour que le décalage change après 10 Hz
sift = sift*10;
if (sift>0){sift = sift-10;} // étendre la zone zéro pour le décalage. 0 à + -30 équivaudra à 0*! pour qu'il soit plus facile d'attraper 0*!
if (sift>0){sift = sift-10;}
if (sift>0){sift = sift-10;}
if (sift<0){sift = sift+10;}
if (sift<0){sift = sift+10;}
if (sift<0){sift = sift+10;}
if (sift>500){sift = 500;}// on le limite pour qu'il ne dépasse pas 500 Hz au bord
}
//***************************** partie TX ****************************
if (shift_tx == true & digitalRead(tx) == LOW ){ sift = sift; } // si le réglage tx de changement de vitesse et la transmission sont activés, alors le changement de vitesse est égal à la position actuelle de la poignée
else { if (digitalRead(tx) == LOW ){ sift = sift_tx; } } /// sinon, si tx alors shift est égal à la valeur écrite
if (digitalRead(tx) == LOW & modulation == 3 ){ sift = 0; } // si le télégraphe et la transmission sont activés alors tamiser = 0
//*************************** SW LSB USB MODES **********************
//Mode_temp,5 cw modulation 1-lsb; 2-usb; 3- cw; 4- fm; 5-am;
//Mode_temp,6 usb
//Mode_temp,7 lsb
if ( modulation == 3 ){temp_BFO = CW_BFO ; Reverse_side_command = 0;
if (digitalRead(tx) == HIGH ){Syn_freq = temp_BFO - CW_tone;} else {Syn_freq = temp_BFO;} // en CW, BFO est égal à tel gène moins le ton, mais pour l'heterodine, la fréquence est utilisée sans tenir compte du ton
temp_IF = CW_IF; } //charge la FI pour le signal de sortie du synthétiseur
else{
if ( flag_plus_or_minus_IF == 0 & modulation == 1 ){temp_BFO = USB_BFO; temp_IF = USB_IF; Reverse_side_command = 1;} //на нижних бэндах если нижняя боковая то опорник LSB_BFO sur les bandes inférieures, si la face inférieure est le support LSB_BFO
if ( flag_plus_or_minus_IF == 0 & modulation == 2 ){temp_BFO = LSB_BFO; temp_IF = LSB_IF; Reverse_side_command = 0;} // et définissez le drapeau Reverse_side_command = 1; si le côté opposé est nécessaire pour contrôler un générateur de référence externe.
if ( flag_plus_or_minus_IF == 1 & modulation == 1 ){temp_BFO = LSB_BFO; temp_IF = LSB_IF; Reverse_side_command = 0;} //sur les bandes inférieures, si la face inférieure est le support LSB_BFO
if ( flag_plus_or_minus_IF == 1 & modulation == 2 ){temp_BFO = USB_BFO; temp_IF = USB_IF; Reverse_side_command = 1;} //
if ( modulation == 4 ){temp_BFO = 0 ; temp_IF = FM_IF;} // DÉSACTIVER BFO LORSQUE LE MODE est en FM !
if ( modulation == 5 ){
if (digitalRead(tx) == HIGH ) {temp_BFO = 0;} // pour la réception en AM, désactivez BFO
else {temp_BFO = AM_BFO;}
temp_IF = AM_IF; } //
Syn_freq = temp_BFO;
}
if ( shift_tx == true & (digitalRead(tx) == HIGH) ){ goto skip1;}// si nous corrigeons shift_tx et dans le mode de réception, nous sautons l'ajout du décalage
if ( flag_plus_or_minus_IF == 0 & modulation == 2 || flag_plus_or_minus_IF == 1 & modulation == 1 ){Syn_freq = Syn_freq + sift;} // si la bande est inversée, alors nous inversons la valeur de décalage
else { Syn_freq = Syn_freq - sift;}
skip1:
if (Syn_freq < 10000 ) {si5351.output_enable(SI5351_CLK0, 0); goto finish_with_BFO;} // éteint la sortie si l'onduleur est à 0, c'est-à-dire que l'onduleur n'est pas nécessaire (pour PPP)
else {si5351.output_enable(SI5351_CLK0, 1); }
if (BFO_drive_strength == 0) {si5351.drive_strength(SI5351_CLK0, SI5351_DRIVE_2MA);}
if (BFO_drive_strength == 1) {si5351.drive_strength(SI5351_CLK0, SI5351_DRIVE_4MA);}
if (BFO_drive_strength == 2) {si5351.drive_strength(SI5351_CLK0, SI5351_DRIVE_6MA);}
if (BFO_drive_strength == 3) {si5351.drive_strength(SI5351_CLK0, SI5351_DRIVE_8MA);}
if (Freq_BFO_prev != Syn_freq){ // vérifier la fréquence précédente pour ne plus la restituer
Freq_BFO_prev = Syn_freq;
Syn_freq = Syn_freq*100ULL; // multiplier par 100 et sortir
si5351.set_freq(Syn_freq,SI5351_PLL_FIXED, SI5351_CLK0); // SI5351_PLL_FIXED
}
else {delay (4);}/// on compense le temps si on ne change pas la fréquence pour que le cycle du programme soit approximativement le même
finish_with_BFO:
//**************** AFFICHAGE DU PROGRAMME *************************************
temp_reg_24_1 = VFO_temp; // étendre la fréquence actuelle
X_coordinate = 190; // commence à partir du deuxième chiffre !!!!!
Y_coordinate = 35;
tft.setFreeFont(FF44);
if (VFO_temp >= 1000000000){temp_reg_24_1 = temp_reg_24_1/10; tft.setTextColor(TFT_BLACK); } else {tft.setTextColor(TFT_GREEN); }
tft.setCursor(X_coordinate+63, Y_coordinate+33, 2);
tft.println(".");
tft.setCursor(X_coordinate+177, Y_coordinate+33, 2);
tft.println(".");
if (VFO_temp >= 1000000000){tft.setTextColor(TFT_GREEN); } else {tft.setTextColor(TFT_BLACK); }
tft.setCursor(X_coordinate+101, Y_coordinate+33, 2);
tft.println(".");
tft.setCursor(X_coordinate+215, Y_coordinate+33, 2);
tft.println(".");
//************* SOUS-PROGRAMME de DECOMPOSITION DES DIZAINES
millions100 =((temp_reg_24_1/100000000)%10);
millions10 = ((temp_reg_24_1/10000000)%10);
millions1 = ((temp_reg_24_1/1000000)%10);
thousands100 = ((temp_reg_24_1/100000)%10);
thousands10 = ((temp_reg_24_1/10000)%10);
thousands1 = ((temp_reg_24_1/1000)%10);
hundreds = ((temp_reg_24_1/100)%10);
tens = ((temp_reg_24_1/10)%10);
tft.setTextColor(TFT_GREEN);
//44 24
if (prev_millions100 != millions100){tft.fillRect(X_coordinate-38, Y_coordinate, 32, 35, TFT_BLACK); // x y width hight
if (millions100>0) {tft.setCursor(X_coordinate-38,Y_coordinate+33, 2); tft.println(millions100);} // écraser si 0
prev_millions100 = millions100; } // si la valeur précédente a changé, alors nous effaçons l'ancienne valeur et en dessinons une nouvelle
if (prev_millions10 != millions10){tft.fillRect(X_coordinate, Y_coordinate, 32, 35, TFT_BLACK); // x y width hight
if (millions10>0 || millions100>0 ) {tft.setCursor(X_coordinate,Y_coordinate+33, 2); tft.println(millions10);} // écraser si 0
prev_millions10 = millions10; } // si la valeur précédente a changé, alors nous effaçons l'ancienne valeur et en dessinons une nouvelle
if (prev_millions1 != millions1){tft.fillRect(X_coordinate+38, Y_coordinate, 32, 35, TFT_BLACK); // x y width hight
tft.setCursor(X_coordinate+38, Y_coordinate+33, 2); tft.println(millions1); prev_millions1 = millions1; }
// si la valeur précédente a changé, alors nous effaçons l'ancienne valeur et en dessinons une nouvelle ...
if (prev_thousands100 != thousands100){tft.fillRect(X_coordinate+76, Y_coordinate, 32, 35, TFT_BLACK); // x y width hight
tft.setCursor(X_coordinate+76, Y_coordinate+33, 2); tft.println(thousands100); prev_thousands100 = thousands100; }
if (prev_thousands10 != thousands10){tft.fillRect(X_coordinate+114, Y_coordinate, 32, 35, TFT_BLACK); // x y width hight
tft.setCursor(X_coordinate+114, Y_coordinate+33, 2); tft.println(thousands10); prev_thousands10 = thousands10; }
if (prev_thousands1 != thousands1){tft.fillRect(X_coordinate+152, Y_coordinate, 32, 35, TFT_BLACK); // x y width hight
tft.setCursor(X_coordinate+152, Y_coordinate+33, 2); tft.println(thousands1); prev_thousands1 = thousands1; }
if (prev_hundreds != hundreds){tft.fillRect(X_coordinate+190, Y_coordinate, 32, 35, TFT_BLACK); // x y width hight
tft.setCursor(X_coordinate+190, Y_coordinate+33, 2); tft.println(hundreds); prev_hundreds = hundreds; }
if (prev_tens != tens){tft.fillRect(X_coordinate+228, Y_coordinate, 32, 35, TFT_BLACK); // x y width hight
tft.setCursor(X_coordinate+228, Y_coordinate+33, 2); tft.println(tens); prev_tens = tens; }
//********************************************
//tft.setFreeFont(FF26); 6 34
tft.setFreeFont(FF42);
tft.setTextColor(TFT_BLUE);
if (modulation_prev != modulation){ //si la valeur a changé alors
tft.fillRect(355, 117, 90, 23, TFT_BLACK); // nous effaçons l'ancien x y width hight
tft.setCursor(367, 139, 1);
if ( modulation == 1){tft.println("- LSB");} //
if ( modulation == 2){tft.println("- USB");} //
if ( modulation == 3){tft.println("- CW");} //
if ( modulation == 4){tft.println("- FM");} //
if ( modulation == 5){tft.println("- AM");} //
modulation_prev = modulation; } //
//******* VFO
if ( VFO_prev!=VFO ){
tft.setFreeFont(FF42); //22
tft.setTextColor(TFT_CYAN);
tft.setCursor(170, 122, 1);
tft.fillRect(170, 100, 100, 23, TFT_BLACK); // nous effaçons l'ancien x y width hight
if (VFO==false)
{tft.println("VFO - A");}
else {tft.println("VFO - B");}
//VFO_prev = VFO;
}
//************** sous-routine de CONFIGURATION 3 (partie d'affichage)****************
tft.setTextColor(TFT_RED);
tft.setFreeFont(FF42);
if ( bitRead(Mode_temp,7)==1 ){
if (negativ_rit == true){tft.fillRect(400, 83, 72, 25, TFT_BLACK);}// effacer OFF
if (prev_thousands_rit != rit ){tft.fillRect(341, 83, 80, 25, TFT_BLACK); // si la valeur a changé, mettre à jour la lecture à l'écran
//tft.fillRect(341, 83, 100, 25, TFT_BLACK
if (rit < 0 ){tft.setCursor(341, 106, 1);tft.println("-");}// si un nombre négatif, dessinez un moins et placez un drapeau pour ne plus dessiner
tft.setCursor(354, 106, 1); tft.println(thousands_rit); //
tft.setCursor(369, 106, 1);
tft.println(".");
tft.setCursor(378, 106, 1); tft.println(hundreds_rit);
tft.setCursor(398, 106, 1); tft.println(tens_rit);
tft.setCursor(420, 106, 1); tft.println("kHz");
prev_thousands_rit = rit; }
negativ_rit = false; }
tft.setTextColor(TFT_GREY1);
if (bitRead(Mode_temp,7)==0 & negativ_rit == false){
tft.fillRect(341, 83, 130, 25, TFT_BLACK);tft.setCursor(367, 106, 1);tft.println("- OFF" );
prev_thousands_rit=20000; // nous réinitialisons les indicateurs de contrôle pour voir ce qui a été imprimé lorsqu'il est activé
negativ_rit = true;}
//******************************************************************************
//************************* Fonctions du coin gauche
//Mode_temp; // bit: 0-ATT; 1- PRE; 2-fast; 3- flag for calibration Smetr; 4/5/6 - MODE; 7- rit;
tft.setFreeFont(FF41); // 29
tft.setTextColor(TFT_BLACK);
if (Mode_temp_prev != Mode_temp){ //si la valeur a changé alors
Mode_temp_prev = Mode_temp;
if ( bitRead(Mode_temp,0)==1 ){tft.fillRoundRect(72, 45, 55, 23, 5, TFT_WHITE);tft.setCursor(80, 62, 1);tft.println("ATT");}
else {tft.fillRoundRect(72, 45, 55, 23, 5, TFT_GREY1);tft.setCursor(80, 62, 1);tft.println("ATT");}
if ( bitRead(Mode_temp,1)==1 ){tft.fillRoundRect(5, 45, 55, 23, 5, TFT_WHITE);tft.setCursor(14, 62, 1); tft.println("PRE");}
else {tft.fillRoundRect(5, 45, 55, 23, 5, TFT_GREY1);tft.setCursor(14, 62, 1); tft.println("PRE");}
if ( bitRead(Mode_temp,2)==1 ){tft.fillRoundRect(5, 75, 55, 23, 5, TFT_WHITE);}
else {tft.fillRoundRect(5, 75, 55, 23, 5, TFT_GREY1);} tft.setCursor(10, 92, 1); tft.println("FAST");
}
//*******************
if ( lock != lock_prev ) {
if ( lock==true)
{tft.fillRoundRect(72, 75, 55, 23, 5, TFT_WHITE);}
else{tft.fillRoundRect(72, 75, 55, 23, 5, TFT_GREY1);}
tft.setCursor(73, 92, 1);
tft.println("LOCK");
lock_prev = lock;}
//*******************
//************ shift_tx ****************
if (shift_tx == true & sift != sift_prev )// si le réglage de la touche shift est activé, alors nous affichons le shift et la nouvelle valeur du shift
{
tft.fillRoundRect(5, 105, 122, 23, 5, TFT_WHITE); //
tft.setCursor(6, 122, 1);
tft.println("ShiftTX");
tft.setCursor(80, 122, 1);
sift_prev = sift;
tft.println(sift);
}
else { // traiter soit shift_tx soit shift_rx !!
//************ shift_rx ****************
if ( sift != sift_prev ) { // cette partie est chargée d'afficher le changement de la valeur de décalage bitRead(Mode_temp,4)==1 &
tft.fillRoundRect(5, 105, 122, 23, 5, TFT_GREY1);
tft.setCursor(6, 122, 1);
tft.println(" SHIFT");
tft.setCursor(80, 122, 1);
tft.println(sift);
sift_prev = sift;
}
}
//******************** RX/TX statue
if (digitalRead(tx) == HIGH & flag_RX_TX == true ) {
tft.fillRoundRect(5, 15, 55, 23, 5, TFT_GREEN); //
tft.setCursor(19, 32, 1);
tft.println("RX");
flag_RX_TX = false; }
if (digitalRead(tx) == LOW & flag_RX_TX== false ) {
tft.fillRoundRect(5, 15, 55, 23, 5, TFT_RED);
tft.setCursor(19, 32, 1);
tft.println("TX");
flag_RX_TX = true; }
//***************
//***************
if ( Split!=Split_prev_state ){
if (Split==true)
{tft.fillRoundRect(72, 15, 55, 23, 5, TFT_WHITE);tft.setCursor(73, 32, 1);tft.println("SPLIT");}
else {tft.fillRoundRect(72, 15, 55, 23, 5, TFT_GREY1);tft.setCursor(73, 32, 1);tft.println("SPLIT");}
Split_prev_state = Split; }
//********************* RTC **************
//tft.setTextColor(TFT_NAVY); // MAROON ORANGE NAVY
tft.setFreeFont(FF21);//6 17
if (RTC_enable == 1 ) { //* si l'horloge est allumée alors nous affichons l'heure
t = rtc.getTime();
if (prev_time != t.min) { // quand la minute a changé
prev_time = t.min;
tft.fillRoundRect(5, 135, 122, 23, 5, TFT_GREY1);
//*********************************
tft.setCursor(37, 154, 1);//Y 154 36
tft.println(rtc.getTimeStr(FORMAT_SHORT));
}
}
else { if ( RTC_enable != 2){ RTC_enable = 2; // utiliser le registre RTC_enable comme indicateur afin de ne pas mettre à jour l'inscription tout le temps "< --:-- >"
tft.fillRoundRect(5, 135, 122, 23, 5, TFT_GREY1);
tft.setCursor(14, 152, 1);// si l'horloge est éteinte alors afficher < --:-- >
tft.println("14HAM-DK2"); }}
//************* SOUS-PROGRAMME DE DECOMPOSITION DES DIZAINES
if (VFO == 1) {temp_reg_24_1 = VFO_A;} else {temp_reg_24_1 = VFO_B;}
if (VFO_opp_prev != temp_reg_24_1 || VFO_prev!=VFO){
VFO_opp_prev = temp_reg_24_1;
VFO_prev = VFO;
if (temp_reg_24_1 >= 1000000000){temp_reg_24_1 = temp_reg_24_1/10; }
millions100 =((temp_reg_24_1/100000000)%10);
millions10 = ((temp_reg_24_1/10000000)%10);
millions1 = ((temp_reg_24_1/1000000)%10);
thousands100 = ((temp_reg_24_1/100000)%10);
thousands10 = ((temp_reg_24_1/10000)%10);
thousands1 = ((temp_reg_24_1/1000)%10);
hundreds = ((temp_reg_24_1/100)%10);
tens = ((temp_reg_24_1/10)%10);
tft.setTextColor(TFT_WHITE);
tft.setFreeFont(FF41);//6
tft.fillRect(180, 165, 270, 18, TFT_BLACK);//15
tft.setCursor(183, 182, 1);
if (VFO == 1) {tft.println("VF0 - A");} else {tft.println("VF0 - B");}
tft.setTextColor(TFT_ORANGE ); // MAROON
tft.setFreeFont(FF42);//6 17
X_coordinate = 275; //1 Mgz shift to center
if(millions10>0){ X_coordinate = 285;} //10 Mgz
if(millions100>0){ X_coordinate = 292;} //100 Mgz
Y_coordinate = 182;
//********************** décalage virgule ***************************
if (VFO_opp_prev >= 1000000000){
tft.setCursor(X_coordinate+66, Y_coordinate, 1);
tft.println(".");
tft.setCursor(X_coordinate+120, Y_coordinate, 1);
tft.println(".");
}
else {
tft.setCursor(X_coordinate+48, Y_coordinate, 1);
tft.println(".");
tft.setCursor(X_coordinate+102, Y_coordinate, 1);
tft.println(".");
}
//*************************************************
if (millions100>0) {tft.setCursor(X_coordinate, Y_coordinate, 1); tft.println(millions100);}
if (millions10>0 || millions100>0) {tft.setCursor(X_coordinate+18, Y_coordinate, 1); tft.println(millions10);} // écraser si 0
tft.setCursor(X_coordinate+36, Y_coordinate, 1);
tft.println(millions1);
tft.setCursor(X_coordinate+54, Y_coordinate, 1);
tft.println(thousands100);
tft.setCursor(X_coordinate+72, Y_coordinate, 1);
tft.println(thousands10);
tft.setCursor(X_coordinate+90, Y_coordinate, 1);
tft.println(thousands1);
tft.setCursor(X_coordinate+108, Y_coordinate, 1);
tft.println(hundreds);
tft.setCursor(X_coordinate+126, Y_coordinate, 1);
tft.println(tens);
//tft.setCursor(422, 182, 1);
//tft.println("MHz");
}
//************************* Voltmeter **********************************
temp_volt++; // nous mesurons la tension tous les 10 cycles
if (temp_volt > 20) { temp_volt = 0;
temp_4bit_reg_1 = analogRead(Voltmter);
temp_4bit_reg_1 = analogRead(Voltmter);
///temp_4bit_reg_1 = 138*4; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
temp_4bit_reg_1 = ((temp_4bit_reg_1/4)%1000); // diviser par 4 (ainsi pour que le voltmètre oscille moins
if (old_volt!=temp_4bit_reg_1){
old_volt = temp_4bit_reg_1 ;
thousands_rit = ((temp_4bit_reg_1/100)%10);
hundreds_rit = ((temp_4bit_reg_1/10)%10); //utiliser des registres pour configurer la décomposition CE PROGRAMME DEVRAIT ALLER APRÈS L'AFFICHAGE DE L'ÉCRAN DE RÉGLAGES !!!!
tens_rit = ((temp_4bit_reg_1/1)%10);
tft.setTextColor(TFT_WHITE);
tft.setFreeFont(FF41);//6 21
tft.fillRect(65, 170, 38, 15, TFT_BLACK);//15
tft.setCursor(65, 182, 1);
tft.println(thousands_rit);
tft.setCursor(75, 182, 1);
tft.println(hundreds_rit);
tft.setCursor(85, 182, 1);
tft.println(".");
tft.setCursor(91, 182, 1);
tft.println(tens_rit );
}
//************************** SOUS-PROGRAMME D'ENREGISTREMENT DES DONNÉES À L'ARRÊT **********************
if (temp_4bit_reg_1 < 105){ Save_and_OFF ();} //si la tension sur le voltmètre est inférieure à 10,5 volt, le synthétiseur s'éteint et vous devez accéder au programme de sauvegarde
}
//************************************ S-METR ****************************
S_P_meter (); // aller à la sous-routine S-METR
}
// ******* SOUS-PROGRAMME DE SAUVEGARDE DE LA VALEUR DE LA FREQUENCE, DES MODES, ETC, A L'ARRET *************
void Save_and_OFF () {
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_GREEN);
//tft.setFreeFont(FF32);
tft.setFreeFont(FF44);
tft.setCursor(135, 150, 1);
tft.println("Goodbye");
//******************************** enregistrer la dernière valeur de fréquence ... dans la cellule correspondante de la dernière plage
temp_4bit_reg_1 = 200;
EEPROM.put(temp_4bit_reg_1, chanel_counter); temp_4bit_reg_1++; //lire le numéro de plage avant d'éteindre
EEPROM.put(temp_4bit_reg_1, load_chanel_for_VFO_A); temp_4bit_reg_1++;
EEPROM.put(temp_4bit_reg_1, load_chanel_for_VFO_B); temp_4bit_reg_1++;
EEPROM.put(temp_4bit_reg_1, VFO_picked); temp_4bit_reg_1++;
EEPROM.put(temp_4bit_reg_1, VFO_A); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_B); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_A); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_B); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_1); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_1); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_2); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_2); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_3); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_3); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_4); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_4); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_5); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_5); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_6); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_6); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_7); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_7); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_8); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_8); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_9); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_9); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_10); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_10); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_11); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_11); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_12); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_12); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_13); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_13); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_14); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_14); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_15); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_15); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, VFO_chanel_16); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
EEPROM.put(temp_4bit_reg_1, Mode_chanel_16); temp_4bit_reg_1 = temp_4bit_reg_1 + 4;
//*****************************************************************************
delay (10000); //attendre 10s
// si après 10 s l'alimentation ne s'éteint pas, alors nous affichons une inscription sur le dysfonctionnement de la carte d'alimentation et de la boucle
malfunction:
tft.setFreeFont(FF1);
tft.setCursor(70, 290, 1);
tft.println("Power supply board malfunction ");//nous affichons une inscription sur un dysfonctionnement de la carte d'alimentation
delay (5000);
goto malfunction;
} |
Partager