Rev 1199 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/****************************************************************************
* Copyright (C) 2011-2012 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
****************************************************************************/
#include "led_out.h"
#define ROWPORT PORTA
#define COLPORT PORTC
#define COLBASE (1 << PC2)
uint8_t col = 0;
uint8_t delay = 0;
uint8_t on = 0; // on-round or off-round
uint8_t animation[7];
volatile uint8_t animation_locked = 0;
#define TIMESON 7 // time slices to stay on
#define TIMESOFF 3 // time slices to stay off
void led_out_init() {
DDRA |= 0xFF; // Z0-Z7 output
DDRC |= ((1 << PC2) | (1 << PC3) | (1 << PC4) | (1 << PC5) | (1 << PC6) | (1 << PC7)); // S0-S5 output
}
void inline led_timer_callback() {
if (!animation_locked) {
// the Epilepsy was not build for powering the LEDs constantly, so we force a dim
delay--;
// only after
if (!delay) {
if (on) {
// time is up, go dark
ROWPORT = 0;
COLPORT &= ~(COLBASE << col);
// controll next col in next round
col = (col + 1) % 6;
delay = TIMESOFF;
} else {
COLPORT |= (COLBASE << col);
// hardware EPI10AQ41 has the rows reversed
// to convert old animations use
// http://www.mylifesucks.de/tools/epireverse/
#if HWVERSION == EPI10AQ41
uint8_t reverse = 0;
for (uint8_t mask = 128; mask; mask >>= 1) {
reverse >>= 1;
if (animation[col] & mask) {
reverse |= 128;
}
}
ROWPORT = reverse;
#else
ROWPORT = animation[col];
#endif
delay = TIMESON;
}
on = !on;
}
}
}