├── ArduinoTX_6CH
├── ArduinoTX_6CH.ino
├── Battery.ino
├── Buttons.ino
├── Buzzer.ino
├── Calibration.ino
├── Config.h
├── Dual_Rates.ino
├── Eeprom.ino
├── PPM_Channels.ino
├── PPM_Output.ino
├── Read_ADC.ino
├── Screen.ino
├── Switches.ino
└── Warn_Switch.ino
├── Docs
├── ArduTX_NANO_5VTX_JAN18.pdf
├── ArduTX_New_Pro_Mini_Header_TX_5V_Power_Supply.pdf
└── Images
│ ├── ARDUINO_RC_Battery_Powered_PCB.png
│ ├── Arduino_Power_Supply_160.png
│ ├── Arduino_Wiring.png
│ ├── Battcheckoled.png
│ ├── Battery_480.png
│ ├── Buzzer_480.png
│ ├── Calibration.png
│ ├── Dual_Rates.png
│ ├── FS_CT6B.png
│ ├── FS_CT6B_160.png
│ ├── FS_CT6B_240.png
│ ├── Gimbal_1_240.png
│ ├── Gimbal_2_240.png
│ ├── Gimbals_wiring_mode1_480.png
│ ├── Gimbals_wiring_mode2_480.png
│ ├── Gimbals_wiring_mode3_480.png
│ ├── Gimbals_wiring_mode4_480.png
│ ├── HK_T6A.png
│ ├── HK_T6A_160.png
│ ├── HK_T6A_240.png
│ ├── JR_Ext_160.png
│ ├── Key_buttons.png
│ ├── LM317_Supply_160.png
│ ├── Lion_240.png
│ ├── Lipo_240.png
│ ├── Menu.png
│ ├── Model.png
│ ├── Multimeter_10K.png
│ ├── Multimeter_20K.png
│ ├── Multimeter_Voltage.png
│ ├── Nano_Shield_160.png
│ ├── Nano_Shield_240.png
│ ├── Nano_Shield_320.png
│ ├── Nano_Shield_Blue_160.png
│ ├── Nano_Shield_Blue_240.png
│ ├── Nano_Shield_Blue_320.png
│ ├── OLED_wiring.png
│ ├── Old_gimbals_480.png
│ ├── Oled_front_240.png
│ ├── Oled_rear_240.png
│ ├── PPM_wiring.png
│ ├── Pot_160.png
│ ├── Pots_wiring_480.png
│ ├── Proto_pcb_240.png
│ ├── RC_pot_160.png
│ ├── RC_switch_160.png
│ ├── RX6CH240.png
│ ├── Screen_0.png
│ ├── Servo_Direction.png
│ ├── Slide_SW_160.png
│ ├── Sub_Trim.png
│ ├── Switch_160.png
│ ├── Switch_Warning.png
│ ├── Switch_long.png
│ ├── Switch_short.png
│ ├── Switch_wiring_1_480.png
│ └── Switch_wiring_2_480.png
├── Extras
├── ArduTX_Battery_Checker
│ ├── Arduino_TX_battery_checker.ino
│ └── README.md
└── EepromClear
│ ├── README.md
│ └── eeprom_clear.ino
├── LICENSE
├── PCB
├── Nano_With_TX_Battery_Powered
│ ├── ARDUTX_6CH_tx_battery_powered_all_files.zip
│ ├── ArduTX.lbr
│ ├── ArduTX_TX_Battery_Powered.brd
│ ├── ArduTX_TX_Battery_Powered.sch
│ ├── ArduTX_TX_Battery_Powered_Components_Side.pdf
│ ├── ArduTX_TX_Battery_Powered_PCB.pdf
│ ├── ArduTX_TX_Battery_Powered_SCH.pdf
│ └── README.md
└── README.md
└── README.md
/ArduinoTX_6CH/ArduinoTX_6CH.ino:
--------------------------------------------------------------------------------
1 | // This code is based on ardutx v1.3 sketch
2 | // (c) 2014 Patricio Reinoso
3 | // www.patolin.com
4 |
5 | /* This project is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 | this code is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 | You should have received a copy of the GNU General Public License
14 | along with this code. If not, see .*/
15 |
16 | // *************************************************************************************************************
17 | // A great Patolin idea to upgrade cheap Hobbyking HK-T6A or Flysky FS-CT6B transmitters or any other old RC TX
18 | // These transmitters offer a configuration through a serial port with an external PC software program
19 | // and no space to store more than one model.
20 | // *************************************************************************************************************
21 | // This sketch has been modified to work with SH1106 SPI 1.3" or SSD1306 SPI 0.96" OLED display through U8g2 library
22 | // Has been used all possible pins of ATmega328 (Arduino UNO, Nano, Pro Mini)
23 | // Every text strings has been stored in flash memory to mantain a lot of free RAM memory
24 | // Sketch terms, text, items has been translated in English to ease users/developers
25 | // *************************************************************************************************************
26 | // Added features to original Patolin code:
27 | // - Support for SH1106 SPI 1.3" or SSD1306 SPI 0.96"(128x64)(U8g2 library)
28 | // - Switches checking status with sound alert at power ON and display which is not in default position
29 | // - Throttle warning with display status and sound alert
30 | // - Hidden data default restoring by pressing and hold Down/Next button on power on
31 | // - Hidden calibration procedure by pressing and hold Menu/Select button on power on
32 | // - Low battery control in real time whith buzzer sound(buzzer with stand alone sound generator)
33 | // - N°2 supplementary switch, they can be configured instead of VRA or VRB pots(SWA, SWB)(Servo Direction Menu)
34 | // - Basic two channel mixer with switch activation V-Mix (Ch1/ch2)
35 | // - Basic four channels Sub Trim setting (ch1, ch2, ch3, ch4)
36 | // *************************************************************************************************************
37 | // Recommended Arduino IDE 1.8.2 // Seems to be optimized and stable compiler. Less Flash and RAM used
38 | // Arduino AVR Boards 1.6.18
39 | // *************************************************************************************************************
40 | /*
41 | +++++++++++++++++
42 | Input Pots
43 | 6 channels
44 | +++++++++++++++++
45 | Aileron CH1 = A0
46 | Elevon CH2 = A1
47 | Throttle CH3 = A2
48 | Rudder CH4 = A3
49 | Pot VRA CH5 = A4
50 | Pot VRB CH6 = A5
51 |
52 | //---------------------------------------------------------------------------------------------
53 | // 2 position switch (pin A6 in the center, VCC and GND at both ends)
54 | // NOTE: switch is activated when pin A6 is closed to GND (normaly closed to VCC)
55 | //---------------------------------------------------------------------------------------------
56 | swA = A6
57 |
58 | //---------------------------------------------------------------------------------------------
59 | // Must be used R1-10K/R2-10K voltage divider for 2S lion/LiPo battery
60 | // (R1-20K/R2-10K voltage divider for 3S lion/LiPo battery)
61 | //---------------------------------------------------------------------------------------------
62 | batPin = A7
63 |
64 | (Battery voltage divider)
65 |
66 | Vbatt MAX 10V ----+
67 | |
68 | R1 10K
69 | |
70 | |+-----> (PIN A7)
71 | |
72 | R2 10K
73 | |
74 | =
75 | . (GND)
76 |
77 | //---------------------------------------------------------------------------------------------
78 | // V-Mix switch
79 | // WARNING !!! If closed to GND will deny to upload sketch
80 | //---------------------------------------------------------------------------------------------
81 | swMix = pin 0[RXD]
82 |
83 | //---------------------------------------------------------------------------------------------
84 | // Mount 0,1uF/100nF(104)ceramic capacitor from pin to GND
85 | // WARNING !!! the capacitor on pin 1[TXD](buttonSelect) will deny to upload sketch
86 | //---------------------------------------------------------------------------------------------
87 | Enter Button pin 1(TXD)
88 | UP Button pin 2
89 | Down Button pin 3
90 |
91 | //---------------------------------------------------------------------------------------------
92 | // 2 position switch (is activated when pin is closed to GND)
93 | //---------------------------------------------------------------------------------------------
94 | swDR pin 4
95 | swTC pin 5
96 | swB Pin 12
97 |
98 | //---------------------------------------------------------------------------------------------
99 | buzzer pin 6 // Buzzer with sound generator (need transistor driving)
100 |
101 | //---------------------------------------------------------------------------------------------
102 | // Must be used voltage divider on pin 7 to limit at 3Vpp ppm signal
103 | // because T6A/CT6B(A7105)TX module is not 5V tollerant
104 | //---------------------------------------------------------------------------------------------
105 | sigPin pin 7
106 |
107 | (PPM Signal voltage divider)
108 |
109 | sigPin 7 ----------+
110 | |
111 | R1 10K
112 | |
113 | |+-----> 2.7Vpp(to TX PPM PIN)
114 | |
115 | R2 12K(Max 15K)
116 | |
117 | =
118 | . (GND)
119 | */
120 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
121 | #include // Arduino standard library
122 | #include // Arduino standard library
123 | #include // Using U8G2 library "https://github.com/olikraus/u8g2"
124 | #include "Config.h" // Load static and variable configuration settings
125 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
126 |
127 | void setup() {
128 |
129 | //Serial.begin(9600);
130 |
131 | // LCD config with U8G2 library display init (mandatory)
132 | u8g2.begin();
133 |
134 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
135 | // Input ADC sampling rate for reading analog input pots (1000 KHz is maximum for stable reading)
136 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
137 |
138 | ADCSRA &= ~(1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); // Remove bit settings from Arduino library
139 | ADCSRA |= (1 << ADPS2); // Set ADC prescaler to 16 (1000 KHz)
140 |
141 | ADMUX |= (1 << REFS0);
142 | ADMUX &= ~(1 << REFS1); // Avcc(+5v) as voltage reference
143 |
144 | ADCSRB &= ~((1 << ADTS2) | (1 << ADTS1) | (1 << ADTS0)); // ADC in free-running mode
145 |
146 | ADCSRA |= (1 << ADEN); // Turn on ADC
147 | ADCSRA |= (1 << ADSC); // Do an initial conversion this one is the slowest to ensure that everything is up and running
148 |
149 | DIDR0 = 0x3F; // Digital circuit on analog ports disabled
150 | DIDR1 = 0x03; // Disable digital input on AIN0/1
151 |
152 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
153 | // Debouncing mechanical buttons
154 | // NOTE: For input pin buttons is necessary to mount on every pin
155 | // 0,1uF/100nF(104)ceramic capacitors from pin to GND
156 | // WARNING !!! the capacitor on pin 1(buttonSelect) will deny to upload sketch
157 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
158 | pinMode(buttonSelect, INPUT); // Pull up is not necessary (pin on LED TXD)
159 | pinMode(buttonUp, INPUT_PULLUP);
160 | pinMode(buttonDown, INPUT_PULLUP);
161 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
162 | pinMode(swTC, INPUT_PULLUP);
163 | pinMode(swDR, INPUT_PULLUP);
164 | pinMode(swB, INPUT_PULLUP);
165 | pinMode(swMix, INPUT); // Pull up is not necessary (pin on LED RXD)
166 | pinMode(buzzer, OUTPUT);
167 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
168 |
169 | res_calc = (R1 + R2) / R2; // Voltage divider calculation
170 |
171 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
172 | // Initialize value for average ADC readings
173 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
174 |
175 | for (int thisReading = 0; thisReading < numReadings; thisReading++)
176 |
177 | readings[thisReading] = 0; // initialize all the readings to 0
178 |
179 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
180 | // Default state values for ppm
181 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
182 | ppm[0] = servoCenter; // channel 1 (A)
183 | ppm[1] = servoCenter; // channel 2 (E)
184 | ppm[2] = ppmMin; // channel 3 (T)
185 | ppm[3] = servoCenter; // channel 4 (R)
186 | ppm[4] = ppmMin; // channel 5 (VRA,SWA)
187 | ppm[5] = ppmMin; // channel 6 (VRB,SW2)
188 |
189 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
190 | // Default state config parameters
191 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
192 |
193 | // Servo Direction bit mask: 0 Normal, 1 Reverse
194 | servoReverse = 0b00000000;
195 |
196 | // Dual Rates and Sub Trim default values (only for first four channels)
197 | for (int i = 0; i < CHANNELS - 2; i++) {
198 |
199 | dual_rate_low[i] = 75;
200 | dual_rate_hi[i] = 100;
201 | subTrim[i] = 512;
202 | }
203 |
204 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
205 | // Config output signal pin
206 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
207 | DDRD |= _BV(sigPin); // Set pin 7 as an output
208 | PORTD ^= _BV(sigPin); // Set pin 7 toggle state
209 |
210 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
211 | // ppm timer config
212 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
213 | configTimer1();
214 |
215 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
216 | // Hold button "Down" on power ON to initialize default memory data
217 | // Will only write data settings to default (not erase calibration data)
218 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
219 |
220 | // Delay before reading button (about charge capacitor pulse on pin)
221 | delay(100);
222 |
223 | if ((PIND & (1 << 3)) == 0) {
224 |
225 | // Recall "Reset to default" macro
226 | resetEeprom();
227 |
228 | u8g2.firstPage();
229 | do {
230 |
231 | // Set font type
232 | u8g2.setFont(u8g2_font_fub14_tr);
233 |
234 | // Set memory buffer for text strings
235 | char msg_buffer[21];
236 |
237 | // Print "ERASE DATA" text string
238 | strcpy_P(msg_buffer, (char*)pgm_read_word(&(messages[5])));
239 | u8g2.setCursor(0, 40);
240 | u8g2.print(msg_buffer);
241 |
242 | } while (u8g2.nextPage());
243 |
244 | delay(2000); // Screen message for 2sec)
245 | }
246 |
247 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
248 | // Load data from Eeprom
249 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
250 | modelActual = storedDataEeprom(255);
251 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
252 |
253 |
254 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
255 | // Set default font type used for all display sessions (mandatory)
256 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
257 | u8g2.setFont(u8g2_font_6x10_tr);
258 | }
259 |
260 | // End of Setup +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
261 |
262 | void loop() {
263 |
264 | // Start Calibration screen if button Enter/Select is pressed on power on ***********************
265 |
266 | if (readKeys() == 2 && statusCalib == 1) {
267 |
268 | Calibration(); // Recall calibration procedure
269 | }
270 |
271 | // Set condition 0 to continue loop if calibration procedure is not selected
272 | else {
273 | statusCalib = 0;
274 | }
275 |
276 | // Start of checking switches default status ****************************************************
277 |
278 | readSwitches(); // Read sw_status switches values
279 |
280 | // This conditions check all switches and throttle status on startup if not in default position
281 | while (onStartup == 1 && (
282 | bitRead(sw_status, 0) == 0 ||
283 | bitRead(sw_status, 1) == 0 ||
284 | bitRead(sw_status, 2) == 0 ||
285 | bitRead(sw_status, 3) == 0 ||
286 | bitRead(sw_status, 4) == 0 ||
287 | bitRead(sw_status, 5) == 0 ))
288 | {
289 | WarnSwitch(); // Recall switch warning screen
290 | }
291 |
292 | // Set condition = 0 to continue loop after all switches are in default mode
293 | onStartup = 0;
294 |
295 | // Starting main session *************************************************************************
296 |
297 | readPots(); // Recall macro for calculating ppm output
298 |
299 | readSwitches(); // Read switches values
300 |
301 | batteryCheck(); // Checking battery status
302 |
303 | // Start of screen display management ************************************************************
304 |
305 | if (screen == 0) { // Print and drawing main screen
306 | Screen_0();
307 | }
308 | else {
309 | if (screen == 1) { // Print menu selection screen
310 | Screen_1();
311 | }
312 | if (screen == 2) {
313 |
314 | if (menuActual == 1) { // Execute "Servo Direction" task
315 | Menu_1();
316 | }
317 | if (menuActual == 2) { // Execute "Dual Rates" task
318 | Menu_2();
319 | }
320 | if (menuActual == 3) { // Execute "Model Selection" task
321 | Menu_3();
322 | }
323 | if (menuActual == 4) { // Execute "Save Model Data" task
324 | Menu_4();
325 | }
326 | if (menuActual == 5) { // Execute "Sub Trim Setup" task
327 | Menu_5();
328 | }
329 | }
330 | }
331 | // If pressed buttonSelect/Enter
332 | if (readKeys() == 2) {
333 | if (screen < 2) {
334 | screen++;
335 | menuActual = menuSubActual;
336 | menuSubActual = 0;
337 | menuSubModel = 0;
338 | }
339 | else {
340 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
341 | // Added if Menu/Select button is pressed without menu cursor (do nothing)
342 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
343 | if (menuActual == 0) {
344 | screen--;
345 | menuActual--;
346 | }
347 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
348 | // Options for each menu
349 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
350 | if (menuActual == 1) {
351 |
352 | // Selection value for Servo Direction
353 | bitWrite(servoReverse, menuSubActual, !bitRead(servoReverse, menuSubActual));
354 | }
355 | if (menuActual == 2) {
356 |
357 | // Selection value for Dual Rates
358 | if (drSelection != 0xFF) {
359 | drSelection = 0xFF;
360 | }
361 | else {
362 | drSelection = menuSubActual;
363 | }
364 | }
365 |
366 | // Model Selection data
367 | if (menuActual == 3) {
368 |
369 | // Selection value for Model Selection
370 | modelActual = menuSubModel;
371 |
372 | // Save data in eeprom
373 | EEPROM.update(511, modelActual);
374 | storedDataEeprom(modelActual);
375 |
376 | delay(10);
377 | }
378 |
379 | if (menuActual == 5) {
380 |
381 | // Selection value for Sub Trim
382 | if (subTrimSelection != 512) {
383 | subTrimSelection = 512;
384 | }
385 | else {
386 | subTrimSelection = menuSubActual;
387 | }
388 | }
389 | }
390 | }
391 |
392 | if (readKeys() == 3) {
393 | switch (menuActual) {
394 |
395 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
396 | // Dual Rate screen step control for selecting channels/values (buttonDown)
397 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
398 | case 2:
399 |
400 | // Initial value for Dual Rates selection value
401 | if (drSelection == 0xFF) {
402 |
403 | // Only first four channels
404 | if (menuSubActual < (CHANNELS * 2) - 5) { // Two values * four channels
405 | menuSubActual++;
406 | if (screen == 0) {
407 | screen++;
408 | }
409 | }
410 | }
411 | // Dual Rates step control for changing selected channel value(DOWN)
412 | else {
413 | if ((drSelection % 2) == 0) {
414 |
415 | // Define Min for LOW Rates value
416 | if (dual_rate_low[drSelection / 2] > 0) {
417 |
418 | // Define step value
419 | dual_rate_low[drSelection / 2]--;
420 | }
421 | }
422 | else {
423 |
424 | // Define Min for HIGH Rates value
425 | if (dual_rate_hi[drSelection / 2] > 0) {
426 |
427 | // Define step value
428 | dual_rate_hi[drSelection / 2]--;
429 | }
430 | }
431 | }
432 |
433 | break;
434 |
435 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
436 | // Sub Trim screen step control for selecting channels/values (buttonDown)
437 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
438 | case 5:
439 |
440 | // Initial value for Sub Trim selection value
441 | if (subTrimSelection == 512) {
442 |
443 | // Only first four channels
444 | if (menuSubActual < CHANNELS - 3) {
445 | menuSubActual++;
446 |
447 | if (screen == 0) {
448 | screen++;
449 | }
450 | }
451 | }
452 |
453 | // Sub Trim step control for changing selected channel value DOWN
454 | else {
455 | if ((subTrimSelection % 1) == 0) {
456 |
457 | // Define Min Sub trim value
458 | if (subTrim[subTrimSelection / 1] > 312 - deadBand ) {
459 |
460 | // Define step value
461 | subTrim[subTrimSelection / 1]--;
462 | }
463 | }
464 | }
465 | break;
466 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
467 |
468 | default:
469 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
470 | // Added for Model Menu management
471 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
472 | if (menuSubModel < 4) { // 0 to 4 items
473 | menuSubModel++;
474 | if (screen == 0) {
475 | screen++;
476 | }
477 | }
478 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
479 |
480 | if (menuSubActual < 5) { // 0 to 5 items
481 | menuSubActual++;
482 | if (screen == 0) {
483 | screen++;
484 | }
485 | }
486 | break;
487 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
488 | }
489 | }
490 |
491 | if (readKeys() == 1) {
492 | switch (menuActual) {
493 |
494 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
495 | // Dual Rate screen step control for selecting channels/values (buttonUp)
496 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
497 | case 2:
498 |
499 | // Initial value for Dual Rates selection value
500 | if (drSelection == 0xFF) {
501 | if (menuSubActual == 0) {
502 | screen--;
503 | menuSubActual = 1;
504 | menuActual = 0;
505 | }
506 | else {
507 | menuSubActual--;
508 | }
509 | }
510 |
511 | // Step control for changing selected channel value UP
512 | else {
513 | if ((drSelection % 2) == 0) {
514 |
515 | // Define Max for LOW Rates value
516 | if (dual_rate_low[drSelection / 2] < 100) {
517 |
518 | // Define step value
519 | dual_rate_low[drSelection / 2]++;
520 | }
521 | }
522 | else {
523 |
524 | // Define Max for HIGH Rates value
525 | if (dual_rate_hi[drSelection / 2] < 100) {
526 |
527 | // Define step value
528 | dual_rate_hi[drSelection / 2]++;
529 | }
530 | }
531 | }
532 | break;
533 |
534 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
535 | // Sub Trim screen step control for selecting channels/values (buttonUp)
536 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
537 | case 5:
538 | if (subTrimSelection == 512) {
539 | if (menuSubActual == 0) {
540 | screen--;
541 | menuSubActual = 1;
542 | menuActual = 0;
543 | }
544 | else {
545 | menuSubActual--;
546 | }
547 | }
548 |
549 | // Sub Trim step control for changing selected channel UP
550 | else {
551 | if ((subTrimSelection % 1) == 0 ) {
552 |
553 | // Define max value for Sub Trim
554 | if ((subTrim[subTrimSelection / 1]) < (712 + deadBand)) {
555 |
556 | // Define step value
557 | subTrim[subTrimSelection / 1]++;
558 | }
559 | }
560 | }
561 | break;
562 |
563 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
564 |
565 | default:
566 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
567 | // Added for Model Menu management
568 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
569 | if (menuSubModel > 0) {
570 | menuSubModel--;
571 | }
572 | else {
573 | if (screen > 0) {
574 | screen--;
575 | menuSubModel = 1;
576 | menuActual = 0;
577 | }
578 | }
579 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
580 |
581 | if (menuSubActual > 0) {
582 | menuSubActual--;
583 | }
584 | else {
585 | if (screen > 0) {
586 | screen--;
587 | menuSubActual = 1;
588 | menuActual = 0;
589 | }
590 | }
591 | break;
592 |
593 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
594 | }
595 | }
596 | }
597 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/Battery.ino:
--------------------------------------------------------------------------------
1 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 | // Macro to calculate average ADC value, checking battery voltage alarm and value for battery bar
3 | // For minBat do not under default value in config file because arduino will be more unstable.
4 | // About 16%(presumed)of battery is enough to landing ASAP
5 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 | void batteryCheck() {
7 |
8 | // Subtract the last reading:
9 | total = total - readings[index];
10 |
11 | // Read from adc input:
12 | readings[index] = read_adc(7);
13 |
14 | // Add reading to total:
15 | total = total + readings[index];
16 |
17 | // Advance to the next position in the array:
18 | index = index + 1;
19 |
20 | // If we're at the end of the array...
21 | if (index >= numReadings)
22 |
23 | // ...wrap around to the beginning:
24 | index = 0;
25 |
26 | // Calculate the average:
27 | average = total / numReadings;
28 |
29 | // Mapping battery voltage from average from 0 to 5V
30 | pin_batt_read = map(average, 0, 1023, 0, 500);
31 |
32 | // Calculating correct voltage value through voltage divider
33 | // Result = 2 digits with 2 decimal (eg 72 = 7.2V)
34 | batt_volt = pin_batt_read * res_calc / 10;
35 |
36 | // Serial.println (batt_volt);
37 |
38 | // Mapping voltage for drawing battery bar
39 | perc_batt = map(batt_volt, minBat, maxBat, 1, 20);
40 | perc_batt = constrain(perc_batt, 1, 20);
41 |
42 |
43 | //Serial.println (perc_batt);
44 |
45 | // Low battery beep alarm
46 | if (perc_batt <= 1 || battStatus == 0) {
47 |
48 | // Set byte 0 to mantain battery alarm even voltage floating +/- on minBat value
49 | battStatus = 0;
50 |
51 | // Set value to mantain battery bar to min value even voltage is under minBat
52 | perc_batt = 1;
53 |
54 | // Recall pulse for buzzer
55 | beep();
56 | }
57 |
58 | // Buzzer alarm OFF
59 | else {
60 | PORTD &= ~_BV(buzzer);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/Buttons.ino:
--------------------------------------------------------------------------------
1 | //+++++++++++++++++++++++++++++++++++++++++++++++++
2 | // Read input buttons status and send value to loop
3 | //+++++++++++++++++++++++++++++++++++++++++++++++++
4 | unsigned char readKeys() {
5 |
6 | // buttonSelect
7 | if ((PIND & (1 << 1)) == 0) {
8 | delay(20);
9 | return 2;
10 | }
11 | // buttonUp
12 | if ((PIND & (1 << 2)) == 0) {
13 | delay(20);
14 | return 1;
15 | }
16 | // buttonDown
17 | if ((PIND & (1 << 3)) == 0) {
18 | delay(20);
19 | return 3;
20 | }
21 | else {
22 | return 0;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/Buzzer.ino:
--------------------------------------------------------------------------------
1 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 | // Macro for buzzer beep battery alarm
3 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 | void beep () {
5 |
6 | if ((bitRead(pulseBuzzer, 0) && bitRead(pulseBuzzer, 5) && bitRead(pulseBuzzer, 1))) {
7 | PORTD |= _BV(buzzer);
8 | }
9 | else {
10 | PORTD &= ~_BV(buzzer);
11 | }
12 | ++pulseBuzzer;
13 | }
14 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/Calibration.ino:
--------------------------------------------------------------------------------
1 | void Calibration() {
2 |
3 | // Set memory buffer for text strings
4 | char msg_buffer[21];
5 | char chName_buffer[6];
6 |
7 | // Setting default mid value reference for calibration
8 | for (int i = 0; i < CHANNELS; i++) {
9 |
10 | calibration[i][0] = 512;
11 | calibration[i][1] = 512;
12 | }
13 | while (statusCalib == 1) {
14 |
15 | // Reading Min and Max value for every channel
16 | unsigned int temporaryReading;
17 |
18 | for (int i = 0; i < CHANNELS; i++) {
19 |
20 | // Get value from every ADC ports
21 | temporaryReading = read_adc(i);
22 |
23 | // Get Min values
24 | if (temporaryReading <= calibration[i][0]) {
25 | calibration[i][0] = temporaryReading;
26 | }
27 | // Get Max values
28 | if (temporaryReading >= calibration[i][1]) {
29 | calibration[i][1] = temporaryReading;
30 | }
31 | }
32 | // Save Min, Max, Center values in Eeprom
33 | int posEeprom = 0;
34 |
35 | // Save Min Max value for all 6 channels
36 | for (int i = 0; i < CHANNELS; i++) {
37 |
38 | // Save Min value
39 | posEeprom = 400 + (i * 4);
40 | EEPROMWriteInt(posEeprom, calibration[i][0]);
41 |
42 | // Save Max value
43 | posEeprom += 2;
44 | EEPROMWriteInt(posEeprom, calibration[i][1]);
45 | }
46 | //delay(10);
47 |
48 | // Start of print real time channels
49 | u8g2.firstPage();
50 | do {
51 |
52 | // Print header text
53 | strcpy_P(msg_buffer, (char*)pgm_read_word(&(messages[3])));
54 | u8g2.setCursor(10, 7);
55 | u8g2.print(msg_buffer);
56 |
57 | // Print footer text
58 | strcpy_P(msg_buffer, (char*)pgm_read_word(&(messages[4])));
59 | u8g2.setCursor(5, 64);
60 | u8g2.print(msg_buffer);
61 |
62 | // Drawing horizontal line under header and vertical/middle line
63 | u8g2.drawHLine(0, 10, 128);
64 | u8g2.drawVLine(64, 16, 35);
65 |
66 | // Print channel 1 name and value
67 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[0])));
68 | u8g2.setCursor(0, 23);
69 | u8g2.print(chName_buffer);
70 | u8g2.setCursor(30, 23);
71 | u8g2.print(read_adc(0));
72 |
73 | // Print channel 2 name and value
74 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[1])));
75 | u8g2.setCursor(75, 23);
76 | u8g2.print(chName_buffer);
77 | u8g2.setCursor(105, 23);
78 | u8g2.print(read_adc(1));
79 |
80 | // Print channel 3 name and value
81 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[2])));
82 | u8g2.setCursor(0, 37);
83 | u8g2.print(chName_buffer);
84 | u8g2.setCursor(30, 37);
85 | u8g2.print(read_adc(2));
86 |
87 | // Print channel 4 name and value
88 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[3])));
89 | u8g2.setCursor(75, 37);
90 | u8g2.print(chName_buffer);
91 | u8g2.setCursor(105, 37);
92 | u8g2.print(read_adc(3));
93 |
94 | // Print channel 5 name and value
95 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[11])));
96 | u8g2.setCursor(0, 50);
97 | u8g2.print(chName_buffer);
98 | u8g2.setCursor(30, 50);
99 | u8g2.print(read_adc(4));
100 |
101 | // Print channel 6 name and value
102 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[12])));
103 | u8g2.setCursor(75, 50);
104 | u8g2.print(chName_buffer);
105 | u8g2.setCursor(105, 50);
106 | u8g2.print(read_adc(5));
107 |
108 | delay(5);
109 |
110 | // Set statusCalib = 0 to exit calibration procedure by pressing ButtonUp
111 | if (readKeys() == 1) {
112 | statusCalib = 0;
113 | }
114 | } while (u8g2.nextPage());
115 |
116 | // End of drawing real time channels values screen for calibration
117 | }
118 |
119 | // Start print calibration storing message
120 | u8g2.firstPage();
121 | do {
122 |
123 | // Changing font type
124 | u8g2.setFont(u8g2_font_9x15B_tr);
125 |
126 | // Print storing data calibration message
127 | strcpy_P(msg_buffer, (char*)pgm_read_word(&(messages[0])));
128 | u8g2.setCursor(25, 15);
129 | u8g2.print(msg_buffer);
130 |
131 | strcpy_P(msg_buffer, (char*)pgm_read_word(&(messages[2])));
132 | u8g2.setCursor(15, 50);
133 | u8g2.print(msg_buffer);
134 |
135 | } while (u8g2.nextPage());
136 |
137 | // End of print calibration storing message
138 |
139 | delay(2000); // Screen message for 2sec
140 |
141 | // Set default font characher
142 | u8g2.setFont(u8g2_font_6x10_tr);
143 | }
144 |
145 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/Config.h:
--------------------------------------------------------------------------------
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 | // Set library for SSD1306 SPI 0.96" OLED display TESTED OK! (128 bytes buffer)
3 | // U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
4 |
5 | // Set library for SH1106 SPI 1.3" OLED display TESTED OK! (128 bytes buffer)
6 | U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
7 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 | /* SPI wires cabling (OLED Pin name dependent on the manufacturer)
9 |
10 | OLED Arduino
11 | ---------------------
12 | RES > pin 8
13 | DC > pin 9
14 | CS > pin 10 (SS)
15 | MOSI > pin 11 (MOSI)
16 | CLK > pin 13 (SCK)*/
17 |
18 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19 | // config PPM settings
20 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 | #define servoCenter 1500 // Servo center value (us)
22 | #define ppmLong 18500 // ppm frame (us) for 6 channels
23 | #define ppmPulse 300 // ppm pulse width (us)
24 | #define onState 0 // Polarity: 0 neg / 1 pos
25 | #define sigPin PD7 // ppm output pin
26 | #define ppmMin 1000 // Min ppm output to be mapped (us)
27 | #define ppmMax 2000 // Max ppm output to be mapped (us)
28 |
29 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 | // Config global TX param
31 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32 | #define CHANNELS 6 // Number of channels
33 | #define MODELS 5 // Total memory models
34 | #define potMin 0 // Pot Min reference value
35 | #define potMax 1023 // Pot Max reference value
36 | #define numBytesPerModel 32 // Maximum bytes for data storage per model
37 |
38 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
39 | // Config pin assignment
40 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
41 | #define swMix 0 // V-Tail mixer switch (active LOW)
42 | #define swTC 4 // Throttle Cut pin (active LOW)
43 | #define swDR 5 // Dual Rate pin (active LOW)
44 | //#define batPin A7 // Battery pin (over 5V need voltage divider and value conversion to display)
45 | #define buzzer PD6 // Buzzer pin (buzzer with standalone sound generator)
46 | #define buttonSelect 1 // Button for Menu/Select functions
47 | #define buttonUp 2 // Button for Up/Prev functions
48 | #define buttonDown 3 // Button for Down/Next functions
49 | #define swA A6 // Switch A Analog pin (active 0)
50 | #define swB 12 // Switch B Digital pin (active LOW)
51 |
52 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53 | #define minBat 70 // Minimum battery voltage for alarm (70 = 7.0V)
54 | #define maxBat 82 // Maximum battery voltage (10V) (82 = 8.2V)
55 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
56 |
57 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
58 | // XBM image size for Model Selection screen
59 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
60 | #define airplane_width 55 // Pixel width of airplane image
61 | #define airplane_height 46 // Pixel height of airplane image
62 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
63 |
64 | unsigned char chanTh = 2; // Throttle channel ID
65 | unsigned char sw_status = 0x00; // 0:TC 1:DR
66 | unsigned short int ppm[CHANNELS]; // ppm output array
67 | unsigned short int pots[CHANNELS]; // Input ADC data array
68 | unsigned short int calibration[CHANNELS][2]; // Min/Max value array for read channels and store calibration
69 | unsigned short int raw_Pots[CHANNELS]; // Read raw input pots array
70 |
71 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
72 | // Menu management variables
73 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
74 | unsigned char menuActual = 0;
75 | unsigned char menuSubActual = 0;
76 | unsigned char modelActual = 0; // Added for Model Menu management
77 | unsigned char menuSubModel = 0; // Added for Model Menu management
78 | unsigned char screen = 0;
79 |
80 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
81 | // Servo management parameters
82 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
83 | unsigned char drSelection = 0xFF; // Default value for Dual Rates
84 | unsigned char servoReverse; // Reading bit status
85 | unsigned char dual_rate_low[CHANNELS]; // Dual Rates LOW value array
86 | unsigned char dual_rate_hi[CHANNELS]; // Dual Rates HIGH value array
87 | unsigned short int NO_DR_VRA; // For pot VRA normal mapping else not working(???)
88 | unsigned short int NO_DR_VRB; // For pot VRB normal mapping else not working(???)
89 |
90 | unsigned short int deadBand = 50; // Deadband center stick value (25 suggested value)
91 | unsigned short int subTrim[CHANNELS]; // Sub Trim channel array
92 | unsigned short int subTrimSelection = 512; // Default value for Sub Trim
93 |
94 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
95 | // Checking conditions control status for warning switch and calibration
96 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
97 | boolean warnSwitch = 1; // One beep control for switch and throttle warning
98 | boolean onStartup = 1; // Status for checking switch and throttle position
99 | boolean statusCalib = 1; // Checking status to enter in calibration procedure
100 | boolean battStatus = 1;
101 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
102 |
103 | byte pulseBuzzer; // Sound pulse for battery alarm
104 |
105 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
106 | // Battery voltage calculation, checking status for alarm, drawing battery bar
107 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
108 | const int numReadings = 8; // Number of reading to calculate average
109 | int readings[numReadings]; // Readings from the analog input (battery input pin A7)
110 | int index = 0; // Index of the current reading
111 | int total = 0; // Running total
112 | int average = 0; // Average value
113 |
114 | float pin_batt_read; // Raw input battery pin value from average reading
115 | float batt_volt; // Battery voltage calculated
116 | float res_calc; // Calculation of voltage divider to be applied to the conversion
117 | float R1 = 10000; // If you need more precision, measure voltage divider resistors value
118 | float R2 = 10000; // with digital multimeter and put them in to R1 R2 variables
119 | unsigned char perc_batt; // Battery bar level indicator (20 pixel) only Min to Max values
120 |
121 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
122 | // Using PROGMEM for characters and text strings to save RAM memory
123 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
124 | // Array text strings for drawing menu
125 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
126 | const char menu_0[] PROGMEM = "SERVO DIRECTION";
127 | const char menu_1[] PROGMEM = "DUAL RATES";
128 | const char menu_2[] PROGMEM = "MODEL SELECTION";
129 | const char menu_3[] PROGMEM = "SAVE MODEL DATA";
130 | const char menu_4[] PROGMEM = "SUB TRIM SETUP";
131 | const char menu_5[] PROGMEM = "SUB TRIM";
132 |
133 | const char* const menu_name[] PROGMEM = {
134 | menu_0,
135 | menu_1,
136 | menu_2,
137 | menu_3,
138 | menu_4,
139 | menu_5
140 | };
141 |
142 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
143 | // Array text strings for screen messages
144 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
145 | const char Message_0[] PROGMEM = "SAVE DATA";
146 | const char Message_1[] PROGMEM = "MODEL";
147 | const char Message_2[] PROGMEM = "CALIBRATION";
148 | const char Message_3[] PROGMEM = "Calibration Started";
149 | const char Message_4[] PROGMEM = "Move the sticks Pots";
150 | const char Message_5[] PROGMEM = "ERASE DATA";
151 | const char Message_6[] PROGMEM = "WARNING !!!";
152 | const char Message_7[] PROGMEM = "SET All SWITCH STICK";
153 | const char Message_8[] PROGMEM = "TO DEFAULT POSITION!";
154 |
155 | const char* const messages[] PROGMEM = {
156 | Message_0,
157 | Message_1,
158 | Message_2,
159 | Message_3,
160 | Message_4,
161 | Message_5,
162 | Message_6,
163 | Message_7,
164 | Message_8
165 | };
166 |
167 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
168 | // Array text strings (short) for Channel/Switch/Pots names, status, model for all screens
169 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
170 | const char chName_0[] PROGMEM = "AIL";
171 | const char chName_1[] PROGMEM = "ELE";
172 | const char chName_2[] PROGMEM = "THR";
173 | const char chName_3[] PROGMEM = "RUD";
174 | const char chName_4[] PROGMEM = "CH5";
175 | const char chName_5[] PROGMEM = "CH6";
176 | const char chName_6[] PROGMEM = "SWA";
177 | const char chName_7[] PROGMEM = "SWB";
178 | const char chName_8[] PROGMEM = "MOD";
179 | const char chName_9[] PROGMEM = "TC";
180 | const char chName_10[] PROGMEM = "DR";
181 | const char chName_11[] PROGMEM = "VRA";
182 | const char chName_12[] PROGMEM = "VRB";
183 | const char chName_13[] PROGMEM = "NOR";
184 | const char chName_14[] PROGMEM = "REV";
185 | const char chName_15[] PROGMEM = "ON";
186 | const char chName_16[] PROGMEM = "OFF";
187 | const char chName_17[] PROGMEM = "MIX";
188 | const char chName_18[] PROGMEM = "MODEL";
189 | const char chName_19[] PROGMEM = "PPM";
190 |
191 | const char* const channel_name[] PROGMEM = {
192 | chName_0,
193 | chName_1,
194 | chName_2,
195 | chName_3,
196 | chName_4,
197 | chName_5,
198 | chName_6,
199 | chName_7,
200 | chName_8,
201 | chName_9,
202 | chName_10,
203 | chName_11,
204 | chName_12,
205 | chName_13,
206 | chName_14,
207 | chName_15,
208 | chName_16,
209 | chName_17,
210 | chName_18,
211 | chName_19
212 | };
213 |
214 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
215 | // Array for single characters
216 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
217 | const char character_0[] PROGMEM = "A";
218 | const char character_1[] PROGMEM = "E";
219 | const char character_2[] PROGMEM = "T";
220 | const char character_3[] PROGMEM = "R";
221 | const char character_4[] PROGMEM = "N";
222 | const char character_5[] PROGMEM = "H";
223 | const char character_6[] PROGMEM = "L";
224 | const char character_7[] PROGMEM = "M";
225 | const char character_8[] PROGMEM = "[";
226 | const char character_9[] PROGMEM = "]";
227 | const char character_10[] PROGMEM = "=";
228 | const char character_11[] PROGMEM = "(";
229 | const char character_12[] PROGMEM = ")";
230 | const char character_13[] PROGMEM = "*";
231 | const char character_14[] PROGMEM = ">";
232 |
233 | const char* const one_char[] PROGMEM = {
234 | character_0,
235 | character_1,
236 | character_2,
237 | character_3,
238 | character_4,
239 | character_5,
240 | character_6,
241 | character_7,
242 | character_8,
243 | character_9,
244 | character_10,
245 | character_11,
246 | character_12,
247 | character_13,
248 | character_14
249 | };
250 |
251 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
252 | // Airplane XBM bitmap for Model Selection screen
253 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
254 | static const unsigned char airplane[] U8X8_PROGMEM = {
255 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
256 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
257 | 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x3F, 0x00, 0x00, 0x00,
258 | 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00,
259 | 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63,
260 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6B, 0x00, 0x00, 0x00, 0x00, 0x00,
261 | 0x00, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00,
262 | 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x00,
263 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x02, 0x00, 0x00,
264 | 0x41, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x41, 0x00, 0x00, 0x20, 0x02,
265 | 0x00, 0x00, 0x41, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x41, 0x00, 0x00,
266 | 0x20, 0x02, 0x00, 0x00, 0x41, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x41,
267 | 0x00, 0x00, 0x20, 0x06, 0xF0, 0x1F, 0x41, 0xFC, 0x07, 0x30, 0xFC, 0x11,
268 | 0x70, 0x7F, 0x07, 0xC4, 0x1F, 0x00, 0x1F, 0x40, 0x63, 0x01, 0x7C, 0x00,
269 | 0x00, 0xF0, 0x9F, 0xC1, 0xFC, 0x07, 0x00, 0x00, 0x00, 0xF0, 0xE3, 0x07,
270 | 0x00, 0x00, 0x00, 0x00, 0x80, 0xE3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
271 | 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00,
272 | 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00,
273 | 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C,
274 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00,
275 | 0xFF, 0xF7, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x77, 0x7C, 0x00, 0x00,
276 | 0x00, 0x00, 0x03, 0x77, 0x60, 0x00, 0x00, 0x00, 0x00, 0x01, 0x36, 0x40,
277 | 0x00, 0x00, 0x00, 0x00, 0x03, 0x36, 0x60, 0x00, 0x00, 0x00, 0x00, 0xFF,
278 | 0xF7, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00,
279 | 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00,
280 | 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C,
281 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
282 | };
283 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/Dual_Rates.ino:
--------------------------------------------------------------------------------
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 | // Percentage calculation for Dual Rates (Endpoints)
3 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 | int setDR(int value, float dr, unsigned char chan, unsigned char chanTh){
5 |
6 | // Dual Rate calculation
7 | int output, temp;
8 | float mult;
9 | mult = dr;
10 |
11 | if (chan == chanTh) {
12 | output = (int)value * mult / 100;
13 | }
14 | else {
15 | temp = value - 512;
16 | output = (int)((temp * mult / 100) + 512);
17 | }
18 | output = constrain(output, 0, 1023);
19 |
20 | return output;
21 | }
22 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/Eeprom.ino:
--------------------------------------------------------------------------------
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 | // This macro will be used to clear eeprom and set default parameters if necessary
3 | // Hold button "Down" on power ON to erase all memory data (NOT Calibration Data)
4 | // NOTE: SHOULD BE USED FOR THE FIRST TIME AFTER CALIBRATION !!!
5 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 | void resetEeprom() {
7 |
8 | // For write Servo Direction and Dual Rates position
9 | unsigned int eepromPos;
10 |
11 | // For read/write Sub Trim values position
12 | unsigned int posEeprom;
13 |
14 | // Writing default model[0]
15 | EEPROM.write(511, 0);
16 |
17 | // Start writing default values for every model memory bank
18 | for (int j = 0; j < MODELS; j++) {
19 |
20 | // Define start position for Eeprom storing (32 * [0,1,2,3,4])
21 | eepromPos = numBytesPerModel * j;
22 |
23 | // Writing Servo Direction default value in first address of start position
24 | EEPROM.write(eepromPos, 0x00);
25 |
26 | // Writing Sub Trim center stick values for four channels in every model memory bank
27 | for (int i = 0; i < CHANNELS - 2; i++) {
28 |
29 | // Writing Sub Trim stick values for every channels
30 | posEeprom = (eepromPos + 10) + (i * 4);
31 | EEPROMWriteInt(posEeprom, 512);
32 | }
33 |
34 | eepromPos++; // +1 counting increment
35 |
36 | // Writing Dual Rates values for every channels in every model memory bank
37 | // Writing values will start after first address of start position
38 | for (int i = 0; i < CHANNELS - 2; i++) {
39 |
40 | // Writing default LOW rates for channels
41 | EEPROM.write(eepromPos, 75);
42 |
43 | eepromPos++; // +1 counting increment
44 |
45 | // Writing default HIGH rates for channels
46 | EEPROM.write(eepromPos, 100);
47 |
48 | eepromPos++; // +1 counting increment
49 | }
50 | }
51 | }
52 |
53 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
54 | // Macro for read selected model data from Eeprom
55 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
56 | unsigned char storedDataEeprom(unsigned char mod) {
57 |
58 | // For Eeprom position reference
59 | unsigned int eepromBase;
60 |
61 | // Read which model to upload data
62 | if (mod == 255) {
63 | mod = EEPROM.read(511);
64 | }
65 |
66 | // Define start position for Eeprom read (32 * [0,1,2,3,4])
67 | eepromBase = numBytesPerModel * mod;
68 |
69 | unsigned int eepromPos = eepromBase;
70 |
71 | // Read Sub Trim center stick values for selected model
72 | for (int i = 0; i < CHANNELS - 2; i++) {
73 |
74 | subTrim[i] = EEPROMReadInt((eepromPos + 10) + (i * 4));
75 | }
76 |
77 | // Read Servo Direction from first position
78 | servoReverse = EEPROM.read(eepromPos);
79 |
80 | eepromPos++; // +1 counting increment
81 |
82 | // Read Dual Rates values after first position
83 | for (int i = 0; i < CHANNELS - 2; i++) {
84 |
85 | // Read LOW rates for channels
86 | dual_rate_low[i] = EEPROM.read(eepromPos);
87 |
88 | eepromPos++; // +1 counting increment
89 |
90 | // Read HIGH rates for channels
91 | dual_rate_hi[i] = EEPROM.read(eepromPos);
92 |
93 | eepromPos++; // +1 counting increment
94 | }
95 |
96 | unsigned int posEeprom;
97 |
98 | // Read Min Max calibration values from Eeprom
99 | for (int i = 0; i < CHANNELS; i++) {
100 |
101 | // Read Min calibration values for channels
102 | posEeprom = 400 + (i * 4);
103 | calibration[i][0] = EEPROMReadInt(posEeprom);
104 |
105 | // Read Max calibration values for channels
106 | posEeprom += 2;
107 | calibration[i][1] = EEPROMReadInt(posEeprom);
108 | }
109 | return mod;
110 | }
111 |
112 | // ++++++++++++++++++++++++++++++++++++++++++++++
113 | // Write, Read and Update Eeprom data format
114 | // ++++++++++++++++++++++++++++++++++++++++++++++
115 | void EEPROMWriteInt(int p_address, int p_value) {
116 |
117 | // Write a 16bit value in Eeprom
118 | byte Byte1 = ((p_value >> 0) & 0xFF);
119 | byte Byte2 = ((p_value >> 8) & 0xFF);
120 |
121 | EEPROM.write(p_address, Byte1);
122 | EEPROM.write(p_address + 1, Byte2);
123 | }
124 |
125 | int EEPROMReadInt(int p_address) {
126 |
127 | // Read a 16 bit value in Eeprom
128 | byte Byte1 = EEPROM.read(p_address);
129 | byte Byte2 = EEPROM.read(p_address + 1);
130 |
131 | long firstTwoBytes = ((Byte1 << 0) & 0xFF) + ((Byte2 << 8) & 0xFF00);
132 | return (firstTwoBytes);
133 | }
134 |
135 | // will update only changed value to preserve eeprom writing cycles
136 | void EEPROMUpdateInt(int p_address, int p_value) {
137 |
138 | // Write a 16bit value in Eeprom
139 | byte Byte1 = ((p_value >> 0) & 0xFF);
140 | byte Byte2 = ((p_value >> 8) & 0xFF);
141 |
142 | EEPROM.update(p_address, Byte1);
143 | EEPROM.update(p_address + 1, Byte2);
144 | }
145 |
146 |
147 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/PPM_Channels.ino:
--------------------------------------------------------------------------------
1 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 | // Macro for read sticks, pots, switches values and applying calibration and rules
3 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 | void readPots() {
5 |
6 | for (int i = 0; i < CHANNELS; i++) {
7 |
8 | raw_Pots[i] = read_adc(i);
9 |
10 | // Applying calibration mapping
11 | pots[i] = map(raw_Pots[i], calibration[i][0], calibration[i][1], potMin, potMax);
12 |
13 | // Assign pot VRA calibrated value
14 | // for NO Dual Rates else not working(???)
15 | NO_DR_VRA = pots[4];
16 |
17 | // Assign pot VRB calibrated value
18 | // for NO Dual Rates else not working(???)
19 | NO_DR_VRB = pots[5];
20 |
21 | // Check Servo Reversing and applying Reverse value if necessary
22 | if (bitRead(servoReverse, i) == 1) {
23 | pots[i] = potMax - pots[i];
24 | }
25 |
26 | // Checking Throttle Cut switch status,
27 | // if TC activated throttle stick not working
28 | if (i == chanTh && bitRead(sw_status, 0) == 0) {
29 | pots[i] = 0;
30 | }
31 |
32 | // Checking Dual Rates switch status,
33 | // if DR activated limitation of the preset percentage value will be applied
34 | if (bitRead(sw_status, 1) == 0) {
35 |
36 | // LOW rates calculation
37 | pots[i] = setDR(pots[i], dual_rate_low[i], i, chanTh);
38 |
39 | // NO Dual rates for pots
40 | pots[4] = NO_DR_VRA;
41 | pots[5] = NO_DR_VRB;
42 | }
43 | else {
44 |
45 | // HIGH rates calculation
46 | pots[i] = setDR(pots[i], dual_rate_hi[i], i, chanTh);
47 |
48 | // NO Dual rates for pots
49 | pots[4] = NO_DR_VRA;
50 | pots[5] = NO_DR_VRB;
51 | }
52 |
53 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
54 | // ppm mapping ch1/ch2 values if V-mix switch is enabled
55 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
56 | if (bitRead(sw_status, 5) == 0) {
57 |
58 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
59 | // V-Mix variables
60 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
61 | unsigned int ppm_CH1;
62 | unsigned int ppm_CH2;
63 | unsigned int mixVal;
64 |
65 | // ppm mapping CH3/CH4 only with deadband
66 | for (int i = 2; i < CHANNELS - 2; i++) {
67 |
68 | if (pots[i] < (subTrim[i] - deadBand)) {
69 | ppm[i] = map(pots[i], potMin, subTrim[i] - deadBand, ppmMin, servoCenter);
70 | }
71 | else if (pots[i] > subTrim[i] + deadBand) {
72 | ppm[i] = map(pots[i], subTrim[i] + deadBand, potMax, servoCenter, ppmMax);
73 | }
74 | else {
75 |
76 | // Auto centering if in deadband
77 | ppm[i] = servoCenter;
78 | }
79 |
80 | // Temporary mapping CH1/CH2 with deadband
81 | if (pots[0] < (subTrim[0] - deadBand)) {
82 | ppm_CH1 = map(pots[0], potMin, subTrim[0] - deadBand, ppmMin, servoCenter);
83 | }
84 | else if (pots[0] > subTrim[0] + deadBand) {
85 | ppm_CH1 = map(pots[0], subTrim[i] + deadBand, potMax, servoCenter, ppmMax);
86 | }
87 | else {
88 |
89 | // Auto centering if in deadband
90 | ppm_CH1 = servoCenter;
91 | }
92 | if (pots[1] < (subTrim[1] - deadBand)) {
93 | ppm_CH2 = map(pots[1], potMin, subTrim[1] - deadBand, ppmMin, servoCenter);
94 | }
95 | else if (pots[1] > subTrim[1] + deadBand) {
96 | ppm_CH2 = map(pots[1], subTrim[1] + deadBand, potMax, servoCenter, ppmMax);
97 | }
98 | else {
99 |
100 | // Auto centering if in deadband
101 | ppm_CH2 = servoCenter;
102 | }
103 |
104 | // Mapping ppm CH1/CH2 values for V-mix
105 | mixVal = (ppm_CH1 - servoCenter);
106 |
107 | // applying the result on CH1/CH2 ppm output
108 | ppm[0] = ppm_CH2 - mixVal;
109 | ppm[1] = ppm_CH2 + mixVal;
110 | }
111 | }
112 | else {
113 |
114 | // ppm mapping CH1/CH2/CH3/CH4 with deadband
115 | for (int i = 0; i < CHANNELS - 2; i++) {
116 |
117 | if (pots[i] < (subTrim[i] - deadBand)) {
118 | ppm[i] = map(pots[i], potMin, subTrim[i] - deadBand, ppmMin, servoCenter);
119 | }
120 | else if (pots[i] > subTrim[i] + deadBand) {
121 | ppm[i] = map(pots[i], subTrim[i] + deadBand, potMax, servoCenter, ppmMax);
122 | }
123 | else {
124 |
125 | // Auto centering if in deadband
126 | ppm[i] = servoCenter;
127 | }
128 | }
129 |
130 | }
131 |
132 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
133 | // ppm mapping pot VRA to Switch SWA
134 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
135 |
136 | // SWA switch ppm mapping on analog input (CH5)
137 | if (bitRead(servoReverse, 4) == 1) {
138 | ppm[4] = map(read_adc(6), potMin, potMax, ppmMax, ppmMin);
139 | }
140 | else {
141 | // VRA pot mapping (CH5)
142 | ppm[4] = map(read_adc(4), potMin, potMax, ppmMin, ppmMax);
143 | }
144 |
145 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
146 | // ppm mapping pot VRB to Switch SWB
147 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
148 |
149 | // SWB switch ppm mapping on digital input (CH6)
150 | if (bitRead(servoReverse, 5) == 1) {
151 | ppm[5] = map(digitalRead(swB), 1, 0, ppmMin, ppmMax);
152 | }
153 | else {
154 | // VRB pot mapping (CH6)
155 | ppm[5] = map(read_adc(5), potMin, potMax, ppmMin, ppmMax);
156 | }
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/PPM_Output.ino:
--------------------------------------------------------------------------------
1 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++
2 | // timer1 setup
3 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++
4 | void configTimer1() {
5 |
6 | cli();
7 | TCCR1A = 0;
8 | TCCR1B = 0;
9 |
10 | OCR1A = 100;
11 | TCCR1B |= (1 << WGM12);
12 | TCCR1B |= (1 << CS11); // prescaler 8: 0.5us - 16mhz
13 |
14 | TIMSK1 |= (1 << OCIE1A);
15 | sei();
16 | }
17 | //+++++++++++++++++++++++++++++++++++++++
18 | // Timer interrupt settings
19 | //+++++++++++++++++++++++++++++++++++++++
20 | ISR(TIMER1_COMPA_vect) {
21 |
22 | static boolean state = true;
23 |
24 | TCNT1 = 0;
25 |
26 | if (state) {
27 | if (onState == 0) {
28 | PORTD &= ~_BV(sigPin); // set bit 0
29 | }
30 | else {
31 | PORTD |= _BV(sigPin); // set bit 1
32 | }
33 | OCR1A = ppmPulse * 2;
34 | state = false;
35 | }
36 | else {
37 | static byte cur_chan_numb;
38 | static unsigned int calc_rest;
39 |
40 | PORTD ^= _BV(sigPin); // toggle bit
41 |
42 | state = true;
43 |
44 | if (cur_chan_numb >= CHANNELS) {
45 | cur_chan_numb = 0;
46 | calc_rest = calc_rest + ppmPulse;
47 | OCR1A = (ppmLong - calc_rest) * 2;
48 | calc_rest = 0;
49 | }
50 | else {
51 | OCR1A = (ppm[cur_chan_numb] - ppmPulse) * 2;
52 | calc_rest = calc_rest + ppm[cur_chan_numb];
53 | cur_chan_numb++;
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/Read_ADC.ino:
--------------------------------------------------------------------------------
1 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 | // Macro for directly read ADC value on all analog ports
3 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 | unsigned short int read_adc(unsigned char channel) {
5 |
6 | ADMUX &= 0xF0; //Clear the older channel that was read
7 | ADMUX |= channel; //Defines the new ADC channel to be read
8 | ADCSRA |= (1 << ADSC); //Starts a new conversion
9 | while (ADCSRA & (1 << ADSC)); //Wait until the conversion is done
10 | return ADCW; //Returns the ADC value of the chosen channel
11 | }
12 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/Screen.ino:
--------------------------------------------------------------------------------
1 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 | // Drawing Main Screen display
3 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 | void Screen_0() {
5 |
6 | // Set memory buffer for text strings
7 | char chName_buffer[6];
8 | char char_buffer[2];
9 |
10 | // Start of main screen display informations "0" ************************
11 | u8g2.firstPage();
12 | do {
13 |
14 | readPots(); // Recall macro again for stable ppm pulse
15 |
16 | // Print "MOD" text string
17 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[8])));
18 | u8g2.setCursor(0, 7);
19 | u8g2.print(chName_buffer);
20 |
21 | // Print number of which model in use
22 | u8g2.setCursor(23, 7);
23 | u8g2.print(modelActual + 1);
24 |
25 | // Throttle Cut switch status checking
26 | if (bitRead(sw_status, 0) == 0) {
27 |
28 | //Print Throttle Cut status only if active (TC)
29 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[9])));
30 | u8g2.setCursor(37, 7);
31 | u8g2.print(chName_buffer);
32 | }
33 | // V-Mix switch status checking
34 | if (bitRead(sw_status, 5) == 0) {
35 |
36 | //Print V-Mix status only if active (MIX)
37 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[17])));
38 | u8g2.setCursor(57, 7);
39 | u8g2.print(chName_buffer);
40 | }
41 | // Dual Rates switch status checking
42 | if (bitRead(sw_status, 1) == 0) {
43 |
44 | // Print Dual Rates status only if active (DR)
45 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[10])));
46 | u8g2.setCursor(82, 7);
47 | u8g2.print(chName_buffer);
48 | }
49 | // Battery simbol contruction
50 | u8g2.drawFrame(102, 0, 24, 8); // Battery box
51 | u8g2.drawBox(104, 2, perc_batt, 4); // level bar
52 | u8g2.drawBox(126, 2, 2, 3); // Battery nipple plus pole
53 |
54 | // Print first 4 channels reference with input pots order
55 | // A0(A), A1(E), A2(T), A3(R)
56 |
57 | // Print "A" character
58 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[0])));
59 | u8g2.setCursor(0, 20);
60 | u8g2.print(char_buffer);
61 |
62 | // Print "E" character
63 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[1])));
64 | u8g2.setCursor(0, 30);
65 | u8g2.print(char_buffer);
66 |
67 | // Print "T" character
68 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[2])));
69 | u8g2.setCursor(0, 40);
70 | u8g2.print(char_buffer);
71 |
72 | // Print "R" character
73 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[3])));
74 | u8g2.setCursor(0, 50);
75 | u8g2.print(char_buffer);
76 |
77 | //Drawing vertical middle/center separation line
78 | u8g2.drawVLine(65, 14, 64);
79 |
80 | // Drawing only first 4 channels
81 | for (int i = 0; i <= 3; i++) {
82 |
83 | // Define value bar reference
84 | unsigned int valBar;
85 |
86 | // Value bars subdivision (ppm value / 100)
87 | valBar = map(ppm[i], ppmMin, ppmMax, 0 , 100);
88 |
89 | // Draw boxes/frames for every channel
90 | u8g2.drawFrame(13, 13 + (i * 10), 105, 8);
91 |
92 | // Drawing cursor in every channel bar
93 | u8g2.drawBox(13 + valBar, 14 + (i * 10), 5, 6);
94 |
95 | if (bitRead(servoReverse, i) == 1) {
96 |
97 | // Print "R"everse channel status for every channel
98 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[3])));
99 | u8g2.setCursor(123, 20 + i * 11);
100 | u8g2.print(char_buffer);
101 | }
102 | else {
103 |
104 | // Print "N"ormal channel status for every channel
105 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[4])));
106 | u8g2.setCursor(123, 20 + i * 11);
107 | u8g2.print(char_buffer);
108 | }
109 | }
110 | //If switch SWA print ON/OFF state
111 | if (bitRead(servoReverse, 4) == 1) {
112 |
113 | // Print "SWA" text
114 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[6])));
115 | u8g2.setCursor(13, 64);
116 | u8g2.print(chName_buffer);
117 |
118 | if (read_adc(6) < 500) {
119 |
120 | // Print SWA "ON" text
121 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[15])));
122 | u8g2.setCursor(40, 64);
123 | u8g2.print(chName_buffer);
124 | }
125 | else {
126 |
127 | // Print SWA "OFF" text
128 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[16])));
129 | u8g2.setCursor(40, 64);
130 | u8g2.print(chName_buffer);
131 | }
132 | }
133 | else {
134 |
135 | //If pot VRA print value in %
136 | unsigned int VRA;
137 | VRA = map(pots[4], 0, potMax, 0, 100);
138 |
139 | // Print "VRA" text
140 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[11])));
141 | u8g2.setCursor(13, 64);
142 | u8g2.print(chName_buffer);
143 |
144 | // Print VRA value
145 | u8g2.setCursor(40, 64);
146 | u8g2.print(VRA);
147 | }
148 |
149 | //If switch SWB print ON/OFF state
150 | if (bitRead(servoReverse, 5) == 1) {
151 |
152 | // Print "SWB" text
153 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[7])));
154 | u8g2.setCursor(73, 64);
155 | u8g2.print(chName_buffer);
156 |
157 | if (digitalRead(swB) == 0) {
158 |
159 | // Print SWB "ON" text
160 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[15])));
161 | u8g2.setCursor(98, 64);
162 | u8g2.print(chName_buffer);
163 | }
164 | else {
165 |
166 | // Print SWB "OFF" text
167 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[16])));
168 | u8g2.setCursor(98, 64);
169 | u8g2.print(chName_buffer);
170 | }
171 | }
172 | else {
173 |
174 | //If pot VRB print value in %
175 | unsigned int VRB;
176 | VRB = map(pots[5], 0, potMax, 0, 100);
177 |
178 | // Print "VRB" text
179 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[12])));
180 | u8g2.setCursor(75, 64);
181 | u8g2.print(chName_buffer);
182 |
183 | // Print VRB value
184 | u8g2.setCursor(100, 64);
185 | u8g2.print(VRB);
186 | }
187 |
188 | } while (u8g2.nextPage());
189 |
190 | // End of main screen display informations "0" **************************
191 | }
192 |
193 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
194 | // Drawing Menu Selection screen display
195 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
196 | void Screen_1 () {
197 |
198 | // Set memory buffer for text strings
199 | char menu_buffer[18];
200 | char char_buffer[2];
201 |
202 | // Start of menu selection screen
203 | u8g2.firstPage();
204 | do {
205 |
206 | readPots(); // Recall macro for stable ppm pulse
207 |
208 | for (int i = 0; i < CHANNELS; i++) {
209 |
210 | // Print main menu items
211 | strcpy_P(menu_buffer, (char*)pgm_read_word(&(menu_name[i - 1])));
212 |
213 | if (i == menuSubActual) {
214 |
215 | // Print selection cursor character "*"
216 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[13])));
217 | u8g2.setCursor(0, i * 12);
218 | u8g2.print(char_buffer);
219 |
220 | // Print main menu items
221 | u8g2.setCursor(15, i * 12);
222 | u8g2.print(menu_buffer);
223 | }
224 | else {
225 |
226 | // Print main menu items
227 | u8g2.setCursor(25, i * 12);
228 | u8g2.print(menu_buffer);
229 | }
230 | }
231 | } while (u8g2.nextPage());
232 | }
233 |
234 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
235 | // Drawing Servo Direction screen display
236 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
237 | void Menu_1 () {
238 |
239 | // Set memory buffer for text strings
240 | char chName_buffer[6];
241 | char char_buffer[2];
242 |
243 | // Start of Servo direction setting screen "2" "1" **********************
244 | u8g2.firstPage();
245 | do {
246 |
247 | readPots(); // Recall macro for stable ppm pulse
248 |
249 | // Print Servo Direction channels screen list
250 | for (int i = 0; i < CHANNELS; i++) {
251 |
252 | // Print channel name list
253 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[i])));
254 |
255 | if (i == menuSubActual) {
256 |
257 | // Print selection cursor "["
258 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[8])));
259 | u8g2.setCursor(0, 7 + i * 11);
260 | u8g2.print(char_buffer);
261 |
262 | // Print character "=");
263 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[10])));
264 | u8g2.setCursor(28, 7 + i * 11);
265 | u8g2.print(char_buffer);
266 |
267 | // Print selection cursor character "]" for selected item
268 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[9])));
269 | u8g2.setCursor(57, 7 + i * 11);
270 | u8g2.print(char_buffer);
271 |
272 | }
273 |
274 | // Print channel items name
275 | u8g2.setCursor(8, 7 + i * 11);
276 | u8g2.print(chName_buffer);
277 |
278 | if (bitRead(servoReverse, i) == 1) {
279 |
280 | // Print(REV)erse status
281 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[14])));
282 | u8g2.setCursor(37, 7 + i * 11);
283 | u8g2.print(chName_buffer);
284 | }
285 | else {
286 |
287 | // Print(NOR)mal status
288 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[13])));
289 | u8g2.setCursor(37, 7 + i * 11);
290 | u8g2.print(chName_buffer);
291 | }
292 | if (bitRead(servoReverse, 4) == 1) {
293 | // Print SWA if REVerse status
294 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[6])));
295 | u8g2.setCursor(37, 51);
296 | u8g2.print(chName_buffer);
297 | }
298 | else {
299 |
300 | // Print VRA if NORmal status
301 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[11])));
302 | u8g2.setCursor(37, 51);
303 | u8g2.print(chName_buffer);
304 | }
305 | if (bitRead(servoReverse, 5) == 1) {
306 | // Print SWB if REVerse status
307 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[7])));
308 | u8g2.setCursor(37, 62);
309 | u8g2.print(chName_buffer);
310 | }
311 | else {
312 |
313 | // Print VRB if NORmal status
314 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[12])));
315 | u8g2.setCursor(37, 62);
316 | u8g2.print(chName_buffer);
317 | }
318 | }
319 |
320 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
321 | // Drawing dynamic graphics items
322 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
323 |
324 | // Drawing status of CH5 if VRA(POT) or SWA(SWITCH)
325 | if (bitRead(servoReverse, 4) == 1) {
326 | u8g2.drawRFrame(74, 43, 11, 20, 3); // Draw SWA box
327 | u8g2.drawDisc(79, 48, 3, U8G2_DRAW_ALL); // Draw SWA round point
328 | }
329 | else {
330 | u8g2.drawCircle(78, 51, 9, U8G2_DRAW_ALL); // Draw VRA
331 | u8g2.drawBox(66, 50, 9, 3); // Draw VRA cursor box
332 | u8g2.drawDisc(78, 51, 5, U8G2_DRAW_ALL); // Draw SWB round point
333 | }
334 |
335 | // Drawing status of CH6 if VRB(POT) or SWB(SWITCH)
336 | if (bitRead(servoReverse, 5) == 1) {
337 | u8g2.drawRFrame(107, 43, 11, 20, 3); // Draw SWB box
338 | u8g2.drawDisc(112, 48, 3, U8G2_DRAW_ALL); // Draw SWB round point
339 | }
340 | else {
341 | u8g2.drawCircle(112, 51, 9, U8G2_DRAW_ALL); // Draw VRB
342 | u8g2.drawBox(100, 50, 9, 3); // Draw VRB cursor box
343 | u8g2.drawDisc(112, 51, 5, U8G2_DRAW_ALL); // Draw VRB round point
344 | }
345 |
346 | u8g2.drawFrame(66, 11, 26, 26); // Left Stick squared box
347 |
348 | // Drawing left stick position CH4/CH3
349 | u8g2.drawDisc(map(ppm[3], 1000 , 2000, 70, 88), map(ppm[2], 1000 , 2000, 32, 15), 2);
350 |
351 | u8g2.drawFrame(100, 11, 26, 26); // Right Stick squared box
352 |
353 | // Drawing left stick position CH1/CH2
354 | u8g2.drawDisc(map(ppm[0], 1000 , 2000, 104, 121), map(ppm[1], 1000 , 2000, 32, 15), 2);
355 |
356 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
357 |
358 | // Print "*" text character
359 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[13])));
360 | u8g2.setCursor(71, 7);
361 | u8g2.print(char_buffer);
362 |
363 | // Print "MODEL" text string
364 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[18])));
365 | u8g2.setCursor(81, 7);
366 | u8g2.print(chName_buffer);
367 |
368 | // Print number of model
369 | u8g2.setCursor(116, 7);
370 | u8g2.print(modelActual + 1);
371 |
372 | } while (u8g2.nextPage());
373 | }
374 |
375 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
376 | // Drawing Dual Rates screen display
377 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
378 | void Menu_2 () {
379 |
380 | // Set memory buffer for text strings
381 | char chName_buffer[6];
382 | char char_buffer[2];
383 | char menu_buffer[18];
384 |
385 | // Start of Dual Rates setting screen ***********************************
386 | u8g2.firstPage();
387 | do {
388 |
389 | readPots(); // Recall macro for stable ppm pulse
390 |
391 | unsigned char counterTemp = 0;
392 |
393 | // Print Dual Rates channels list
394 | for (int i = 0; i < CHANNELS - 2; i++) {
395 |
396 | // Print channel name list
397 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[i])));
398 | u8g2.setCursor(0, 25 + i * 13);
399 | u8g2.print(chName_buffer);
400 |
401 | if (menuSubActual == counterTemp) {
402 | if (drSelection == counterTemp) {
403 |
404 | // Print "[" character for item selected for LOW value
405 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[8])));
406 | u8g2.setCursor(24, 25 + i * 13);
407 | u8g2.print(char_buffer);
408 |
409 | // Print "]" character for item selected for LOW value
410 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[9])));
411 | u8g2.setCursor(68, 25 + i * 13);
412 | u8g2.print(char_buffer);
413 | }
414 | else {
415 |
416 | // Print selection cursor character ">" for LOW value
417 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[14])));
418 | u8g2.setCursor(24, 25 + i * 13);
419 | u8g2.print(char_buffer);
420 | }
421 | }
422 |
423 | // Print "L" character for LOW value
424 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[6])));
425 | u8g2.setCursor(31, 25 + i * 13);
426 | u8g2.print(char_buffer);
427 |
428 | // Print character "=");
429 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[10])));
430 | u8g2.setCursor(40, 25 + i * 13);
431 | u8g2.print(char_buffer);
432 |
433 | // Print LOW value
434 | u8g2.setCursor(49, 25 + i * 13);
435 | u8g2.print(dual_rate_low[i]);
436 |
437 | counterTemp++;
438 |
439 | if (menuSubActual == counterTemp) {
440 | if (drSelection == counterTemp) {
441 |
442 | // Print "[" character for item selected for HIGH value
443 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[8])));
444 | u8g2.setCursor(78, 25 + i * 13);
445 | u8g2.print(char_buffer);
446 |
447 | // Print "]" character for item selected for HIGH value
448 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[9])));
449 | u8g2.setCursor(123, 25 + i * 13);
450 | u8g2.print(char_buffer);
451 | }
452 | else {
453 |
454 | // Print selection cursor character ">" for HIGH value
455 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[14])));
456 | u8g2.setCursor(78, 25 + i * 13);
457 | u8g2.print(char_buffer);
458 | }
459 | }
460 |
461 | // Print "H" text character for HIGH value
462 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[5])));
463 | u8g2.setCursor(85, 25 + i * 13);
464 | u8g2.print(char_buffer);
465 |
466 | // Print character "=");
467 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[10])));
468 | u8g2.setCursor(95, 25 + i * 13);
469 | u8g2.print(char_buffer);
470 |
471 | // Print HIGH value
472 | u8g2.setCursor(104, 25 + i * 13);
473 | u8g2.print(dual_rate_hi[i]);
474 |
475 | counterTemp++;
476 | }
477 |
478 | // Print "*" text character
479 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[13])));
480 | u8g2.setCursor(0, 7);
481 | u8g2.print(char_buffer);
482 |
483 | // Print "MODEL" text string
484 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[18])));
485 | u8g2.setCursor(10, 7);
486 | u8g2.print(chName_buffer);
487 |
488 | // Print number of actual model
489 | u8g2.setCursor(45, 7);
490 | u8g2.print(modelActual + 1);
491 |
492 | // Print "DUAL RATES" text string
493 | strcpy_P(menu_buffer, (char*)pgm_read_word(&(menu_name[1])));
494 | u8g2.setCursor(68, 7);
495 | u8g2.print(menu_buffer);
496 |
497 | } while (u8g2.nextPage());
498 | }
499 |
500 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
501 | // Drawing Model Selection screen display
502 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
503 | void Menu_3 () {
504 |
505 | // Set memory buffer for text strings
506 | char char_buffer[2];
507 | char chName_buffer[6];
508 |
509 | // Start of Model Selection screen ***********************************
510 |
511 | u8g2.firstPage();
512 | do {
513 |
514 | readPots(); // Recall macro for stable ppm pulse
515 |
516 | // Print Model Selection list
517 | for (int i = 0; i <= MODELS - 1; i++) {
518 |
519 | u8g2.setCursor(15, 7 + i * 14);
520 | u8g2.print(i + 1);
521 |
522 | if (i == menuSubModel) {
523 |
524 | // Print model selection cursor
525 |
526 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[8])));
527 | u8g2.setCursor(0, 7 + i * 14);
528 | u8g2.print(char_buffer);
529 |
530 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[9])));
531 | u8g2.setCursor(30, 7 + i * 14);
532 | u8g2.print(char_buffer);
533 | }
534 | }
535 |
536 | // Print "MODEL" text string
537 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[18])));
538 | u8g2.setCursor(62, 7);
539 | u8g2.print(chName_buffer);
540 |
541 | u8g2.setCursor(103, 7);
542 | u8g2.print(modelActual + 1);
543 |
544 | // Drawing vertical line before airplane XBM image
545 | u8g2.drawBox(45, 0, 3, 64);
546 |
547 | // Print airplane XBM image
548 | u8g2.drawXBMP(58, 16, airplane_width, airplane_height, airplane);
549 |
550 | // Drawing vertical line after airplane XBM image
551 | u8g2.drawBox(124, 0, 3, 64);
552 |
553 | } while (u8g2.nextPage());
554 | }
555 |
556 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
557 | // Drawing Save Model Data screen display
558 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
559 | void Menu_4 () {
560 |
561 | // For Eeprom position reference
562 | unsigned int eepromBase;
563 |
564 | // For write/Update Sub Trim stored values
565 | unsigned int posEeprom;
566 |
567 | // Define start position for Eeprom write/update (32 * [0,1,2,3,4])
568 | eepromBase = numBytesPerModel * modelActual;
569 |
570 | // For write/Update Servo Direction and Dual Rates position
571 | unsigned int eepromPos = eepromBase;
572 |
573 | // Save Actual Model data
574 | EEPROM.update(511, modelActual);
575 |
576 | // Save Servo Direction data
577 | EEPROM.update(eepromPos, servoReverse);
578 |
579 | // Save Sub Trim center stick values for four channels in every model memory bank
580 | for (int i = 0; i < CHANNELS - 2; i++) {
581 |
582 | // Save center stick values for every channels
583 | posEeprom = (eepromPos + 10) + (i * 4);
584 | EEPROMWriteInt(posEeprom, subTrim[i]);
585 | }
586 |
587 | eepromPos++; // +1 counting increment
588 |
589 | // Save Dual Rates data
590 | for (int i = 0; i < CHANNELS - 2; i++) {
591 |
592 | EEPROM.update(eepromPos, dual_rate_low[i]);
593 | eepromPos++;
594 |
595 | EEPROM.update(eepromPos, dual_rate_hi[i]);
596 | eepromPos++;
597 | }
598 |
599 | // Start of Save Data message screen ************************
600 | u8g2.firstPage();
601 | do {
602 |
603 | // Changing fot type
604 | u8g2.setFont(u8g2_font_9x15B_tr);
605 |
606 | // Set memory buffer for text strings
607 | char msg_buffer[21];
608 |
609 | strcpy_P(msg_buffer, (char*)pgm_read_word(&(messages[0])));
610 | u8g2.setCursor(25, 15);
611 | u8g2.print(msg_buffer);
612 |
613 | strcpy_P(msg_buffer, (char*)pgm_read_word(&(messages[1])));
614 | u8g2.setCursor(35, 45);
615 | u8g2.print(msg_buffer);
616 |
617 | u8g2.setCursor(90, 45);
618 | u8g2.print(modelActual + 1);
619 |
620 | } while (u8g2.nextPage());
621 |
622 | // End of Save Data message screen **************************
623 |
624 | delay(2000); // Screen message for 2sec
625 |
626 | // Changing to default font type
627 | u8g2.setFont(u8g2_font_6x10_tr);
628 |
629 | screen--;
630 | menuActual = 1;
631 | menuSubActual = 1;
632 | }
633 |
634 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
635 | // Drawing Sub Trim Setup screen display
636 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
637 | void Menu_5 () {
638 |
639 | // Set memory buffer for text strings
640 | char chName_buffer[6];
641 | char char_buffer[2];
642 | char menu_buffer[18];
643 |
644 | // Start Sub Trim Setup screen ***********************************
645 | u8g2.firstPage();
646 | do {
647 |
648 | readPots(); // Recall macro for stable ppm pulse
649 |
650 | unsigned char temp_Counter = 0;
651 |
652 | // Print Sub Trim channels list
653 | for (int i = 0; i < CHANNELS - 2; i++) {
654 |
655 | // Print channel name items
656 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[i])));
657 | u8g2.setCursor(8, 25 + i * 13);
658 | u8g2.print(chName_buffer);
659 |
660 | if (menuSubActual == temp_Counter) {
661 | if (subTrimSelection == temp_Counter) {
662 |
663 | // Print selection cursor character ">" for channel
664 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[14])));
665 | u8g2.setCursor(0, 25 + i * 13);
666 | u8g2.print(char_buffer);
667 |
668 | // Print selection cursor character "[" for selected item
669 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[8])));
670 | u8g2.setCursor(28, 25 + i * 13);
671 | u8g2.print(char_buffer);
672 |
673 | // Print selection cursor character "]" for selected item
674 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[9])));
675 | u8g2.setCursor(54, 25 + i * 13);
676 | u8g2.print(char_buffer);
677 | }
678 | else {
679 |
680 | // Print selection cursor character ">" for channel
681 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[14])));
682 | u8g2.setCursor(0, 25 + i * 13);
683 | u8g2.print(char_buffer);
684 | }
685 | }
686 |
687 | // Print Sub Trim value
688 | u8g2.setCursor(35, 25 + i * 13);
689 | u8g2.print(subTrim[i]);
690 |
691 | // Print character "=");
692 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[10])));
693 | u8g2.setCursor(62, 25 + i * 13);
694 | u8g2.print(char_buffer);
695 |
696 | // Print "PPM" text string
697 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[19])));
698 | u8g2.setCursor(71, 25 + i * 13);
699 | u8g2.print(chName_buffer);
700 |
701 | // Print ppm real time ppm value
702 | u8g2.setCursor(94, 25 + i * 13);
703 | u8g2.print(ppm[i]);
704 |
705 | temp_Counter++;
706 | }
707 |
708 | // Print "*" text character
709 | strcpy_P(char_buffer, (char*)pgm_read_word(&(one_char[13])));
710 | u8g2.setCursor(0, 7);
711 | u8g2.print(char_buffer);
712 |
713 | // Print "MODEL" text string
714 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[18])));
715 | u8g2.setCursor(10, 7);
716 | u8g2.print(chName_buffer);
717 |
718 | // Print number of actual model
719 | u8g2.setCursor(45, 7);
720 | u8g2.print(modelActual + 1);
721 |
722 | // Print "SUB TRIM" text string
723 | strcpy_P(menu_buffer, (char*)pgm_read_word(&(menu_name[5])));
724 | u8g2.setCursor(71, 7);
725 | u8g2.print(menu_buffer);
726 |
727 | } while (u8g2.nextPage());
728 |
729 | // End Sub Trim Setup screen ***********************************
730 | }
731 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/Switches.ino:
--------------------------------------------------------------------------------
1 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 | // Macro for read switch status definitions (sw_status)
3 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 | void readSwitches() {
5 |
6 | if (bit_is_clear(PIND, swTC)) {
7 | bitWrite(sw_status, 0, 0);
8 | }
9 | else {
10 | bitWrite(sw_status, 0, 1);
11 | }
12 | if (bit_is_clear(PIND, swDR)) {
13 | bitWrite(sw_status, 1, 0);
14 | }
15 | else {
16 | bitWrite(sw_status, 1, 1);
17 | }
18 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19 | // Added status for supplementary switches SWA, SWB (sw_status)
20 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 |
22 | // Read value directly from analog port
23 | if (read_adc(6) < 1000) {
24 | bitWrite(sw_status, 2, 0);
25 | }
26 | else {
27 | bitWrite(sw_status, 2, 1);
28 | }
29 | // Read bit status on swB digital pin 12
30 | if (bit_is_clear(PINB, 4)) {
31 | bitWrite(sw_status, 3, 0);
32 | }
33 | else {
34 | bitWrite(sw_status, 3, 1);
35 | }
36 |
37 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
38 | // Added status for Throttle position (sw_status)
39 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
40 |
41 | unsigned int thr_check;
42 |
43 | // Checking if Throttle is reversed and remapping ppm value
44 | if (bitRead(servoReverse, chanTh) == 1) {
45 | thr_check = map(read_adc(chanTh), calibration[chanTh][0], calibration[chanTh][1], ppmMax, ppmMin);
46 | }
47 | else {
48 | thr_check = map(read_adc(chanTh), calibration[chanTh][0], calibration[chanTh][1], ppmMin, ppmMax);
49 | }
50 | // ppm stick value for Throttle alarm
51 | if (thr_check >= 1050) {
52 | bitWrite(sw_status, 4, 0);
53 | }
54 | else {
55 | bitWrite(sw_status, 4, 1);
56 | }
57 |
58 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
59 | // Added status for swMix switch position (sw_status)
60 | /// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
61 |
62 | // Read bit status on swMix digital pin 0
63 | if (bit_is_clear(PIND, 0)) {
64 | bitWrite(sw_status, 5, 0);
65 | }
66 | else {
67 | bitWrite(sw_status, 5, 1);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/ArduinoTX_6CH/Warn_Switch.ino:
--------------------------------------------------------------------------------
1 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 | // Macro to check switches and throttle status
3 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 |
5 | void WarnSwitch() {
6 |
7 | // Set memory buffer for text strings
8 | char msg_buffer[21];
9 | char chName_buffer[6];
10 |
11 | // One beep sound warning if something is not in default position
12 | if (warnSwitch == 1) {
13 | PORTD |= _BV(buzzer);
14 | delay(500);
15 | PORTD &= ~_BV(buzzer);
16 | warnSwitch = 0;
17 | }
18 |
19 | u8g2.firstPage();
20 | do {
21 |
22 | // Changing font type
23 | u8g2.setFont(u8g2_font_9x15B_tr);
24 |
25 | // Print warning message
26 | strcpy_P(msg_buffer, (char*)pgm_read_word(&(messages[6])));
27 | u8g2.setCursor(20, 15);
28 | u8g2.print(msg_buffer);
29 |
30 | // Changing font type
31 | u8g2.setFont(u8g2_font_6x10_tr);
32 |
33 | // Print warning message instructions 1
34 | strcpy_P(msg_buffer, (char*)pgm_read_word(&(messages[7])));
35 | u8g2.setCursor(5, 30);
36 | u8g2.print(msg_buffer);
37 |
38 | // Print warning message instructions 2
39 | strcpy_P(msg_buffer, (char*)pgm_read_word(&(messages[8])));
40 | u8g2.setCursor(5, 45);
41 | u8g2.print(msg_buffer);
42 |
43 | // Drawing line separation
44 | u8g2.drawHLine(0, 50, 128);
45 |
46 | // Changing font type
47 | u8g2.setFont(u8g2_font_6x13_tr);
48 |
49 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
50 | // Print switches and throttle stick text name when not in default position
51 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
52 |
53 | // Checking TC switch and print text string if active
54 | if (bitRead(sw_status, 0) == 0) {
55 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[9])));
56 | u8g2.setCursor(25, 64);
57 | u8g2.print(chName_buffer);
58 | }
59 |
60 | // Checking DR switch and print text string if active
61 | if (bitRead(sw_status, 1) == 0) {
62 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[10])));
63 | u8g2.setCursor(92, 64);
64 | u8g2.print(chName_buffer);
65 | }
66 |
67 | // Checking SWA switch and print text string if active
68 | if (bitRead(sw_status, 2) == 0) {
69 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[6])));
70 | u8g2.setCursor(0, 64);
71 | u8g2.print(chName_buffer);
72 | }
73 |
74 | // Checking SWB switch and print text string if active
75 | if (bitRead(sw_status, 3) == 0) {
76 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[7])));
77 | u8g2.setCursor(110, 64);
78 | u8g2.print(chName_buffer);
79 | }
80 |
81 | // Checking THR stick and print text string if active
82 | if (bitRead(sw_status, 4) == 0) {
83 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[2])));
84 | u8g2.setCursor(43, 64);
85 | u8g2.print(chName_buffer);
86 | }
87 |
88 | // Checking swMix switch and print text string if active
89 | if (bitRead(sw_status, 5) == 0) {
90 | strcpy_P(chName_buffer, (char*)pgm_read_word(&(channel_name[17])));
91 | u8g2.setCursor(67, 64);
92 | u8g2.print(chName_buffer);
93 | }
94 | } while (u8g2.nextPage());
95 |
96 | // Read sw_status switches value if status have been changed
97 | readSwitches();
98 |
99 | // restore default font characters
100 | u8g2.setFont(u8g2_font_6x10_tr);
101 | }
102 |
--------------------------------------------------------------------------------
/Docs/ArduTX_NANO_5VTX_JAN18.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/ArduTX_NANO_5VTX_JAN18.pdf
--------------------------------------------------------------------------------
/Docs/ArduTX_New_Pro_Mini_Header_TX_5V_Power_Supply.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/ArduTX_New_Pro_Mini_Header_TX_5V_Power_Supply.pdf
--------------------------------------------------------------------------------
/Docs/Images/ARDUINO_RC_Battery_Powered_PCB.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/ARDUINO_RC_Battery_Powered_PCB.png
--------------------------------------------------------------------------------
/Docs/Images/Arduino_Power_Supply_160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Arduino_Power_Supply_160.png
--------------------------------------------------------------------------------
/Docs/Images/Arduino_Wiring.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Arduino_Wiring.png
--------------------------------------------------------------------------------
/Docs/Images/Battcheckoled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Battcheckoled.png
--------------------------------------------------------------------------------
/Docs/Images/Battery_480.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Battery_480.png
--------------------------------------------------------------------------------
/Docs/Images/Buzzer_480.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Buzzer_480.png
--------------------------------------------------------------------------------
/Docs/Images/Calibration.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Calibration.png
--------------------------------------------------------------------------------
/Docs/Images/Dual_Rates.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Dual_Rates.png
--------------------------------------------------------------------------------
/Docs/Images/FS_CT6B.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/FS_CT6B.png
--------------------------------------------------------------------------------
/Docs/Images/FS_CT6B_160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/FS_CT6B_160.png
--------------------------------------------------------------------------------
/Docs/Images/FS_CT6B_240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/FS_CT6B_240.png
--------------------------------------------------------------------------------
/Docs/Images/Gimbal_1_240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Gimbal_1_240.png
--------------------------------------------------------------------------------
/Docs/Images/Gimbal_2_240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Gimbal_2_240.png
--------------------------------------------------------------------------------
/Docs/Images/Gimbals_wiring_mode1_480.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Gimbals_wiring_mode1_480.png
--------------------------------------------------------------------------------
/Docs/Images/Gimbals_wiring_mode2_480.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Gimbals_wiring_mode2_480.png
--------------------------------------------------------------------------------
/Docs/Images/Gimbals_wiring_mode3_480.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Gimbals_wiring_mode3_480.png
--------------------------------------------------------------------------------
/Docs/Images/Gimbals_wiring_mode4_480.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Gimbals_wiring_mode4_480.png
--------------------------------------------------------------------------------
/Docs/Images/HK_T6A.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/HK_T6A.png
--------------------------------------------------------------------------------
/Docs/Images/HK_T6A_160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/HK_T6A_160.png
--------------------------------------------------------------------------------
/Docs/Images/HK_T6A_240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/HK_T6A_240.png
--------------------------------------------------------------------------------
/Docs/Images/JR_Ext_160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/JR_Ext_160.png
--------------------------------------------------------------------------------
/Docs/Images/Key_buttons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Key_buttons.png
--------------------------------------------------------------------------------
/Docs/Images/LM317_Supply_160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/LM317_Supply_160.png
--------------------------------------------------------------------------------
/Docs/Images/Lion_240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Lion_240.png
--------------------------------------------------------------------------------
/Docs/Images/Lipo_240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Lipo_240.png
--------------------------------------------------------------------------------
/Docs/Images/Menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Menu.png
--------------------------------------------------------------------------------
/Docs/Images/Model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Model.png
--------------------------------------------------------------------------------
/Docs/Images/Multimeter_10K.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Multimeter_10K.png
--------------------------------------------------------------------------------
/Docs/Images/Multimeter_20K.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Multimeter_20K.png
--------------------------------------------------------------------------------
/Docs/Images/Multimeter_Voltage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Multimeter_Voltage.png
--------------------------------------------------------------------------------
/Docs/Images/Nano_Shield_160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Nano_Shield_160.png
--------------------------------------------------------------------------------
/Docs/Images/Nano_Shield_240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Nano_Shield_240.png
--------------------------------------------------------------------------------
/Docs/Images/Nano_Shield_320.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Nano_Shield_320.png
--------------------------------------------------------------------------------
/Docs/Images/Nano_Shield_Blue_160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Nano_Shield_Blue_160.png
--------------------------------------------------------------------------------
/Docs/Images/Nano_Shield_Blue_240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Nano_Shield_Blue_240.png
--------------------------------------------------------------------------------
/Docs/Images/Nano_Shield_Blue_320.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Nano_Shield_Blue_320.png
--------------------------------------------------------------------------------
/Docs/Images/OLED_wiring.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/OLED_wiring.png
--------------------------------------------------------------------------------
/Docs/Images/Old_gimbals_480.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Old_gimbals_480.png
--------------------------------------------------------------------------------
/Docs/Images/Oled_front_240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Oled_front_240.png
--------------------------------------------------------------------------------
/Docs/Images/Oled_rear_240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Oled_rear_240.png
--------------------------------------------------------------------------------
/Docs/Images/PPM_wiring.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/PPM_wiring.png
--------------------------------------------------------------------------------
/Docs/Images/Pot_160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Pot_160.png
--------------------------------------------------------------------------------
/Docs/Images/Pots_wiring_480.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Pots_wiring_480.png
--------------------------------------------------------------------------------
/Docs/Images/Proto_pcb_240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Proto_pcb_240.png
--------------------------------------------------------------------------------
/Docs/Images/RC_pot_160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/RC_pot_160.png
--------------------------------------------------------------------------------
/Docs/Images/RC_switch_160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/RC_switch_160.png
--------------------------------------------------------------------------------
/Docs/Images/RX6CH240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/RX6CH240.png
--------------------------------------------------------------------------------
/Docs/Images/Screen_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Screen_0.png
--------------------------------------------------------------------------------
/Docs/Images/Servo_Direction.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Servo_Direction.png
--------------------------------------------------------------------------------
/Docs/Images/Slide_SW_160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Slide_SW_160.png
--------------------------------------------------------------------------------
/Docs/Images/Sub_Trim.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Sub_Trim.png
--------------------------------------------------------------------------------
/Docs/Images/Switch_160.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Switch_160.png
--------------------------------------------------------------------------------
/Docs/Images/Switch_Warning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Switch_Warning.png
--------------------------------------------------------------------------------
/Docs/Images/Switch_long.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Switch_long.png
--------------------------------------------------------------------------------
/Docs/Images/Switch_short.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Switch_short.png
--------------------------------------------------------------------------------
/Docs/Images/Switch_wiring_1_480.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Switch_wiring_1_480.png
--------------------------------------------------------------------------------
/Docs/Images/Switch_wiring_2_480.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/Docs/Images/Switch_wiring_2_480.png
--------------------------------------------------------------------------------
/Extras/ArduTX_Battery_Checker/Arduino_TX_battery_checker.ino:
--------------------------------------------------------------------------------
1 | /* This sketch want provide help for testing and calibrate battery value from Arduino pin
2 | with low battery alarm functionality through OLED display(without connecting buzzer)
3 |
4 | NOTES and safety WARNING:
5 |
6 | - Use linear voltage variable power supply to simulate voltage battery, when it possible.
7 |
8 | - If you want correct visualization of values after uploading sketch in Arduino
9 | is necessary remove USB programming cable from PC because it makes the readings unstable.
10 |
11 | - For 2S voltage divider do not over 10V, For 3S voltage divider do not over 15V.
12 | otherwise Arduino pin will be fried.
13 |
14 | - WARNING if you want to reset ALARM OLED display indication
15 | is necessary to put battery voltage to the maximum and restart Arduino with reset button
16 |
17 | - For testing you can modify these parameters:
18 |
19 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
20 | const int numReadings = 8; // Number of reading to calculate average
21 | lower value means fast reaction, high value slow reaction (8 value is maximum)
22 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 |
24 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25 | #define minBat 70 // Minimum battery voltage for alarm (70 = 7.0V)for 2S LiOn/LiPo battery
26 | #define maxBat 82 // Maximum battery voltage (10V) (82 = 8.2V)for 2S LiOn/LiPo battery
27 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
28 |
29 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 | #define minBat 100 // Minimum battery voltage for alarm (100 = 10V)for 3S LiOn/LiPo battery
31 | #define maxBat 125 // Maximum battery voltage (125 = 12.5V)for 3S LiOn/LiPo battery
32 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33 |
34 | If you need more precision, measure voltage divider resistors value
35 | with digital multimeter and put them in to R1/R2 variables and trim these values
36 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
37 | float R1 = 10430;
38 | float R2 = 10055;
39 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
40 |
41 | //---------------------------------------------------------------------------------------------
42 | // Must be used R1-10K/R2-10K voltage divider for 2S lion/LiPo battery
43 | // (R1-20K/R2-10K voltage divider for 3S lion/LiPo battery)
44 | //---------------------------------------------------------------------------------------------
45 |
46 | batPin = A7
47 |
48 | (Default battery voltage divider for 2S lion/LiPo)
49 |
50 | Vbatt MAX 10V ----+
51 | |
52 | R1 10K
53 | |
54 | |+-----> (PIN A7)
55 | |
56 | R2 10K
57 | |
58 | =
59 | . (GND)
60 |
61 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
62 |
63 | (Battery voltage divider for 3S lion/LiPo)
64 |
65 | Vbatt MAX 15V ----+
66 | |
67 | R1 20K
68 | |
69 | |+-----> (PIN A7)
70 | |
71 | R2 10K
72 | |
73 | =
74 | . (GND)
75 | */
76 |
77 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
78 | #include // Arduino standard library
79 | #include // Using U8G2 library "https://github.com/olikraus/u8g2"
80 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
81 |
82 | // Set library for SH1106 SPI 1.3" or SSD1306 0.96" OLED display TESTED OK! (128 bytes buffer)
83 | U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
84 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
85 | /* SPI wires cabling (OLED Pin name dependent on the manufacturer)
86 |
87 | OLED Arduino
88 | ---------------------
89 | RES > pin 8
90 | DC > pin 9
91 | CS > pin 10 (SS)
92 | MOSI > pin 11 (MOSI)
93 | CLK > pin 13 (SCK)*/
94 |
95 | #define buzzer PD6 // Buzzer pin (buzzer with standalone sound generator)
96 |
97 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
98 | #define minBat 100 // Minimum battery voltage for alarm (100 = 10V)
99 | #define maxBat 125 // Maximum battery voltage (125 = 12.5V)
100 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
101 |
102 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
103 | // Battery voltage calculation, checking status for alarm, drawing battery bar
104 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
105 | const int numReadings = 8; // Number of reading to calculate average
106 | int readings[numReadings]; // Readings from the analog input (battery input pin A7)
107 | int index = 0; // Index of the current reading
108 | int total = 0; // Running total
109 | int average = 0; // Average value
110 |
111 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
112 | float pin_batt_read; // Raw input battery pin value from average reading
113 | float batt_volt; // Battery voltage calculated
114 | float res_calc; // Calculation of voltage divider to be applied to the conversion
115 | float R1 = 10000; // If you need more precision, measure voltage divider resistors value
116 | float R2 = 10000; // with digital multimeter and put them in to R1 R2 variables
117 | unsigned char perc_batt; // Battery bar level indicator (20 pixel) only Min to Max values
118 |
119 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
120 | float batt_display; // Battery voltage on display
121 | unsigned char perc_display; // Battery percentage on display
122 |
123 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
124 | boolean battStatus = 1;
125 |
126 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
127 | byte pulseBuzzer; // Sound pulse for battery alarm
128 |
129 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
130 | void setup() {
131 |
132 | //Serial.begin(9600);
133 |
134 | // LCD config with U8G2 library display init (mandatory)
135 | u8g2.begin();
136 |
137 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
138 | // Input ADC sampling rate for reading analog input pots (1000 KHz is maximum for stable reading)
139 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
140 |
141 | ADCSRA &= ~(1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); // Remove bit settings from Arduino library
142 | ADCSRA |= (1 << ADPS2); // Set ADC prescaler to 16 (1000 KHz)
143 |
144 | ADMUX |= (1 << REFS0);
145 | ADMUX &= ~(1 << REFS1); // Avcc(+5v) as voltage reference
146 |
147 | ADCSRB &= ~((1 << ADTS2) | (1 << ADTS1) | (1 << ADTS0)); // ADC in free-running mode
148 |
149 | ADCSRA |= (1 << ADEN); // Turn on ADC
150 | ADCSRA |= (1 << ADSC); // Do an initial conversion this one is the slowest to ensure that everything is up and running
151 |
152 | DIDR0 = 0x3F; // Digital circuit on analog ports disabled
153 | DIDR1 = 0x03; // Disable digital input on AIN0/1
154 |
155 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
156 |
157 | res_calc = (R1 + R2) / R2; // Voltage divider calculation
158 |
159 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
160 | // Initialize value for average ADC readings
161 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
162 |
163 | for (int thisReading = 0; thisReading < numReadings; thisReading++)
164 |
165 | readings[thisReading] = 0; // initialize all the readings to 0
166 |
167 | // End of Setup +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
168 |
169 | pinMode(buzzer, OUTPUT);
170 |
171 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
172 | // Set default font type used for all display sessions (mandatory)
173 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
174 | u8g2.setFont(u8g2_font_7x14_tr);
175 |
176 | }
177 |
178 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
179 | // Macro for directly read ADC value on all analog ports
180 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
181 | unsigned short int read_adc(unsigned char channel) {
182 |
183 | ADMUX &= 0xF0; //Clear the older channel that was read
184 | ADMUX |= channel; //Defines the new ADC channel to be read
185 | ADCSRA |= (1 << ADSC); //Starts a new conversion
186 | while (ADCSRA & (1 << ADSC)); //Wait until the conversion is done
187 | return ADCW; //Returns the ADC value of the chosen channel
188 | }
189 |
190 | void loop() {
191 |
192 | batteryCheck();
193 | Screen_0();
194 |
195 | }
196 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
197 | // Drawing Main Screen display
198 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
199 | void Screen_0() {
200 |
201 | // Start of main screen display informations "0" ************************
202 | u8g2.firstPage();
203 | do {
204 |
205 | // Battery simbol contruction
206 | u8g2.drawFrame(102, 0, 24, 8); // Battery box
207 | u8g2.drawBox(104, 2, perc_batt, 4); // level bar
208 | u8g2.drawBox(126, 2, 2, 3); // Battery nipple plus pole
209 |
210 | u8g2.setCursor(10, 10);
211 | u8g2.print(batt_display);
212 |
213 | u8g2.setCursor(50, 10);
214 | u8g2.print("Volt");
215 |
216 | u8g2.setCursor(10, 25);
217 | u8g2.print(perc_batt);
218 |
219 | u8g2.setCursor(40, 25);
220 | u8g2.print("Batt pixels");
221 |
222 | u8g2.setCursor(10, 40);
223 | u8g2.print(perc_display);
224 |
225 | u8g2.setCursor(40, 40);
226 | u8g2.print("Batt %");
227 |
228 | if (perc_batt <= 1 || battStatus == 0) {
229 | u8g2.setCursor(10, 55);
230 | u8g2.print("Alarm ON");
231 | }
232 | } while (u8g2.nextPage());
233 | }
234 | // End of main screen display informations "0" **************************
235 |
236 |
237 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
238 | // Macro to calculate average ADC value, checking battery voltage alarm and value for battery bar
239 | // For minBat do not under default value in config file because arduino will be more unstable.
240 | // About 16%(presumed)of battery is enough to landing ASAP
241 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
242 | void batteryCheck() {
243 |
244 | // Subtract the last reading:
245 | total = total - readings[index];
246 |
247 | // Read from adc input:
248 | readings[index] = read_adc(7);
249 |
250 | // Add reading to total:
251 | total = total + readings[index];
252 |
253 | // Advance to the next position in the array:
254 | index = index + 1;
255 |
256 | // If we're at the end of the array...
257 | if (index >= numReadings)
258 |
259 | // ...wrap around to the beginning:
260 | index = 0;
261 |
262 | // Calculate the average:
263 | average = total / numReadings;
264 |
265 | // Mapping battery voltage from average from 0 to 5V
266 | pin_batt_read = map(average, 0, 1023, 0, 500);
267 |
268 | // Calculating correct voltage value through voltage divider
269 | // Result = 2 digits with 2 decimal (eg 72 = 7.2V)
270 | batt_volt = pin_batt_read * res_calc / 10;
271 | batt_display = pin_batt_read * res_calc / 100;
272 | //Serial.println (batt_display);
273 |
274 | // Mapping voltage for drawing battery bar
275 | perc_batt = map(batt_volt, minBat, maxBat, 1, 20);
276 | perc_batt = constrain(perc_batt, 1, 20);
277 |
278 | // Mapping voltage for display battery percentage
279 | perc_display = map(batt_volt, minBat, maxBat, 1, 100);
280 | perc_display = constrain(perc_display, 1, 100);
281 |
282 | // Serial.println (perc_batt);
283 |
284 | // Low battery beep alarm
285 | if (perc_batt == 1 || battStatus == 0) {
286 |
287 | // Set byte 0 to mantain battery alarm even voltage floating +/- on minBat value
288 | battStatus = 0;
289 |
290 | // Set value to mantain battery bar to min value even voltage is under minBat
291 | perc_batt = 1;
292 |
293 | // Recall pulse for buzzer
294 | beep();
295 | }
296 |
297 | // Buzzer alarm OFF
298 | else {
299 | PORTD &= ~_BV(buzzer);
300 | }
301 | }
302 |
303 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
304 | // Macro for buzzer beep battery alarm
305 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
306 | void beep () {
307 |
308 | if ((bitRead(pulseBuzzer, 0) && bitRead(pulseBuzzer, 5) && bitRead(pulseBuzzer, 1))) {
309 | PORTD |= _BV(buzzer);
310 | }
311 | else {
312 | PORTD &= ~_BV(buzzer);
313 | }
314 | ++pulseBuzzer;
315 | }
316 |
--------------------------------------------------------------------------------
/Extras/ArduTX_Battery_Checker/README.md:
--------------------------------------------------------------------------------
1 | ## **Sketch file for calibrate battery and testing low battery alarm with OLED display**
2 |
3 | 
4 |
5 | This sketch want provide help for testing and calibrate battery value from Arduino pin
6 | with low battery alarm functionality through OLED display (without connecting buzzer)
7 |
8 | **NOTES and safety WARNING:**
9 |
10 | - Use linear voltage variable power supply to simulate voltage battery, when it possible.
11 |
12 | - If you want a correct visualization of values after uploading sketch in Arduino
13 | is necessary remove USB programming cable from PC because it makes readings unstable.
14 | - **[Must be used R1-10K/R2-10K voltage divider for 2S(8.4V) lion/LiPo battery](https://github.com/Gabapentin/Arduino-RC-6CH-Radio-control/wiki/4.6-(Battery-Monitor-Wiring))**
15 | - **[Must be used R1-20K/R2-10K voltage divider for 3S(12.6V) lion/LiPo battery](https://github.com/Gabapentin/Arduino-RC-6CH-Radio-control/wiki/4.6-(Battery-Monitor-Wiring))**
16 | - **For 2S voltage divider do not over 10V, For 3S voltage divider do not over 15V.
17 | Otherwise Arduino pin will be fried.**
18 |
19 | - **WARNING: If you want reset ALARM OLED display indication!
20 | is necessary to put battery voltage to the maximum and restart Arduino with reset button**
21 |
22 | ## For testing you can modify these parameters:
23 |
24 | **Number of reading to calculate average
25 | lower value means fast reaction, high value slow reaction (8 value is maximum)**
26 |
27 | ```javascript
28 | const int numReadings = 8;
29 | ```
30 | ```javascript
31 | #define minBat 70 // Minimum battery voltage for alarm (70 = 7.0V)for 2S LiOn/LiPo battery
32 | #define maxBat 82 // Maximum battery voltage (10V) (82 = 8.2V)for 2S LiOn/LiPo battery
33 |
34 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
35 | #define minBat 100 // Minimum battery voltage for alarm (100 = 10V)for 3S LiOn/LiPo battery
36 | #define maxBat 125 // Maximum battery voltage (125 = 12.5V)for 3S LiOn/LiPo battery
37 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
38 | ```
39 |
40 | **If you need more precision, measure voltage divider resistors value with digital multimeter
41 | put them in to R1/R2 variables and trim these values**
42 | ```javascript
43 | float R1 = 10430;
44 | float R2 = 10055;
45 | ```
46 | ## **After ending test you need to put result values in config.h file**
47 |
48 |
49 | 
50 | 
51 | 
52 |
--------------------------------------------------------------------------------
/Extras/EepromClear/README.md:
--------------------------------------------------------------------------------
1 | p
2 |
--------------------------------------------------------------------------------
/Extras/EepromClear/eeprom_clear.ino:
--------------------------------------------------------------------------------
1 | /*
2 | * EEPROM Clear
3 | *
4 | * Sets all of the bytes of the EEPROM to 0.
5 | * Please see eeprom_iteration for a more in depth
6 | * look at how to traverse the EEPROM.
7 | *
8 | * This example code is in the public domain.
9 | */
10 |
11 | #include
12 |
13 | void setup() {
14 | // initialize the LED pin as an output.
15 | pinMode(13, OUTPUT);
16 |
17 | /***
18 | Iterate through each byte of the EEPROM storage.
19 |
20 | Larger AVR processors have larger EEPROM sizes, E.g:
21 | - Arduno Duemilanove: 512b EEPROM storage.
22 | - Arduino Uno: 1kb EEPROM storage.
23 | - Arduino Mega: 4kb EEPROM storage.
24 |
25 | Rather than hard-coding the length, you should use the pre-provided length function.
26 | This will make your code portable to all AVR processors.
27 | ***/
28 |
29 | for (int i = 0 ; i < EEPROM.length() ; i++) {
30 | EEPROM.write(i, 0);
31 | }
32 |
33 | // turn the LED on when we're done
34 | digitalWrite(13, HIGH);
35 | }
36 |
37 | void loop() {
38 | /** Empty loop. **/
39 | }
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/PCB/Nano_With_TX_Battery_Powered/ARDUTX_6CH_tx_battery_powered_all_files.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/PCB/Nano_With_TX_Battery_Powered/ARDUTX_6CH_tx_battery_powered_all_files.zip
--------------------------------------------------------------------------------
/PCB/Nano_With_TX_Battery_Powered/ArduTX.lbr:
--------------------------------------------------------------------------------
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 | <b>PIN HEADER</b>
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 | >NAME
181 | >VALUE
182 |
183 |
184 | <b>PIN HEADER</b>
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 | >NAME
214 | >VALUE
215 |
216 |
217 | <b>PIN HEADER</b>
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 | >NAME
265 | >VALUE
266 |
267 |
268 | <b>PIN HEADER</b>
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 | >NAME
343 | >VALUE
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 | >NAME
369 | >VALUE
370 |
371 |
372 | <b>CAPACITOR</b><p>
373 | grid 5 mm, outline 2.5 x 7.5 mm
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 | >NAME
391 | >VALUE
392 |
393 |
394 | <b>BUZZER</b>
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 | >NAME
403 | >VALUE
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 | <b>TO 92</b>
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 | >NAME
465 | >VALUE
466 | 2
467 | 3
468 | 1
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
--------------------------------------------------------------------------------
/PCB/Nano_With_TX_Battery_Powered/ArduTX_TX_Battery_Powered_Components_Side.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/PCB/Nano_With_TX_Battery_Powered/ArduTX_TX_Battery_Powered_Components_Side.pdf
--------------------------------------------------------------------------------
/PCB/Nano_With_TX_Battery_Powered/ArduTX_TX_Battery_Powered_PCB.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/PCB/Nano_With_TX_Battery_Powered/ArduTX_TX_Battery_Powered_PCB.pdf
--------------------------------------------------------------------------------
/PCB/Nano_With_TX_Battery_Powered/ArduTX_TX_Battery_Powered_SCH.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gabapentin/Arduino-RC-6CH-Radio-control/742f162231e1b87ca48290bc01071bc29184ea39/PCB/Nano_With_TX_Battery_Powered/ArduTX_TX_Battery_Powered_SCH.pdf
--------------------------------------------------------------------------------
/PCB/Nano_With_TX_Battery_Powered/README.md:
--------------------------------------------------------------------------------
1 | ### **Please remember at this time It's only prototype. Will be modified!** ###
2 | #### This directory contains all files for Arduino Nano one layer PCB shield (60x40mm dimension)
3 | #### This shield will provide directly battery power to TX module like **[Multiprotocol](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)** or FRSKY/FLYSKY external module
4 |
5 | ### **DO NOT USE this PCB for Hobbyking HK-T6A or Flysky FS-CT6B original Transmitter module**
6 | #### NOTES:
7 | * #### Arduino Nano must be mounted on a female header socket to permit capacitors mounting under Nano module
8 | * #### Maximum battery voltage is 10V (2S Lion/LiPo 8.4V is enough for long time operation)
9 | * #### For 3S 12.6V battery voltage is necessary to modify R1 to 20K and some parameters on sketch
10 | * #### PPM voltage is reduced from voltage divider to 2.7Vpp
11 |
12 |
13 | 
14 |
--------------------------------------------------------------------------------
/PCB/README.md:
--------------------------------------------------------------------------------
1 | This directory will contain Eagle files for PCB production
2 | you can make your own PCB
3 | For one layer PCB seems to be comfortable to use Arduino NANO version
4 | * #### **WITH TRANSMITTER POWERED DIRECTLY FROM BATTERY**
5 | #### **DO NOT USE this PCB for Hobbyking HK-T6A or Flysky FS-CT6B original Transmitter module**
6 | 
7 |
8 | ***
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Arduino-RC-6CH-Radio-control
2 |
3 | ----------------------------------------------------------------------------------------------------------
4 |
5 | 
6 | 
7 | 
8 | 
9 |
10 |
11 | 
12 | 
13 | 
14 | 
15 |
16 |
17 |
18 | | FS-CT6B | | HK-T6A |
19 | | ------- | :---: | ------ |
20 | |  |  |  |
21 |
22 |
23 | Arduino project to upgrade cheap Hobbyking HK-T6A or Flysky FS-CT6B transmitters or any other old RC TX
24 |
25 | This code is based on ardutx v1.3 sketch (2014) from Patricio Reinoso www.patolin.com
26 |
27 | **You can see discussion on RCGroups Forum site**
28 | https://www.rcgroups.com/forums/showthread.php?1817699-Hobbyking-6ch-tx-arduino-computer-update
29 |
30 |
31 | **If you want discuss this project I have already open thread on RCGroups**
32 | https://www.rcgroups.com/forums/showthread.php?2959179-Arduino-radio-for-HK-T6A-or-Flysky-FS-CT6B-(ArduTX-rebirth)
33 |
34 | ----------------------------------------------------------------------------------------------------------
35 |
36 | The code has been modified to work with SH1106 SPI 1.3" or SSD1306 SPI 0.96" OLED LCD through U8g2 library
37 |
38 | Have been used all possible pins of ATmega328P (Arduino Nano, Pro Mini)
39 |
40 | Every text strings has been stored in flash memory to mantain a lot of free RAM memory
41 |
42 | ----------------------------------------------------------------------------------------------------------
43 |
44 | Added features to original Patolin code:
45 |
46 | - 3 digital buttons input for menu (Enter/Select) (Down/Next) (Up/Previous) [previously analogs]
47 |
48 | - Switches checking status with sound alert at power ON and display which is not in default position
49 |
50 | - Throttle warning with display status of switches and sound alert
51 |
52 | - Hidden data default restoring by pressing and hold Down/Next button on power on
53 |
54 | - Hidden calibration procedure by pressing and hold Menu/Select button on power on
55 |
56 | - Low battery control in real time whith buzzer sound(buzzer with stand alone sound generator)
57 |
58 | - N°2 supplementary switch, they can be configured instead of VRA or VRB pots (SWA, SWB)(Servo Direction Menu)
59 |
60 | - Basic two channel mixer with switch activation V-Mix (Ch1/ch2)
61 |
62 | - Basic four channels Sub Trim setting (ch1, ch2, ch3, ch4)
63 |
64 | *************************************************************************************************************
65 |
66 | Recommended Arduino **[Arduino IDE 1.8.2 or above](https://www.arduino.cc/en/main/software)**
67 | (Seems to be optimized and stable compiler. Less Flash and RAM used)
68 |
69 | Arduino AVR Boards 1.6.18
70 |
71 | #include Using U8G2 library **[UG2 Github link](https://github.com/olikraus/U8g2_Arduino)**
72 |
73 | #include Arduino standard library
74 |
75 | #include Arduino standard library
76 |
77 | ### **[See Wiki pages](https://github.com/Gabapentin/Arduino-RC-6CH-Radio-control/wiki)**
78 |
--------------------------------------------------------------------------------