Rev 886 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include <inttypes.h>
#include "led.h"
#include "fc.h"
uint16_t LED1_Time = 0;
uint16_t LED2_Time = 0;
// initializes the LED control outputs J16, J17
void LED_Init(void)
{
// set PC2 & PC3 as output (control of J16 & J17)
DDRC |= (1<<DDC2)|(1<<DDC3);
J16_OFF;
J17_OFF;
}
// called in UpdateMotors() every 2ms
void LED_Update(void)
{
static uint16_t J16_blinkcount = 0;
static uint16_t J17_blinkcount = 0;
if (LED1_Time < 20) J16_ON;
else if(LED1_Time < 220)
{
if((2 * J16_blinkcount) < LED1_Time) J16_ON;
else J16_OFF;
if(J16_blinkcount++ >= LED1_Time) J16_blinkcount = 0;
}
else J16_ON;
if (LED2_Time < 20) J17_OFF;
else if(LED2_Time < 220)
{
if((2 * J17_blinkcount) < LED2_Time) J17_ON;
else J17_OFF;
if(J17_blinkcount++ >= LED2_Time) J17_blinkcount = 0;
}
else J17_OFF;
}