I'm quite new to multiwii. First contact was about a year ago when I received my B-EX. As the availability of spare parts for this model is very disappointing I started building a new quad. For better orientation I also added some leds at the end of the arms. With the integrated LED Flasher code this was quite simple.
I read some posts about others who modified the code in order to show the different flight modes with blink patterns. That is something, I also wanted. So I started modifying source code and implemented patterns for the three VBAT levels, angle and horizon mode.
Another idea was to introduce something like a "night mode" for all led patterns. Let's take a look at the default pattern for armed: 0b00000101. Two short flashes. This is a good signal if you do not need the leds to get the orientation of your copter. If it is getting darker, you would want to invert the pattern: 0b11111010. So the lights stay on most of the time for better orientation and you still get visible signals from the fc. I know you can get status from the buzzer, but if your copter is about 100m away you cannot hear it anymore. Depending on the leds the signal is visible at a longer distance.
The changes to the code are just straight forward:
Code: Select all
diff -uNr MultiWii_r1741_FPV_Quad/Alarms.cpp MultiWii_r1741_FPV_Quad_LEDMOD/Alarms.cpp
--- MultiWii_r1741_FPV_Quad/Alarms.cpp 2014-11-20 23:17:12.000000000 +0100
+++ MultiWii_r1741_FPV_Quad_LEDMOD/Alarms.cpp 2015-02-08 15:19:54.687588743 +0100
@@ -503,9 +503,15 @@
#else
if (!on) {
#endif
- LED_FLASHER_PORT |= (1<<LED_FLASHER_BIT);
+ if (!rcOptions[BOXLEDINV])
+ LED_FLASHER_PORT |= (1<<LED_FLASHER_BIT);
+ else
+ LED_FLASHER_PORT &= ~(1<<LED_FLASHER_BIT);
} else {
- LED_FLASHER_PORT &= ~(1<<LED_FLASHER_BIT);
+ if (!rcOptions[BOXLEDINV])
+ LED_FLASHER_PORT &= ~(1<<LED_FLASHER_BIT);
+ else
+ LED_FLASHER_PORT |= (1<<LED_FLASHER_BIT);
}
#endif
}
@@ -544,6 +550,41 @@
}
#endif
+ #if defined(LED_FLASHER_SEQUENCE_VBAT_CRIT)
+ if ( IS_ALARM_SET(ALRM_FAC_VBAT , ALRM_LVL_VBAT_CRIT) ) {
+ led_flasher_set_sequence(LED_FLASHER_SEQUENCE_VBAT_CRIT);
+ return;
+ }
+ #endif
+
+ #if defined(LED_FLASHER_SEQUENCE_VBAT_WARN)
+ if ( IS_ALARM_SET(ALRM_FAC_VBAT , ALRM_LVL_VBAT_WARN) ) {
+ led_flasher_set_sequence(LED_FLASHER_SEQUENCE_VBAT_WARN);
+ return;
+ }
+ #endif
+
+ #if defined(LED_FLASHER_SEQUENCE_VBAT_INFO)
+ if ( IS_ALARM_SET(ALRM_FAC_VBAT , ALRM_LVL_VBAT_INFO) ) {
+ led_flasher_set_sequence(LED_FLASHER_SEQUENCE_VBAT_INFO);
+ return;
+ }
+ #endif
+
+ #if defined(LED_FLASHER_SEQUENCE_ANGLE)
+ if (f.ARMED && f.ANGLE_MODE) {
+ led_flasher_set_sequence(LED_FLASHER_SEQUENCE_ANGLE);
+ return;
+ }
+ #endif
+
+ #if defined(LED_FLASHER_SEQUENCE_HORIZON)
+ if (f.ARMED && f.HORIZON_MODE) {
+ led_flasher_set_sequence(LED_FLASHER_SEQUENCE_HORIZON);
+ return;
+ }
+ #endif
+
#if defined(LED_FLASHER_SEQUENCE_ARMED)
/* do we have a special sequence for armed copters? */
if (f.ARMED) {
@@ -702,4 +743,4 @@
}
#endif
-
+
diff -uNr MultiWii_r1741_FPV_Quad/config.h MultiWii_r1741_FPV_Quad_LEDMOD/config.h
--- MultiWii_r1741_FPV_Quad/config.h 2015-02-08 14:05:42.000000000 +0100
+++ MultiWii_r1741_FPV_Quad_LEDMOD/config.h 2015-02-08 15:19:54.687588743 +0100
@@ -613,11 +613,15 @@
//#define LED_FLASHER_PORT PORTB
//#define LED_FLASHER_BIT PORTB4
//#define LED_FLASHER_INVERT
- //#define LED_FLASHER_SEQUENCE 0b00000000 // leds OFF
- //#define LED_FLASHER_SEQUENCE_ARMED 0b00000101 // create double flashes
- //#define LED_FLASHER_SEQUENCE_MAX 0b11111111 // full illumination
- //#define LED_FLASHER_SEQUENCE_LOW 0b00000000 // no illumination
-
+ //#define LED_FLASHER_SEQUENCE 0b00000000 // leds OFF
+ //#define LED_FLASHER_SEQUENCE_ARMED 0b00000101 // create double flashes
+ //#define LED_FLASHER_SEQUENCE_MAX 0b11111111 // full illumination
+ //#define LED_FLASHER_SEQUENCE_LOW 0b00000000 // no illumination
+ //#define LED_FLASHER_SEQUENCE_VBAT_CRIT 0b00101011
+ //#define LED_FLASHER_SEQUENCE_VBAT_WARN 0b00001011
+ //#define LED_FLASHER_SEQUENCE_VBAT_INFO 0b00000011
+ //#define LED_FLASHER_SEQUENCE_ANGLE 0b00110011
+ //#define LED_FLASHER_SEQUENCE_HORIZON 0b00001111
/******************************* Landing lights *********************************/
/* Landing lights
diff -uNr MultiWii_r1741_FPV_Quad/MultiWii.cpp MultiWii_r1741_FPV_Quad_LEDMOD/MultiWii.cpp
--- MultiWii_r1741_FPV_Quad/MultiWii.cpp 2015-02-01 15:15:26.000000000 +0100
+++ MultiWii_r1741_FPV_Quad_LEDMOD/MultiWii.cpp 2015-02-08 15:19:54.687588743 +0100
@@ -79,6 +79,7 @@
#if defined(LED_FLASHER)
"LEDMAX;"
"LEDLOW;"
+ "LEDINV;"
#endif
#if defined(LANDING_LIGHTS_DDR)
"LLIGHTS;"
@@ -134,22 +135,23 @@
#if defined(LED_FLASHER)
14, //"LEDMAX;"
15, //"LEDLOW;"
+ 16, //"LEDINV;"
#endif
#if defined(LANDING_LIGHTS_DDR)
- 16, //"LLIGHTS;"
+ 17, //"LLIGHTS;"
#endif
#ifdef INFLIGHT_ACC_CALIBRATION
- 17, //"CALIB;"
+ 18, //"CALIB;"
#endif
#ifdef GOVERNOR_P
- 18, //"GOVERNOR;"
+ 19, //"GOVERNOR;"
#endif
#ifdef OSD_SWITCH
- 19, //"OSD_SWITCH;"
+ 20, //"OSD_SWITCH;"
#endif
#if GPS
- 20, //"MISSION;"
- 21, //"LAND;"
+ 21, //"MISSION;"
+ 22, //"LAND;"
#endif
};
diff -uNr MultiWii_r1741_FPV_Quad/Protocol.cpp MultiWii_r1741_FPV_Quad_LEDMOD/Protocol.cpp
--- MultiWii_r1741_FPV_Quad/Protocol.cpp 2015-02-01 15:16:12.000000000 +0100
+++ MultiWii_r1741_FPV_Quad_LEDMOD/Protocol.cpp 2015-02-08 15:19:54.687588743 +0100
@@ -435,6 +435,7 @@
#if defined(LED_FLASHER)
if(rcOptions[BOXLEDMAX]) tmp |= 1<<BOXLEDMAX;
if(rcOptions[BOXLEDLOW]) tmp |= 1<<BOXLEDLOW;
+ if(rcOptions[BOXLEDINV]) tmp |= 1<<BOXLEDINV;
#endif
#if defined(LANDING_LIGHTS_DDR)
if(rcOptions[BOXLLIGHTS]) tmp |= 1<<BOXLLIGHTS;
diff -uNr MultiWii_r1741_FPV_Quad/types.h MultiWii_r1741_FPV_Quad_LEDMOD/types.h
--- MultiWii_r1741_FPV_Quad/types.h 2015-02-01 15:17:25.000000000 +0100
+++ MultiWii_r1741_FPV_Quad_LEDMOD/types.h 2015-02-08 15:19:54.687588743 +0100
@@ -66,6 +66,7 @@
#if defined(LED_FLASHER)
BOXLEDMAX, // we want maximum illumination
BOXLEDLOW, // low/no lights
+ BOXLEDINV, // invert flasher patterns
#endif
#if defined(LANDING_LIGHTS_DDR)
BOXLLIGHTS, // enable landing lights at any altitude
Codebase for the diff is the actual revision 1741. Maybe this is useful for someone else.
Cheers,
LutzB