Commit f860a22a authored by Oystein Smith's avatar Oystein Smith

fixes and tuning

parent d77b2035
......@@ -27,22 +27,22 @@
<eraseonlaunchrule>0</eraseonlaunchrule>
<AsfFrameworkConfig>
<framework-data>
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.18.1" />
</dependencies>
</framework-data>
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.18.1" />
</dependencies>
</framework-data>
</AsfFrameworkConfig>
<avrtool>com.atmel.avrdbg.tool.jtagice3plus</avrtool>
<avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
<avrtoolinterface>PDI</avrtoolinterface>
<com_atmel_avrdbg_tool_jtagice3plus>
<ToolOptions>
<InterfaceProperties>
<PdiClock>4000000</PdiClock>
<PdiClock>0</PdiClock>
</InterfaceProperties>
<InterfaceName>PDI</InterfaceName>
</ToolOptions>
......@@ -53,18 +53,20 @@
<com_atmel_avrdbg_tool_atmelice>
<ToolOptions>
<InterfaceProperties>
<PdiClock>0</PdiClock>
<PdiClock>4000000</PdiClock>
</InterfaceProperties>
<InterfaceName>PDI</InterfaceName>
</ToolOptions>
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
<ToolNumber>J41800003864</ToolNumber>
<ToolNumber>J41800004247</ToolNumber>
<ToolName>Atmel-ICE</ToolName>
</com_atmel_avrdbg_tool_atmelice>
<preserveEEPROM>true</preserveEEPROM>
<avrtoolserialnumber>J30200033026</avrtoolserialnumber>
<avrtoolserialnumber>J41800004247</avrtoolserialnumber>
<avrdeviceexpectedsignature>0x1E9646</avrdeviceexpectedsignature>
<avrtoolinterfaceclock>4000000</avrtoolinterfaceclock>
<ResetRule>0</ResetRule>
<EraseKey />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
......
......@@ -20,42 +20,48 @@ void set_leds(uint16_t val){
}
// Gradual fill
void effect_gradual_fill( void ){
for(uint8_t i = 0; i < 16; i++)
void effect_gradual_fill(uint8_t n){
for(uint8_t t = 0; t < n; t++)
{
LED_SET(i, LED_MAX);
_delay_ms(25);
}
for(uint8_t i = 0; i < 16; i++)
{
LED_SET(i, LED_MIN);
_delay_ms(25);
for(uint8_t i = 0; i < 16; i++)
{
LED_SET(i, LED_MAX);
_delay_ms(10);
}
for(uint8_t i = 0; i < 16; i++)
{
LED_SET(i, LED_MIN);
_delay_ms(10);
}
}
}
// Down and up
void effect_downandup( void )
void effect_downandup(uint8_t n)
{
for(uint8_t i = 0; i < 8; i++)
{
LED_SET(7-i, LED_MAX);
LED_SET(8+i, LED_MAX);
_delay_ms(37);
}
for(int16_t i = 7; i >= 0; i--)
for(uint8_t t = 0; t < n; t++)
{
LED_SET(7-i, LED_MIN);
LED_SET(8+i, LED_MIN);
_delay_ms(37);
for(uint8_t i = 0; i < 8; i++)
{
LED_SET(7-i, LED_MAX);
LED_SET(8+i, LED_MAX);
_delay_ms(10);
}
for(int16_t i = 7; i >= 0; i--)
{
LED_SET(7-i, LED_MIN);
LED_SET(8+i, LED_MIN);
_delay_ms(10);
}
}
}
// Fade in, fade out
void effect_fadeinout( void )
void effect_fadeinout(uint8_t n)
{
for(uint8_t t = 0; t < 4; t++)
for(uint8_t t = 0; t < n; t++)
{
for(uint8_t percent = 0; percent <= LED_MAX; percent++)
for(uint16_t percent = LED_MID; percent <= LED_MAX; percent++)
{
for(uint8_t led_i = 0; led_i < 16; led_i++)
{
......@@ -63,8 +69,8 @@ void effect_fadeinout( void )
}
_delay_ms(2);
}
_delay_ms(10);
for(int16_t percent = LED_MAX; percent >= 0; percent--)
//_delay_ms(10);
for(int16_t percent = LED_MAX; percent >= LED_MID; percent--)
{
for(uint8_t led_i = 0; led_i < 16; led_i++)
{
......@@ -76,9 +82,9 @@ void effect_fadeinout( void )
}
// Snake
void effect_snake( void )
void effect_snake(uint8_t n)
{
for (uint8_t t = 0; t < 4; t++)
for (uint8_t t = 0; t < n; t++)
{
for(uint8_t pos = 0; pos < 18; pos++)
{
......@@ -90,17 +96,17 @@ void effect_snake( void )
{
LED_SET(pos, LED_MAX);
}
_delay_ms(25);
_delay_ms(10);
}
}
}
// Fade half
void effect_fadehalf( void )
void effect_fadehalf(uint8_t n)
{
for(uint8_t t = 0; t < 5; t++)
for(uint8_t t = 0; t < n; t++)
{
for(uint8_t percent = 0; percent <= LED_MAX; percent++)
for(uint8_t percent = LED_MID; percent <= LED_MAX; percent++)
{
for(uint8_t led_i = 0; led_i < 15; led_i += 2)
{
......@@ -109,8 +115,8 @@ void effect_fadehalf( void )
}
_delay_ms(1);
}
_delay_ms(25);
for(int16_t percent = LED_MAX; percent >= 0; percent--)
_delay_ms(10);
for(int16_t percent = LED_MAX; percent >= LED_MID; percent--)
{
for(uint8_t led_i = 0; led_i < 15; led_i += 2)
{
......@@ -119,26 +125,50 @@ void effect_fadehalf( void )
}
_delay_ms(1);
}
_delay_ms(10);
}
}
// Snake circle
void effect_snakecircle( void )
void effect_snakecircle(uint8_t n)
{
for (uint8_t t = 0; t < 4; t++)
for (uint8_t t = 0; t < n; t++)
{
for(uint8_t pos = 0; pos < 16; pos++)
for(uint8_t pos = 2; pos < 14; pos++)
{
if(pos < 4)
{
LED_SET(pos+10, LED_MIN);
}
if(pos > 1)
{
LED_SET(pos-2, LED_MIN);
}
if(pos < 16)
if(pos < 14)
{
LED_SET(pos, LED_MAX);
}
_delay_ms(25);
_delay_ms(10);
}
}
}
void effect_knightrider(uint8_t n)
{
for (uint8_t t = 0; t < n; t++)
{
for (uint8_t pos = 5; pos < 11; pos++)
{
LED_SET(pos, LED_MAX);
LED_SET(pos-1, LED_MIN);
_delay_ms(10);
}
for (uint8_t pos = 10; pos > 4; pos--)
{
LED_SET(pos, LED_MAX);
LED_SET(pos+1, LED_MIN);
_delay_ms(10);
}
}
}
\ No newline at end of file
}
......@@ -13,15 +13,17 @@
void set_leds(uint16_t val);
void effect_gradual_fill( void );
void effect_downandup( void );
void effect_fadeinout( void );
void effect_snake( void );
void effect_fadehalf( void );
void effect_snakecircle( void );
void effect_gradual_fill(uint8_t n);
void effect_downandup(uint8_t n);
void effect_fadeinout(uint8_t n);
void effect_snake(uint8_t n);
void effect_fadehalf(uint8_t n);
void effect_snakecircle(uint8_t n);
void effect_knightrider(uint8_t n);
#define LED_SET(led_num,led_percent) *led_outputs[led_num] = ((uint16_t)(100 - led_percent)*(uint16_t)(100 - led_percent))
#define LED_MAX 100
#define LED_SET(led_num,led_percent) *led_outputs[led_num] = ((uint16_t)(256 - led_percent)*(uint16_t)(256 - led_percent))-1
#define LED_MAX 180
#define LED_MID 155
#define LED_MIN 0
#endif /* EFFECTS_H_ */
\ No newline at end of file
......@@ -15,11 +15,14 @@
// LED layout in omega pattern
register16_t* led_outputs[16] = {
&TCC0.CCABUF, &TCC0.CCBBUF, &TCC0.CCCBUF, &TCC0.CCDBUF,
&TCC1.CCABUF, &TCC1.CCBBUF,
&TCD0.CCABUF, &TCD0.CCBBUF, &TCD0.CCCBUF, &TCD0.CCDBUF,
&TCD0.CCCBUF, &TCD0.CCDBUF,
&TCD1.CCABUF, &TCD1.CCBBUF,
&TCE0.CCABUF, &TCE0.CCBBUF, &TCE0.CCCBUF, &TCE0.CCDBUF
&TCE0.CCABUF, &TCE0.CCBBUF,
&TCE0.CCCBUF, &TCE0.CCDBUF,
&TCC0.CCABUF, &TCC0.CCBBUF,
&TCC0.CCCBUF, &TCC0.CCDBUF,
&TCC1.CCABUF, &TCC1.CCBBUF,
&TCD0.CCABUF, &TCD0.CCBBUF
};
void init_pwm( void );
......@@ -28,11 +31,13 @@ int main(void) {
init_pwm();
set_leds(LED_MIN);
while(1) {
effect_snake();
effect_gradual_fill();
effect_downandup();
effect_fadeinout();
effect_fadehalf();
effect_snake(2);
effect_gradual_fill(2);
effect_downandup(1);
effect_knightrider(5);
effect_fadeinout(3);
effect_snakecircle(4);
effect_fadehalf(5);
}
}
......@@ -51,7 +56,7 @@ void init_pwm( void ) {
// ???
for (uint8_t i = 0; i < 16; i++) {
*led_outputs[i] = 9000;
*led_outputs[i] = 0xffff;
}
// Set WG mode to single slope
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment