summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/display.cc10
-rw-r--r--src/display.h21
-rw-r--r--src/main.cc5
-rw-r--r--src/system.cc2
4 files changed, 29 insertions, 9 deletions
diff --git a/src/display.cc b/src/display.cc
index 1cdc0a2..43b95d6 100644
--- a/src/display.cc
+++ b/src/display.cc
@@ -94,16 +94,16 @@ void Display::reset()
char_pos = -1;
}
-void Display::setString(const char *new_str)
+void Display::show(text t)
{
- setString((char *)new_str);
+ show(t.str);
}
-void Display::setString(char *new_str)
+void Display::show(char *str)
{
int i;
- for (i = 0; new_str[i] != 0; i++) {
- string[i] = new_str[i];
+ for (i = 0; str[i] != 0; i++) {
+ string[i] = str[i];
}
string[i] = 0; // trailing null byte
reset();
diff --git a/src/display.h b/src/display.h
index f48d1c3..685e6ee 100644
--- a/src/display.h
+++ b/src/display.h
@@ -4,6 +4,21 @@
#include <util/delay.h>
#include <stdlib.h>
+struct __text {
+ uint8_t speed_delay;
+ uint8_t direction_reserved;
+ char *str;
+};
+
+struct __animation {
+ uint8_t speed;
+ uint8_t delay;
+ char *data;
+};
+
+typedef struct __text text;
+typedef struct __animation animation;
+
class Display {
private:
uint16_t update_delay;
@@ -17,11 +32,13 @@ class Display {
Display();
void enable(void);
void disable(void);
+
void multiplex(void);
void reset(void);
void update(void);
- void setString(const char *str);
- void setString(char *str);
+
+ void show(text t);
+ void show(char *str);
};
extern Display display;
diff --git a/src/main.cc b/src/main.cc
index 8ca3e21..fad0c8e 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -12,6 +12,9 @@
int main (void)
{
+ text ohai;
+ ohai.str = (char *)"Ohai! ";
+
// disable ADC to save power
PRR |= _BV(PRADC);
@@ -21,7 +24,7 @@ int main (void)
// Enable pull-ups on PC3 and PC7 (button pins)
PORTC |= _BV(PC3) | _BV(PC7);
- display.setString("Ohai! ");
+ display.show(ohai);
display.enable();
modem.enable();
diff --git a/src/system.cc b/src/system.cc
index 5c7b177..544ac97 100644
--- a/src/system.cc
+++ b/src/system.cc
@@ -77,7 +77,7 @@ void System::loop()
i = 0;
} else if (modem_char == 0) {
i = 0;
- display.setString(disp_buf);
+ display.show(disp_buf);
}
}
}