summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-01-27 13:00:12 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-01-27 13:00:12 +0100
commit420cb4b1b01166739d57d37c3b95e6b6391555d7 (patch)
tree67fb47aafd7d23372e646699e3d58c2b91dbc9f1
parentce235210b76332493ee5c78bded63fb5b69ff6d3 (diff)
read scroll speed from text struct
-rw-r--r--src/display.cc15
-rw-r--r--src/display.h8
-rw-r--r--src/main.cc1
3 files changed, 14 insertions, 10 deletions
diff --git a/src/display.cc b/src/display.cc
index f3d48da..6b81684 100644
--- a/src/display.cc
+++ b/src/display.cc
@@ -12,7 +12,6 @@ Display display;
Display::Display()
{
char_pos = -1;
- update_delay = 400;
}
void Display::disable()
@@ -36,7 +35,7 @@ void Display::enable()
void Display::multiplex()
{
- static uint16_t scroll;
+ static uint8_t scroll;
/*
* To avoid flickering, do not put any code (or expensive index
@@ -46,12 +45,12 @@ void Display::multiplex()
PORTD = disp_buf[active_col];
PORTB = _BV(active_col);
- if (++active_col == 8)
+ if (++active_col == 8) {
active_col = 0;
-
- if (++scroll == update_delay) {
- scroll = 0;
- need_update = 1;
+ if (++scroll == active_text.speed) {
+ scroll = 0;
+ need_update = 1;
+ }
}
}
@@ -107,12 +106,14 @@ void Display::reset()
void Display::show(text_t text)
{
mode = TEXT;
+ active_text = text;
show(text.str);
}
void Display::show(animation_t anim)
{
mode = ANIMATION;
+ active_anim = anim;
show(anim.data);
}
diff --git a/src/display.h b/src/display.h
index 8687874..70939ca 100644
--- a/src/display.h
+++ b/src/display.h
@@ -5,8 +5,9 @@
#include <stdlib.h>
struct __text {
- uint8_t speed_delay;
- uint8_t direction_reserved;
+ uint8_t speed;
+ uint8_t delay;
+ uint8_t direction;
uint8_t *str;
};
@@ -21,7 +22,8 @@ typedef struct __animation animation_t;
class Display {
private:
- uint16_t update_delay;
+ text_t active_text;
+ animation_t active_anim;
uint8_t need_update;
uint8_t active_col;
uint8_t disp_buf[8];
diff --git a/src/main.cc b/src/main.cc
index e3bc2f9..76a2046 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -13,6 +13,7 @@
int main (void)
{
text_t ohai;
+ ohai.speed = (4 << 4) + 15;
ohai.str = (uint8_t *)"Ohai! ";
//uint8_t anim_data[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0 };