M:Robe 500: Start of proper remote support, touchscreen works without remote now.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20684 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Karl Kurbjun 2009-04-11 07:23:56 +00:00
parent 9f19f33c41
commit 5449b1ed1d
13 changed files with 387 additions and 17 deletions

View file

@ -89,13 +89,21 @@
#define HAVE_LCD_SLEEP
/* remote LCD */
//#define HAVE_REMOTE_LCD
#define HAVE_REMOTE_LCD
#define LCD_REMOTE_WIDTH 79
#define LCD_REMOTE_HEIGHT 16
#define LCD_REMOTE_HEIGHT 64
#define LCD_REMOTE_DEPTH 1
/* Remote display colours, for screenshots and sim (0xRRGGBB) */
#define LCD_REMOTE_DARKCOLOR 0x000000
#define LCD_REMOTE_BRIGHTCOLOR 0x5a915a
#define LCD_REMOTE_BL_DARKCOLOR 0x000000
#define LCD_REMOTE_BL_BRIGHTCOLOR 0x82b4fa
#define LCD_REMOTE_PIXELFORMAT VERTICAL_PACKING
#define CONFIG_REMOTE_KEYPAD MROBE_REMOTE
#define MIN_REMOTE_CONTRAST_SETTING 0
#define MAX_REMOTE_CONTRAST_SETTING 15
#define DEFAULT_REMOTE_CONTRAST_SETTING 7

View file

@ -114,6 +114,7 @@
#define H100_REMOTE 1
#define H300_REMOTE 2
#define X5_REMOTE 3
#define MROBE_REMOTE 4
/* CONFIG_BACKLIGHT_FADING */
/* No fading capabilities at all (yet) */

View file

@ -128,12 +128,6 @@ inline bool button_hold(void)
return false;
}
static void remote_heartbeat(void)
{
char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'};
uart1_puts(data, 5);
}
#define TOUCH_MARGIN 8
char r_buffer[5];
int r_button = BUTTON_NONE;
@ -142,13 +136,14 @@ int button_read_device(int *data)
int retval, calbuf;
static int oldbutton = BUTTON_NONE;
static long last_touch = 0;
r_button=BUTTON_NONE;
*data = 0;
if (touch_available)
{
short x,y;
static long last_touch = 0;
bool send_touch = false;
tsc2100_read_values(&x, &y, &last_z1, &last_z2);
if (TIME_BEFORE(last_touch + HZ/5, current_tick))
@ -175,7 +170,14 @@ int button_read_device(int *data)
last_touch = current_tick;
touch_available = false;
}
remote_heartbeat();
else
{
/* Touch hasn't happened in a while, clear the bits */
if(last_touch+3>current_tick)
{
oldbutton&=(0xFF);
}
}
if ((IO_GIO_BITSET0&0x01) == 0)
{

View file

@ -0,0 +1,287 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: $
*
* Copyright (C) 2009 Karl Kurbjun
*
* 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 "config.h"
#include "system.h"
#include "file.h"
#include "lcd-remote.h"
#include "adc.h"
#include "scroll_engine.h"
#include "uart-target.h"
static enum remote_control_states
{
REMOTE_CONTROL_IDLE,
REMOTE_CONTROL_NOP,
REMOTE_CONTROL_POWER,
REMOTE_CONTROL_MASK,
REMOTE_CONTROL_DRAW1,
REMOTE_CONTROL_DRAW_PAUSE1,
REMOTE_CONTROL_DRAW2,
REMOTE_CONTROL_DRAW_PAUSE2,
REMOTE_CONTROL_SLEEP
} remote_state_control = REMOTE_CONTROL_NOP;
bool remote_initialized=true;
unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING;
unsigned char remote_power=0x00;
/*** hardware configuration ***/
int lcd_remote_default_contrast(void)
{
return DEFAULT_REMOTE_CONTRAST_SETTING;
}
void lcd_remote_sleep(void)
{
remote_state_control=REMOTE_CONTROL_SLEEP;
}
void lcd_remote_powersave(bool on)
{
if(on)
{
remote_power|=0xC0;
remote_state_control=REMOTE_CONTROL_POWER;
}
else
{
remote_power&=~(0xC0);
remote_state_control=REMOTE_CONTROL_POWER;
}
}
void lcd_remote_set_contrast(int val)
{
remote_contrast=(char)val;
remote_state_control=REMOTE_CONTROL_POWER;
}
void lcd_remote_set_invert_display(bool yesno)
{
(void)yesno;
}
/* turn the display upside down (call lcd_remote_update() afterwards) */
void lcd_remote_set_flip(bool yesno)
{
(void)yesno;
}
bool remote_detect(void)
{
return true;
}
void lcd_remote_on(void)
{
remote_power|=0x80;
remote_state_control=REMOTE_CONTROL_POWER;
}
void lcd_remote_off(void)
{
remote_power&=~(0x80);
remote_state_control=REMOTE_CONTROL_POWER;
}
unsigned char lcd_remote_test[16]=
{0x80,0xFF,0x80,0x00,0xFF,0x89,0x89,0x00,0xC1,0x89,0x8F,0x80,0xFF,0x80,0,0};
/* Monitor remote hotswap */
static void remote_tick(void)
{
unsigned char i;
unsigned char remote_payload[10], remote_payload_size;
unsigned char remote_check_xor, remote_check_sum;
switch (remote_state_control)
{
case REMOTE_CONTROL_IDLE:
remote_payload_size=0;
remote_state_control=REMOTE_CONTROL_IDLE;
break;
case REMOTE_CONTROL_NOP:
remote_payload[0]=0x11;
remote_payload[1]=0x30;
remote_payload_size=2;
remote_state_control=REMOTE_CONTROL_NOP;
break;
case REMOTE_CONTROL_POWER:
remote_payload[0]=0x31;
remote_payload[1]=remote_power;
remote_payload[2]=remote_contrast;
remote_payload_size=3;
remote_state_control=REMOTE_CONTROL_NOP;
break;
case REMOTE_CONTROL_MASK:
remote_payload[0]=0x41;
remote_payload[1]=0x94;
remote_payload_size=2;
remote_state_control=REMOTE_CONTROL_NOP;
break;
case REMOTE_CONTROL_DRAW1:
remote_payload[0]=0x51;
remote_payload[1]=0x80;
remote_payload[2]=14;
remote_payload[3]=0;
remote_payload[4]=0;
remote_payload[5]=14;
remote_payload[6]=8;
remote_payload_size=7;
remote_state_control=REMOTE_CONTROL_DRAW_PAUSE1;
break;
case REMOTE_CONTROL_DRAW_PAUSE1:
remote_payload[0]=0x11;
remote_payload[1]=0x30;
remote_payload_size=2;
remote_state_control=REMOTE_CONTROL_DRAW2;
break;
case REMOTE_CONTROL_DRAW2:
remote_payload[0]=0x51;
remote_payload[1]=0x80;
remote_payload[2]=14;
remote_payload[3]=0;
remote_payload[4]=8;
remote_payload[5]=14;
remote_payload[6]=16;
remote_payload_size=7;
remote_state_control=REMOTE_CONTROL_DRAW_PAUSE2;
break;
case REMOTE_CONTROL_DRAW_PAUSE2:
remote_payload[0]=0x11;
remote_payload[1]=0x30;
remote_payload_size=2;
remote_state_control=REMOTE_CONTROL_NOP;
break;
case REMOTE_CONTROL_SLEEP:
remote_payload[0]=0x71;
remote_payload[1]=0x30;
remote_payload_size=2;
remote_state_control=REMOTE_CONTROL_IDLE;
break;
default:
remote_payload_size=0;
break;
}
if(remote_payload_size==0)
{
return;
}
remote_check_xor=remote_payload[0];
remote_check_sum=remote_payload[0];
for(i=1; i<remote_payload_size; i++)
{
remote_check_xor^=remote_payload[i];
remote_check_sum+=remote_payload[i];
}
if(remote_payload[0]==0x51)
{
unsigned char offset;
unsigned char x;
if(remote_payload[4]==8)
{
offset=79;
}
else
{
offset=0;
}
for (x = 0; x < 14; x++)
{
remote_check_xor^=lcd_remote_test[x];
remote_check_sum+=lcd_remote_test[x];
}
uart1_puts(remote_payload, remote_payload_size);
lcd_remote_test[14]=remote_check_xor;
lcd_remote_test[15]=remote_check_sum;
uart1_puts(lcd_remote_test, 16);
}
else
{
remote_payload[remote_payload_size]=remote_check_xor;
remote_payload[remote_payload_size+1]=remote_check_sum;
uart1_puts(remote_payload, remote_payload_size+2);
}
}
void lcd_remote_init_device(void)
{
lcd_remote_clear_display();
if (remote_detect())
lcd_remote_on();
/* put the remote control in the tick task */
tick_add_task(remote_tick);
}
/* Update the display.
This must be called after all other LCD functions that change the display. */
void lcd_remote_update(void)
{
if(remote_state_control!=REMOTE_CONTROL_DRAW1
&& remote_state_control!=REMOTE_CONTROL_DRAW_PAUSE1
&& remote_state_control!=REMOTE_CONTROL_DRAW2
&& remote_state_control!=REMOTE_CONTROL_DRAW_PAUSE2)
{
remote_state_control=REMOTE_CONTROL_DRAW1;
}
}
/* Update a fraction of the display. */
void lcd_remote_update_rect(int x, int y, int width, int height)
{
(void)x;
(void)y;
(void)width;
(void)height;
lcd_remote_update();
}
void _remote_backlight_on(void)
{
remote_power|=0x40;
remote_state_control=REMOTE_CONTROL_POWER;
}
void _remote_backlight_off(void)
{
remote_power&=~(0x40);
remote_state_control=REMOTE_CONTROL_POWER;
}

View file

@ -0,0 +1,45 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: $
*
* Copyright (C) 2009 by Karl Kurbjun
*
* 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.
*
****************************************************************************/
#ifndef LCD_REMOTE_TARGET_H
#define LCD_REMOTE_TARGET_H
#define REMOTE_INIT_LCD 1
#define REMOTE_DEINIT_LCD 2
void lcd_remote_powersave(bool on);
void lcd_remote_set_invert_display(bool yesno);
//void lcd_remote_set_flip(bool yesno);
bool remote_detect(void);
void lcd_remote_init_device(void);
void lcd_remote_on(void);
void lcd_remote_off(void);
void lcd_remote_update(void);
void lcd_remote_update_rect(int, int, int, int);
void _remote_backlight_on(void);
void _remote_backlight_off(void);
extern bool remote_initialized;
void lcd_remote_sleep(void);
#endif

View file

@ -72,6 +72,7 @@ void power_off(void)
{
/* turn off backlight and wait for 1 second */
_backlight_off();
lcd_remote_sleep();
lcd_sleep();
sleep(HZ);
/* Hard shutdown */

View file

@ -123,7 +123,7 @@ void UART1(void)
panicf("UART1 buffer overflow");
else
{
if(uart1_recieve_write==RECIEVE_RING_SIZE)
if(uart1_recieve_write>=RECIEVE_RING_SIZE)
uart1_recieve_write=0;
uart1_recieve_buffer_ring[uart1_recieve_write] = IO_UART1_DTRR & 0xff;