/* Beleuchtungssteuerung:
/* Steuert die Beleuchtung des Quadrocopters
/*Pinbelegung Quanton:
/*RS232 Schnittstelle = WS2812 LEDs
/*PWM Out 10 = LEDs
/*PWM Out 11 = Summer
#include "system.h"
#include "flightbatterystate.h"
/* Variablen Deklarieren:
short LEDupdate=1;
short TMPArmed=2;
short r=0,g=0,b=0;
int Summervar=0;
short LEDblOn=0;
Short WS2812On=0;
/* WS2812 library */
#define nLED 10
unsigned char bufLED[nLED*3];
void setLED(unsigned short n, unsigned char r, unsigned char g, unsigned char b) {
if (n < nLED) {
unsigned short offset = 3*n;
bufLED[offset++] = r;
bufLED[offset++] = g;
bufLED[offset++] = b;
}
}
void sendLED() {
ChangeBaud(9600);
SendBuffer(bufLED, sizeof(bufLED));
}
/* end of RGB-LED library */
/*Batteriestatus:
FlightBatteryStateData BatteryData;
short TMPBattery=4;
void batterystatus()
{
FlightBatteryStateGet(&BatteryData);
if ((BatteryData.Voltage < 10.4) && (TMPBattery != 1))
{
TMPBattery = 1;
Summervar=2000;
}
if ((BatteryData.Voltage < 10.8) && (BatteryData.Voltage > 10.4) && (TMPBattery != 2))
{
TMPBattery = 2;
Summervar=1000;
}
if ((10.8 > BatteryData.Voltage) && (TMPBattery != 3))
{
TMPBattery = 3;
Summervar=0;
}
PWMOutSet(11,Summervar);
}
/*WS2812 LEDs schalten (Farben definieren): setLED(n,r,g,b);
void PosLEDs()
{
int n=1
while(n<3)
{
setLED(n,255,0,0);
n=n+1;
}
while(n<5)
{
setLED(n,0,255,0);
n=n+1;
}
while(n<7)
{
setLED(n,0,0,255);
n=n+1;
}
while(n<10)
{
setLED(n,0,255,255);
n=n+1;
}
}
void PosLEDsAus()
{
int n=1
while(n<3)
{
setLED(n,0,0,0);
n=n+1;
}
while(n<5)
{
setLED(n,0,0,0);
n=n+1;
}
while(n<7)
{
setLED(n,0,0,0);
n=n+1;
}
while(n<10)
{
setLED(n,0,255,0);
n=n+1;
}
}
TestValSet(1);
TestValSet(2);
while(TestValGet() > 0)
{
batterystatus();
printf("Summerstatus: ");
printf(Summervar);
printf(" \n");
if (armed() && (TMPArmed != 1))
{
PosLEDs();
LEDblOn = 1;
TMPArmed = 1;
LEDupdate=1;
}
else if (!armed() && (TMPArmed != 0))
{
PosLEDsAus();
LEDblOn = 0;
TMPArmed = 0;
LEDupdate=1;
}
/* BlinkLEDs ein-/ausschalten
if (LEDblOn == 1)
{
PWMOutSet(10,2000);
}
else
PWMOutSet(10,0);
}
if (LEDupdate == 1) {
sendLED();
LEDupdate = 0;
}
delay(500);
}
TestValSet(99);