/*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id: $ * * Copyright (C) 2002 Mats Lidell * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ****************************************************************************/ #include "config.h" #include #include #include "lcd.h" #include "menu.h" #include "button.h" #include "mpeg.h" #include "settings.h" void entertext(char* prompt, char* str, int size) { static char character = 'A'; char buf[11]; int pos = 0; int lastpos = -1; bool done = false; str[0] = '\0'; while (!done) { if (pos != lastpos) { lcd_clear_display(); lcd_stop_scroll(); lcd_puts_scroll(0, 1, str); lastpos = pos; } if (size < pos) lcd_puts(0,0, "At EOS"); else { snprintf(buf, sizeof(buf), "%s: %c", prompt, character); // snprintf(buf, sizeof(buf), "%c - %d", character, (int)character); lcd_puts(0,0,buf); } lcd_update(); switch( button_get(true) ) { #ifdef HAVE_RECORDER_KEYPAD case BUTTON_UP: #else case BUTTON_RIGHT: #endif ++character; break; #ifdef HAVE_RECORDER_KEYPAD case BUTTON_DOWN: #else case BUTTON_LEFT: #endif --character; break; case BUTTON_PLAY: if (pos <= size) { /* Accept the character */ str[pos] = character; str[pos+1] = '\0'; ++pos; } break; #ifdef HAVE_RECORDER_KEYPAD case BUTTON_LEFT: #else case BUTTON_STOP: #endif /* Delete one character */ --pos; if (pos < 0) pos = 0; str[pos] = '\0'; break; #ifdef HAVE_RECORDER_KEYPAD case BUTTON_OFF: #else case BUTTON_ON: case BUTTON_MENU: #endif /* Accept string */ done = true; break; } } lcd_stop_scroll(); } #define SIZE 31 void test_entertext(void) { char str[SIZE+1]; entertext("Prompt", str, sizeof(str)); }