From 09ce8f22b360591da836b03167765e1050b45161 Mon Sep 17 00:00:00 2001 From: Christian Kroll Date: Wed, 27 Aug 2014 05:08:39 +0200 Subject: [PATCH] display_loop.c, uart_commands.c: more reliable "prev" command --- src/display_loop.c | 12 +++++++++++- src/uart/uart_commands.c | 11 +++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/display_loop.c b/src/display_loop.c index 8cbbf75..2f14bd4 100644 --- a/src/display_loop.c +++ b/src/display_loop.c @@ -1,5 +1,6 @@ #include +#include #include #include "config.h" @@ -49,7 +50,7 @@ # include "joystick/joystick.h" #endif -volatile unsigned char oldMode, oldOldmode, mode; +volatile unsigned char oldMode, oldOldmode, reverseMode, mode; jmp_buf newmode_jmpbuf; @@ -77,6 +78,7 @@ void display_loop(){ clear_screen(0); #endif oldMode = mode; + switch(mode++) { #ifdef ANIMATION_SCROLLTEXT @@ -365,6 +367,14 @@ void display_loop(){ off(); break; #endif + default: + if (reverseMode) { + if (reverseMode-- == (mode - 1)) { + mode -= 2; + } else { + reverseMode = 0; + } + } } } } diff --git a/src/uart/uart_commands.c b/src/uart/uart_commands.c index 7a0d4f2..a8e76a6 100644 --- a/src/uart/uart_commands.c +++ b/src/uart/uart_commands.c @@ -22,7 +22,8 @@ char g_rx_buffer[UART_BUFFER_SIZE]; uint8_t g_rx_index; extern jmp_buf newmode_jmpbuf; -volatile unsigned char mode; +extern volatile unsigned char mode; +extern volatile unsigned char reverseMode; #if !(defined(eeprom_update_block) && \ ((E2PAGESIZE == 2) || (E2PAGESIZE == 4) || (E2PAGESIZE == 8))) @@ -138,12 +139,14 @@ static void uartcmd_next_anim(void) { static void uartcmd_prev_anim(void) { uart_puts_p(UART_STR_PROMPT); uartcmd_clear_buffer(); - if (mode > 1) { #ifdef JOYSTICK_SUPPORT - if (waitForFire) + if (waitForFire) { + reverseMode = mode - 2; #endif - longjmp(newmode_jmpbuf, mode - 2); + longjmp(newmode_jmpbuf, mode - 2); +#ifdef JOYSTICK_SUPPORT } +#endif }