Hi
I want to make in the MultiWii 2.3 script a funktion that use a free port for the Position light like it is on the airplanes.
i know the funktion LED FLasher and LED landing lights but i dont want to use it.
i have try to insert the normal blink script from arduino but it dosent work with the Multiwii code.
i use MW on a arduino Mega 2560 V3 and has many digital ports free.
can someone help me with it?
Position light insert MW 2.3 help
Re: Position light insert MW 2.3 help
I have described the fulfilment of your wishes for a MEGA in viewtopic.php?f=16&t=4779&p=47933#p47933
The solution is integrated into the alarm handling of multiwii, does not harm flight stability since it is non-blocking and requires 3 free pins for blue, green and red LEDs. Those LEDs are signalling the state of the copter (red: static=BAT ok, blinking=BAT low; green: static = stable, blinking=ACRO or unstable; blue: static = GPS FIX ok, blinking: no fix or position hold or return to home) You can adapt the software due to your purposes.
The solution is integrated into the alarm handling of multiwii, does not harm flight stability since it is non-blocking and requires 3 free pins for blue, green and red LEDs. Those LEDs are signalling the state of the copter (red: static=BAT ok, blinking=BAT low; green: static = stable, blinking=ACRO or unstable; blue: static = GPS FIX ok, blinking: no fix or position hold or return to home) You can adapt the software due to your purposes.
Re: Position light insert MW 2.3 help
i dont want the flashing light to use for it.
it has severall infos of diverse modis (8 at my version)
the led flasher give the status of the copter but position light should be on at everytime the copter has power.
it should help to locate the copter in the air for other vehicle in the air like the airplanes.
i dont want to use the led flasher oder led landing lights for it because i want to use this for the other fuctions.
i want a third funktion that blink like it is on a plane. in eglish is has the name navigation lights http://en.wikipedia.org/wiki/Navigation_light
i should light to the side of the copter an not to me.
i have many free ports on the mega 2560 to use for it.
it has severall infos of diverse modis (8 at my version)
the led flasher give the status of the copter but position light should be on at everytime the copter has power.
it should help to locate the copter in the air for other vehicle in the air like the airplanes.
i dont want to use the led flasher oder led landing lights for it because i want to use this for the other fuctions.
i want a third funktion that blink like it is on a plane. in eglish is has the name navigation lights http://en.wikipedia.org/wiki/Navigation_light
i should light to the side of the copter an not to me.
i have many free ports on the mega 2560 to use for it.
Re: Position light insert MW 2.3 help
And where is your problem?
Just use the functions setTiming or patternDecode from the file alarm.cpp and adapt it to your own purpose.
Just use the functions setTiming or patternDecode from the file alarm.cpp and adapt it to your own purpose.
Re: Position light insert MW 2.3 help
i dont want change the led flasher or landing lights function.
and the led flasher is for status messages not to tell other flying vehicle the position of a copter.
i have 8 status function with the led flasher that doesnt work with a function to set position light
and the led flasher is for status messages not to tell other flying vehicle the position of a copter.
i have 8 status function with the led flasher that doesnt work with a function to set position light
Re: Position light insert MW 2.3 help
You are repeating yourself. So, I am afraid you are not understanding my proposal. Therefore, let's start from scratch.
Add and change the Mega section of the file def.h as follows:
Now add to config.h
Look at the setup()-section of the file multiwii.cpp and add
Look in the file multiwii.cpp for
and change it to the file multiwii.cpp (or multiwii2_3.cpp or similiar)
Finally, add to file alarm.cpp at the end of the module alarmPatternComposer()
change the module toggleResource() as follows:
That should it be!
Add and change the Mega section of the file def.h as follows:
Code: Select all
/************************** all the Mega types ***********************************/
#if defined(MEGA)
#if defined(MY_LED)
#undef GPS_LED_INDICATOR
#undef PILOTLAMP
#define LEDPIN_PINMODE pinMode (13, OUTPUT);
#define LEDPIN_TOGGLE PINB |= (1 << 7);
#define LEDPIN_ON PORTB |= (1 << 7);
#define LEDPIN_OFF PORTB &= ~(1 << 7);
#define LED_GREEN_PINMODE pinMode (30, OUTPUT); // Those outputs have to be available!
#define LED_BLUE_PINMODE pinMode (31, OUTPUT);
#define LED_RED_PINMODE pinMode (33, OUTPUT);
#if defined(MY_LED_REV)
#define LED_GREEN_ON PORTC &= ~(1 << 7);
#define LED_GREEN_OFF PORTC |= (1 << 7);
#define LED_BLUE_ON PORTC &= ~(1 << 6);
#define LED_BLUE_OFF PORTC |= (1 << 6);
#define LED_RED_ON PORTC &= ~(1 << 4);
#define LED_RED_OFF PORTC |= (1 << 4);
#define LED_ALL_ON PORTC &= ~(1 << 4); PORTC &= ~(1 << 5); PORTC &= ~(1 << 6); PORTC &= ~(1 << 7);
#define LED_ALL_OFF PORTC |= (1 << 4); PORTC |= (1 << 5); PORTC |= (1 << 6); PORTC |= (1 << 7);
#else
#define LED_GREEN_ON PORTC |= (1 << 7);
#define LED_GREEN_OFF PORTC &= ~(1 << 7);
#define LED_BLUE_ON PORTC |= (1 << 6);
#define LED_BLUE_OFF PORTC &= ~(1 << 6);
#define LED_RED_ON PORTC |= (1 << 4);
#define LED_RED_OFF PORTC &= ~(1 << 4);
#define LED_ALL_ON PORTC |= (1 << 4); PORTC |= (1 << 5); PORTC |= (1 << 6); PORTC |= (1 << 7);
#define LED_ALL_OFF PORTC &= ~(1 << 4); PORTC &= ~(1 << 5); PORTC &= ~(1 << 6); PORTC &= ~(1 << 7);
#endif
#else // as defined before LED change
#define LEDPIN_PINMODE pinMode (13, OUTPUT);pinMode (30, OUTPUT);
#define LEDPIN_TOGGLE PINB |= (1<<7); PINC |= (1<<7);
#define LEDPIN_ON PORTB |= (1<<7); PORTC |= (1<<7);
#define LEDPIN_OFF PORTB &= ~(1<<7);PORTC &= ~(1<<7);
#define STABLEPIN_PINMODE pinMode (31, OUTPUT);
#define STABLEPIN_ON PORTC |= (1 << 6);
#define STABLEPIN_OFF PORTC &= ~(1 << 6);
#define BUZZERPIN_PINMODE pinMode (32, OUTPUT);
#if defined PILOTLAMP
#define PL_PIN_ON PORTC |= 1<<5;
#define PL_PIN_OFF PORTC &= ~(1<<5);
#else
#define BUZZERPIN_ON PORTC |= 1<<5;
#define BUZZERPIN_OFF PORTC &= ~(1<<5);
#endif
#endif
Now add to config.h
Code: Select all
/***************** My LED *********************************/
// alternative status monitor via led-stripes
#define MY_LED
#define MY_LED_REV // changign polarity
Look at the setup()-section of the file multiwii.cpp and add
Code: Select all
#if defined(MY_LED)
LED_GREEN_PINMODE;
LED_BLUE_PINMODE;
LED_RED_PINMODE;
LED_ALL_OFF;
#endif
Look in the file multiwii.cpp for
Code: Select all
#if defined(BUZZER)
alarmHandler(); // external buzzer routine that handles buzzer events globally now
#endif
and change it to the file multiwii.cpp (or multiwii2_3.cpp or similiar)
Code: Select all
#if defined(BUZZER) || defined(MY_LED)
alarmHandler(); // external buzzer routine that handles buzzer events globally now
#endif
Finally, add to file alarm.cpp at the end of the module alarmPatternComposer()
Code: Select all
#if defined(MY_LED)
resource = 1; //green LEDs are blinking, 2=blue, 3=red
setTiming(resource,100,100); //all very fast blink --> bigger value = slower blinking
#endif
change the module toggleResource() as follows:
Code: Select all
void toggleResource(uint8_t resource, uint8_t activate){
switch(resource) {
#if defined (BUZZER)
case 1:
if (activate == 1) {BUZZERPIN_ON;}
else BUZZERPIN_OFF;
break;
#endif
#if defined (PILOTLAMP)
case 2:
if (activate == 1) PilotLamp(PL_GRN_ON);
else PilotLamp(PL_GRN_OFF);
break;
case 3:
if (activate == 1) PilotLamp(PL_BLU_ON);
else PilotLamp(PL_BLU_OFF);
break;
case 4:
if (activate == 1) PilotLamp(PL_RED_ON);
else PilotLamp(PL_RED_OFF);
break;
#endif
#if defined (MY_LED)
case 2:
if (activate == 1) {LED_GREEN_ON;}
else {LED_GREEN_OFF;}
break;
case 3:
if (activate == 1) {LED_BLUE_ON;}
else {LED_BLUE_OFF;}
break;
case 4:
if (activate == 1) {LED_RED_ON;}
else {LED_RED_OFF;}
break;
#endif
case 0:
default:
if (activate == 1) {LEDPIN_ON;}
else LEDPIN_OFF;
break;
}
return;
}
That should it be!