From 9a8ed6ba35959f049ec85d8be6ec498fdbb67bb6 Mon Sep 17 00:00:00 2001 From: Lorenzo Miori Date: Mon, 16 Sep 2013 00:02:28 +0200 Subject: Simulator for Samsung YP-R0 Enable simulator for the target ypr0 to be built and used. Change-Id: I1b080f07ab90f5c4856881d08ad70e1053bbb0c0 Reviewed-on: http://gerrit.rockbox.org/618 Reviewed-by: Frank Gevaerts --- firmware/SOURCES | 4 +- firmware/export/config/samsungypr0.h | 21 +++++--- firmware/target/hosted/sdl/sim-ui-defines.h | 7 +++ tools/configure | 8 +++ uisimulator/bitmaps/UI-samsungypr0.bmp | Bin 0 -> 526456 bytes uisimulator/buttonmap/SOURCES | 2 + uisimulator/buttonmap/samsung-ypr0.c | 81 ++++++++++++++++++++++++++++ 7 files changed, 114 insertions(+), 9 deletions(-) create mode 100644 uisimulator/bitmaps/UI-samsungypr0.bmp create mode 100644 uisimulator/buttonmap/samsung-ypr0.c diff --git a/firmware/SOURCES b/firmware/SOURCES index 86bf746df9..884e1102e2 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -14,7 +14,7 @@ powermgmt.c target/hosted/cpuinfo-linux.c #endif -#ifndef SAMSUNG_YPR0 /* uses as3514 rtc */ +#if !defined(SAMSUNG_YPR0) || defined(SIMULATOR) /* uses as3514 rtc */ target/hosted/rtc.c #endif @@ -74,7 +74,7 @@ target/hosted/sdl/app/button-application.c #endif #endif -#ifdef SAMSUNG_YPR0 +#if defined(SAMSUNG_YPR0) && !defined(SIMULATOR) drivers/adc-as3514.c drivers/lcd-memframe.c #if (CONFIG_RTC == RTC_AS3514) diff --git a/firmware/export/config/samsungypr0.h b/firmware/export/config/samsungypr0.h index 970879772f..c1266f4732 100644 --- a/firmware/export/config/samsungypr0.h +++ b/firmware/export/config/samsungypr0.h @@ -5,16 +5,15 @@ /* We don't run on hardware directly */ /* YP-R0 need it too of course */ +#ifndef SIMULATOR #define CONFIG_PLATFORM (PLATFORM_HOSTED) +#endif /* For Rolo and boot loader */ #define MODEL_NUMBER 100 #define MODEL_NAME "Samsung YP-R0" -/*TODO: implement USB data transfer management -> see safe mode script and think a way to implemtent it in the code */ -#define USB_NONE - /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP @@ -90,6 +89,12 @@ #define CONFIG_KEYPAD SAMSUNG_YPR0_PAD #define BUTTON_DRIVER_CLOSE +/** Non-simulator section **/ +#ifndef SIMULATOR + +/*TODO: implement USB data transfer management -> see safe mode script and think a way to implemtent it in the code */ +#define USB_NONE + /* The YPR0 has a as3534 codec */ #define HAVE_AS3514 #define HAVE_AS3543 @@ -109,6 +114,12 @@ /* We have a GPIO pin that detects this */ #define HAVE_HEADPHONE_DETECTION +/* Define current usage levels. */ +#define CURRENT_NORMAL 24 /* ~25h, on 600mAh that's about 24mA */ +#define CURRENT_BACKLIGHT 62 /* ~6,5h -> 92mA. Minus 24mA normal that gives us 68mA */ + +#endif /* SIMULATOR */ + /* FIXME * Lot of people reports bad battery life and funny charging times. * Check what's going on... @@ -120,10 +131,6 @@ #define BATTERY_CAPACITY_INC 0 /* capacity increment */ #define BATTERY_TYPES_COUNT 1 /* only one type */ -/* Define current usage levels. */ -#define CURRENT_NORMAL 24 /* ~25h, on 600mAh that's about 24mA */ -#define CURRENT_BACKLIGHT 62 /* ~6,5h -> 92mA. Minus 24mA normal that gives us 68mA */ - #define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE /* Linux controlls charging, we can monitor */ diff --git a/firmware/target/hosted/sdl/sim-ui-defines.h b/firmware/target/hosted/sdl/sim-ui-defines.h index de250735e2..b238520aac 100644 --- a/firmware/target/hosted/sdl/sim-ui-defines.h +++ b/firmware/target/hosted/sdl/sim-ui-defines.h @@ -473,6 +473,13 @@ #define UI_WIDTH LCD_WIDTH #define UI_HEIGHT LCD_HEIGHT +#elif defined(SAMSUNG_YPR0) +#define UI_TITLE "Samsung YP-R0" +#define UI_WIDTH 313 /* width of GUI window */ +#define UI_HEIGHT 560 /* height of GUI window */ +#define UI_LCD_POSX 36 +#define UI_LCD_POSY 37 + #elif defined(SIMULATOR) #error no UI defines #endif diff --git a/tools/configure b/tools/configure index 4e548eea91..8491ffdb35 100755 --- a/tools/configure +++ b/tools/configure @@ -3701,6 +3701,14 @@ if [ -z "$debug" ]; then GCCOPTS="$GCCOPTS $GCCOPTIMIZE" fi +# if building a simulator for an hosted port, APPLICATION +# define clashes with SIMULATOR define + +if [ "yes" = "$simulator" ]; then + echo Unsetting APPLICATION define for SIMULATOR build + unset application +fi + if [ "yes" = "$application" ]; then echo Building Rockbox as an Application extradefines="$extradefines -DAPPLICATION" diff --git a/uisimulator/bitmaps/UI-samsungypr0.bmp b/uisimulator/bitmaps/UI-samsungypr0.bmp new file mode 100644 index 0000000000..ad82b41a11 Binary files /dev/null and b/uisimulator/bitmaps/UI-samsungypr0.bmp differ diff --git a/uisimulator/buttonmap/SOURCES b/uisimulator/buttonmap/SOURCES index de9cf51467..bc6e62bcd6 100644 --- a/uisimulator/buttonmap/SOURCES +++ b/uisimulator/buttonmap/SOURCES @@ -75,5 +75,7 @@ creative-zenxfi2.c sansa-connect.c #elif CONFIG_KEYPAD == SONY_NWZ_PAD sony-nwz.c +#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD +samsung-ypr0.c #endif #endif /* SIMULATOR */ diff --git a/uisimulator/buttonmap/samsung-ypr0.c b/uisimulator/buttonmap/samsung-ypr0.c new file mode 100644 index 0000000000..8936c98296 --- /dev/null +++ b/uisimulator/buttonmap/samsung-ypr0.c @@ -0,0 +1,81 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2013 by Lorenzo Miori + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + + +#include +#include "button.h" +#include "buttonmap.h" + +int key_to_button(int keyboard_button) +{ + int new_btn = BUTTON_NONE; + switch (keyboard_button) + { + case SDLK_KP4: + case SDLK_LEFT: + new_btn = BUTTON_LEFT; + break; + case SDLK_KP6: + case SDLK_RIGHT: + new_btn = BUTTON_RIGHT; + break; + case SDLK_KP8: + case SDLK_UP: + new_btn = BUTTON_UP; + break; + case SDLK_KP2: + case SDLK_DOWN: + new_btn = BUTTON_DOWN; + break; + case SDLK_PAGEUP: + case SDLK_KP9: + new_btn = BUTTON_MENU; + break; + case SDLK_KP7: + new_btn = BUTTON_BACK; + break; + case SDLK_KP5: + case SDLK_SPACE: + case SDLK_KP_ENTER: + case SDLK_RETURN: + new_btn = BUTTON_SELECT; + break; + case SDLK_KP3: + new_btn = BUTTON_POWER; + break; + case SDLK_KP1: + new_btn = BUTTON_USER; + break; + } + return new_btn; +} + +struct button_map bm[] = { + { SDLK_KP7, 66, 423, 25, "Back" }, + { SDLK_KP8, 152, 406, 25, "Up" }, + { SDLK_KP9, 249, 429, 25, "Menu" }, + { SDLK_KP4, 105, 451, 25, "Left" }, + { SDLK_KP5, 155, 450, 25, "Select" }, + { SDLK_KP6, 208, 449, 25, "Right" }, + { SDLK_KP1, 65, 484, 25, "User" }, + { SDLK_KP2, 154, 501, 25, "Down" }, + { SDLK_KP3, 248, 484, 25, "Power" }, + { 0, 0, 0, 0, "None" } +}; -- cgit v1.2.3