-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommande_gqrx.ino
168 lines (131 loc) · 3.1 KB
/
commande_gqrx.ino
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
#include <LiquidCrystal.h>
//#include <string.h>
#define potA A0 // potentiometre pour MHz
#define potB A1// potentiometre pour KHz
#define butP 9 // selection type modulation +
#define butM 6 // selection type modulation -
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int potAVal = 0;
int potBVal = 0;
int freq = 0;
int bufF = 0;
char freq_to_send[10] = {0};
char freq_to_print[10] = {0};
char mod[20] = {0};
int modN = 0;
int butPstate = 0;
int butMstate = 0;
int i = 0;
int j = 0;
bool flagSend = false;
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(butP, INPUT);
pinMode(butM, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
bufF = freq;
potAVal = map(analogRead(potA), 0, 1023, 8, 70);
potBVal = map(analogRead(potB), 0, 1023, 0, 99);
butPstate = digitalRead(butP);
butMstate = digitalRead(butM);
freq = potAVal*100 + potBVal;
sprintf(freq_to_send,"F %ld" , freq*100000);
if(freq/10 < 100){
sprintf(freq_to_print,"0%d.%d MHz" , freq/10, freq - (freq/10)*10);
}
else{
sprintf(freq_to_print,"%d.%d MHz" , freq/10, freq - (freq/10)*10);
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(freq_to_print);
if(butPstate == HIGH){ // sélection de la démodulation
flagSend = true;
modN+=1;
if(modN > 11){
modN = 0;
}
}
if(butMstate == HIGH){
flagSend = true;
modN-=1;
if(modN < 0){
modN = 11;
}
}
switch(modN){ //types de démodulations
case 0:
sprintf(mod, "M OFF");
lcd.setCursor(0, 1);
lcd.print("DEMOD: OFF");
break;
case 1:
sprintf(mod, "M RAW");
lcd.setCursor(0, 1);
lcd.print("DEMOD: RAW IQ");
break;
case 2:
sprintf(mod, "M AM");
lcd.setCursor(0, 1);
lcd.print("DEMOD: AM");
break;
case 3:
sprintf(mod, "M FM");
lcd.setCursor(0, 1);
lcd.print("DEMOD: FM");
break;
case 4:
sprintf(mod, "M WFM");
lcd.setCursor(0, 1);
lcd.print("DEMOD: Wide FM");
break;
case 5:
sprintf(mod, "M WFM_ST");
lcd.setCursor(0, 1);
lcd.print("DEMOD: WFMSTereo");
break;
case 6:
sprintf(mod, "M WFM_ST_OIRT");
lcd.setCursor(0, 1);
lcd.print("DEMOD: WFMSTOIRT");
break;
case 7:
sprintf(mod, "M LSB");
lcd.setCursor(0, 1);
lcd.print("DEMOD: LSB");
break;
case 8:
sprintf(mod, "M USB");
lcd.setCursor(0, 1);
lcd.print("DEMOD: USB");
break;
case 9:
sprintf(mod, "M CW");
lcd.setCursor(0, 1);
lcd.print("DEMOD: CW");
break;
case 10:
sprintf(mod, "M CWL");
lcd.setCursor(0, 1);
lcd.print("DEMOD: CWL");
break;
case 11:
sprintf(mod, "M CWU");
lcd.setCursor(0, 1);
lcd.print("DEMOD: CWU");
break;
default:
break;
}
if(flagSend){
Serial.print(mod); //on indique le nouveau type de démodulation
delay(250);
flagSend = false;
}
Serial.print(freq_to_send); //on met à jour la fréquence
delay(250);
}