Commit 4a8f3408 authored by Alexander Detsch's avatar Alexander Detsch 🐘
Browse files

I HATE TILDE!!!!

parent 2aa4e13f
......@@ -8,7 +8,7 @@
#include "Dotmatrix.h"
uint8_t Dotmatrix::screenMem[5]; // screen memory
uint8_t Dotmatrix::screenMem[7]; // screen memory
uint8_t Dotmatrix::activeColumn; // active row
char Dotmatrix::buffer[60];
uint8_t Dotmatrix::messagePointer = 0; // points to the active char in the message
......@@ -32,106 +32,130 @@ Dotmatrix::~Dotmatrix()
} //~Dotmatrix
void Dotmatrix::init() {
// setting pin direction to output
DDRA |= (1 << ROW_0) | (1 << ROW_1) | (1 << ROW_2) | (1 << ROW_3) | (1 << ROW_4) | (1 << ROW_5) | (1 << ROW_6);
DDRB |= (1 << COLUMN_0) | (1 << COLUMN_1) | (1 << COLUMN_2) | (1 << COLUMN_3) | (1 << COLUMN_4);
// turning all leds off
clearScreen();
Time::attachRepeatingTask(Dotmatrix::displayActiveColumn, 1000);
// setting pin direction to output
DDRA |= (1 << ROW_0) | (1 << ROW_1) | (1 << ROW_2) | (1 << ROW_3) | (1 << ROW_4) | (1 << ROW_5) | (1 << ROW_6);
DDRB |= (1 << COLUMN_0) | (1 << COLUMN_1) | (1 << COLUMN_2) | (1 << COLUMN_3) | (1 << COLUMN_4);
// turning all leds off
clearScreen();
Time::attachRepeatingTask(Dotmatrix::displayActiveColumn, 3000);
}
void Dotmatrix::displayActiveColumn() {
// turn all leds off
clearScreen();
activeColumn = (activeColumn + 1) % 5;
uint8_t column = 0;
for (uint8_t i = 0; i < 7; i++) {
column >>= ((screenMem[i] >> activeColumn) & 0x01);
}
// output all rows, switch leds on.
if ((column & 0x80) == 0x80) PORTA |= (1 << ROW_0);
if ((column & 0x40) == 0x40) PORTA |= (1 << ROW_1);
if ((column & 0x20) == 0x20) PORTA |= (1 << ROW_2);
if ((column & 0x10) == 0x10) PORTA |= (1 << ROW_3);
if ((column & 0x08) == 0x08) PORTA |= (1 << ROW_4);
if ((column & 0x04) == 0x04) PORTA |= (1 << ROW_5);
if ((column & 0x02) == 0x02) PORTA |= (1 << ROW_6);
switch (activeColumn) {
case 0:
PORTB &= ~(1 << COLUMN_0);
break;
case 1:
PORTB &= ~(1 << COLUMN_1);
break;
case 2:
PORTB &= ~(1 << COLUMN_2);
break;
case 3:
PORTB &= ~(1 << COLUMN_3);
break;
case 4:
PORTB &= ~(1 << COLUMN_4);
break;
}
// turn all leds off
clearScreen();
activeColumn = (activeColumn + 1) % 5;
uint8_t column = 0;
/*for (uint8_t i = 0; i < 7; i++) {
column <<= ((screenMem[i] >> activeColumn) & 0x01);
}*/
if ((screenMem[0] >> activeColumn) & 0x01) column |= (1 << 0);
if ((screenMem[1] >> activeColumn) & 0x01) column |= (1 << 1);
if ((screenMem[2] >> activeColumn) & 0x01) column |= (1 << 2);
if ((screenMem[3] >> activeColumn) & 0x01) column |= (1 << 3);
if ((screenMem[4] >> activeColumn) & 0x01) column |= (1 << 4);
if ((screenMem[5] >> activeColumn) & 0x01) column |= (1 << 5);
if ((screenMem[6] >> activeColumn) & 0x01) column |= (1 << 6);
//column |= 0x02;
//column |= 0x80;
//column &= ~(1 << 7);
//column <<= 1;
// output all rows, switch leds on.
if ((column & 0x40) == 0x40) PORTA |= (1 << ROW_0);
if ((column & 0x20) == 0x20) PORTA |= (1 << ROW_1);
if ((column & 0x10) == 0x10) PORTA |= (1 << ROW_2);
if ((column & 0x08) == 0x08) PORTA |= (1 << ROW_3);
if ((column & 0x04) == 0x04) PORTA |= (1 << ROW_4);
if ((column & 0x02) == 0x02) PORTA |= (1 << ROW_5);
if ((column & 0x01) == 0x01) PORTA |= (1 << ROW_6);
switch (activeColumn) {
case 0:
PORTB &= ~(1 << COLUMN_0);
break;
case 1:
PORTB &= ~(1 << COLUMN_1);
break;
case 2:
PORTB &= ~(1 << COLUMN_2);
break;
case 3:
PORTB &= ~(1 << COLUMN_3);
break;
case 4:
PORTB &= ~(1 << COLUMN_4);
break;
}
}
bool e = true;
void Dotmatrix::showChar() {
// move screen one pixel to the left
for (uint8_t i = 0; i < 5; i++) {
screenMem[i] <<= 1;
}
if (charPointer == charLength) {
messagePointer++;
if (messagePointer == messageLength) {
messagePointer = 0;
messageDisplayed++;
}
activeChar = buffer[messagePointer] - CHAR_OFFSET;
charLength = pgm_read_byte(&font[activeChar * 4 + 3]);
charPointer = 0;
return;
}
uint8_t currentColumn = pgm_read_byte(&font[activeChar * 4 + charPointer++]);
for (uint8_t i = 0; i < 7; i++) {
if ((currentColumn & (1 << i)) == (1 << i)) {
screenMem[i+1] |= 1;
}
}
// move screen one pixel to the left
for (uint8_t i = 0; i < 7; i++) {
screenMem[i] <<= 1;
}
if (charPointer == charLength) {
messagePointer++;
if (messagePointer == messageLength) {
messagePointer = 0;
messageDisplayed++;
}
activeChar = buffer[messagePointer] - CHAR_OFFSET;
charLength = pgm_read_byte(&font[activeChar * 6 + 5]);
charPointer = 0;
return;
}
uint8_t currentColumn = pgm_read_byte(&font[activeChar * 6 + charPointer++]);
for (uint8_t i = 0; i < 7; i++) {
if ((currentColumn & (1 << i)) == (1 << i)) {
screenMem[i] |= 1;
}
}
//screenMem[7] = 1;
/*screenMem[0] = 3;
//screenMem[2] |= 1;
screenMem[3] = 1;
screenMem[4] = 1;
screenMem[5] = 0xff;
screenMem[6] = 1;
screenMem[7] = 1;
screenMem[1] = 1;*/
}
void Dotmatrix::schedule() {
switch (scheduleState) {
case STATE_INIT:
strcpy_P(buffer, (char*)pgm_read_word(&messages[mode]));
messageLength = strlen(buffer);
scheduleState = STATE_SHOW;
// after initialization we want to continue directly with the next stage, so no break here
case STATE_SHOW:
if (Time::millis() >= scheduleLast + TEXT_SCROLL_SPEED) {
showChar();
scheduleLast = Time::millis();
if (messageDisplayed < REPEAT_TEXT) {
messageDisplayed = 0;
//mode++;
if (mode > MAX_MESSAGES) mode = 0;
scheduleState = STATE_INIT;
clearScreen();
}
}
break;
}
switch (scheduleState) {
case STATE_INIT:
strcpy_P(buffer, (char*)pgm_read_word(&messages[mode]));
messageLength = strlen(buffer);
scheduleState = STATE_SHOW;
// after initialization we want to continue directly with the next stage, so no break here
case STATE_SHOW:
if (Time::millis() >= scheduleLast + TEXT_SCROLL_SPEED) {
showChar();
scheduleLast = Time::millis();
if (messageDisplayed < REPEAT_TEXT) {
messageDisplayed = 0;
//mode++;
if (mode > MAX_MESSAGES) mode = 0;
scheduleState = STATE_INIT;
clearScreen();
}
}
break;
}
}
void Dotmatrix::clearScreen() {
PORTA &= (1 << ROW_0) & ~(1 << ROW_1) & ~(1 << ROW_2) & ~(1 << ROW_3) & ~(1 << ROW_4) & ~(1 << ROW_5) & ~(1 << ROW_6);
PORTB |= (1 << COLUMN_0) | (1 << COLUMN_1) | (1 << COLUMN_2) | (1 << COLUMN_3) | (1 << COLUMN_4);
PORTA &= ~(1 << ROW_0) & ~(1 << ROW_1) & ~(1 << ROW_2) & ~(1 << ROW_3) & ~(1 << ROW_4) & ~(1 << ROW_5) & ~(1 << ROW_6);
PORTB |= (1 << COLUMN_0) | (1 << COLUMN_1) | (1 << COLUMN_2) | (1 << COLUMN_3) | (1 << COLUMN_4);
}
......@@ -44,33 +44,33 @@ class Dotmatrix {
public:
protected:
private:
static uint8_t screenMem[5]; // screen memory
static uint8_t activeColumn; // active row
static char buffer[60]; // stores the active message or sprite
static uint8_t messagePointer; // points to the active char in the message
static uint8_t messageDisplayed; // how often has the message been displayed?
static uint8_t activeChar; // stores the active char
static uint8_t messageLength; // stores the length of the active message
static uint8_t charPointer; // points to the active col in the char
static uint8_t charLength; // stores the length of the active char
static uint8_t mode;
static uint8_t scheduleState;
static uint32_t scheduleLast;
static uint8_t screenMem[7]; // screen memory
static uint8_t activeColumn; // active row
static char buffer[60]; // stores the active message or sprite
static uint8_t messagePointer; // points to the active char in the message
static uint8_t messageDisplayed; // how often has the message been displayed?
static uint8_t activeChar; // stores the active char
static uint8_t messageLength; // stores the length of the active message
static uint8_t charPointer; // points to the active col in the char
static uint8_t charLength; // stores the length of the active char
static uint8_t mode;
static uint8_t scheduleState;
static uint32_t scheduleLast;
//functions
public:
Dotmatrix();
~Dotmatrix();
static void init();
static void clearScreen();
static void displayActiveColumn();
static void showChar();
static void schedule();
Dotmatrix();
~Dotmatrix();
static void init();
static void clearScreen();
static void displayActiveColumn();
static void showChar();
static void schedule();
protected:
private:
Dotmatrix( const Dotmatrix &c );
Dotmatrix& operator=( const Dotmatrix &c );
Dotmatrix( const Dotmatrix &c );
Dotmatrix& operator=( const Dotmatrix &c );
}; //Dotmatrix
......
......@@ -16,71 +16,71 @@
#define CHAR_OFFSET 32
const uint8_t font[] PROGMEM = {
// 3 chars bitmap, 1 char length
0x00, 0x00, 0x00, 0x01 , // 0x20, 32, ' '
0x17, 0x00, 0x00, 0x01 , // 0x21, 33, !
0x03, 0x00, 0x03, 0x03 , // 0x22, 34, "
0x00, 0x00, 0x00, 0x03 , // 0x23, 35, #
0x00, 0x00, 0x00, 0x03 , // 0x24, 36, $
0x00, 0x00, 0x00, 0x03 , // 0x25, 37, %
0x00, 0x00, 0x00, 0x03 , // 0x26, 38, &
0x03, 0x00, 0x00, 0x01 , // 0x27, 39, '
0x0e, 0x11, 0x00, 0x02 , // 0x28, 40, (
0x11, 0x0e, 0x00, 0x02 , // 0x29, 41, )
0x00, 0x00, 0x00, 0x03 , // 0x2A, 42, *
0x08, 0x1c, 0x08, 0x03 , // 0x2B, 43, +
0x18, 0x00, 0x00, 0x01 , // 0x2C, 44, ,
0x04, 0x04, 0x00, 0x03 , // 0x2D, 45, -
0x10, 0x00, 0x00, 0x01 , // 0x2E, 46, .
0x18, 0x04, 0x03, 0x03 , // 0x2F, 47, /
0x1f, 0x11, 0x1f, 0x03 , // 0x30, 48, 0
0x01, 0x1f, 0x00, 0x02 , // 0x31, 49, 1
0x1d, 0x15, 0x17, 0x03 , // 0x32, 50, 2
0x15, 0x15, 0x0e, 0x03 , // 0x33, 51, 3
0x0f, 0x08, 0x1f, 0x03 , // 0x34, 52, 4
0x17, 0x15, 0x1d, 0x03 , // 0x35, 53, 5
0x1f, 0x12, 0x1e, 0x03 , // 0x36, 54, 6
0x11, 0x09, 0x07, 0x03 , // 0x37, 55, 7
0x1f, 0x15, 0x1f, 0x03 , // 0x38, 56, 8
0x0f, 0x09, 0x1f, 0x03 , // 0x39, 57, 9
0x0a, 0x00, 0x00, 0x01 , // 0x3A, 58, :
0x1a, 0x00, 0x00, 0x01 , // 0x3B, 59, ;
0x08, 0x14, 0x00, 0x02 , // 0x3C, 60, <
0x14, 0x14, 0x00, 0x02 , // 0x3D, 61, =
0x14, 0x08, 0x00, 0x02 , // 0x3E, 62, >
0x15, 0x05, 0x02, 0x03 , // 0x3F, 63, ?
0x0e, 0x17, 0x16, 0x03 , // 0x40, 64, @
0x1f, 0x09, 0x1f, 0x03 , // 0x41, 65, A
0x1f, 0x15, 0x0a, 0x03 , // 0x42, 66, B
0x0e, 0x11, 0x11, 0x03 , // 0x43, 67, C
0x1f, 0x11, 0x0e, 0x03 , // 0x44, 68, D
0x0e, 0x15, 0x15, 0x03 , // 0x45, 69, E
0x1e, 0x05, 0x05, 0x03 , // 0x46, 70, F
0x0e, 0x11, 0x1d, 0x03 , // 0x47, 71, G
0x1f, 0x04, 0x1f, 0x03 , // 0x48, 72, H
0x1f, 0x00, 0x00, 0x01 , // 0x49, 73, I
0x08, 0x10, 0x0f, 0x03 , // 0x4A, 74, J
0x1f, 0x04, 0x1b, 0x03 , // 0x4B, 75, K
0x0f, 0x10, 0x10, 0x03 , // 0x4C, 76, L
0x1f, 0x02, 0x1f, 0x03 , // 0x4D, 77, M
0x1f, 0x01, 0x1e, 0x03 , // 0x4E, 78, N
0x0e, 0x11, 0x0e, 0x03 , // 0x4F, 79, O
0x1f, 0x09, 0x06, 0x03 , // 0x50, 80, P
0x06, 0x19, 0x06, 0x03 , // 0x51, 81, Q
0x1f, 0x09, 0x16, 0x03 , // 0x52, 82, R
0x12, 0x15, 0x09, 0x03 , // 0x53, 83, S
0x01, 0x1f, 0x01, 0x03 , // 0x54, 84, T
0x0f, 0x10, 0x0f, 0x03 , // 0x55, 85, U
0x1f, 0x10, 0x0f, 0x03 , // 0x56, 86, V
0x1f, 0x08, 0x1f, 0x03 , // 0x57, 87, W
0x1b, 0x04, 0x1b, 0x03 , // 0x58, 88, X
0x03, 0x1c, 0x03, 0x03 , // 0x59, 89, Y
0x19, 0x15, 0x13, 0x03 , // 0x5A, 90, Z
0x1f, 0x11, 0x00, 0x02 , // 0x5B, 91, [
0x03, 0x04, 0x18, 0x03 , // 0x5C, 92,
0x11, 0x1f, 0x00, 0x02 , // 0x5D, 93, [
0x11, 0x1f, 0x00, 0x02 , // 0x5E, 94, ^
0x1f, 0x1f, 0x1f, 0x03 // 0x5F, 95, _, used as block, all on
// 3 chars bitmap, 1 char length
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x20, 32, ' '
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x21, 33, !
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x22, 34, "
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x23, 35, #
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x24, 36, $
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x25, 37, %
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x26, 38, &
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x27, 39, '
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x28, 40, (
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x29, 41, )
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x2A, 42, *
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x2B, 43, +
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x2C, 44, ,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x2D, 45, -
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x2E, 46, .
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x2F, 47, /
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x30, 48, 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x31, 49, 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x32, 50, 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x33, 51, 3
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x34, 52, 4
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x35, 53, 5
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x36, 54, 6
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x37, 55, 7
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x38, 56, 8
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x39, 57, 9
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x3A, 58, :
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x3B, 59, ;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x3C, 60, <
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x3D, 61, =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x3E, 62, >
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x3F, 63, ?
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x40, 64, @
0x7e, 0x09, 0x09, 0x09, 0x7e, 0x05 , // 0x41, 65, A
0x00, 0x00, 0x00, 0x00, 0x00, 0x05 , // 0x42, 66, B
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x43, 67, C
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x44, 68, D
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x45, 69, E
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x46, 70, F
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x47, 71, G
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x48, 72, H
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x49, 73, I
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x4A, 74, J
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x4B, 75, K
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x4C, 76, L
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x4D, 77, M
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x4E, 78, N
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x4F, 79, O
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x50, 80, P
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x51, 81, Q
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x52, 82, R
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x53, 83, S
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x54, 84, T
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x55, 85, U
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x56, 86, V
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x57, 87, W
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x58, 88, X
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x59, 89, Y
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x5A, 90, Z
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x5B, 91, [
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x5C, 92,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x5D, 93, [
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , // 0x5E, 94, ^
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // 0x5F, 95, _, used as block, all on
};
......
......@@ -15,7 +15,7 @@
#include <string.h>
// Change these values to adjust scroll speeds and animation iterations
#define TEXT_SCROLL_SPEED 500 // how fast to scroll the text
#define TEXT_SCROLL_SPEED 1500 // how fast to scroll the text
#define REPEAT_TEXT 5 // how often to repeat the text if in cycling mode
// How to add a new message:
......@@ -39,18 +39,18 @@ const char PROGMEM message_11[] = " HTTP://TINKERLOG.COM ";
#define MAX_MESSAGES 12
PGM_P const PROGMEM messages[] = {
message_00
,message_01
,message_02
,message_03
,message_04
,message_05
,message_06
,message_07
,message_08
,message_09
,message_10
,message_11
message_00
,message_01
,message_02
,message_03
,message_04
,message_05
,message_06
,message_07
,message_08
,message_09
,message_10
,message_11
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment