Danke, beim Brain gibt es einen Flex Stecker der I2C unterstuetzen kann.
Ich häng mal meinen Source, hängt leider :-(
#include "system.h"
#include "flightbatterystate.h"
#define nLED 8
unsigned char bufLED[nLED*3];
unsigned char clrLED[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));
}
void clearLED() {
ChangeBaud(9600);
SendBuffer(clrLED,sizeof(clrLED));
}
/* end of RGB-LED library */
/* create link to ARM code */
FlightBatteryStateData BatteryData;
short LEDblink=0;
short LEDupdate=1;
short TMParmed=2;
short r=0,g=0,b=0;
TestValSet(1);
sync(0);
while(TestValGet() > 0)
{
FlightBatteryStateGet(&BatteryData);
if (BatteryData.Voltage < 10.4)
LEDblink=1;
else LEDblink=0;
if (armed() && (TMParmed != 1))
{
setLED(0,170,0,0);
setLED(1,170,0,0);
setLED(2,170,0,0);
setLED(3,170,0,0);
TMParmed = 1;
LEDupdate=1;
}
else if (!armed() && (TMParmed != 0))
{
setLED(0,0,170,0);
setLED(1,0,170,0);
setLED(2,0,170,0);
setLED(3,0,170,0);
TMParmed = 0;
LEDupdate=1;
}
if (LEDupdate == 1) {
if(LEDblink==0)
sendLED();
else
clrLED();
LEDupdate = 0;
}
delay(500);
}
TestValSet(2);