Rewrote the clock plugin in a cleaner and more modular way so that it can scale on remote screens. Use left-right keys to change the type of clock displayed (analogic, digital, binary) and up/downto change the look of the clock

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14174 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Kevin Ferrare 2007-08-04 03:01:46 +00:00
parent ffbbc60f38
commit 93b2f9fd44
56 changed files with 1969 additions and 1746 deletions

View file

@ -112,12 +112,12 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 68
#define PLUGIN_API_VERSION 69
/* 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 68
#define PLUGIN_MIN_API_VERSION 69
/* plugin return codes */
enum plugin_status {

View file

@ -82,7 +82,6 @@ vu_meter.c
wormlet.c
#if CONFIG_RTC
clock.c
#if CONFIG_KEYPAD == RECORDER_PAD /* Recorder models only for now */
calendar.c
#endif

View file

@ -3,6 +3,11 @@
/* For all targets */
/* For various targets... */
#if CONFIG_RTC
clock
#endif
#if (CONFIG_KEYPAD == RECORDER_PAD) || defined(HAVE_LCD_COLOR) \
|| defined(IRIVER_H100_SERIES) || defined(IAUDIO_M5)
rockboy

View file

@ -112,6 +112,7 @@ chessbox_pieces.64x64x1.bmp
/* Clock */
#if (LCD_WIDTH >= 320) && (LCD_HEIGHT >= 240) && (LCD_DEPTH >= 16)
clock_binary.320x240x16.bmp
clock_digits.320x240x16.bmp
clock_smalldigits.320x240x16.bmp
clock_segments.320x240x16.bmp
@ -119,6 +120,7 @@ clock_smallsegments.320x240x16.bmp
clock_logo.320x240x16.bmp
clock_messages.320x240x16.bmp
#elif (LCD_WIDTH >= 220) && (LCD_HEIGHT >= 176) && (LCD_DEPTH >= 16)
clock_binary.220x176x16.bmp
clock_digits.220x176x16.bmp
clock_smalldigits.220x176x16.bmp
clock_segments.220x176x16.bmp
@ -126,6 +128,7 @@ clock_smallsegments.220x176x16.bmp
clock_logo.220x176x16.bmp
clock_messages.220x176x16.bmp
#elif (LCD_WIDTH >= 176) && (LCD_HEIGHT >= 132) && (LCD_DEPTH >= 16)
clock_binary.160x128x16.bmp
clock_digits.160x128x16.bmp
clock_smalldigits.160x128x16.bmp
clock_segments.160x128x16.bmp
@ -133,6 +136,7 @@ clock_smallsegments.160x128x16.bmp
clock_logo.176x132x16.bmp
clock_messages.176x132x16.bmp
#elif (LCD_WIDTH >= 160) && (LCD_HEIGHT >= 128) && (LCD_DEPTH >= 16)
clock_binary.160x128x16.bmp
clock_digits.160x128x16.bmp
clock_smalldigits.160x128x16.bmp
clock_segments.160x128x16.bmp
@ -140,6 +144,7 @@ clock_smallsegments.160x128x16.bmp
clock_logo.160x128x16.bmp
clock_messages.160x128x16.bmp
#elif (LCD_WIDTH >= 128) && (LCD_HEIGHT >= 128) && (LCD_DEPTH >= 16)
clock_binary.128x128x16.bmp
clock_digits.128x128x16.bmp
clock_smalldigits.128x128x16.bmp
clock_segments.128x128x16.bmp
@ -147,6 +152,7 @@ clock_smallsegments.128x128x16.bmp
clock_logo.128x128x16.bmp
clock_messages.128x128x16.bmp
#elif (LCD_WIDTH >= 160) && (LCD_HEIGHT >= 128) && (LCD_DEPTH >= 2)
clock_binary.160x128x2.bmp
clock_digits.160x128x2.bmp
clock_smalldigits.160x128x2.bmp
clock_segments.160x128x2.bmp
@ -154,6 +160,7 @@ clock_smallsegments.160x128x2.bmp
clock_logo.160x128x2.bmp
clock_messages.160x128x2.bmp
#elif (LCD_WIDTH >= 138) && (LCD_HEIGHT >= 110) && (LCD_DEPTH >= 2)
clock_binary.138x110x2.bmp
clock_digits.138x110x2.bmp
clock_smalldigits.160x128x2.bmp
clock_segments.138x110x2.bmp
@ -161,6 +168,7 @@ clock_smallsegments.160x128x2.bmp
clock_logo.138x110x2.bmp
clock_messages.138x110x2.bmp
#elif (LCD_WIDTH >= 112) && (LCD_HEIGHT >= 64) && (LCD_DEPTH >= 1)
clock_binary.112x64x1.bmp
clock_digits.112x64x1.bmp
clock_smalldigits.112x64x1.bmp
clock_segments.112x64x1.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 135 KiB

Before After
Before After

View file

@ -4,3 +4,14 @@ osx.dummy.bmp
/* Jackpot */
jackpot_slots_remote.15x210x1.bmp
clock_logo_remote.112x64x1.bmp
clock_messages_remote.112x64x1.bmp
clock_binary_remote.112x64x1.bmp
clock_digits_remote.112x64x1.bmp
clock_smalldigits_remote.112x64x1.bmp
clock_segments_remote.112x64x1.bmp
clock_smallsegments_remote.112x64x1.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

File diff suppressed because it is too large Load diff

112
apps/plugins/clock/Makefile Normal file
View file

@ -0,0 +1,112 @@
# __________ __ ___.
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
# \/ \/ \/ \/ \/
# $$Id: $$
#
INCLUDES = -I$(APPSDIR) -I.. -I. -I$(APPSDIR)/plugins/lib \
$(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export \
-I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR) \
-I$(BUILDDIR)/pluginbitmaps
CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET) $(EXTRA_DEFINES) \
-DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN
ifdef APPEXTRA
INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
endif
LINKFILE := $(OBJDIR)/link.lds
DEPFILE = $(OBJDIR)/dep-clock
# This sets up 'SRC' based on the files mentioned in SOURCES
include $(TOOLSDIR)/makesrc.inc
SOURCES = $(SRC)
OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
DIRS = .
ifndef SIMVER
LDS := ../plugin.lds
OUTPUT = $(OUTDIR)/clock.rock
else ## simulators
OUTPUT = $(OUTDIR)/clock.rock
endif
all: $(OUTPUT)
ifndef SIMVER
$(OBJDIR)/clock.elf: $(OBJS) $(LINKFILE) $(BITMAPLIBS)
$(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -O -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -lplugin -lgcc \
$(LINKBITMAPS) -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/clock.map
$(OUTPUT): $(OBJDIR)/clock.elf
$(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
else
ifeq ($(SIMVER), x11)
###################################################
# This is the X11 simulator version
$(OUTPUT): $(OBJS)
$(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $(OBJS) -L$(BUILDDIR) -lplugin $(LINKBITMAPS) -o $@
ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
# 'x' must be kept or you'll have "Win32 error 5"
# $ fgrep 5 /usr/include/w32api/winerror.h | head -1
# #define ERROR_ACCESS_DENIED 5L
else
@chmod -x $@
endif
else # end of x11-simulator
ifeq ($(SIMVER), sdl)
###################################################
# This is the SDL simulator version
$(OUTPUT): $(OBJS)
$(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $(OBJS) -L$(BUILDDIR) -lplugin $(LINKBITMAPS) -o $@
ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
# 'x' must be kept or you'll have "Win32 error 5"
# $ fgrep 5 /usr/include/w32api/winerror.h | head -1
# #define ERROR_ACCESS_DENIED 5L
else
@chmod -x $@
endif
else # end of sdl-simulator
###################################################
# This is the win32 simulator version
DLLTOOLFLAGS = --export-all
DLLWRAPFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 -mno-cygwin
$(OUTPUT): $(OBJS)
$(call PRINTS,DLL $(@F))$(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $(OBJS)
$(SILENT)$(DLLWRAP) $(DLLWRAPFLAGS) --def $(OBJDIR)/$*.def $(OBJS) \
$(BUILDDIR)/libplugin.a $(BITMAPLIBS) -o $@
ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
# 'x' must be kept or you'll have "Win32 error 5"
# $ fgrep 5 /usr/include/w32api/winerror.h | head -1
# #define ERROR_ACCESS_DENIED 5L
else
@chmod -x $@
endif
endif # end of win32-simulator
endif
endif # end of simulator section
include $(TOOLSDIR)/make.inc
# MEMORYSIZE should be passed on to this makefile with the chosen memory size
# given in number of MB
$(LINKFILE): $(LDS)
$(call PRINTS,build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) \
$(DEFINES) -E -P - >$@
clean:
$(call PRINTS,cleaning clock)rm -rf $(OBJDIR)/clock
$(SILENT)rm -f $(OBJDIR)/clock.* $(DEPFILE)
-include $(DEPFILE)

View file

@ -0,0 +1,10 @@
clock.c
clock_bitmaps.c
clock_bitmap_strings.c
clock_counter.c
clock_draw.c
clock_draw_analog.c
clock_draw_binary.c
clock_draw_digital.c
clock_menu.c
clock_settings.c

199
apps/plugins/clock/clock.c Normal file
View file

@ -0,0 +1,199 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: clock.c 14095 2007-07-31 10:53:53Z nls $
*
* Copyright (C) 2007 Kévin Ferrare
*
* 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"
#include "time.h"
#include "pluginlib_actions.h"
#include "xlcd.h"
#include "clock.h"
#include "clock_counter.h"
#include "clock_draw.h"
#include "clock_menu.h"
#include "clock_settings.h"
PLUGIN_HEADER
/* Keymaps */
const struct button_mapping* plugin_contexts[]={
generic_actions,
generic_directions,
#if NB_SCREENS == 2
remote_directions
#endif
};
#define NB_ACTION_CONTEXTS sizeof(plugin_contexts)/sizeof(plugin_contexts[0])
#define ACTION_COUNTER_TOGGLE PLA_FIRE
#define ACTION_COUNTER_RESET PLA_FIRE_REPEAT
#define ACTION_MENU PLA_MENU
#define ACTION_EXIT PLA_QUIT
#define ACTION_MODE_NEXT PLA_RIGHT
#define ACTION_MODE_PREV PLA_LEFT
#define ACTION_SKIN_NEXT PLA_UP
#define ACTION_SKIN_PREV PLA_DOWN
extern struct plugin_api* rb;
/**************************
* Cleanup on plugin return
*************************/
void cleanup(void *parameter)
{
(void)parameter;
clock_draw_restore_colors();
if(clock_settings.general.save_settings == 1)
save_settings();
/* restore set backlight timeout */
rb->backlight_set_timeout(rb->global_settings->backlight_timeout);
}
/* puts the current time into the time struct */
void clock_update_time( struct time* time){
struct tm* current_time = rb->get_time();
time->hour = current_time->tm_hour;
time->minute = current_time->tm_min;
time->second = current_time->tm_sec;
/*********************
* Date info
*********************/
time->year = current_time->tm_year + 1900;
time->day = current_time->tm_mday;
time->month = current_time->tm_mon + 1;
}
void format_date(char* buffer, struct time* time, enum date_format format){
switch(format){
case JAPANESE:
rb->snprintf(buffer, 20, "%04d/%02d/%02d",
time->year, time->month, time->day);
break;
case EUROPEAN:
rb->snprintf(buffer, 20, "%02d/%02d/%04d",
time->day, time->month, time->year);
break;
case ENGLISH:
rb->snprintf(buffer, 20, "%02d/%02d/%04d",
time->month, time->day, time->year);
break;
case NONE:
default:
break;
}
}
/**********************************************************************
* Plugin starts here
**********************************************************************/
enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
int button;
int last_second = -1;
bool redraw=true;
int i;
struct time time;
struct counter counter;
bool exit_clock = false;
(void)parameter;
rb = api;
#if LCD_DEPTH > 1
rb->lcd_set_backdrop(NULL);
#endif
load_settings();
/* init xlcd functions */
xlcd_init(rb);
counter_init(&counter);
clock_draw_set_colors();
while(!exit_clock){
clock_update_time(&time);
if(!clock_settings.general.idle_poweroff)
rb->reset_poweroff_timer();
/*************************
* Scan for button presses
************************/
button = pluginlib_getaction(rb, HZ/10, plugin_contexts, NB_ACTION_CONTEXTS);
redraw=true;/* we'll set it to false afterwards if there was no action */
switch (button){
case ACTION_COUNTER_TOGGLE: /* start/stop counter */
if(clock_settings.general.show_counter)
counter_toggle(&counter);
break;
case ACTION_COUNTER_RESET: /* reset counter */
if(clock_settings.general.show_counter)
counter_reset(&counter);
break;
case ACTION_MODE_NEXT:
clock_settings.mode++;
if(clock_settings.mode >= NB_CLOCK_MODES)
clock_settings.mode = 0;
break;
case ACTION_MODE_PREV:
clock_settings.mode--;
if(clock_settings.mode < 0)
clock_settings.mode = NB_CLOCK_MODES-1;
break;
case ACTION_SKIN_PREV:
clock_settings_skin_next(&clock_settings);
break;
case ACTION_SKIN_NEXT:
clock_settings_skin_previous(&clock_settings);
break;
case ACTION_MENU:
clock_draw_restore_colors();
exit_clock=main_menu();
break;
case ACTION_EXIT:
/*clock_draw_restore_colors();
exit_clock=main_menu();*/
exit_clock=true;
break;
default:
redraw=false;
if(rb->default_event_handler_ex(button, cleanup, NULL)
== SYS_USB_CONNECTED)
return PLUGIN_USB_CONNECTED;
break;
}
if(time.second != last_second){
last_second=time.second;
redraw=true;
}
if(redraw){
clock_draw_set_colors();
FOR_NB_SCREENS(i)
clock_draw(rb->screens[i], &time, &counter);
redraw=false;
}
}
cleanup(NULL);
return PLUGIN_OK;
}

View file

@ -0,0 +1,32 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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.
*
****************************************************************************/
#ifndef _CLOCK_
#define _CLOCK_
#include "clock_settings.h"
extern struct plugin_api* rb;
struct time{
int year, day, month;
int hour, minute, second;
};
void format_date(char* buffer, struct time* time, enum date_format format);
#endif /* _CLOCK_ */

View file

@ -0,0 +1,46 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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 "clock.h"
#include "clock_bitmap_strings.h"
void draw_string(struct screen* display, const struct picture* bitmaps,
char* str, int x, int y){
int i, bitmap_pos;
char c;
for(i=0;(c=str[i]);i++){
bitmap_pos=-1;
if(c>='0'&&c<='9')
bitmap_pos=c-'0';
else if(c==':')
bitmap_pos=10;
else if(c=='A' || c=='/')/* 'AM' in digits, '/' in smalldigits */
bitmap_pos=11;
else if(c=='P' || c=='.')/* 'PM' in digits, '.' in smalldigits */
bitmap_pos=12;
if(bitmap_pos>=0)
vertical_picture_draw_sprite(display, bitmaps, bitmap_pos,
x+i*bitmaps->width, y);
}
}
void getstringsize(const struct picture* bitmaps, char* str, int *w, int *h ){
*h=bitmaps->height;
*w=rb->strlen(str)*bitmaps->width;
}

View file

@ -0,0 +1,31 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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.
*
****************************************************************************/
#ifndef _CLOCK_BITMAP_STRINGS_
#define _CLOCK_BITMAP_STRINGS_
#include "plugin.h"
#include "picture.h"
void draw_string(struct screen* display, const struct picture* bitmaps,
char* str, int x, int y);
void getstringsize(const struct picture* bitmaps, char* str, int *w, int *h );
#endif /* _CLOCK_BITMAP_STRINGS_ */

View file

@ -0,0 +1,105 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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 "clock_bitmaps.h"
/* bitmaps */
#include "clock_binary.h"
#include "clock_digits.h"
#include "clock_smalldigits.h"
#include "clock_segments.h"
#include "clock_smallsegments.h"
#include "clock_logo.h"
#include "clock_messages.h"
#if NB_SCREENS==2
#include "clock_binary_remote.h"
#include "clock_digits_remote.h"
#include "clock_smalldigits_remote.h"
#include "clock_segments_remote.h"
#include "clock_smallsegments_remote.h"
#include "clock_logo_remote.h"
#include "clock_messages_remote.h"
#endif
const struct picture logos[]={
{clock_logo, BMPWIDTH_clock_logo, BMPHEIGHT_clock_logo},
#if NB_SCREENS==2
{clock_logo_remote,BMPWIDTH_clock_logo_remote,BMPHEIGHT_clock_logo_remote}
#endif
};
const struct picture messages[]={
{clock_messages,BMPWIDTH_clock_messages,
BMPHEIGHT_clock_messages/6},
#if NB_SCREENS==2
{clock_messages_remote,BMPWIDTH_clock_messages_remote,
BMPHEIGHT_clock_messages_remote/6}
#endif
};
const struct picture binary[]={
{clock_binary,
BMPWIDTH_clock_binary, BMPHEIGHT_clock_binary/2 },
#if NB_SCREENS==2
{clock_binary_remote,
BMPWIDTH_clock_binary_remote,BMPHEIGHT_clock_binary_remote/2}
#endif
};
const struct picture digits[]={
{clock_digits,
BMPWIDTH_clock_digits, BMPHEIGHT_clock_digits/13 },
#if NB_SCREENS==2
{clock_digits_remote,
BMPWIDTH_clock_digits_remote,BMPHEIGHT_clock_digits_remote/13}
#endif
};
const struct picture smalldigits[]={
{clock_smalldigits,
BMPWIDTH_clock_smalldigits, BMPHEIGHT_clock_smalldigits/13 },
#if NB_SCREENS==2
{clock_smalldigits_remote,
BMPWIDTH_clock_smalldigits_remote,BMPHEIGHT_clock_smalldigits_remote/13}
#endif
};
const struct picture segments[]={
{clock_segments,
BMPWIDTH_clock_segments, BMPHEIGHT_clock_segments/13 },
#if NB_SCREENS==2
{clock_segments_remote,
BMPWIDTH_clock_segments_remote,BMPHEIGHT_clock_segments_remote/13}
#endif
};
const struct picture smallsegments[]={
{clock_smallsegments,
BMPWIDTH_clock_smallsegments, BMPHEIGHT_clock_smallsegments/13 },
#if NB_SCREENS==2
{clock_smallsegments_remote,
BMPWIDTH_clock_smallsegments_remote,BMPHEIGHT_clock_smallsegments_remote/13}
#endif
};

View file

@ -0,0 +1,33 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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.
*
****************************************************************************/
#ifndef _CLOCK_BITMAPS_
#define _CLOCK_BITMAPS_
#include "picture.h"
extern const struct picture logos[];
extern const struct picture messages[];
extern const struct picture binary[];
extern const struct picture digits[];
extern const struct picture smalldigits[];
extern const struct picture segments[];
extern const struct picture smallsegments[];
#endif

View file

@ -0,0 +1,42 @@
#include "clock_counter.h"
#include "clock_bitmap_strings.h"
void counter_init(struct counter* counter){
counter->ticks_since_started=0;
counter->ticks_at_last_unpause=0;
counter->paused=true;
}
int counter_get_ticks_since_last_pause(struct counter* counter){
if(!counter->paused)
return(*rb->current_tick - counter->ticks_at_last_unpause);
return(0);
}
void counter_toggle(struct counter* counter){
counter_pause(counter, !counter->paused);
}
void counter_pause(struct counter* counter, bool pause){
if(pause){
counter->ticks_since_started+=counter_get_ticks_since_last_pause(counter);
}else{
counter->ticks_at_last_unpause=*rb->current_tick;
}
counter->paused=pause;
}
void counter_get_elapsed_time(struct counter* counter, struct time* elapsed_time){
int total_time=counter_get_ticks_since_last_pause(counter);
total_time+=counter->ticks_since_started;
total_time/=HZ;/* converts ticks to seconds */
elapsed_time->second = total_time%60;
elapsed_time->minute = (total_time%3600) / 60;
elapsed_time->hour = total_time / 3600;
/* not yet ! */
elapsed_time->day=0;
elapsed_time->month=0;
elapsed_time->year=0;
}

View file

@ -0,0 +1,19 @@
#ifndef _CLOCK_MESSAGE_
#define _CLOCK_MESSAGE_
#include "clock.h"
#include "plugin.h"
#include "picture.h"
struct counter{
int ticks_at_last_unpause;/* to count the time from last pause to now */
int ticks_since_started;/* accumulated time */
bool paused;
};
void counter_init(struct counter* counter);
void counter_toggle(struct counter* counter);
#define counter_reset(counter) counter_init(counter)
void counter_pause(struct counter* counter, bool paused);
void counter_get_elapsed_time(struct counter* counter, struct time* elapsed_time);
#endif /* _CLOCK_MESSAGE_ */

View file

@ -0,0 +1,103 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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 "clock.h"
#include "clock_draw.h"
#include "clock_draw_digital.h"
#include "clock_draw_analog.h"
#include "clock_draw_binary.h"
#include "clock_settings.h"
void black_background(struct screen* display){
#if (LCD_DEPTH > 1) || (defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH > 1))
if(display->depth>1){
display->set_background(LCD_BLACK);
display->clear_display();
}else
#endif
{
display->clear_display();
display->fillrect(0,0,display->width,display->height);
}
}
void white_background(struct screen* display){
#if (LCD_DEPTH > 1) || (defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH > 1))
if(display->depth>1){
#if defined(HAVE_LCD_COLOR)
if(display->is_color)/* restore to the bitmap's background */
display->set_background(LCD_RGBPACK(180,200,230));
else
#endif
display->set_background(LCD_WHITE);
}
#endif
display->clear_display();
}
bool skin_require_black_background(int mode, int skin){
return((mode==BINARY && skin==2) || (mode==DIGITAL && skin==1 ));
}
void skin_set_background(struct screen* display, int mode, int skin){
if(skin_require_black_background(mode, skin) )
black_background(display);
else
white_background(display);
}
void skin_restore_background(struct screen* display, int mode, int skin){
if(skin_require_black_background(mode, skin) )
white_background(display);
}
void clock_draw_set_colors(void){
int i;
FOR_NB_SCREENS(i)
skin_set_background(rb->screens[i],
clock_settings.mode,
clock_settings.skin[clock_settings.mode]);
}
void clock_draw_restore_colors(void){
int i;
FOR_NB_SCREENS(i){
skin_restore_background(rb->screens[i],
clock_settings.mode,
clock_settings.skin[clock_settings.mode]);
rb->screens[i]->update();
}
}
void clock_draw(struct screen* display, struct time* time,
struct counter* counter){
if(!clock_settings.general.show_counter)
counter=0;
int skin=clock_settings.skin[clock_settings.mode];
skin_set_background(display, clock_settings.mode, skin);
if(clock_settings.mode == ANALOG)
analog_clock_draw(display, time, &clock_settings, counter, skin);
else if(clock_settings.mode == DIGITAL)
digital_clock_draw(display, time, &clock_settings, counter, skin);
else if(clock_settings.mode == BINARY)
binary_clock_draw(display, time, skin);
display->update();
}

View file

@ -0,0 +1,32 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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.
*
****************************************************************************/
#ifndef _CLOCK_DRAW_
#define _CLOCK_DRAW_
#include "plugin.h"
#include "clock.h"
#include "clock_counter.h"
void clock_draw_set_colors(void);
void clock_draw_restore_colors(void);
void clock_draw(struct screen* display, struct time* time,
struct counter* counter);
#endif /* _CLOCK_DRAW_ */

View file

@ -0,0 +1,217 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare based on Zakk Roberts's work
*
* 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 "clock_draw_analog.h"
#include "xlcd.h"
#include "fixedpoint.h"
#include "clock_bitmaps.h"
#include "clock_bitmap_strings.h"
#define ANALOG_SECOND_RADIUS(screen, round) \
ANALOG_MINUTE_RADIUS(screen, round)
#define ANALOG_MINUTE_RADIUS(screen, round) \
(round?MIN(screen->height/2 -10, screen->width/2 -10):screen->height/2)
#define ANALOG_HOUR_RADIUS(screen, round) \
(ANALOG_MINUTE_RADIUS(screen, round)/2)
#define HOUR_ANGLE(hour, minute, second) (30*(hour) +(minute)/2)
#define MINUTE_ANGLE(minute, second) (6*(minute)+(second)/10)
#define SECOND_ANGLE(second) (6 * (second))
void polar_to_cartesian(int a, int r, int* x, int* y){
*x = (sin_int(a) * r) >> 14;
*y = (sin_int(a-90) * r) >> 14;
}
void polar_to_cartesian_screen_centered(struct screen * display,
int a, int r, int* x, int* y){
polar_to_cartesian(a, r, x, y);
*x+=display->width/2;
*y+=display->height/2;
}
void angle_to_square(int square_width, int square_height,
int a, int* x, int* y){
a = (a+360-90)%360;
if(a>45 && a<=135){/* top line */
a-=45;
*x=square_width-(square_width*2*a)/90;
*y=square_height;
}else if(a>135 && a<=225){/* left line */
a-=135;
*x=-square_width;
*y=square_height-(square_height*2*a)/90;
}else if(a>225 && a<=315){/* bottom line */
a-=225;
*x=(square_width*2*a)/90-square_width;
*y=-square_height;
}else if(a>315 || a<=45){/* right line */
if(a>315)
a-=315;
else
a+=45;
*x=square_width;
*y=(square_height*2*a)/90-square_height;
}
}
void angle_to_square_screen_centered(struct screen * display,
int square_width, int square_height,
int a, int* x, int* y){
angle_to_square(square_width, square_height, a, x, y);
*x+=display->width/2;
*y+=display->height/2;
}
void draw_hand(struct screen* display, int angle,
int radius, int thickness, bool round){
int x1, y1; /* the longest */
int x2, y2, x3, y3; /* the base */
if(round){/* round clock */
polar_to_cartesian_screen_centered(display, angle,
radius, &x1, &y1);
}else{/* fullscreen clock, hands describes square motions */
int square_width, square_height;
/* radius is defined smallest between width and height */
square_height=radius;
square_width=(radius*display->width)/display->height;
angle_to_square_screen_centered(
display, square_width, square_height, angle, &x1, &y1);
}
polar_to_cartesian_screen_centered(display, (angle+120)%360,
radius/40+thickness, &x2, &y2);
polar_to_cartesian_screen_centered(display, (angle+240)%360,
radius/40+thickness, &x3, &y3);
xlcd_filltriangle_screen(display, x1, y1, x2, y2, x3, y3);
}
void draw_hands(struct screen* display, int hour, int minute, int second,
int thickness, bool round, bool draw_seconds){
if(draw_seconds){
draw_hand(display, SECOND_ANGLE(second),
ANALOG_SECOND_RADIUS(display, round), thickness, round);
}
draw_hand(display, MINUTE_ANGLE(minute, second),
ANALOG_MINUTE_RADIUS(display, round), thickness+2, round);
draw_hand(display, HOUR_ANGLE(hour, minute, second),
ANALOG_HOUR_RADIUS(display, round), thickness+2, round);
}
/*******************
* Analog clock mode
******************/
void analog_clock_draw(struct screen* display, struct time* time,
struct clock_settings* settings,
struct counter* counter,
int skin){
int i;
const struct picture* smalldigits_bitmaps =
&(smalldigits[display->screen_type]);
int hour=time->hour;
if(hour >= 12)
hour -= 12;
/* show_date */
/* show_digital_time*/
/* Crappy fake antialiasing (color LCDs only)!
* how this works is we draw a large mid-gray hr/min/sec hand,
* then the actual (slightly smaller) hand on top of those.
* End result: mid-gray edges to the black hands, smooths them out. */
#ifdef HAVE_LCD_COLOR
if(display->is_color){
display->set_foreground(LCD_RGBPACK(100,110,125));
draw_hands(display, hour, time->minute, time->second, 2,
skin, settings->analog.show_seconds);
display->set_foreground(LCD_BLACK);
}
#endif
draw_hands(display, hour, time->minute, time->second, 0, skin,
settings->analog.show_seconds);
if(settings->analog.show_border){
/* Draws square dots every 5 minutes */
int x, y;
int size=display->height/50;/* size of the square dots */
if(size%2)/* a pair number */
size++;
for(i=0; i < 60; i+=5){
if(skin){
polar_to_cartesian_screen_centered(display, MINUTE_ANGLE(i, 0),
ANALOG_MINUTE_RADIUS(display, skin), &x, &y);
}else{
angle_to_square_screen_centered(
display, display->width/2-size/2, display->height/2-size/2,
MINUTE_ANGLE(i, 0), &x, &y);
}
display->fillrect(x-size/2, y-size/2, size, size);
}
}
if(counter){
char buffer[10];
int second_str_w, hour_str_w, str_h;
struct time counter_time;
counter_get_elapsed_time(counter, &counter_time);
rb->snprintf(buffer, 10, "%02d:%02d",
counter_time.hour, counter_time.minute);
getstringsize(smalldigits_bitmaps, buffer, &hour_str_w, &str_h);
draw_string(display, smalldigits_bitmaps, buffer,
display->width-hour_str_w,
display->height-2*str_h);
rb->snprintf(buffer, 10, "%02d", counter_time.second);
getstringsize(smalldigits_bitmaps, buffer, &second_str_w, &str_h);
draw_string(display, smalldigits_bitmaps, buffer,
display->width-(hour_str_w+second_str_w)/2,
display->height-str_h);
}
if(settings->analog.show_date && settings->general.date_format!=NONE){
char buffer[10];
int year_str_w, monthday_str_w, str_h;
if(settings->general.date_format==ENGLISH){
rb->snprintf(buffer, 10, "%02d/%02d", time->month, time->day);
}else{
rb->snprintf(buffer, 10, "%02d/%02d", time->day, time->month);
}
getstringsize(smalldigits_bitmaps, buffer, &monthday_str_w, &str_h);
draw_string(display, smalldigits_bitmaps, buffer,
0, display->height-2*str_h);
rb->snprintf(buffer, 10, "%04d", time->year);
getstringsize(smalldigits_bitmaps, buffer, &year_str_w, &str_h);
draw_string(display, smalldigits_bitmaps, buffer,
(monthday_str_w-year_str_w)/2, display->height-str_h);
}
/* Draw the cover over the center */
display->drawline((display->width/2)-1, (display->height/2)+3,
(display->width/2)+1, (display->height/2)+3);
display->drawline((display->width/2)-3, (display->height/2)+2,
(display->width/2)+3, (display->height/2)+2);
display->drawline((display->width/2)-4, (display->height/2)+1,
(display->width/2)+4, (display->height/2)+1);
display->drawline((display->width/2)-4, display->height/2,
(display->width/2)+4, display->height/2);
display->drawline((display->width/2)-4, (display->height/2)-1,
(display->width/2)+4, (display->height/2)-1);
display->drawline((display->width/2)-3, (display->height/2)-2,
(display->width/2)+3, (display->height/2)-2);
display->drawline((display->width/2)-1, (display->height/2)-3,
(display->width/2)+1, (display->height/2)-3);
}

View file

@ -0,0 +1,32 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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.
*
****************************************************************************/
#ifndef _ANALOG_CLOCK_
#define _ANALOG_CLOCK_
#include "plugin.h"
#include "clock.h"
#include "clock_counter.h"
#include "clock_settings.h"
void analog_clock_draw(struct screen* display, struct time* time,
struct clock_settings* settings,
struct counter* counter,
int skin);
#endif /* _ANALOG_CLOCK_ */

View file

@ -0,0 +1,51 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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 "clock_draw_binary.h"
#include "clock_bitmap_strings.h"
#include "clock_bitmaps.h"
#include "picture.h"
const struct picture* binary_skin[]={binary,digits,segments};
void print_binary(char* buffer, int number, int nb_bits){
int i;
int mask=1;
buffer[nb_bits]='\0';
for(i=0; i<nb_bits; i++){
if((number & mask) !=0)
buffer[nb_bits-i-1]='1';
else
buffer[nb_bits-i-1]='0';
mask=mask<<1;
}
}
void binary_clock_draw(struct screen* display, struct time* time, int skin){
int lines_values[]={
time->hour,time->minute,time->second
};
char buffer[9];
int i;
const struct picture* binary_bitmaps = &(binary_skin[skin][display->screen_type]);
for(i=0;i<3;i++){
print_binary(buffer, lines_values[i], 6);
draw_string(display, binary_bitmaps, buffer, 0,
binary_bitmaps->height*i);
}
}

View file

@ -0,0 +1,27 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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.
*
****************************************************************************/
#ifndef _BINARY_CLOCK_
#define _BINARY_CLOCK_
#include "plugin.h"
#include "clock.h"
void binary_clock_draw(struct screen* display, struct time* time, int skin);
#endif /* _BINARY_CLOCK_ */

View file

@ -0,0 +1,87 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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 "clock.h"
#include "clock_draw_digital.h"
#include "clock_bitmap_strings.h"
#include "clock_bitmaps.h"
#include "picture.h"
const struct picture* digits_skin[]={digits,segments};
const struct picture* smalldigits_skin[]={smalldigits,smallsegments};
#define buffer_printf(buffer, buffer_pos, ... ) \
buffer_pos+=rb->snprintf(&buffer[buffer_pos], sizeof(buffer)-buffer_pos, __VA_ARGS__);
void digital_clock_draw(struct screen* display,
struct time* time,
struct clock_settings* settings,
struct counter* counter,
int skin){
bool display_colon;
const struct picture* digits_bitmaps = &(digits_skin[skin][display->screen_type]);
const struct picture* smalldigits_bitmaps = &(smalldigits_skin[skin][display->screen_type]);
int hour=time->hour;
int str_w, str_h;
char buffer[20];
int buffer_pos=0;
if(settings->digital.blinkcolon){
display_colon=(time->second%2==0);
}
else
display_colon=true;
if(settings->general.hour_format==H12){/* AM/PM format */
if(hour>12){
buffer_printf(buffer, buffer_pos, "P");/* AM */
/* readjust the hour to 12-hour format
* ( 13:00+ -> 1:00+ ) */
hour -= 12;
}else
buffer_printf(buffer, buffer_pos, "A");/* AM */
}
buffer_printf(buffer, buffer_pos, "%02d", hour);
buffer_printf(buffer, buffer_pos, "%c", display_colon?':':' ');
buffer_printf(buffer, buffer_pos, "%02d", time->minute);
getstringsize(digits_bitmaps, buffer, &str_w, &str_h);
draw_string(display, digits_bitmaps, buffer, (display->width-str_w)/2, 0);
if(settings->digital.show_seconds){
buffer_pos=0;
buffer_printf(buffer, buffer_pos, "%02d", time->second);
getstringsize(digits_bitmaps, buffer, &str_w, &str_h);
draw_string(display, digits_bitmaps, buffer, (display->width-str_w)/2,
digits_bitmaps->height);
}
if(settings->general.date_format!=NONE){
format_date(buffer, time, settings->general.date_format);
getstringsize(smalldigits_bitmaps, buffer, &str_w, &str_h);
draw_string(display, smalldigits_bitmaps, buffer, (display->width-str_w)/2,
display->height-smalldigits_bitmaps->height*2);
}
if(counter){
struct time counter_time;
counter_get_elapsed_time(counter, &counter_time);
rb->snprintf(buffer, 20, "%02d:%02d:%02d",
counter_time.hour, counter_time.minute, counter_time.second);
getstringsize(smalldigits_bitmaps, buffer, &str_w, &str_h);
draw_string(display, smalldigits_bitmaps, buffer, (display->width-str_w)/2,
display->height-str_h);
}
}

View file

@ -0,0 +1,31 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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.
*
****************************************************************************/
#ifndef _DIGITAL_CLOCK_
#define _DIGITAL_CLOCK_
#include "plugin.h"
#include "clock.h"
#include "clock_counter.h"
#include "clock_settings.h"
void digital_clock_draw(struct screen* display, struct time* time,
struct clock_settings* settings,
struct counter* counter, int skin);
#endif /* _DIGITAL_CLOCK_ */

View file

@ -0,0 +1,246 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2003 Zakk Roberts
*
* 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 "clock.h"
#include "clock_bitmaps.h"
#include "clock_settings.h"
/* Option structs (possible selections per each option) */
static const struct opt_items noyes_text[] = {
{ "No", -1 },
{ "Yes", -1 }
};
static const struct opt_items backlight_settings_text[] = {
{ "Always Off", -1 },
{ "Rockbox setting", -1 },
{ "Always On", -1 }
};
static const struct opt_items idle_poweroff_text[] = {
{ "Disabled", -1 },
{ "Enabled", -1 }
};
static const struct opt_items date_format_text[] = {
{ "No date", -1 },
{ "English format", -1 },
{ "European format", -1 },
{ "Japanese format", -1 },
};
static const struct opt_items hour_format_text[] = {
{ "24-hour Format", -1 },
{ "12-hour Format", -1 }
};
/***************
* Select a mode, returs true when the mode has been selected
* (we go back to clock display then)
**************/
bool menu_mode_selector(void){
MENUITEM_STRINGLIST(menu,"Mode Selector",NULL, "Analog",
"Digital", "Binary");
if(rb->do_menu(&menu, &clock_settings.mode) >=0)
return(true);
return(false);
}
/**********************
* Analog settings menu
*********************/
void menu_analog_settings(void)
{
int selection=0, result=0;
MENUITEM_STRINGLIST(menu,"Analog Mode Settings",NULL,"Show Date",
"Show Second Hand","Show Border");
while(result>=0){
result=rb->do_menu(&menu, &selection);
switch(result){
case 0:
rb->set_option("Show Date", &clock_settings.analog.show_date,
BOOL, noyes_text, 2, NULL);
break;
case 1:
rb->set_option("Show Second Hand",
&clock_settings.analog.show_seconds,
BOOL, noyes_text, 2, NULL);
break;
case 2:
rb->set_option("Show Border",
&clock_settings.analog.show_border,
BOOL, noyes_text, 2, NULL);
break;
}
}
}
/***********************
* Digital settings menu
**********************/
void menu_digital_settings(void){
int selection=0, result=0;
MENUITEM_STRINGLIST(menu,"Digital Mode Settings",NULL,"Show Seconds",
"Blinking Colon");
while(result>=0){
result=rb->do_menu(&menu, &selection);
switch(result){
case 0:
rb->set_option("Show Seconds",
&clock_settings.digital.show_seconds,
BOOL, noyes_text, 2, NULL);
break;
case 1:
rb->set_option("Blinking Colon",
&clock_settings.digital.blinkcolon,
BOOL, noyes_text, 2, NULL);
break;
}
}
}
/***********************************************************
* Confirm resetting of settings, used in general_settings()
**********************************************************/
void confirm_reset(void){
int result=0;
rb->set_option("Reset all settings?", &result, INT, noyes_text, 2, NULL);
if(result == 1){ /* reset! */
clock_settings_reset(&clock_settings);
rb->splash(HZ, "Settings reset!");
}
else
rb->splash(HZ, "Settings NOT reset.");
}
/************************************
* General settings. Reset, save, etc
***********************************/
void menu_general_settings(void){
int selection=0, result=0;
MENUITEM_STRINGLIST(menu,"General Settings",NULL,
"Hour format","Date format","Show Counter",
"Reset Settings","Save Settings Now",
"Save On Exit","Backlight Settings",
"Idle Poweroff (temporary)");
while(result>=0){
result=rb->do_menu(&menu, &selection);
switch(result){
case 0:
rb->set_option("Hour format",
&clock_settings.general.hour_format,
INT, hour_format_text, 2, NULL);
break;
case 1:
rb->set_option("Date format",
&clock_settings.general.date_format,
INT, date_format_text, 4, NULL);
break;
case 2:
rb->set_option("Show Counter", &clock_settings.general.show_counter,
BOOL, noyes_text, 2, NULL);
break;
case 3:
confirm_reset();
break;
case 4:
save_settings_wo_gui();
rb->splash(HZ, "Settings saved");
break;
case 5:
rb->set_option("Save On Exit",
&clock_settings.general.save_settings,
BOOL, noyes_text, 2, NULL);
/* if we no longer save on exit,
we better save now to remember that */
if(!clock_settings.general.save_settings)
save_settings_wo_gui();
break;
case 6:
rb->set_option("Backlight Settings",
&clock_settings.general.backlight,
INT, backlight_settings_text, 3, NULL);
apply_backlight_setting(clock_settings.general.backlight);
break;
case 7:
rb->set_option("Idle Poweroff (temporary)",
&clock_settings.general.idle_poweroff,
BOOL, idle_poweroff_text, 2, NULL);
break;
}
}
}
/***********
* Main menu
**********/
bool main_menu(void){
int selection=0;
bool done = false;
bool exit_clock=false;
MENUITEM_STRINGLIST(menu,"Clock Menu",NULL,"View Clock","Mode Selector",
"Mode Settings","General Settings","Quit");
while(!done){
switch(rb->do_menu(&menu, &selection)){
case 0:
done = true;
break;
case 1:
done=menu_mode_selector();
break;
case 2:
switch(clock_settings.mode){
case ANALOG: menu_analog_settings();break;
case DIGITAL: menu_digital_settings();break;
case BINARY: /* no settings */;break;
}
break;
case 3:
menu_general_settings();
break;
case 4:
exit_clock = true;
done = true;
break;
default:
done=true;
break;
}
}
return(exit_clock);
}

View file

@ -0,0 +1,7 @@
#ifndef _CLOCK_MENU_
#define _CLOCK_MENU_
bool main_menu(void);
#endif /* _CLOCK_MENU_ */

View file

@ -0,0 +1,200 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare based on Zakk Roberts's work
*
* 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 "clock.h"
#include "clock_bitmaps.h"
#include "clock_draw.h"
#include "clock_settings.h"
#include "picture.h"
static int max_skin[]={
[ANALOG]=2,
[BINARY]=3,
[DIGITAL]=2,
};
enum message{
MESSAGE_LOADING,
MESSAGE_LOADED,
MESSAGE_ERRLOAD,
MESSAGE_SAVING,
MESSAGE_SAVED,
MESSAGE_ERRSAVE
};
enum settings_file_status{
LOADED, ERRLOAD,
SAVED, ERRSAVE
};
struct clock_settings clock_settings;
void clock_settings_reset(struct clock_settings* settings){
settings->mode = ANALOG;
int i;
for(i=0;i<NB_CLOCK_MODES;i++){
settings->skin[i]=0;
}
settings->general.hour_format = H12;
settings->general.date_format = EUROPEAN;
settings->general.show_counter = true;
settings->general.save_settings = true;
settings->general.idle_poweroff=true;
settings->general.backlight = ROCKBOX_SETTING;
settings->analog.show_date = false;
settings->analog.show_seconds = true;
settings->analog.show_border = true;
settings->digital.show_seconds = true;
settings->digital.blinkcolon = false;
apply_backlight_setting(settings->general.backlight);
}
void apply_backlight_setting(int backlight_setting)
{
if(backlight_setting == ALWAS_OFF)
rb->backlight_set_timeout(0);
else if(backlight_setting == ROCKBOX_SETTING)
rb->backlight_set_timeout(rb->global_settings->backlight_timeout);
else if(backlight_setting == ALWAYS_ON)
rb->backlight_set_timeout(1);
}
void clock_settings_skin_next(struct clock_settings* settings){
settings->skin[settings->mode]++;
if(settings->skin[settings->mode]>=max_skin[settings->mode])
settings->skin[settings->mode]=0;
}
void clock_settings_skin_previous(struct clock_settings* settings){
settings->skin[settings->mode]--;
if(settings->skin[settings->mode]<0)
settings->skin[settings->mode]=max_skin[settings->mode]-1;
}
enum settings_file_status clock_settings_load(struct clock_settings* settings,
char* filename){
int fd = rb->open(filename, O_RDONLY);
if(fd >= 0){ /* does file exist? */
/* basic consistency check */
if(rb->filesize(fd) == sizeof(*settings)){
rb->read(fd, settings, sizeof(*settings));
rb->close(fd);
apply_backlight_setting(settings->general.backlight);
return(LOADED);
}
}
/* Initializes the settings with default values at least */
clock_settings_reset(settings);
return(ERRLOAD);
}
enum settings_file_status clock_settings_save(struct clock_settings* settings,
char* filename){
int fd = rb->creat(filename);
if(fd >= 0){ /* does file exist? */
rb->write (fd, settings, sizeof(*settings));
rb->close(fd);
return(SAVED);
}
return(ERRSAVE);
}
void draw_logo(struct screen* display){
#ifdef HAVE_LCD_COLOR
if(display->is_color){
display->set_foreground(LCD_BLACK);
display->set_background(LCD_RGBPACK(180,200,230));
}
#endif
const struct picture* logo = &(logos[display->screen_type]);
display->clear_display();
picture_draw(display, logo, 0, 0);
}
void draw_message(struct screen* display, int msg, int y){
const struct picture* message = &(messages[display->screen_type]);
display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
display->fillrect(0, display->height-message->height,
display->width, message->height);
display->set_drawmode(DRMODE_SOLID);
vertical_picture_draw_sprite(display, message, msg,
0, display->height-(message->height*y));
}
void load_settings(void){
int i;
struct screen* display;
FOR_NB_SCREENS(i){
display=rb->screens[i];
display->clear_display();
draw_logo(display);
draw_message(display, MESSAGE_LOADING, 1);
display->update();
}
enum settings_file_status load_status=
clock_settings_load(&clock_settings, settings_filename);
FOR_NB_SCREENS(i){
display=rb->screens[i];
if(load_status==LOADED)
draw_message(display, MESSAGE_LOADED, 1);
else
draw_message(display, MESSAGE_ERRLOAD, 1);
display->update();
}
#ifndef SIMULATOR
rb->ata_sleep();
#endif
rb->sleep(HZ);
}
void save_settings(void){
int i;
struct screen* display;
FOR_NB_SCREENS(i){
display=rb->screens[i];
display->clear_display();
draw_logo(display);
draw_message(display, MESSAGE_SAVING, 1);
display->update();
}
enum settings_file_status load_status=
clock_settings_save(&clock_settings, settings_filename);
FOR_NB_SCREENS(i){
display=rb->screens[i];
if(load_status==SAVED)
draw_message(display, MESSAGE_SAVED, 1);
else
draw_message(display, MESSAGE_ERRSAVE, 1);
display->update();
}
rb->sleep(HZ);
}
void save_settings_wo_gui(void){
clock_settings_save(&clock_settings, settings_filename);
}

View file

@ -0,0 +1,91 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare based on Zakk Roberts's work
*
* 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.
*
****************************************************************************/
#ifndef _CLOCK_SETTINGS_
#define _CLOCK_SETTINGS_
#include "plugin.h"
enum date_format{
NONE,
ENGLISH,
EUROPEAN,
JAPANESE,
};
enum hour_format{
H24,
H12
};
enum clock_modes{
ANALOG,
DIGITAL,
BINARY,
NB_CLOCK_MODES
};
enum backlight_handling{
ALWAS_OFF,
ROCKBOX_SETTING,
ALWAYS_ON
};
struct general_settings{
int hour_format;/* 0:24h, 1:12h*/
int date_format;
bool show_counter;
bool save_settings;
bool idle_poweroff;
int backlight;
};
struct analog_settings{
bool show_date;
bool show_seconds;
bool show_border;
};
struct digital_settings{
int show_seconds;
int blinkcolon;
};
struct clock_settings{
int mode; /* clock mode */
int skin[NB_CLOCK_MODES];/* how does each mode looks like */
struct general_settings general;
struct analog_settings analog;
struct digital_settings digital;
};
extern struct clock_settings clock_settings;
/* settings are saved to this location */
#define settings_filename "/.rockbox/rocks/.clock_settings"
void clock_settings_skin_next(struct clock_settings* settings);
void clock_settings_skin_previous(struct clock_settings* settings);
void apply_backlight_setting(int backlight_setting);
void clock_settings_reset(struct clock_settings* settings);
void load_settings(void);
void save_settings(void);
void save_settings_wo_gui(void);
#endif /* _CLOCK_SETTINGS_ */

View file

@ -21,6 +21,7 @@ profile_plugin.c
#endif
#ifdef HAVE_LCD_BITMAP
checkbox.c
picture.c
xlcd_core.c
xlcd_draw.c
xlcd_scroll.c

View file

@ -0,0 +1,70 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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 "picture.h"
void picture_draw(struct screen* display, const struct picture* picture,
int x, int y){
display->bitmap(
picture->data,
x, y,
picture->width, picture->height
);
}
/**
* Draws a part of the given picture on the given screen
* Use it when the data contains multiple pictures from top to bottom.
* In that case, picture.height represents the height of one picture,
* not the whole set.
* @param display the screen where to display the picture
* @param picture the picture's data, only a part will be displayed
* @param yoffset display the data in the picture from yoffset to
* yoffset+picture.height
* @param x abscissa where to put the picture
* @param y ordinate where to put the picture
*/
void vertical_picture_draw_part(struct screen* display, const struct picture* picture,
int yoffset,
int x, int y){
display->bitmap_part(
picture->data,
/*slice into picture->data */
0, yoffset,
picture->width,
/* Position on the screen */
x, y, picture->width, picture->height
);
}
/**
* Draws a part of the given picture on the given screen
* Use it when the data contains multiple pictures from top to bottom.
*
* @param display the screen where to display the picture
* @param picture the picture's data, only a part will be displayed
* @param sprite_no display that sprite in the picture
* @param x abscissa where to put the picture
* @param y ordinate where to put the picture
*/
void vertical_picture_draw_sprite(struct screen* display, const struct picture* picture,
int sprite_no,
int x, int y){
vertical_picture_draw_part(display, picture, sprite_no*picture->height, x, y);
}

View file

@ -0,0 +1,40 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
*
* Copyright (C) 2007 Copyright Kévin Ferrare
*
* 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.
*
****************************************************************************/
#ifndef _PICTURE_
#define _PICTURE_
#include "plugin.h"
struct picture{
const void* data;
int width;
int height;
};
void picture_draw(struct screen* display, const struct picture* picture,
int x, int y);
void vertical_picture_draw_part(struct screen* display, const struct picture* picture,
int yoffset,
int x, int y);
void vertical_picture_draw_sprite(struct screen* display, const struct picture* picture,
int sprite_no,
int x, int y);
#endif

View file

@ -28,7 +28,8 @@
void xlcd_init(struct plugin_api* newrb);
void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3);
void xlcd_filltriangle_screen(struct screen* display,
int x1, int y1, int x2, int y2, int x3, int y3);
#if LCD_DEPTH >= 8
void xlcd_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
int stride, int x, int y, int width, int height);

View file

@ -25,46 +25,58 @@
#ifdef HAVE_LCD_BITMAP
#include "xlcd.h"
#if (LCD_DEPTH >= 8) || (LCD_PIXELFORMAT == HORIZONTAL_PACKING)
/* draw a filled triangle, using horizontal lines for speed */
void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
/* sort the given coordinates by increasing x value */
void sort_points_by_increasing_x(int* x1, int* y1,
int* x2, int* y2,
int* x3, int* y3)
{
int x, y;
long fp_x1, fp_x2, fp_dx1, fp_dx2;
/* sort vertices by increasing y value */
if (y1 > y3)
if (*x1 > *x3)
{
if (y2 < y3) /* y2 < y3 < y1 */
if (*x2 < *x3) /* x2 < x3 < x1 */
{
x = x1; x1 = x2; x2 = x3; x3 = x;
y = y1; y1 = y2; y2 = y3; y3 = y;
x = *x1; *x1 = *x2; *x2 = *x3; *x3 = x;
y = *y1; *y1 = *y2; *y2 = *y3; *y3 = y;
}
else if (y2 > y1) /* y3 < y1 < y2 */
else if (*x2 > *x1) /* x3 < x1 < x2 */
{
x = x1; x1 = x3; x3 = x2; x2 = x;
y = y1; y1 = y3; y3 = y2; y2 = y;
x = *x1; *x1 = *x3; *x3 = *x2; *x2 = x;
y = *y1; *y1 = *y3; *y3 = *y2; *y2 = y;
}
else /* y3 <= y2 <= y1 */
else /* x3 <= x2 <= x1 */
{
x = x1; x1 = x3; x3 = x;
y = y1; y1 = y3; y3 = y;
x = *x1; *x1 = *x3; *x3 = x;
y = *y1; *y1 = *y3; *y3 = y;
}
}
else
{
if (y2 < y1) /* y2 < y1 <= y3 */
if (*x2 < *x1) /* x2 < x1 <= x3 */
{
x = x1; x1 = x2; x2 = x;
y = y1; y1 = y2; y2 = y;
x = *x1; *x1 = *x2; *x2 = x;
y = *y1; *y1 = *y2; *y2 = y;
}
else if (y2 > y3) /* y1 <= y3 < y2 */
else if (*x2 > *x3) /* x1 <= x3 < x2 */
{
x = x2; x2 = x3; x3 = x;
y = y2; y2 = y3; y3 = y;
x = *x2; *x2 = *x3; *x3 = x;
y = *y2; *y2 = *y3; *y3 = y;
}
/* else already sorted */
}
}
#define sort_points_by_increasing_y(x1, y1, x2, y2, x3, y3) \
sort_points_by_increasing_x(y1, x1, y2, x2, y3, x3)
/* draw a filled triangle, using horizontal lines for speed */
void xlcd_filltriangle_horizontal(struct screen* display,
int x1, int y1,
int x2, int y2,
int x3, int y3)
{
long fp_x1, fp_x2, fp_dx1, fp_dx2;
int y;
sort_points_by_increasing_y(&x1, &y1, &x2, &y2, &x3, &y3);
if (y1 < y3) /* draw */
{
@ -72,12 +84,12 @@ void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
fp_x1 = (x1 << 16) + (1<<15) + (fp_dx1 >> 1);
if (y1 < y2) /* first part */
{
{
fp_dx2 = ((x2 - x1) << 16) / (y2 - y1);
fp_x2 = (x1 << 16) + (1<<15) + (fp_dx2 >> 1);
for (y = y1; y < y2; y++)
{
_xlcd_rb->lcd_hline(fp_x1 >> 16, fp_x2 >> 16, y);
display->hline(fp_x1 >> 16, fp_x2 >> 16, y);
fp_x1 += fp_dx1;
fp_x2 += fp_dx2;
}
@ -88,53 +100,23 @@ void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
fp_x2 = (x2 << 16) + (1<<15) + (fp_dx2 >> 1);
for (y = y2; y < y3; y++)
{
_xlcd_rb->lcd_hline(fp_x1 >> 16, fp_x2 >> 16, y);
display->hline(fp_x1 >> 16, fp_x2 >> 16, y);
fp_x1 += fp_dx1;
fp_x2 += fp_dx2;
}
}
}
}
#else /* (LCD_DEPTH < 8) && (LCD_PIXELFORMAT == VERTICAL_PACKING) */
/* draw a filled triangle, using vertical lines for speed */
void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
{
int x, y;
long fp_y1, fp_y2, fp_dy1, fp_dy2;
}
/* sort vertices by increasing x value */
if (x1 > x3)
{
if (x2 < x3) /* x2 < x3 < x1 */
{
x = x1; x1 = x2; x2 = x3; x3 = x;
y = y1; y1 = y2; y2 = y3; y3 = y;
}
else if (x2 > x1) /* x3 < x1 < x2 */
{
x = x1; x1 = x3; x3 = x2; x2 = x;
y = y1; y1 = y3; y3 = y2; y2 = y;
}
else /* x3 <= x2 <= x1 */
{
x = x1; x1 = x3; x3 = x;
y = y1; y1 = y3; y3 = y;
}
}
else
{
if (x2 < x1) /* x2 < x1 <= x3 */
{
x = x1; x1 = x2; x2 = x;
y = y1; y1 = y2; y2 = y;
}
else if (x2 > x3) /* x1 <= x3 < x2 */
{
x = x2; x2 = x3; x3 = x;
y = y2; y2 = y3; y3 = y;
}
/* else already sorted */
}
/* draw a filled triangle, using vertical lines for speed */
void xlcd_filltriangle_vertical(struct screen* display,
int x1, int y1,
int x2, int y2,
int x3, int y3)
{
long fp_y1, fp_y2, fp_dy1, fp_dy2;
int x;
sort_points_by_increasing_x(&x1, &y1, &x2, &y2, &x3, &y3);
if (x1 < x3) /* draw */
{
@ -142,12 +124,12 @@ void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
fp_y1 = (y1 << 16) + (1<<15) + (fp_dy1 >> 1);
if (x1 < x2) /* first part */
{
{
fp_dy2 = ((y2 - y1) << 16) / (x2 - x1);
fp_y2 = (y1 << 16) + (1<<15) + (fp_dy2 >> 1);
for (x = x1; x < x2; x++)
{
_xlcd_rb->lcd_vline(x, fp_y1 >> 16, fp_y2 >> 16);
display->vline(x, fp_y1 >> 16, fp_y2 >> 16);
fp_y1 += fp_dy1;
fp_y2 += fp_dy2;
}
@ -158,14 +140,33 @@ void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3)
fp_y2 = (y2 << 16) + (1<<15) + (fp_dy2 >> 1);
for (x = x2; x < x3; x++)
{
_xlcd_rb->lcd_vline(x, fp_y1 >> 16, fp_y2 >> 16);
display->vline(x, fp_y1 >> 16, fp_y2 >> 16);
fp_y1 += fp_dy1;
fp_y2 += fp_dy2;
}
}
}
}
#endif /* LCD_DEPTH, LCD_PIXELFORMAT */
void xlcd_filltriangle(int x1, int y1,
int x2, int y2,
int x3, int y3)
{
/* default is main screen */
xlcd_filltriangle_screen(_xlcd_rb->screens[SCREEN_MAIN],
x1, y1, x2, y2, x3, y3);
}
void xlcd_filltriangle_screen(struct screen* display,
int x1, int y1,
int x2, int y2,
int x3, int y3)
{
if(display->pixel_format==HORIZONTAL_PACKING || display->depth>=8)
xlcd_filltriangle_horizontal(display, x1, y1, x2, y2, x3, y3);
else
xlcd_filltriangle_vertical(display, x1, y1, x2, y2, x3, y3);
}
#if LCD_DEPTH >= 8

View file

@ -39,6 +39,7 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
#ifdef HAVE_REMOTE_LCD
case SCREEN_REMOTE:
screen->is_color=false;/* No color remotes yet */
screen->pixel_format=LCD_REMOTE_PIXELFORMAT;
screen->depth=LCD_REMOTE_DEPTH;
screen->has_disk_led=false;
@ -117,6 +118,9 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
screen->is_color=true;
#else
screen->is_color=false;
#endif
#ifdef HAVE_LCD_BITMAP
screen->pixel_format=LCD_PIXELFORMAT;
#endif
screen->depth=LCD_DEPTH;
#if (CONFIG_LED == LED_VIRTUAL)

View file

@ -58,6 +58,9 @@ struct screen
enum screen_type screen_type;
int depth;
bool is_color;
#ifdef HAVE_LCD_BITMAP
int pixel_format;
#endif
int char_width;
int char_height;
#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)