From 514e0eed2d6e8161d247547c762830cd184261ae Mon Sep 17 00:00:00 2001 From: Thomas Feldmann Date: Fri, 20 Dec 2013 14:32:49 +0100 Subject: [PATCH] added rudimentary matrix prototype --- Firmware/Controller.ino | 51 +++++++++++++++++++++++- Firmware/Time.ino | 6 +-- Firmware/globals.h | 1 + Software/qlocktoo/marquee/fixed_width.py | 10 ++--- Software/qlocktoo/marquee/marquee.py | 2 - 5 files changed, 59 insertions(+), 11 deletions(-) diff --git a/Firmware/Controller.ino b/Firmware/Controller.ino index 8e5e4cf..2394c72 100644 --- a/Firmware/Controller.ino +++ b/Firmware/Controller.ino @@ -55,13 +55,18 @@ void controller_buttons() brightness_next_step(); } - // switch through demo modes + // cycle through demo modes if (btn1.read() && btn2.risingEdge()) { if (STATE_IS_ACTIVE(STATE_TIMEWORDS)) STATE_SWITCH(STATE_WHITE); + if (STATE_IS_ACTIVE(STATE_WHITE)) + STATE_SWITCH(STATE_MATRIX); + + if (STATE_IS_ACTIVE(STATE_MATRIX)) STATE_SWITCH(STATE_ES_LACHT_NE_KUH); + if (STATE_IS_ACTIVE(STATE_ES_LACHT_NE_KUH)) STATE_SWITCH(STATE_TIMEWORDS); } @@ -153,6 +158,50 @@ STATEMACHINE STATE_LEAVE END_OF_STATE + STATE_ENTER(STATE_MATRIX) + brightness = 1; + matrix_clear(); + // light first line + for (byte x = 0; x < COLS; x++) + { + matrix[0][x] = 255; + } + STATE_LOOP + brightness = 1; + static int _ovf10 = 0; + static int _ovf30 = 0; + + // every 10 updates + if (++_ovf10 == 10) + { + _ovf10 = 0; + + // move rows one down + for (byte y = ROWS - 1; y > 0; y--) + { + for (byte x = 0; x < COLS; x++) + { + matrix[y][x] = matrix[y-1][x]; + } + } + + // darken first line + for (byte x = 0; x < COLS; x++) + { + matrix[0][x] = 0.8 * matrix[0][x]; + } + } + + // every 30 steps add a light + if (++_ovf30 == 30) + { + _ovf30 = 0; + byte col = rand() % COLS; + matrix[0][col] = constrain(matrix[0][col] + rand() % 255, 0, 255); + } + STATE_LEAVE + END_OF_STATE + STATE_ENTER(STATE_ES_LACHT_NE_KUH) matrix_clear(); corner_clear(); diff --git a/Firmware/Time.ino b/Firmware/Time.ino index e0e8068..e88d64c 100644 --- a/Firmware/Time.ino +++ b/Firmware/Time.ino @@ -65,10 +65,10 @@ void time_startTimer() ISR(TIMER1_OVF_vect) { - noInterrupts(); // disable all interrupts + noInterrupts(); // disable all interrupts time_addSecond(); - TCNT1 = 3036; - interrupts(); // enable all interrupts + TCNT1 = 3036; // preload timer + interrupts(); // enable all interrupts } diff --git a/Firmware/globals.h b/Firmware/globals.h index 7ea0cd0..4ab61d1 100644 --- a/Firmware/globals.h +++ b/Firmware/globals.h @@ -31,6 +31,7 @@ STATES( STATE_TEMPERATURE, STATE_WAIT_FOR_DCF, STATE_WHITE, + STATE_MATRIX, STATE_ES_LACHT_NE_KUH, STATE_STREAM, ); diff --git a/Software/qlocktoo/marquee/fixed_width.py b/Software/qlocktoo/marquee/fixed_width.py index 0f7347b..ddde613 100644 --- a/Software/qlocktoo/marquee/fixed_width.py +++ b/Software/qlocktoo/marquee/fixed_width.py @@ -959,7 +959,7 @@ [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], - [0, 1, 1, 1, 0], + [1, 1, 1, 1, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0] @@ -1114,8 +1114,8 @@ [0, 0, 0, 1, 0], [0, 0, 0, 1, 0], [0, 0, 0, 1, 0], - [0, 0, 0, 0, 1], - [0, 0, 0, 0, 0] + [0, 0, 0, 1, 0], + [0, 0, 0, 0, 1] ], ")": @@ -1128,8 +1128,8 @@ [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 0, 0, 0], - [1, 0, 0, 0, 0], - [0, 0, 0, 0, 0] + [0, 1, 0, 0, 0], + [1, 0, 0, 0, 0] ], ">": diff --git a/Software/qlocktoo/marquee/marquee.py b/Software/qlocktoo/marquee/marquee.py index afeeefe..c976cdc 100644 --- a/Software/qlocktoo/marquee/marquee.py +++ b/Software/qlocktoo/marquee/marquee.py @@ -98,8 +98,6 @@ def cursorPositionChanged(self, old, new): self.marquee.setText(text) if len(text) > 0: self.device.matrix = self.marquee.regionFromLetter(new) - else: - print "test" def _frequency(self, speed): """