Closed GoogleCodeExporter closed 8 years ago
Here more info:
http://diydrones.com/profiles/blogs/give-your-arducopter-mega-and?xg_source=msg_
appr_blogpost
Original comment by oli...@voltivo.com
on 24 May 2011 at 10:24
Here the refined code and patch:
Index: ArduCopterMega/APM_Config.h
===================================================================
+#define PIEZO ENABLED //Enables Piezo Code and
beeps once on Startup to verify operation
+#define PIEZO_PIN AN5 //Last pin on the back ADC
connector
+#define PIEZO_LOW_VOLTAGE ENABLED //Enables Tone on reaching
low battery or current alert
+#define PIEZO_ARMING ENABLED //Two tones on ARM, 1 Tone
on disarm
Index: ArduCopterMega/motors.pde
===================================================================
--- ArduCopterMega/motors.pde (revision 2459)
+++ ArduCopterMega/motors.pde (working copy)
@@ -14,7 +14,10 @@
if (arming_counter >= ARM_DELAY) {
motor_armed = true;
arming_counter = ARM_DELAY;
-
+ #if PIEZO_ARMING == 1
+ piezo_beep();
+ piezo_beep();
+ #endif
// Remember Orientation
// ---------------------------
init_simple_bearing();
@@ -29,7 +32,9 @@
motor_armed = false;
arming_counter = DISARM_DELAY;
compass.save_offsets();
-
+ #if PIEZO_ARMING == 1
+ piezo_beep();
+ #endif
}else{
arming_counter++;
}
@@ -144,4 +149,4 @@
nav_throttle,
angle_boost());
*/
- //}
\ No newline at end of file
+ //}
Index: ArduCopterMega/system.pde
===================================================================
--- ArduCopterMega/system.pde (revision 2459)
+++ ArduCopterMega/system.pde (working copy)
@@ -198,6 +198,11 @@
pinMode(RI_LED, OUTPUT); // GPS status LED
pinMode(LE_LED, OUTPUT); // GPS status LED
#endif
+
+ #if PIEZO == 1
+ pinMode(PIEZO_PIN,OUTPUT);
+ piezo_beep();
+ #endif
// Logging:
// --------
Index: ArduCopterMega/sensors.pde
===================================================================
--- ArduCopterMega/sensors.pde (revision 2459)
+++ ArduCopterMega/sensors.pde (working copy)
@@ -105,9 +105,26 @@
}
#if BATTERY_EVENT == 1
- if(battery_voltage < LOW_VOLTAGE) low_battery_event();
- if(g.battery_monitoring == 4 && current_total >
g.pack_capacity) low_battery_event();
- #endif
+ if ( (battery_voltage < LOW_VOLTAGE) || (g.battery_monitoring == 4 &&
current_total > g.pack_capacity) ) {
+ low_battery_event();
+ #if PIEZO_LOW_VOLTAGE == 1
+ // Only Activate if a battery is connected to avoid
alarm on USB only
+ if (battery_voltage1 > 1){
+ piezo_on();
+ }
+ else {
+ piezo_off();
+ }
+
+ #endif
+ }
+ else {
+ #if PIEZO_LOW_VOLTAGE == 1
+ piezo_off();
+ #endif
+ }
+ #endif
+
}
//v: 10.9453, a: 17.4023, mah: 8.2
Index: ArduCopterMega/events.pde
===================================================================
--- ArduCopterMega/events.pde (revision 2459)
+++ ArduCopterMega/events.pde (working copy)
@@ -94,3 +94,26 @@
PORTL ^= B00000100;
}
+
+#if PIEZO == 1
+void piezo_on()
+{
+ digitalWrite(PIEZO_PIN,HIGH);
+ //PORTF |= B00100000;
+}
+
+void piezo_off()
+{
+ digitalWrite(PIEZO_PIN,LOW);
+ //PORTF &= ~B00100000;
+}
+
+void piezo_beep()
+{
+ // Note: This command should not be used in time sensitive loops
+ piezo_on();
+ delay(100);
+ piezo_off();
+}
+#endif
+
Original comment by fueck...@gmail.com
on 1 Jun 2011 at 6:46
Added to latest rev. Thanks!
Jason
Original comment by jasonshort
on 19 Sep 2011 at 12:14
Original issue reported on code.google.com by
oli...@voltivo.com
on 24 May 2011 at 10:20Attachments: