mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 19:40:31 +03:00
imported STM32 multiwii port into baseflight dir
git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@86 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
commit
d262c6e66c
128 changed files with 71076 additions and 0 deletions
54
mw-svn/LED.cpp
Executable file
54
mw-svn/LED.cpp
Executable file
|
@ -0,0 +1,54 @@
|
|||
#if defined(LED_RING)
|
||||
|
||||
#define LED_RING_ADDRESS 0xDA //8 bits -- my initial :)
|
||||
|
||||
void i2CLedRingState()
|
||||
{
|
||||
uint8_t b[10];
|
||||
static uint8_t state;
|
||||
|
||||
if (state == 0) {
|
||||
b[0] = 'z';
|
||||
b[1] = (180 - heading) / 2; // 1 unit = 2 degrees;
|
||||
i2c_rep_start(LED_RING_ADDRESS);
|
||||
for (uint8_t i = 0; i < 2; i++)
|
||||
i2c_write(b[i]);
|
||||
i2c_stop();
|
||||
state = 1;
|
||||
} else if (state == 1) {
|
||||
b[0] = 'y';
|
||||
b[1] = constrain(angle[ROLL] / 10 + 90, 0, 180);
|
||||
b[2] = constrain(angle[PITCH] / 10 + 90, 0, 180);
|
||||
i2c_rep_start(LED_RING_ADDRESS);
|
||||
for (uint8_t i = 0; i < 3; i++)
|
||||
i2c_write(b[i]);
|
||||
i2c_stop();
|
||||
state = 2;
|
||||
} else if (state == 2) {
|
||||
b[0] = 'd'; // all unicolor GREEN
|
||||
b[1] = 1;
|
||||
if (armed)
|
||||
b[2] = 1;
|
||||
else
|
||||
b[2] = 0;
|
||||
i2c_rep_start(LED_RING_ADDRESS);
|
||||
for (uint8_t i = 0; i < 3; i++)
|
||||
i2c_write(b[i]);
|
||||
i2c_stop();
|
||||
state = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void blinkLedRing()
|
||||
{
|
||||
uint8_t b[3];
|
||||
b[0] = 'k';
|
||||
b[1] = 10;
|
||||
b[2] = 10;
|
||||
i2c_rep_start(LED_RING_ADDRESS);
|
||||
for (uint8_t i = 0; i < 3; i++)
|
||||
i2c_write(b[i]);
|
||||
i2c_stop();
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue