Permalink
Browse files

Merge branch 'landinglights'

  • Loading branch information...
wertarbyte committed May 20, 2012
2 parents bdbc468 + db7cb88 commit 2ca87f16e40eb329decc9dae6070880d8e7ef432
Showing with 45 additions and 0 deletions.
  1. +25 −0 LED.pde
  2. +6 −0 MultiWii.ino
  3. +14 −0 config.h
View
25 LED.pde
@@ -68,4 +68,29 @@ void switch_led_flasher() {
LED_FLASHER_PORT &= ~(1<<LED_FLASHER_BIT);
}
}
+
+#if defined(LANDING_LIGHTS_DDR)
+void init_landing_lights(void) {
+ LANDING_LIGHTS_DDR |= 1<<LANDING_LIGHTS_BIT;
+}
+
+void switch_landing_lights(uint8_t on) {
+ if (on) {
+ LANDING_LIGHTS_PORT |= 1<<LANDING_LIGHTS_BIT;
+ } else {
+ LANDING_LIGHTS_PORT &= ~(1<<LANDING_LIGHTS_BIT);
+ }
+}
+
+void auto_switch_landing_lights(void) {
+ #if defined(LANDING_LIGHTS_AUTO_ALTITUDE) & SONAR
+ if (sonarAlt >= 0 && sonarAlt <= LANDING_LIGHTS_AUTO_ALTITUDE && armed) {
+ switch_landing_lights(1);
+ } else {
+ switch_landing_lights(0);
+ }
+ #endif
+}
+#endif
+
#endif
View
@@ -416,6 +416,9 @@ void setup() {
#ifdef LCD_CONF_DEBUG
configurationLoop();
#endif
+ #ifdef LANDING_LIGHTS_DDR
+ init_landing_lights();
+ #endif
ADCSRA |= _BV(ADPS2) ; ADCSRA &= ~_BV(ADPS1); ADCSRA &= ~_BV(ADPS0); // this speeds up analogRead without loosing too much resolution: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1208715493/11
#if defined(DATENSCHLAG_CHANNEL)
datenschlag_reset();
@@ -713,6 +716,9 @@ void loop () {
#if SONAR
Sonar_update();debug3 = sonarAlt;
#endif
+ #ifdef LANDING_LIGHTS_DDR
+ auto_switch_landing_lights();
+ #endif
break;
}
}
View
@@ -464,6 +464,20 @@
//#define LED_FLASHER_SEQUENCE_ARMED ( (uint8_t) (1<<0 | 1<<2) )
+ /******************************* Landing lights *********************************/
+ /* Landing lights
+ *
+ * Use an output pin to control landing lights.
+ * They can be switched automatically when used in conjunction
+ * with altitude data from a sonar unit.
+ */
+ //#define LANDING_LIGHTS_DDR DDRC
+ //#define LANDING_LIGHTS_PORT PORTC
+ //#define LANDING_LIGHTS_BIT PC0
+
+ /* altitude above ground (in cm) as reported by sonar */
+ //#define LANDING_LIGHTS_AUTO_ALTITUDE 50
+
/************************* INFLIGHT ACC Calibration *****************************/
/* This will activate the ACC-Inflight calibration if unchecked */

0 comments on commit 2ca87f1

Please sign in to comment.