Also output smooth led on pin 3
This commit is contained in:
parent
196b169fbe
commit
eb68b98cf5
|
@ -16,6 +16,7 @@ extern "C" {
|
||||||
#include "led_setting.h"
|
#include "led_setting.h"
|
||||||
#define TIMER 3
|
#define TIMER 3
|
||||||
#define PIN_PWM_C 4
|
#define PIN_PWM_C 4
|
||||||
|
#define PIN_PWM_B 3
|
||||||
|
|
||||||
static uint16_t pwm_max = 0;
|
static uint16_t pwm_max = 0;
|
||||||
}
|
}
|
||||||
|
@ -25,8 +26,11 @@ void setup (void)
|
||||||
hwtimer_ini (3, HWT_WGM_PWM_PHASE_8_BIT, HWT_CLOCK_PRESCALER_8, 0);
|
hwtimer_ini (3, HWT_WGM_PWM_PHASE_8_BIT, HWT_CLOCK_PRESCALER_8, 0);
|
||||||
//hwtimer_pwm_ini (TIMER, 1000, HWT_PWM_FAST, 0);
|
//hwtimer_pwm_ini (TIMER, 1000, HWT_PWM_FAST, 0);
|
||||||
hwtimer_pwm_enable (TIMER, HWT_CHANNEL_C);
|
hwtimer_pwm_enable (TIMER, HWT_CHANNEL_C);
|
||||||
|
hwtimer_pwm_enable (TIMER, HWT_CHANNEL_B);
|
||||||
hwtimer_set_pwm (TIMER, HWT_CHANNEL_C, 0);
|
hwtimer_set_pwm (TIMER, HWT_CHANNEL_C, 0);
|
||||||
|
hwtimer_set_pwm (TIMER, HWT_CHANNEL_B, 255);
|
||||||
pinMode (PIN_PWM_C, OUTPUT);
|
pinMode (PIN_PWM_C, OUTPUT);
|
||||||
|
pinMode (PIN_PWM_B, OUTPUT);
|
||||||
pwm_max = hwtimer_pwm_max_ticks (TIMER);
|
pwm_max = hwtimer_pwm_max_ticks (TIMER);
|
||||||
printf ("pwm_max: %u\n", pwm_max);
|
printf ("pwm_max: %u\n", pwm_max);
|
||||||
}
|
}
|
||||||
|
@ -36,6 +40,7 @@ void loop (void)
|
||||||
static int direction = 1;
|
static int direction = 1;
|
||||||
static unsigned const char *led_ptr = led_setting;
|
static unsigned const char *led_ptr = led_setting;
|
||||||
hwtimer_set_pwm (TIMER, HWT_CHANNEL_C, *led_ptr);
|
hwtimer_set_pwm (TIMER, HWT_CHANNEL_C, *led_ptr);
|
||||||
|
hwtimer_set_pwm (TIMER, HWT_CHANNEL_B, 255 - *led_ptr);
|
||||||
//printf ("p: %u\n", *led_ptr);
|
//printf ("p: %u\n", *led_ptr);
|
||||||
if (led_ptr >= led_setting + sizeof (led_setting) - 1 && direction > 0) {
|
if (led_ptr >= led_setting + sizeof (led_setting) - 1 && direction > 0) {
|
||||||
direction = -1;
|
direction = -1;
|
||||||
|
|
Loading…
Reference in a new issue