diff options
-rw-r--r-- | software/effects.ino | 6 | ||||
-rw-r--r-- | software/scan.ino | 11 | ||||
-rw-r--r-- | software/util.ino | 2 |
3 files changed, 15 insertions, 4 deletions
diff --git a/software/effects.ino b/software/effects.ino index 6cf2cfc..e8741af 100644 --- a/software/effects.ino +++ b/software/effects.ino @@ -2,7 +2,7 @@ #include "effects.h" #include "animation.h" -#define FX_LEN_ROUNDABOUT 5e3 +#define FX_LEN_ROUNDABOUT (unsigned long) 5e3 void fx_roundabout (unsigned long relative_time) { memset(led_state, 0, sizeof(led_state)); unsigned long tick = relative_time / 300; @@ -19,7 +19,7 @@ void fx_roundabout (unsigned long relative_time) { return; } -#define FX_LEN_WIPEXYZ 6e3 +#define FX_LEN_WIPEXYZ (unsigned long) 6e3 void fx_wipexyz (unsigned long relative_time) { memset(led_state, 0, sizeof(led_state)); unsigned long tick = relative_time / 200; @@ -30,7 +30,7 @@ void fx_wipexyz (unsigned long relative_time) { return; } -#define FX_LEN_RAINFALL 7e3 +#define FX_LEN_RAINFALL (unsigned long) 7e3 unsigned long last_frame; void fx_rainfall (unsigned long relative_time) { unsigned long frame = get_frame(relative_time); diff --git a/software/scan.ino b/software/scan.ino index cc72e21..b369609 100644 --- a/software/scan.ino +++ b/software/scan.ino @@ -1,6 +1,7 @@ #include "scan.h" #include "shift.h" #include "software.h" +#include "util.h" // 0 = horizontal (top-bottom), 1 = vertical (left-right) unsigned char scan_direction = 0; @@ -18,6 +19,8 @@ unsigned char get_state_row(unsigned char row, unsigned char direction) { } void scan() { + optimize_scan(); + shift_state[0] = 0x00 ^ (1 << scan_index); shift_state[1] = 0xff ^ get_state_row(scan_index, scan_direction); @@ -45,6 +48,14 @@ void optimize_scan() { } } + Serial.print("[ "); + for(int i = 0; i < 8; i++) { + Serial.print((unsigned int) hv_empty[0][i], DEC); + if(i != 7) Serial.print(", "); + } + Serial.print(" ]"); + + optimal_direction = hv_emptyc[0] > hv_emptyc[1] ? 0 : 1; scan_direction = optimal_direction; memcpy(&scan_order, &hv_emptyc[optimal_direction], sizeof(scan_order)); diff --git a/software/util.ino b/software/util.ino index 5a8ed12..e399c3e 100644 --- a/software/util.ino +++ b/software/util.ino @@ -16,7 +16,7 @@ void print_led_state() { } } -void print_padded_number(unsigned int number, char* pad_with, unsigned int pad_count) { +void print_padded_number(unsigned int number, const char* pad_with, unsigned int pad_count) { unsigned int pad_amount = pad_count - (int) log10(number); for(int i = 0; i < pad_amount; i++) Serial.print(pad_with); Serial.print(number, DEC); |