summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-01-26 18:44:44 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-01-26 18:44:44 +0100
commit0e8a263587c91fe0b8bf177ec94a49c207eef4cf (patch)
treee8d1eb7366d83706c7af584a652dfe732caf71ad /src
parent02b15618cdf0c459d0ba68c85ce56decc96c0563 (diff)
use uint8_t arrays instead of chars for all buffer data structures
Diffstat (limited to 'src')
-rw-r--r--src/display.cc10
-rw-r--r--src/display.h8
-rw-r--r--src/main.cc2
-rw-r--r--src/system.cc10
4 files changed, 15 insertions, 15 deletions
diff --git a/src/display.cc b/src/display.cc
index 43b95d6..0767c4f 100644
--- a/src/display.cc
+++ b/src/display.cc
@@ -65,7 +65,7 @@ void Display::update() {
disp_buf[i] = disp_buf[i+1];
}
- glyph_addr = (uint8_t *)pgm_read_ptr(&font[(uint8_t)display.string[str_pos]]);
+ glyph_addr = (uint8_t *)pgm_read_ptr(&font[display.data_buf[str_pos]]);
glyph_len = pgm_read_byte(&glyph_addr[0]);
char_pos++;
@@ -74,7 +74,7 @@ void Display::update() {
str_pos++;
}
- if (display.string[str_pos] == 0) {
+ if (display.data_buf[str_pos] == 0) {
str_pos = 0;
}
@@ -99,13 +99,13 @@ void Display::show(text t)
show(t.str);
}
-void Display::show(char *str)
+void Display::show(uint8_t *str)
{
int i;
for (i = 0; str[i] != 0; i++) {
- string[i] = str[i];
+ data_buf[i] = str[i];
}
- string[i] = 0; // trailing null byte
+ data_buf[i] = 0; // trailing null byte
reset();
}
diff --git a/src/display.h b/src/display.h
index 685e6ee..5c66586 100644
--- a/src/display.h
+++ b/src/display.h
@@ -7,13 +7,13 @@
struct __text {
uint8_t speed_delay;
uint8_t direction_reserved;
- char *str;
+ uint8_t *str;
};
struct __animation {
uint8_t speed;
uint8_t delay;
- char *data;
+ uint8_t *data;
};
typedef struct __text text;
@@ -27,7 +27,7 @@ class Display {
uint8_t disp_buf[8];
uint8_t str_pos;
int8_t char_pos;
- char string[128];
+ uint8_t data_buf[128];
public:
Display();
void enable(void);
@@ -38,7 +38,7 @@ class Display {
void update(void);
void show(text t);
- void show(char *str);
+ void show(uint8_t *str);
};
extern Display display;
diff --git a/src/main.cc b/src/main.cc
index fad0c8e..b47c848 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -13,7 +13,7 @@
int main (void)
{
text ohai;
- ohai.str = (char *)"Ohai! ";
+ ohai.str = (uint8_t *)"Ohai! ";
// disable ADC to save power
PRR |= _BV(PRADC);
diff --git a/src/system.cc b/src/system.cc
index 544ac97..a53b8f1 100644
--- a/src/system.cc
+++ b/src/system.cc
@@ -12,12 +12,12 @@
System rocket;
-char disp_buf[128];
+uint8_t disp_buf[128];
void System::loop()
{
static uint8_t i = 0;
- char modem_char;
+ uint8_t modem_byte;
// both buttons are pressed
if ((PINC & (_BV(PC3) | _BV(PC7))) == 0) {
// naptime!
@@ -71,11 +71,11 @@ void System::loop()
}
while (modem.buffer_available()) {
- modem_char = modem.buffer_get();
- disp_buf[i++] = modem_char;
+ modem_byte = modem.buffer_get();
+ disp_buf[i++] = modem_byte;
if (i == 127) {
i = 0;
- } else if (modem_char == 0) {
+ } else if (modem_byte == 0) {
i = 0;
display.show(disp_buf);
}