summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/display.cc22
-rw-r--r--src/display.h7
-rw-r--r--src/modem.cc16
-rw-r--r--src/modem.h7
4 files changed, 32 insertions, 20 deletions
diff --git a/src/display.cc b/src/display.cc
index 30a441f..4b4c22d 100644
--- a/src/display.cc
+++ b/src/display.cc
@@ -9,6 +9,19 @@
Display display;
+Display::Display()
+{
+ disp_buf[0] = 0xff;
+ disp_buf[1] = 0xfb;
+ disp_buf[2] = 0xdd;
+ disp_buf[3] = 0xfd;
+ disp_buf[4] = 0xdd;
+ disp_buf[5] = 0xfb;
+ disp_buf[6] = 0xff;
+ disp_buf[7] = 0xff;
+ char_pos = -1;
+}
+
void Display::disable()
{
TIMSK0 &= ~_BV(TOIE0);
@@ -30,14 +43,7 @@ void Display::enable()
void Display::multiplex()
{
- static uint8_t active_col = 0;
- static uint16_t scroll = 0;
-
- static uint8_t disp_buf[] = {0xff,0xfb,0xdd,0xfd,0xdd,0xfb,0xff,0xff};
-
- static uint8_t str_pos = 0;
- static int8_t char_pos = -1;
-
+ static uint16_t scroll;
uint8_t i, glyph_len;
uint8_t *glyph_addr;
diff --git a/src/display.h b/src/display.h
index 6545caa..655ffa1 100644
--- a/src/display.h
+++ b/src/display.h
@@ -5,8 +5,13 @@
#include <stdlib.h>
class Display {
+ private:
+ uint8_t active_col;
+ uint8_t disp_buf[8];
+ uint8_t str_pos;
+ int8_t char_pos;
public:
- Display() {};
+ Display();
void enable(void);
void disable(void);
void multiplex(void);
diff --git a/src/modem.cc b/src/modem.cc
index 0a89586..e9cddb7 100644
--- a/src/modem.cc
+++ b/src/modem.cc
@@ -11,26 +11,22 @@
#include <stdlib.h>
#include "modem.h"
-/* Ring buffer global variables */
-static volatile uint8_t modem_buffer_head = 0, modem_buffer_tail = 0;
-static volatile uint8_t modem_buffer[MODEM_BUFFER_SIZE];
-
Modem modem;
/*
* Returns number of available bytes in ringbuffer or 0 if empty
*/
uint8_t Modem::buffer_available() {
- return modem_buffer_head - modem_buffer_tail;
+ return buffer_head - buffer_tail;
}
/*
* Store 1 byte in ringbuffer
*/
-static inline void modem_buffer_put(const uint8_t c) {
+inline void Modem::buffer_put(const uint8_t c) {
if (modem.buffer_available() != MODEM_BUFFER_SIZE) {
- modem_buffer[modem_buffer_head++ % MODEM_BUFFER_SIZE] = c;
- }
+ buffer[buffer_head++ % MODEM_BUFFER_SIZE] = c;
+ }
}
/*
@@ -39,7 +35,7 @@ static inline void modem_buffer_put(const uint8_t c) {
uint8_t Modem::buffer_get() {
uint8_t b = 0;
if (buffer_available() != 0) {
- b = modem_buffer[modem_buffer_tail++ % MODEM_BUFFER_SIZE];
+ b = buffer[buffer_tail++ % MODEM_BUFFER_SIZE];
}
return b;
}
@@ -98,7 +94,7 @@ void Modem::receive() {
/* Check if we received complete byte and store it in ring buffer */
if (!(++modem_bit % 0x08)) {
- modem_buffer_put(modem_byte);
+ buffer_put(modem_byte);
}
}
diff --git a/src/modem.h b/src/modem.h
index afd6aff..18273f0 100644
--- a/src/modem.h
+++ b/src/modem.h
@@ -11,7 +11,7 @@
#include <stdlib.h>
/* Modem ring buffer size must be power of 2 */
-#define MODEM_BUFFER_SIZE 4
+#define MODEM_BUFFER_SIZE 8
/* Modem defines */
#define MODEM_SYNC_LEN 42
@@ -23,6 +23,11 @@
#define MODEM_DDR DDRA
class Modem {
+ private:
+ uint8_t buffer_head;
+ uint8_t buffer_tail;
+ uint8_t buffer[MODEM_BUFFER_SIZE];
+ void buffer_put(const uint8_t c);
public:
Modem() {};
uint8_t buffer_available(void);