Permalink
Browse files

merge

  • Loading branch information...
sebseb7
sebseb7 committed Oct 31, 2011
2 parents f5077f8 + 29bc1e7 commit 7848a00fb7a2e760974d0946e1d07d9072104821
View
@@ -33,7 +33,7 @@ OPT = s
##########################################################################################################
# List C source files here. (C dependencies are automatically generated.)
-SRC = main.c libs/font.c apps/cccdd.c apps/plasma_seb.c apps/helix.c apps/random.c apps/scroll.c apps/ball.c apps/snake.c apps/strobe.c apps/click.c
+SRC = main.c libs/font.c apps/cccdd.c apps/battery.c apps/scroll2.c apps/plasma_seb.c apps/helix.c apps/random.c apps/scroll.c apps/ball.c apps/snake.c apps/strobe.c apps/replicate.c
#SRC = main.c libs/font.c apps/cccdd.c
##########################################################################################################
View
@@ -1,6 +1,41 @@
#include <main.h>
-
-static const uint8_t logo[] = {
+#include "binary.h"
+
+#define b00000 0
+#define b00001 1
+#define b00010 2
+#define b00011 3
+#define b00100 4
+#define b00101 5
+#define b00110 6
+#define b00111 7
+#define b01000 8
+#define b01001 9
+#define b01010 10
+#define b01011 11
+#define b01100 12
+#define b01101 13
+#define b01110 14
+#define b01111 15
+#define b10000 16
+#define b10001 17
+#define b10010 18
+#define b10011 19
+#define b10100 20
+#define b10101 21
+#define b10110 22
+#define b10111 23
+#define b11000 24
+#define b11001 25
+#define b11010 26
+#define b11011 27
+#define b11100 28
+#define b11101 29
+#define b11110 30
+#define b11111 31
+
+
+static uint8_t logo[] = {
0b00000,
0b00000,
0b00000,
@@ -43,7 +78,7 @@ static const uint8_t logo[] = {
0b00000,
0b00000,
0b00000,
- 0b00000,
+ 0b00000
};
View
@@ -7,7 +7,7 @@
#define MIN(a,b) ((a) > (b) ? (b) : (a))
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(*array))
-#define PENALTY -1
+#define PENALTY -4
static void init(void) ATTRIBUTES;
static uint8_t tick(void);
@@ -24,7 +24,7 @@ static uint8_t end = 0;
static uint8_t state = 0;
void init(void) {
- registerApp(tick, key, 22);
+ registerApp(tick, key, 42);
}
uint8_t tick() {
@@ -59,13 +59,13 @@ uint8_t tick() {
void key(key_type key, event_type event) {
if(event == DOWN && end == 0) {
if(key == KEY_A) {
- right_bar = MAX(right_bar + (flash_light > 0 ? 1 : PENALTY), 0);
+ right_bar = MAX(right_bar + (flash_light > 0 ? 4 : PENALTY), 0);
if (right_bar >= LED_HEIGHT * 7) winner = 1;
} else {
- left_bar = MAX(left_bar + (flash_light > 0 ? 1 : PENALTY), 0);
+ left_bar = MAX(left_bar + (flash_light > 0 ? 4 : PENALTY), 0);
if (left_bar >= LED_HEIGHT * 7) winner = 2;
}
- if(winner > 0) end = 10;
+ if(winner > 0) end = 20;
}
}
View
@@ -32,18 +32,20 @@ static uint8_t tick() {
for(y = 0; y < LED_HEIGHT; y++) {
for(x = 0; x < LED_WIDTH; x++) {
- uint16_t c = 5*sini(x*2+sini(a)) + 8*cosi(y*3+a+120) + 3*sini(b/2);
- uint16_t d = 2*sini(x*2-b) + 3*cosi(y*3-cosi(a)) + 3*sini(a/4)+ c;
+// uint16_t c = 5*sini(x*2+sini(a)) + 8*cosi(y*3+a+120) + 3*sini(b/2);
+ //uint16_t d = 2*sini(x*2-b);// + 3*cosi(y*3-cosi(a));// + 3*sini(a/4);//+ c;
+ uint16_t d = 2*cosi(x*4-cosi(a/2))+ 3*cosi(y*3-cosi(a));// + 3*sini(a/4);//+ c;
- uint8_t col = (((cosi(d>>4)>>5))+(d>>6))&15;
+// uint8_t col = (((cosi(d>>4)>>5))+(d>>6))&15;
+ uint8_t col = ((d>>5))&15;
if(col > 7) col = 15 - col;
setLedXY(x, y, col);
}
}
_a--;
- b = cosi(a);
+ b = a;
return 0;
}
View
@@ -0,0 +1,79 @@
+#include <main.h>
+#include <stdlib.h>
+
+#define CHAIN_LENGTH 128
+
+typedef enum { INIT, SHOW, LISTEN, QUIT } State;
+
+static State state = INIT;
+static uint8_t chain[CHAIN_LENGTH];
+static uint8_t length = 3;
+static uint8_t level = 0;
+static uint8_t step = 0;
+static uint8_t sub_step = 0;
+
+static uint8_t tick() {
+
+ if(state == INIT) {
+ uint8_t i;
+ for(i = 0; i < length; i++) chain[i] = rand() & 1;
+
+ state = SHOW;
+ }
+
+ if(state == SHOW) {
+ ++sub_step;
+ if(sub_step < 10) {
+
+ uint8_t side = chain[step];
+ uint8_t color = sub_step < 8 ? 8 - sub_step : 0;
+
+ uint8_t x, y;
+ for(x = 0; x < LED_WIDTH; x++) {
+ uint8_t c = (x >= LED_WIDTH / 2) ^ side;
+ for(y = 0; y < LED_HEIGHT; y++)
+ {
+ setLedXY(x, y, c ? color : 0);
+ }
+ }
+ }
+ else {
+ sub_step = 0;
+ ++step;
+ if(step == length) {
+ step = 0;
+ state = LISTEN;
+ }
+ }
+
+ }
+
+ return state == QUIT;
+}
+
+static void key(key_type key, event_type event) {
+ if(state != LISTEN || event != DOWN)
+ return;
+
+ if(key == chain[step]) {
+ ++step;
+ if(step == length) {
+ chain[step] = rand() & 1;
+ step = 0;
+ ++length;
+ ++level;
+ state = SHOW;
+ }
+ }
+ else {
+ // TODO: print level before exiting
+ state = QUIT;
+ }
+}
+
+static void init(void) ATTRIBUTES;
+void init(void) {
+ registerApp(tick, key, 7);
+}
+
+
View
@@ -11,12 +11,14 @@ void init_scroll(void) ATTRIBUTES;
#ifdef __AVR__
-char text[] PROGMEM =" CLOUDY MIT AUSSICHT AUF DATENSPUREN ";
+char text[] PROGMEM =" LEONA ";
+//char text[] PROGMEM =" CLOUDY MIT AUSSICHT AUF DATENSPUREN ";
#else
char text[] =" CLOUDY MIT AUSSICHT AUF DATENSPUREN ";
#endif
-const uint8_t text_len = 37;
+const uint8_t text_len = 7;
+//const uint8_t text_len = 37;
uint16_t pos = 0;
View
@@ -11,9 +11,9 @@ void init_scroll2(void) ATTRIBUTES;
#ifdef __AVR__
-char text2[] PROGMEM =" <<</>> Pentalight ";
+char text2[] PROGMEM =" Pentalight ";
#else
-char text2[] =" <<</>> Pentalight ";
+char text2[] =" Pentalight ";
#endif
const uint8_t text_len2 = 19;
View
@@ -51,7 +51,7 @@ static void new_apple(void) {
}
void init_snake(void) {
- registerApp(tick_snake, key_snake, 17);
+ registerApp(tick_snake, key_snake, 32);
}
uint8_t tick_snake() {
@@ -131,7 +131,7 @@ uint8_t tick_snake() {
// paint start of tail
const int8_t last = CYCLE(pointer - 2, ARRAY_SIZE(buffer));
- setLedXY(buffer[last], buffer[last+1], 3);
+ setLedXY(buffer[last], buffer[last+1], 5);
// clear tail
View
@@ -61,6 +61,7 @@
*/
#define EXIT_WDT_TIME WDTO_250MS
+void __vector_default(void) { ; }
/*
* define the following if the bootloader should not output
@@ -87,9 +88,8 @@
#include <avr/wdt.h>
#include <avr/boot.h>
#include <avr/pgmspace.h>
-#include <avr/eeprom.h>
-#include <avr/interrupt.h>
-#include <util/delay.h>
+//#include <avr/interrupt.h>
+//#include <util/delay.h>
#include "chipdef.h"
@@ -156,20 +156,6 @@ static inline uint16_t writeFlashPage(uint16_t waddr, pagebuf_t size)
return baddr>>1;
}
-static inline uint16_t writeEEpromPage(uint16_t address, pagebuf_t size)
-{
- uint8_t *tmp = gBuffer;
-
- do {
- eeprom_write_byte( (uint8_t*)address, *tmp++ );
- address++; // Select next byte
- size--; // Decreas number of bytes to write
- } while (size); // Loop until all bytes written
-
- // eeprom_busy_wait();
-
- return address;
-}
static inline uint16_t readFlashPage(uint16_t waddr, pagebuf_t size)
{
@@ -206,16 +192,6 @@ static inline uint16_t readFlashPage(uint16_t waddr, pagebuf_t size)
return baddr>>1;
}
-static inline uint16_t readEEpromPage(uint16_t address, pagebuf_t size)
-{
- do {
- sendchar( eeprom_read_byte( (uint8_t*)address ) );
- address++;
- size--; // Decrease number of bytes to read
- } while (size); // Repeat until block has been read
-
- return address;
-}
static void send_boot(void)
@@ -234,41 +210,14 @@ static void (*jump_to_app)(void) = 0x0000;
int main(void)
{
-#ifdef WDT_OFF_SPECIAL
-#warning "using target specific watchdog_off"
bootloader_wdt_off();
-#else
- cli();
- wdt_reset();
- wdt_disable();
-#endif
uint16_t address = 0;
uint8_t device = 0, val;
BLDDR &= ~(1<<BLPNUM); // set as Input
BLPORT |= (1<<BLPNUM); // Enable pullup
- //enable LED channels as output
- PORTB |= (1<<PORTB0)|(1<<PORTB6);
- PORTC |= (1<<PORTC3);
-
- DDRB |= (1<<PORTB0)|(1<<PORTB6);
- DDRC |= (1<<PORTC3);
-
-
- PORTC &= ~(1<<PORTC3);
-
- _delay_ms(500);
-
-/* // Set baud rate
- UART_BAUD_HIGH = (UART_CALC_BAUDRATE(BAUDRATE)>>8) & 0xFF;
- UART_BAUD_LOW = (UART_CALC_BAUDRATE(BAUDRATE) & 0xFF);
-
-#ifdef UART_DOUBLESPEED
- UART_STATUS = ( 1<<UART_DOUBLE );
-#endif
-*/
UART_STATUS = ( 1<<UART_DOUBLE );
UART_BAUD_HIGH = 0;
@@ -277,19 +226,10 @@ int main(void)
UART_CTRL = UART_CTRL_DATA;
UART_CTRL2 = UART_CTRL2_DATA;
- if ((BLPIN & (1<<BLPNUM)) && (GPIOR2 == 0) ) {
-
+ if (BLPIN & (1<<BLPNUM)) {
// jump to main app if pin is not grounded and GPIOR2 is zero
- BLPORT &= ~(1<<BLPNUM); // set to default
- PORTB &= ~(1<<PORTB0);
jump_to_app(); // Jump to application sector
}
- PORTB &= ~(1<<PORTB6);
-
- if(GPIOR2 != 0)
- {
- GPIOR2=0;
- }
for(;;) {
@@ -321,8 +261,6 @@ int main(void)
if (device == DEVTYPE) {
if (val == 'F') {
address = writeFlashPage(address, size);
- } else if (val == 'E') {
- address = writeEEpromPage(address, size);
}
sendchar('\r');
} else {
@@ -338,8 +276,6 @@ int main(void)
if (val == 'F') {
address = readFlashPage(address, size);
- } else if (val == 'E') {
- address = readEEpromPage(address, size);
}
// Chip erase
Oops, something went wrong.

0 comments on commit 7848a00

Please sign in to comment.