Add ledmatrix support

This commit is contained in:
Thammi 2013-09-07 12:08:57 +02:00
parent a27dd51912
commit ec9e6d9506
2 changed files with 22 additions and 7 deletions

View File

@ -3,14 +3,29 @@
#include <pentabug/app.h>
#include <pentabug/hal.h>
#ifdef MATRIX
uint8_t inv = 0;
#endif
static void init(void) {
led_on(RIGHT);
matrix_start();
}
static void blinker(void) {
led_inv(RIGHT);
led_inv(LEFT);
#ifdef MATRIX
for(uint8_t x = 0; x < 3; ++x) {
for(uint8_t y = 0; y < 3; ++y) {
matrix_set(x, y, ((x + y) & 1) ^ inv);
}
}
inv = !inv;
#endif
wait_ms(500);
if(button_clicked(RIGHT)) {

View File

@ -13,24 +13,24 @@ void matrix_init(void) {
}
static void move_line(uint8_t line) {
PORTD &= ~0xe0;
PORTD |= 1 << (line + 5);
PORTD |= 0xe0;
PORTD &= ~(1 << (line + 5));
}
static void write_line(uint8_t data[]) {
PORTC |= (1 << 5) | (1 << 4);
PORTB |= 1 << 2;
PORTC &= ~((1 << 5) | (1 << 4));
PORTB &= ~(1 << 2);
if(data[0]) {
PORTC &= ~(1 << 5);
PORTC |= 1 << 5;
}
if(data[1]) {
PORTC &= ~(1 << 4);
PORTC |= 1 << 4;
}
if(data[2]) {
PORTB &= ~(1 << 2);
PORTB |= 1 << 2;
}
}