From c78b30dac867d956a48df96ac4eb73e2372f0fbc Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 12 Dec 2003 13:31:16 +0000 Subject: New Neo-specific code from the Open Neo project. Unfortunately, the sources don't say who've written this stuff so I can give credit to any specific person (yet). The sources have been modified by me to conform to Rockbox standards. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4135 a1c6a512-1295-4272-9138-f99709370657 --- apps/neo/icons.h | 33 ++++++ apps/neo/keyboard.c | 299 +++++++++++++++++++++++++++++++++++++++++++++++++ apps/neo/lcd-charset.h | 46 ++++++++ 3 files changed, 378 insertions(+) create mode 100644 apps/neo/icons.h create mode 100644 apps/neo/keyboard.c create mode 100644 apps/neo/lcd-charset.h (limited to 'apps') diff --git a/apps/neo/icons.h b/apps/neo/icons.h new file mode 100644 index 0000000000..c96f821cfa --- /dev/null +++ b/apps/neo/icons.h @@ -0,0 +1,33 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 Justin Heiner + * + * 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 + +/* + * Icons of size 5x7 pixels for the Player LCD + */ + +#ifdef HAVE_LCD_CHARCELLS + +enum { + Unknown=0x90, + Plugin = 0x17, + Folder, Mod_Ajz, Language, File, Wps, Playlist, Text, Config, +}; + +#endif diff --git a/apps/neo/keyboard.c b/apps/neo/keyboard.c new file mode 100644 index 0000000000..9f02f2a9c8 --- /dev/null +++ b/apps/neo/keyboard.c @@ -0,0 +1,299 @@ + +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2003 by an Open Neo author (FILL IN) + * + * 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 + +#include "lcd.h" +#include "button.h" +#include "kernel.h" +#include "version.h" +#include "sprintf.h" +#include "lcd-charset.h" +#include "lang.h" +#include "debug.h" + +#define KEYBOARD_MAX_LENGTH 255 + +static unsigned char* kbd_screens[3] = { + "ABCDEFGHIJKLMNOPQRSTUVWXYZ", + "abcdefghijklmnopqrstuvwxyz", + " !\"#$%&'()*+,-./0123456789;<=>?@[]^_`{|}" +}; + +static unsigned char* kbd_screens_names[3] = { + "Capitals", + "Small", + "Others" +}; + +static void kbd_show_legend( int nb ) +{ + char buf[24]; + snprintf(buf, sizeof(buf), "[%s]", kbd_screens_names[nb] ); + lcd_puts( 0, 1, buf ); + lcd_puts( 0, 2, kbd_screens[nb] ); + lcd_puts( 0, 3, &kbd_screens[nb][20] ); +} + +/* returns text len + Max = KEYBOARD_MAX_LENGTH characters +*/ +int kbd_input( char* text, int buflen ) +{ + char* pstart; + char* pcursor; + char* pold; + int bufferlen; + char cursorpos = 0; + int ret = 0; + char buffer[KEYBOARD_MAX_LENGTH+1]; + bool done = false; + int key; + int screen = 0; + int screenidx = -1; + unsigned char * pcurscreen = kbd_screens[0]; + bool ctl; + + bufferlen = strlen(text); + + if( bufferlen > KEYBOARD_MAX_LENGTH ) + bufferlen = KEYBOARD_MAX_LENGTH; + + strncpy( buffer, text, bufferlen ); + buffer[bufferlen] = 0; + + lcd_clear_display(); + + /* Initial setup */ + lcd_puts( 0, 0, buffer ); + kbd_show_legend( screen ); + lcd_cursor( cursorpos, 0 ); + lcd_write(true,LCD_BLINKCUR); + + pstart = pcursor = buffer; + + while(!done) { + /* We want all the keys except the releases and the repeats */ + key = button_get(true); + + if( key & BUTTON_IR) + ctl = key & (NEO_IR_BUTTON_PLAY|NEO_IR_BUTTON_STOP|NEO_IR_BUTTON_BROWSE); + else + ctl = key & (BUTTON_PLAY|BUTTON_STOP|BUTTON_MENU); + + if( ctl ) { + /* These key do not change the first line */ + switch( key ) { + case BUTTON_MENU: + case BUTTON_IR|NEO_IR_BUTTON_BROWSE: + + /* Toggle legend screen */ + screen++; + if( screen == 3 ) + screen = 0; + + pcurscreen = kbd_screens[screen]; + + screenidx = -1; + kbd_show_legend( screen ); + + /* Restore cursor */ + lcd_cursor( cursorpos, 0 ); + break; + + case BUTTON_PLAY: + case BUTTON_IR|NEO_IR_BUTTON_PLAY: + + if( bufferlen ) { + strncpy(text, buffer, bufferlen); + text[bufferlen] = 0; + ret = bufferlen; + } + /* fallthrough */ + + case BUTTON_STOP: + case BUTTON_IR|NEO_IR_BUTTON_STOP: + + /* Remove blinking cursor */ + lcd_write(true,LCD_OFFCUR); + done = true; + } + } + else { + + switch( key ) { + + case BUTTON_PROGRAM: + case BUTTON_PROGRAM|BUTTON_REPEAT: + case BUTTON_IR|NEO_IR_BUTTON_PROGRAM: + + /* Delete char at pcursor */ + /* Check if we are at the last char */ + + if( *(pcursor+1) != 0 ) { + /* move rest of the string to the left in buffer */ + pold = pcursor; + while( *pcursor ){ + *pcursor = *(pcursor+1); + pcursor++; + } + + /* Restore position */ + pcursor = pold; + } + else { + *pcursor = 0; + pcursor--; + cursorpos--; + } + + bufferlen--; + break; + + case BUTTON_IR|NEO_IR_BUTTON_EQ: + case BUTTON_SELECT|BUTTON_LEFT: + + /* Insert left */ + + if(bufferlen >= KEYBOARD_MAX_LENGTH ) + break; + + pold = pcursor; + + /* Goto end */ + while( *pcursor ) + pcursor++; + + /* Move string content to the right */ + while( pcursor >= pold ){ + *(pcursor+1) = *pcursor; + pcursor--; + } + + pcursor = pold; + *pcursor = ' '; + + bufferlen++; + break; + + case BUTTON_IR|NEO_IR_BUTTON_MUTE: + case BUTTON_SELECT|BUTTON_RIGHT: + + /* Insert Right */ + + if(bufferlen >= KEYBOARD_MAX_LENGTH ) + break; + + pold = pcursor; + + /* Goto end */ + while( *pcursor ) + pcursor++; + + /* Move string content to the right */ + while( pcursor > pold ){ + *(pcursor+1) = *pcursor; + pcursor--; + } + + pcursor = pold; + *(pcursor+1) = ' '; + + bufferlen++; + + button_add( BUTTON_RIGHT ); + break; + + case BUTTON_LEFT: + case BUTTON_REPEAT|BUTTON_LEFT: + case BUTTON_IR|NEO_IR_BUTTON_REWIND: + case BUTTON_IR|NEO_IR_BUTTON_REWIND|BUTTON_REPEAT: + + /* Move cursor left. Shift text right if all the way to the + left */ + + /* Check for start of string */ + if( pcursor > buffer ) { + + screenidx = -1; + cursorpos--; + pcursor--; + + /* Check if were going off the screen */ + if( cursorpos == -1 ) { + cursorpos = 0; + + /* Shift text right if we are */ + pstart--; + } + } + break; + + case BUTTON_RIGHT: + case BUTTON_REPEAT|BUTTON_RIGHT: + case BUTTON_IR|NEO_IR_BUTTON_FFORWARD: + case BUTTON_IR|NEO_IR_BUTTON_FFORWARD|BUTTON_REPEAT: + + /* Move cursor right. Shift text left if all the way to + the right */ + + /* Check for end of string */ + if( *(pcursor+1) != 0 ) { + screenidx = -1; + cursorpos++; + pcursor++; + + /* Check if were going of the screen */ + if( cursorpos == 20 ) { + cursorpos = 19; + + /* Shift text left if we are */ + pstart++; + } + } + break; + + case BUTTON_UP: + case BUTTON_UP|BUTTON_REPEAT: + case BUTTON_IR|NEO_IR_BUTTON_VOLUP: + case BUTTON_IR|NEO_IR_BUTTON_VOLUP|BUTTON_REPEAT: + screenidx += 2; + /* fallthrough */ + case BUTTON_DOWN: + case BUTTON_DOWN|BUTTON_REPEAT: + case BUTTON_IR|NEO_IR_BUTTON_VOLDN: + case BUTTON_IR|NEO_IR_BUTTON_VOLDN|BUTTON_REPEAT: + screenidx--; + + if( screenidx < 0 ) + screenidx = strlen(pcurscreen)-1; + + if( pcurscreen[screenidx] == 0 ) + screenidx = 0; + + /* Changes the character over the cursor */ + *pcursor = pcurscreen[screenidx]; + } + + lcd_puts( 0, 0, pstart); + lcd_cursor( cursorpos, 0 ); + } + } + return ret; +} diff --git a/apps/neo/lcd-charset.h b/apps/neo/lcd-charset.h new file mode 100644 index 0000000000..24e3b223c2 --- /dev/null +++ b/apps/neo/lcd-charset.h @@ -0,0 +1,46 @@ +#define CGRAM0 0x00 +#define CGRAM1 0x01 +#define CGRAM2 0x02 +#define CGRAM3 0x03 +#define CGRAM4 0x04 +#define CGRAM5 0x05 +#define CGRAM6 0x06 +#define CGRAM7 0x07 + +#define CGRAM0_CHAR 0x10 +#define CGRAM1_CHAR 0x11 +#define CGRAM2_CHAR 0x12 +#define CGRAM3_CHAR 0x13 +#define CGRAM4_CHAR 0x14 +#define CGRAM5_CHAR 0x15 +#define CGRAM6_CHAR 0x16 +#define CGRAM7_CHAR 0x17 + +#define RESERVED_CHAR 0xff +#define NOCHAR_OLD 0x24 +#define UNKNOWN_CHAR 0x3f + +#define LARROW_CHAR 0x1e +#define RARROW_CHAR 0x1f +#define FULLGRID_CHAR 0x7f + +#define BACKSLASH_LCD CGRAM0 +#define RARROW_LCD 0x7e +#define LARROW_LCD 0x7f +#define FULLGRID_LCD 0xff + +#define PROGRESS1_LCD CGRAM1 +#define PROGRESS2_LCD CGRAM2 +#define PROGRESS3_LCD CGRAM3 +#define PROGRESS4_LCD CGRAM4 +#define PROGRESS5_LCD FULLGRID_LCD + +#define PROGRESS1_CHAR CGRAM1_CHAR +#define PROGRESS2_CHAR CGRAM2_CHAR +#define PROGRESS3_CHAR CGRAM3_CHAR +#define PROGRESS4_CHAR CGRAM4_CHAR +#define PROGRESS5_CHAR FULLGRID_CHAR + + +extern unsigned char latin1_to_lcd[256]; + -- cgit v1.2.3