summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-03-16 21:00:03 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-03-16 21:00:03 +0100
commitcada20fe245628f1be7ccc57a3a41e828ec13c66 (patch)
treee1f43ab12abfd69628f1e23b72576c5e408a41fa
parentbdb7cce4d563250f567dac299c4cab25d01bf329 (diff)
make delay independent from speed, document meaning of both
-rw-r--r--MessageSpecification.md30
-rw-r--r--src/display.cc6
-rw-r--r--src/display.h6
-rw-r--r--src/system.cc12
4 files changed, 46 insertions, 8 deletions
diff --git a/MessageSpecification.md b/MessageSpecification.md
index 10f141f..1df7ea4 100644
--- a/MessageSpecification.md
+++ b/MessageSpecification.md
@@ -41,6 +41,31 @@ XXXX XXXX XXXX XXXX (MSB -> LSB)
The speed and delay ranges from a numeric value from 0 (0000) to 15 (1111). The higher the number, the faster the speed and the longer the delay. A direction of 0 (0000) specifies a left direction, a direction of 1 (0001) specifies a right direction.
+The scroll rate is about 1 / (0.5 - (0.032 * speed)) columns per second (or,
+precisely, 1 / (0.002048 * (250 - (16 * speed))) columns per second). This
+means that it can range from about 2 columns per second (speed=0) to almost 49
+columns per second (speed=15). Note that it is not a linear function -- see the
+following speed <-> columns per second translation list for details:
+
+* speed = 0 : 1.95 cps
+* speed = 1 : 2.09 cps
+* speed = 2 : 2.24 cps
+* speed = 3 : 2.42 cps
+* speed = 4 : 2.63 cps
+* speed = 5 : 2.87 cps
+* speed = 6 : 3.17 cps
+* speed = 7 : 3.54 cps
+* speed = 8 : 4.00 cps
+* speed = 9 : 4.61 cps
+* speed = 10 : 5.43 cps
+* speed = 11 : 6.60 cps
+* speed = 12 : 8.42 cps
+* speed = 13 : 11.6 cps
+* speed = 14 : 18.8 cps
+* speed = 15 : 48.8 cps
+
+The delay takes 0.5 * delay seconds.
+
##### ANIMATION METADATA
A *`ANIMMETA`* is a two byte (16 bit) length metadata field for animation type pattern. It encodes the frame rate in the lower nibble of the first byte and the delay in the lower nibble of the second byte.
@@ -51,7 +76,10 @@ A *`ANIMMETA`* is a two byte (16 bit) length metadata field for animation type p
SPEED DELAY
```
-The speed and delay ranges from a numeric value from 0 (0000) to 15 (1111).
+The speed and delay ranges from a numeric value from 0 (0000) to 15 (1111)
+and are calculated as described in TEXT METADATA (except that the speed
+now refers to frames per second).
+
## Message format
The message transmitted has to follow the following diagram:
diff --git a/src/display.cc b/src/display.cc
index 98b394a..b0f5369 100644
--- a/src/display.cc
+++ b/src/display.cc
@@ -55,7 +55,7 @@ void Display::multiplex()
if (++active_col == 8) {
active_col = 0;
- if (++update_cnt == current_anim->speed) {
+ if (++update_cnt == update_threshold) {
update_cnt = 0;
need_update = 1;
}
@@ -124,6 +124,7 @@ void Display::update() {
str_pos = 0;
if (current_anim->delay > 0) {
status = PAUSED;
+ update_threshold = 244;
}
if (current_anim->length > 128) {
storage.loadChunk(str_chunk, current_anim->data);
@@ -139,6 +140,7 @@ void Display::update() {
if (current_anim->delay > 0) {
str_pos = 0;
status = PAUSED;
+ update_threshold = 244;
} else {
str_pos = (current_anim->length - 1) % 128;
}
@@ -159,6 +161,7 @@ void Display::update() {
else
str_pos = 127;
status = RUNNING;
+ update_threshold = current_anim->speed;
}
}
}
@@ -180,6 +183,7 @@ void Display::show(animation_t *anim)
{
current_anim = anim;
reset();
+ update_threshold = current_anim->speed;
if (current_anim->direction == 1) {
if (current_anim->length > 128) {
str_chunk = (current_anim->length - 1) / 128;
diff --git a/src/display.h b/src/display.h
index 1bf5758..aac64dd 100644
--- a/src/display.h
+++ b/src/display.h
@@ -102,6 +102,12 @@ class Display {
uint8_t need_update;
/**
+ * Number of frames after which update() is called. This value
+ * holds either the current animation's speed or its delay.
+ */
+ uint8_t update_threshold;
+
+ /**
* The currently active column in multiplex()
*/
uint8_t active_col;
diff --git a/src/system.cc b/src/system.cc
index 9e36c0a..7e43966 100644
--- a/src/system.cc
+++ b/src/system.cc
@@ -83,11 +83,11 @@ void System::loadPattern_buf(uint8_t *pattern)
if (active_anim.type == AnimationType::TEXT) {
active_anim.speed = 250 - (pattern[2] & 0xf0);
- active_anim.delay = (pattern[2] & 0x0f ) << 4;
+ active_anim.delay = (pattern[2] & 0x0f );
active_anim.direction = pattern[3] >> 4;
} else if (active_anim.type == AnimationType::FRAMES) {
active_anim.speed = 250 - ((pattern[2] & 0x0f) << 4);
- active_anim.delay = (pattern[3] & 0x0f) << 2;
+ active_anim.delay = (pattern[3] & 0x0f);
active_anim.direction = 0;
}
@@ -288,9 +288,9 @@ void System::shutdown()
display.update();
// and some more to debounce the buttons (and finish powerdown animation)
- for (i = 0; i < 100; i++) {
+ for (i = 0; i < 200; i++) {
display.update();
- _delay_ms(2);
+ _delay_ms(1);
}
// turn off display to indicate we're about to shut down
@@ -319,9 +319,9 @@ void System::shutdown()
display.update();
// debounce
- for (i = 0; i < 50; i++) {
+ for (i = 0; i < 100; i++) {
display.update();
- _delay_ms(2);
+ _delay_ms(1);
}
// finally, turn on the modem...