display_loop.c, uart_commands.c: more reliable "prev" command

This commit is contained in:
Christian Kroll 2014-08-27 05:08:39 +02:00
parent b9471a6637
commit 09ce8f22b3
2 changed files with 18 additions and 5 deletions

View File

@ -1,5 +1,6 @@
#include <setjmp.h>
#include <stdbool.h>
#include <stdio.h>
#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;
}
}
}
}
}

View File

@ -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);
#ifdef JOYSTICK_SUPPORT
}
#endif
}