Removed lcd_roll() and lcd_remote_roll() functions. These functions were not really portable. Removed the only plugin that used lcd_roll(): Oscillograph. Oscilloscope offers everything that oscillograph did and more, in a portable way. * Bumped & sorted plugin API.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8995 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2006-03-11 09:28:49 +00:00
parent 37f529cc3c
commit 06bc627c99
10 changed files with 21 additions and 441 deletions

View file

@ -104,9 +104,6 @@ static const struct plugin_api rockbox_api = {
PREFIX(lcd_icon),
lcd_double_height,
#else
#ifndef SIMULATOR
lcd_roll,
#endif
lcd_set_drawmode,
lcd_get_drawmode,
lcd_setfont,
@ -155,9 +152,6 @@ static const struct plugin_api rockbox_api = {
lcd_remote_puts,
lcd_remote_puts_scroll,
lcd_remote_stop_scroll,
#ifndef SIMULATOR
lcd_remote_roll,
#endif
lcd_remote_set_drawmode,
lcd_remote_get_drawmode,
lcd_remote_setfont,
@ -245,6 +239,14 @@ static const struct plugin_api rockbox_api = {
profile_func_exit,
#endif
#ifdef SIMULATOR
/* special simulator hooks */
#if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
sim_lcd_ex_init,
sim_lcd_ex_update_rect,
#endif
#endif
/* strings and memory */
snprintf,
strcpy,
@ -290,6 +292,7 @@ static const struct plugin_api rockbox_api = {
pcm_set_frequency,
pcm_is_playing,
pcm_play_pause,
pcm_calculate_peaks,
#endif
#endif
@ -401,18 +404,10 @@ static const struct plugin_api rockbox_api = {
screen_dump_set_hook,
#endif
show_logo,
tree_get_context,
/* new stuff at the end, sort into place next time
the API gets incompatible */
tree_get_context,
#if defined(SIMULATOR) && defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
sim_lcd_ex_init,
sim_lcd_ex_update_rect,
#endif
#if (CONFIG_CODEC == SWCODEC)
pcm_calculate_peaks,
#endif
};
int plugin_load(const char* plugin, void* parameter)

View file

@ -99,12 +99,12 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 10
#define PLUGIN_API_VERSION 11
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 10
#define PLUGIN_MIN_API_VERSION 11
/* plugin return codes */
enum plugin_status {
@ -137,9 +137,6 @@ struct plugin_api {
void (*PREFIX(lcd_icon))(int icon, bool enable);
void (*lcd_double_height)(bool on);
#else
#ifndef SIMULATOR
void (*lcd_roll)(int pixels);
#endif
void (*lcd_set_drawmode)(int mode);
int (*lcd_get_drawmode)(void);
void (*lcd_setfont)(int font);
@ -200,9 +197,6 @@ struct plugin_api {
void (*lcd_remote_puts)(int x, int y, const unsigned char *string);
void (*lcd_remote_lcd_puts_scroll)(int x, int y, const unsigned char* string);
void (*lcd_remote_lcd_stop_scroll)(void);
#ifndef SIMULATOR
void (*lcd_remote_roll)(int pixels);
#endif
void (*lcd_remote_set_drawmode)(int mode);
int (*lcd_remote_get_drawmode)(void);
void (*lcd_remote_setfont)(int font);
@ -298,6 +292,14 @@ struct plugin_api {
void (*profile_func_exit)(void *this_fn, void *call_site);
#endif
#ifdef SIMULATOR
/* special simulator hooks */
#if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
void (*sim_lcd_ex_init)(int shades, unsigned long (*getpixel)(int, int));
void (*sim_lcd_ex_update_rect)(int x, int y, int width, int height);
#endif
#endif
/* strings and memory */
int (*snprintf)(char *buf, size_t size, const char *fmt, ...);
char* (*strcpy)(char *dst, const char *src);
@ -344,6 +346,7 @@ struct plugin_api {
void (*pcm_set_frequency)(unsigned int frequency);
bool (*pcm_is_playing)(void);
void (*pcm_play_pause)(bool play);
void (*pcm_calculate_peaks)(int *left, int *right);
#endif
#endif /* !SIMULATOR */
@ -466,16 +469,7 @@ struct plugin_api {
void (*screen_dump_set_hook)(void (*hook)(int fh));
#endif
int (*show_logo)(void);
struct tree_context* (*tree_get_context)(void);
#if defined(SIMULATOR) && defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
void (*sim_lcd_ex_init)(int shades, unsigned long (*getpixel)(int, int));
void (*sim_lcd_ex_update_rect)(int x, int y, int width, int height);
#endif
#if (CONFIG_CODEC == SWCODEC)
void (*pcm_calculate_peaks)(int *left, int *right);
#endif
/* new stuff at the end, sort into place next time
the API gets incompatible */

View file

@ -44,7 +44,6 @@ chip8.c
demystify.c
flipit.c
minesweeper.c
oscillograph.c
oscilloscope.c
pong.c
rockblox.c

View file

@ -1,300 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 Philipp Pertermann
*
* 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 "plugin.h"
#ifdef HAVE_LCD_BITMAP
PLUGIN_HEADER
/* The different drawing modes */
#define DRAW_MODE_FILLED 0
#define DRAW_MODE_OUTLINE 1
#define DRAW_MODE_PIXEL 2
#define DRAW_MODE_COUNT 3
#define MAX_PEAK 0x8000
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define OSCILLOGRAPH_QUIT BUTTON_OFF
#define OSCILLOGRAPH_SPEED_UP BUTTON_UP
#define OSCILLOGRAPH_SPEED_DOWN BUTTON_DOWN
#define OSCILLOGRAPH_ROLL BUTTON_F1
#define OSCILLOGRAPH_MODE BUTTON_F2
#define OSCILLOGRAPH_SPEED_RESET BUTTON_F3
#define OSCILLOGRAPH_PAUSE BUTTON_PLAY
#elif CONFIG_KEYPAD == ONDIO_PAD
#define OSCILLOGRAPH_QUIT BUTTON_OFF
#define OSCILLOGRAPH_SPEED_UP BUTTON_UP
#define OSCILLOGRAPH_SPEED_DOWN BUTTON_DOWN
#define OSCILLOGRAPH_ROLL BUTTON_RIGHT
#define OSCILLOGRAPH_MODE BUTTON_MENU
#define OSCILLOGRAPH_SPEED_RESET BUTTON_LEFT
#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
(CONFIG_KEYPAD == IRIVER_H300_PAD)
#define OSCILLOGRAPH_QUIT BUTTON_OFF
#define OSCILLOGRAPH_SPEED_UP BUTTON_UP
#define OSCILLOGRAPH_SPEED_DOWN BUTTON_DOWN
#define OSCILLOGRAPH_ROLL BUTTON_RIGHT
#define OSCILLOGRAPH_MODE BUTTON_SELECT
#define OSCILLOGRAPH_SPEED_RESET BUTTON_LEFT
#elif (CONFIG_KEYPAD == IPOD_3G_PAD) || \
(CONFIG_KEYPAD == IPOD_4G_PAD)
#define OSCILLOGRAPH_QUIT BUTTON_MENU
#define OSCILLOGRAPH_SPEED_UP BUTTON_SCROLL_FWD
#define OSCILLOGRAPH_SPEED_DOWN BUTTON_SCROLL_BACK
#define OSCILLOGRAPH_ROLL BUTTON_RIGHT
#define OSCILLOGRAPH_MODE BUTTON_SELECT
#define OSCILLOGRAPH_SPEED_RESET BUTTON_LEFT
#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
#define OSCILLOGRAPH_QUIT BUTTON_POWER
#define OSCILLOGRAPH_SPEED_UP BUTTON_UP
#define OSCILLOGRAPH_SPEED_DOWN BUTTON_DOWN
#define OSCILLOGRAPH_ROLL BUTTON_RIGHT
#define OSCILLOGRAPH_MODE BUTTON_SELECT
#define OSCILLOGRAPH_SPEED_RESET BUTTON_LEFT
#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
#define OSCILLOGRAPH_QUIT BUTTON_POWER
#define OSCILLOGRAPH_SPEED_UP BUTTON_UP
#define OSCILLOGRAPH_SPEED_DOWN BUTTON_DOWN
#define OSCILLOGRAPH_ROLL BUTTON_RIGHT
#define OSCILLOGRAPH_MODE BUTTON_SELECT
#define OSCILLOGRAPH_SPEED_RESET BUTTON_LEFT
#endif
#if SIMULATOR && (CONFIG_CODEC != SWCODEC)
#define mas_codec_readreg(x) rand()%MAX_PEAK
#endif
/* global api struct pointer */
static struct plugin_api* rb;
/* number of ticks between two volume samples */
static int speed = 1;
#ifndef SIMULATOR
/* roll == true -> lcd rolls */
static bool roll = true;
#endif
/* see DRAW_MODE_XXX constants for valid values */
static int drawMode = DRAW_MODE_FILLED;
/**
* cleanup on return / usb
*/
void cleanup(void *parameter)
{
(void)parameter;
#ifndef SIMULATOR
/* restore to default roll position.
Looks funny if you forget to do this... */
rb->lcd_roll(0);
#endif
rb->lcd_update();
}
/**
* Displays a vertically scrolling oscillosgraph using
* hardware scrolling of the display. The user can change
* speed
*/
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int button;
/* stores current volume value left */
int left;
/* stores current volume value right */
int right;
/* specifies the current position on the lcd */
int y = LCD_WIDTH - 1;
/* only needed when drawing lines */
int lastLeft = 0;
int lastRight = 0;
int lasty = 0;
bool exit = false;
(void)parameter;
rb = api;
/* the main loop */
while (!exit) {
/* read the volume info */
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
left = rb->mas_codec_readreg(0xC);
right = rb->mas_codec_readreg(0xD);
#elif (CONFIG_CODEC == SWCODEC)
rb->pcm_calculate_peaks(&left, &right);
#endif
left = left / (MAX_PEAK / (LCD_WIDTH / 2 - 2));
right = right / (MAX_PEAK / (LCD_WIDTH / 2 - 2));
/* delete current line */
rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
rb->lcd_drawline(0, y, LCD_WIDTH-1, y);
rb->lcd_set_drawmode(DRMODE_SOLID);
switch (drawMode) {
case DRAW_MODE_FILLED:
rb->lcd_drawline(LCD_WIDTH / 2 + 1 , y,
LCD_WIDTH / 2 + 1 + right, y);
rb->lcd_drawline(LCD_WIDTH / 2 - 1 , y,
LCD_WIDTH / 2 - 1 -left , y);
break;
case DRAW_MODE_OUTLINE:
/* last position needed for lines */
lasty = MAX(y-1, 0);
/* Here real lines were neccessary because
anything else was ugly. */
rb->lcd_drawline(LCD_WIDTH / 2 + right , y,
LCD_WIDTH / 2 + lastRight , lasty);
rb->lcd_drawline(LCD_WIDTH / 2 - left , y,
LCD_WIDTH / 2 - lastLeft, lasty);
/* have to store the old values for drawing lines
the next time */
lastRight = right;
lastLeft = left;
break;
case DRAW_MODE_PIXEL:
/* straight and simple */
rb->lcd_drawpixel(LCD_WIDTH / 2 + right, y);
rb->lcd_drawpixel(LCD_WIDTH / 2 - left, y);
break;
}
/* increment and adjust the drawing position */
y++;
if (y >= LCD_HEIGHT)
y = 0;
#ifndef SIMULATOR
/* I roll before update because otherwise the new
line would appear at the wrong end of the display */
if (roll)
rb->lcd_roll(y);
#endif
/* now finally make the new sample visible */
rb->lcd_update_rect(0, MAX(y-1, 0), LCD_WIDTH, 2);
/* There are two mechanisms to alter speed:
1.) slowing down is achieved by increasing
the time waiting for user input. This
mechanism uses positive values.
2.) speeding up is achieved by leaving out
the user input check for (-speed) volume
samples. For this mechanism negative values
are used.
*/
if (speed >= 0 || ((speed < 0) && (y % (-speed) == 0))) {
bool draw = false;
/* speed values > 0 slow the oszi down. By user input
speed might become < 1. If a value < 1 was
passed user input would be disabled. Thus
it must be ensured that at least 1 is passed. */
/* react to user input */
button = rb->button_get_w_tmo(MAX(speed, 1));
switch (button) {
case OSCILLOGRAPH_SPEED_UP:
speed++;
draw = true;
break;
case OSCILLOGRAPH_SPEED_DOWN:
speed--;
draw = true;
break;
#ifdef OSCILLOGRAPH_PAUSE
case OSCILLOGRAPH_PAUSE:
/* pause the demo */
rb->button_get(true);
break;
#endif
#ifndef SIMULATOR
case OSCILLOGRAPH_ROLL:
/* toggle rolling */
roll = !roll;
break;
#endif
case OSCILLOGRAPH_MODE:
/* step through the display modes */
drawMode ++;
drawMode = drawMode % DRAW_MODE_COUNT;
#ifndef SIMULATOR
/* lcd buffer might be rolled so that
the transition from LCD_HEIGHT to 0
takes place in the middle of the screen.
That produces ugly results in DRAW_MODE_OUTLINE
mode. If rolling is enabled this change will
be reverted before the next update anyway.*/
rb->lcd_roll(0);
#endif
break;
case OSCILLOGRAPH_SPEED_RESET:
speed = 1;
draw = true;
break;
case OSCILLOGRAPH_QUIT:
exit = true;
break;
default:
if (rb->default_event_handler_ex(button, cleanup, NULL)
== SYS_USB_CONNECTED)
return PLUGIN_USB_CONNECTED;
break;
}
if (draw) {
char buf[16];
rb->snprintf(buf, sizeof buf, "Speed: %d", -speed);
rb->lcd_putsxy(0, (y + LCD_HEIGHT - 8) % LCD_HEIGHT, buf);
rb->lcd_update_rect(0, (y + LCD_HEIGHT - 8) % LCD_HEIGHT,
LCD_WIDTH, 8);
}
}
}
cleanup(NULL);
/* standard return */
return PLUGIN_OK;
}
#endif

View file

@ -100,7 +100,6 @@ static bool remote_initialized = false;
static bool cached_invert = false;
static bool cached_flip = false;
static int cached_contrast = 32;
static int cached_roll = 0;
#endif
/* scrolling */
@ -393,30 +392,6 @@ void lcd_remote_set_flip(bool yesno)
}
}
/* Rolls up the lcd display by the specified amount of lines.
* Lines that are rolled out over the top of the screen are
* rolled in from the bottom again. This is a hardware
* remapping only and all operations on the lcd are affected.
* ->
* @param int lines - The number of lines that are rolled.
* The value must be 0 <= pixels < LCD_REMOTE_HEIGHT. */
void lcd_remote_roll(int lines)
{
char data[2];
cached_roll = lines;
if (remote_initialized)
{
lines &= LCD_REMOTE_HEIGHT-1;
data[0] = lines & 0xff;
data[1] = lines >> 8;
lcd_remote_write_command(LCD_REMOTE_CNTL_INIT_LINE | 0x0); // init line
lcd_remote_write_data(data, 2);
}
}
/* The actual LCD init */
static void remote_lcd_init(void)
{
@ -443,7 +418,6 @@ static void remote_lcd_init(void)
lcd_remote_set_flip(cached_flip);
lcd_remote_set_contrast(cached_contrast);
lcd_remote_set_invert_display(cached_invert);
lcd_remote_roll(cached_roll);
}
static int _remote_type = 0;

View file

@ -136,19 +136,6 @@ void lcd_set_flip(bool yesno)
}
}
/* Rolls up the lcd display by the specified amount of lines.
* Lines that are rolled out over the top of the screen are
* rolled in from the bottom again. This is a hardware
* remapping only and all operations on the lcd are affected.
* ->
* @param int lines - The number of lines that are rolled.
* The value must be 0 <= pixels < LCD_HEIGHT. */
void lcd_roll(int lines)
{
lines &= LCD_HEIGHT-1;
lcd_write_command_ex(LCD_CNTL_DISPLAY_START_LINE, lines, -1);
}
#endif /* !SIMULATOR */
/* LCD init */
@ -163,8 +150,6 @@ void lcd_init(void)
void lcd_init(void)
{
static unsigned char area_data[4] = { 0x01, 0x00, 0x7f, 0x80 };
/* GPO35 is the LCD A0 pin
GPO46 is LCD RESET */
or_l(0x00004008, &GPIO1_OUT);
@ -198,9 +183,6 @@ void lcd_init(void)
sleep(HZ/10); /* 100 ms pause */
lcd_write_command_ex(LCD_CNTL_POWER_CONTROL, 0x17, -1);
lcd_write_command(LCD_CNTL_AREA_SCROLL);
lcd_write_data(area_data, sizeof(area_data));
lcd_write_command_ex(LCD_CNTL_DISPLAY_START_LINE, 0, -1);
lcd_write_command_ex(LCD_CNTL_GRAY_SCALE_PATTERN, 0x42, -1);
lcd_write_command_ex(LCD_CNTL_DISPLAY_MODE, 0, -1); /* Greyscale mode */

View file

@ -107,19 +107,6 @@ void lcd_set_flip(bool yesno)
(void)yesno;
}
/* Rolls up the lcd display by the specified amount of lines.
* Lines that are rolled out over the top of the screen are
* rolled in from the bottom again. This is a hardware
* remapping only and all operations on the lcd are affected.
* ->
* @param int lines - The number of lines that are rolled.
* The value must be 0 <= pixels < LCD_HEIGHT. */
void lcd_roll(int lines)
{
(void)lines;
}
/* LCD init */
void lcd_init_device(void)
{

View file

@ -141,19 +141,6 @@ void lcd_blit(const unsigned char* data, int x, int by, int width,
(void)stride;
}
/* Rolls up the lcd display by the specified amount of lines.
* Lines that are rolled out over the top of the screen are
* rolled in from the bottom again. This is a hardware
* remapping only and all operations on the lcd are affected.
* ->
* @param int lines - The number of lines that are rolled.
* The value must be 0 <= pixels < LCD_HEIGHT. */
void lcd_roll(int lines)
{
/* TODO Implement lcd_roll() */
lines &= LCD_HEIGHT-1;
}
/*** hardware configuration ***/
/* Update the display.
@ -314,19 +301,6 @@ void lcd_set_flip(bool yesno)
(void)yesno;
}
/* Rolls up the lcd display by the specified amount of lines.
* Lines that are rolled out over the top of the screen are
* rolled in from the bottom again. This is a hardware
* remapping only and all operations on the lcd are affected.
* ->
* @param int lines - The number of lines that are rolled.
* The value must be 0 <= pixels < LCD_HEIGHT. */
void lcd_roll(int lines)
{
/* TODO: Implement lcd_roll() */
lines &= LCD_HEIGHT-1;
}
/* LCD init */
void lcd_init_device(void)
{

View file

@ -50,19 +50,6 @@ void lcd_set_flip(bool yesno)
(void)yesno;
}
/* Rolls up the lcd display by the specified amount of lines.
* Lines that are rolled out over the top of the screen are
* rolled in from the bottom again. This is a hardware
* remapping only and all operations on the lcd are affected.
* ->
* @param int lines - The number of lines that are rolled.
* The value must be 0 <= pixels < LCD_HEIGHT. */
void lcd_roll(int lines)
{
/* TODO: Implement lcd_roll() */
lines &= LCD_HEIGHT-1;
}
/* LCD init */
void lcd_init_device(void)
{

View file

@ -226,18 +226,6 @@ void lcd_set_flip(bool yesno)
#endif
}
/* Rolls up the lcd display by the specified amount of lines.
* Lines that are rolled out over the top of the screen are
* rolled in from the bottom again. This is a hardware
* remapping only and all operations on the lcd are affected.
* ->
* @param int lines - The number of lines that are rolled.
* The value must be 0 <= pixels < LCD_HEIGHT. */
void lcd_roll(int lines)
{
lcd_write_command(LCD_SET_DISPLAY_START_LINE | (lines & (LCD_HEIGHT-1)));
}
#endif /* !SIMULATOR */
/* LCD init */