From: Jan "Yenya" Kasprzak Date: Tue, 4 Jun 2013 15:46:59 +0000 (+0200) Subject: patterns: 3 bits for duration, 5 bits for mode X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=4728997cb5f6eff94c8a9d9e253d1675b7516987;p=bike-lights.git patterns: 3 bits for duration, 5 bits for mode I plan to use a single mode for encoding all three pwmleds: 2 bits for PWMLED 0 1 bit for PWMLED 1 2 bits for PWMLED 2 --- diff --git a/firmware/control.c b/firmware/control.c index da59972..a90bb71 100644 --- a/firmware/control.c +++ b/firmware/control.c @@ -30,23 +30,23 @@ static pattern_t panic_pattern[] = { }; pattern_t on1_pattern [] = { - { 1, 0x10 }, + { 1, 0x7 }, PATTERN_END }; static pattern_t on2_pattern [] = { - { 2, 0x10 }, + { 2, 0x7 }, PATTERN_END }; static pattern_t on3_pattern [] = { - { 3, 0x10 }, + { 3, 0x7 }, PATTERN_END }; static pattern_t brake_pattern [] = { { 4, 0x2 }, - { 3, 0x8 }, + { 3, 0x7 }, PATTERN_END }; @@ -54,11 +54,11 @@ static pattern_t normal2_pattern[] = { { 2, 0x1 }, { 0, 0x1 }, { 2, 0x1 }, - { 0, 0x8 }, + { 0, 0x7 }, { 1, 0x1 }, { 0, 0x1 }, { 1, 0x1 }, - { 0, 0x8 }, + { 0, 0x7 }, PATTERN_END }; @@ -66,11 +66,11 @@ static pattern_t normal3_pattern[] = { { 3, 0x1 }, { 0, 0x1 }, { 3, 0x1 }, - { 0, 0x8 }, + { 0, 0x7 }, { 1, 0x1 }, { 0, 0x1 }, { 1, 0x1 }, - { 0, 0x8 }, + { 0, 0x7 }, PATTERN_END }; @@ -78,29 +78,32 @@ static pattern_t normal4_pattern[] = { { 4, 0x1 }, { 0, 0x1 }, { 4, 0x1 }, - { 0, 0x8 }, + { 0, 0x7 }, { 1, 0x1 }, { 0, 0x1 }, { 1, 0x1 }, - { 0, 0x8 }, + { 0, 0x7 }, PATTERN_END }; static pattern_t slow1_pattern[] = { { 1, 0x01 }, - { 0, 0x10 }, + { 0, 0x7 }, + { 0, 0x7 }, PATTERN_END }; static pattern_t slow2_pattern[] = { { 2, 0x01 }, - { 0, 0x10 }, + { 0, 0x7 }, + { 0, 0x7 }, PATTERN_END }; static pattern_t slow3_pattern[] = { { 3, 0x01 }, - { 0, 0x10 }, + { 0, 0x7 }, + { 0, 0x7 }, PATTERN_END }; diff --git a/firmware/lights.h b/firmware/lights.h index 41ee4d6..f317606 100644 --- a/firmware/lights.h +++ b/firmware/lights.h @@ -73,8 +73,8 @@ void ambient_adc(uint16_t adc_val); /* pattern.c */ typedef struct { - unsigned char mode: 3; - unsigned char duration: 5; + unsigned char mode: 5; + unsigned char duration: 3; } pattern_t; #define PATTERN_END { 0, 0 } diff --git a/firmware/pattern.c b/firmware/pattern.c index 55b64cc..77f026a 100644 --- a/firmware/pattern.c +++ b/firmware/pattern.c @@ -21,8 +21,8 @@ static pattern_t boot_pattern[] = { { 0, 0x1 }, { 1, 0x1 }, { 0, 0x1 }, - { 1, 0x10 }, - { 0, 0x10 }, + { 1, 0x7 }, + { 0, 0x7 }, PATTERN_END }; @@ -47,7 +47,8 @@ static pattern_t pattern_num[] = { { 1, 0x1 }, /* 2 */ { 0, 0x5 }, { 1, 0x1 }, /* 1 */ - { 0, 0xF }, + { 0, 0x7 }, + { 0, 0x7 }, PATTERN_END }; @@ -72,7 +73,8 @@ static pattern_t pattern_invnum[] = { { 0, 0x1 }, /* 2 */ { 1, 0x5 }, { 0, 0x1 }, /* 1 */ - { 1, 0xF }, + { 1, 0x7 }, + { 1, 0x7 }, PATTERN_END };