diff --git a/devel/lib/lcd.h b/devel/lib/lcd.h index 8c45f85..b1a98d9 100644 --- a/devel/lib/lcd.h +++ b/devel/lib/lcd.h @@ -289,7 +289,9 @@ void _lcd_write_byte(uint8_t bb) /** Wait until the device is ready */ void _lcd_wait_bf() { - while(lcd_read_bf_addr() & _BV(7)); + uint8_t d = 0; + while(d++ < 120 && lcd_read_bf_addr() & _BV(7)) + _delay_us(1); } diff --git a/devel/moo/Makefile b/devel/rgbs/Makefile similarity index 100% rename from devel/moo/Makefile rename to devel/rgbs/Makefile diff --git a/devel/moo/lib b/devel/rgbs/lib similarity index 100% rename from devel/moo/lib rename to devel/rgbs/lib diff --git a/devel/moo/main.c b/devel/rgbs/main.c similarity index 100% rename from devel/moo/main.c rename to devel/rgbs/main.c diff --git a/devel/moo2/Makefile b/devel/snake/Makefile similarity index 100% rename from devel/moo2/Makefile rename to devel/snake/Makefile diff --git a/devel/moo2/lcd_default.asm b/devel/snake/lcd_default.asm similarity index 100% rename from devel/moo2/lcd_default.asm rename to devel/snake/lcd_default.asm diff --git a/devel/moo2/lib b/devel/snake/lib similarity index 100% rename from devel/moo2/lib rename to devel/snake/lib diff --git a/devel/moo2/main.c b/devel/snake/main.c similarity index 100% rename from devel/moo2/main.c rename to devel/snake/main.c diff --git a/projects/lcdsnake/lib/lcd.h b/projects/lcdsnake/lib/lcd.h index 8c45f85..b1a98d9 100644 --- a/projects/lcdsnake/lib/lcd.h +++ b/projects/lcdsnake/lib/lcd.h @@ -289,7 +289,9 @@ void _lcd_write_byte(uint8_t bb) /** Wait until the device is ready */ void _lcd_wait_bf() { - while(lcd_read_bf_addr() & _BV(7)); + uint8_t d = 0; + while(d++ < 120 && lcd_read_bf_addr() & _BV(7)) + _delay_us(1); } diff --git a/projects/lcdsnake/main.c b/projects/lcdsnake/main.c index 4b5c438..e776f78 100644 --- a/projects/lcdsnake/main.c +++ b/projects/lcdsnake/main.c @@ -28,7 +28,7 @@ #define BTN_RIGHT D3 #define BTN_UP D4 #define BTN_DOWN D5 -#define BTN_SELECT D6 +#define BTN_PAUSE D6 #define BTN_RESTART D7 // Debouncer channels for buttons @@ -37,7 +37,7 @@ #define D_RIGHT 1 #define D_UP 2 #define D_DOWN 3 -#define D_SELECT 4 +#define D_PAUSE 4 #define D_RESTART 5 #define DEBO_CHANNELS 6 @@ -75,7 +75,7 @@ void SECTION(".init8") init() as_input_pu(BTN_RIGHT); as_input_pu(BTN_UP); as_input_pu(BTN_DOWN); - as_input_pu(BTN_SELECT); + as_input_pu(BTN_PAUSE); as_input_pu(BTN_RESTART); // add buttons to debouncer @@ -83,7 +83,7 @@ void SECTION(".init8") init() debo_add_rev(BTN_RIGHT); debo_add_rev(BTN_UP); debo_add_rev(BTN_DOWN); - debo_add_rev(BTN_SELECT); + debo_add_rev(BTN_PAUSE); debo_add_rev(BTN_RESTART); // setup timer @@ -256,6 +256,8 @@ void init_gameboard() uint8_t presc = 0; bool restart_held; +bool pause_held; +bool paused; void update() { if (debo_get_pin(D_RESTART)) { @@ -271,7 +273,18 @@ void update() restart_held = false; } - if(!crashed) { + if (debo_get_pin(D_PAUSE)) { + + if (!pause_held) { + paused ^= true; + pause_held = true; + } + + } else { + pause_held = false; + } + + if(!crashed && !paused) { // resolve movement direction if (debo_get_pin(D_LEFT))