summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/clock.c654
1 files changed, 333 insertions, 321 deletions
diff --git a/apps/plugins/clock.c b/apps/plugins/clock.c
index 5e16415d4d..612f283e33 100644
--- a/apps/plugins/clock.c
+++ b/apps/plugins/clock.c
@@ -5,7 +5,7 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id: clock.c,v 2.31 2003/12/8 8 * $Id: clock.c,v 2.40 2003/12/8
9 * 9 *
10 * Copyright (C) 2003 Zakk Roberts 10 * Copyright (C) 2003 Zakk Roberts
11 * 11 *
@@ -20,6 +20,13 @@
20/***************************** 20/*****************************
21 * RELEASE NOTES 21 * RELEASE NOTES
22 22
23***** VERSION 2.40 **
24-Cleaned and optimized code, -removed unused code and bitmaps,
25-Progressbar and more animations at credits screen, -centered
26text all over, -general settings added at ON+F3, -new arrow bitmap
27for general settings and mode selector, -bugfix: 12:00AM is no longer
2800:00AM
29
23***** VERSION 2.31 ** 30***** VERSION 2.31 **
24Fixed credits roll - now displays all names. Features 31Fixed credits roll - now displays all names. Features
25improved animations. Also revised release notes. 32improved animations. Also revised release notes.
@@ -61,7 +68,7 @@ Original release, featuring analog / digital modes and a few options.
61 68
62#ifdef HAVE_LCD_BITMAP 69#ifdef HAVE_LCD_BITMAP
63 70
64#define CLOCK_VERSION "2.31" 71#define CLOCK_VERSION "2.40"
65 72
66/* prototypes */ 73/* prototypes */
67void show_logo(bool animate, bool show_clock_text); 74void show_logo(bool animate, bool show_clock_text);
@@ -85,11 +92,15 @@ int remaining_h=0, remaining_m=0, remaining_s=0;
85bool editing_target = false; 92bool editing_target = false;
86bool display_counter = true; 93bool display_counter = true;
87 94
95/* used for centering of text all over */
96char buf[20];
97int buf_w, buf_h;
98
88static struct plugin_api* rb; 99static struct plugin_api* rb;
89 100
90/*********************************************************** 101/***********************************************************
91 * Used for hands to define lengths at a given time - ANALOG 102 * Used for hands to define lengths at a given time - ANALOG
92 ***********************************************************/ 103 **********************************************************/
93static unsigned char xminute[] = { 104static unsigned char xminute[] = {
9456,59,61,64,67,70,72,75,77,79,80,82,83,84,84,84,84,84,83,82,80,79,77,75,72,70,67,64,61,59,56,53,51,48,45,42,40,37,35,33,32,30,29,28,28,28,28,28,29,30,32,33,35,37,40,42,45,48,51,53, 10556,59,61,64,67,70,72,75,77,79,80,82,83,84,84,84,84,84,83,82,80,79,77,75,72,70,67,64,61,59,56,53,51,48,45,42,40,37,35,33,32,30,29,28,28,28,28,28,29,30,32,33,35,37,40,42,45,48,51,53,
95}; 106};
@@ -105,7 +116,7 @@ static unsigned char xhour[] = {
105 116
106/************************************************************** 117/**************************************************************
107 * Used for hands to define lengths at a give time - FULLSCREEN 118 * Used for hands to define lengths at a give time - FULLSCREEN
108 **************************************************************/ 119 *************************************************************/
109static unsigned char xminute_full[] = { 120static unsigned char xminute_full[] = {
11056,58,61,65,69,74,79,84,91,100,110,110,110,110,110,110,110,110,110,110,110,100,91,84,79,74,69,65,61,58,56,54,51,47,43,38,33,28,21,12,1,1,1,1,1,1,1,1,1,1,1,12,21,28,33,38,43,47,51,54 12156,58,61,65,69,74,79,84,91,100,110,110,110,110,110,110,110,110,110,110,110,100,91,84,79,74,69,65,61,58,56,54,51,47,43,38,33,28,21,12,1,1,1,1,1,1,1,1,1,1,1,12,21,28,33,38,43,47,51,54
111}; 122};
@@ -122,9 +133,9 @@ static unsigned char yhour_full[] = {
122/**************************** 133/****************************
123 * BITMAPS 134 * BITMAPS
124 ****************************/ 135 ****************************/
125/**************************** 136/*************************
126 * "0" bitmap - for binary 137 * "0" bitmap - for binary
127 ****************************/ 138 ************************/
128static unsigned char bitmap_0[] = { 139static unsigned char bitmap_0[] = {
1290xc0, 0xf0, 0x3c, 0x0e, 0x06, 0x03, 0x03, 0x03, 0x03, 0x06, 0x0e, 0x3c, 0xf0, 1400xc0, 0xf0, 0x3c, 0x0e, 0x06, 0x03, 0x03, 0x03, 0x03, 0x06, 0x0e, 0x3c, 0xf0,
1300xc0, 0x00, 1410xc0, 0x00,
@@ -132,9 +143,9 @@ static unsigned char bitmap_0[] = {
1320x1f, 0x00, 1430x1f, 0x00,
1330x00, 0x00, 0x01, 0x03, 0x03, 0x06, 0x06, 0x06, 0x06, 0x03, 0x03, 0x01, 0x00, 1440x00, 0x00, 0x01, 0x03, 0x03, 0x06, 0x06, 0x06, 0x06, 0x03, 0x03, 0x01, 0x00,
1340x00, 0x00 }; 1450x00, 0x00 };
135/**************************** 146/*************************
136 * "1" bitmap - for binary 147 * "1" bitmap - for binary
137 ****************************/ 148 ************************/
138static unsigned char bitmap_1[] = { 149static unsigned char bitmap_1[] = {
1390xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 1500xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1400x00, 0x00, 1510x00, 0x00,
@@ -144,170 +155,21 @@ static unsigned char bitmap_1[] = {
1440x06, 0x00 }; 1550x06, 0x00 };
145/**************************** 156/****************************
146 * PM indicator (moon + text) 157 * PM indicator (moon + text)
147 ****************************/ 158 ***************************/
148static unsigned char pm[] = { 0xFF,0xFF,0x33,0x33,0x33,0x1E,0x0C,0x00,0xFF,0xFF,0x06,0x0C,0x06,0xFF,0xFF }; 159static unsigned char pm[] = { 0xFF,0xFF,0x33,0x33,0x33,0x1E,0x0C,0x00,0xFF,0xFF,0x06,0x0C,0x06,0xFF,0xFF };
149/**************************** 160/****************************
150 * AM Indicator (sun and text 161 * AM Indicator (sun and text
151 ****************************/ 162 ***************************/
152static unsigned char am[] = { 0xFE,0xFF,0x1B,0x1B,0xFF,0xFE,0x00,0x00,0xFF,0xFF,0x06,0x0C,0x06,0xFF,0xFF }; 163static unsigned char am[] = { 0xFE,0xFF,0x1B,0x1B,0xFF,0xFE,0x00,0x00,0xFF,0xFF,0x06,0x0C,0x06,0xFF,0xFF };
153 164/**************
154/***************************************** 165 * Arrow bitmap
155 * We've got 4 different clock logos... 166 *************/
156 * The currently used one is #4, 167static unsigned char arrow[] = { 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x1E, 0x0C };
157 * "clockbox" -- the others are kept here 168
158 * in case the logo selector is ever 169/************************************
159 * brought back or we want to switch.. 170 * "Clockbox" clock logo - by Adam S.
160 ****************************************/ 171 ***********************************/
161/* Logo #1 - Standard (by Zakk Roberts) */ 172const unsigned char clocklogo[] = {
162const unsigned char clocklogo_1[] = {
1630x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1640x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1650x00, 0xe0, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1660x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1670x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1680x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1690x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
1700xf8, 0xfc, 0xfe, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1710x00, 0x80, 0xc0, 0xe0, 0xe0, 0xe0, 0xc0, 0x00,
1720x80, 0xe0, 0xf0, 0xf8, 0xfc, 0xfc, 0xfe, 0xfe, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e,
1730x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x3e, 0x3e, 0x3e, 0x1e, 0x0e, 0x00, 0x00,
1740x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf0,
1750xf8, 0xfc, 0xfc, 0x7e, 0x3e, 0x3e, 0x3e, 0x3e, 0xbe, 0xbe, 0x3e, 0x3e, 0x3e,
1760x3e, 0x7e, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x80, 0xe0,
1770xf0, 0xf8, 0xfc, 0xfc, 0xfe, 0xfe, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e,
1780x7e, 0x7e, 0x7e, 0x7e, 0x3e, 0x3e, 0x3e, 0x1e, 0x0e, 0x00, 0x00, 0x00, 0xff,
1790xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe,
1800xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x00,
1810xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1820x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1830x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
1840xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x3f, 0xc0, 0xc0, 0xc0,
1850xc0, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff,
1860xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1870x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
1880xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xc7, 0x83, 0x01,
1890x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1900xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
1910x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1920x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
1930xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
1940x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff,
1950xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
1960x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
1970xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff,
1980xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00,
1990x0f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f,
2000x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1e, 0x1c, 0x00, 0x00,
2010x00, 0x1f, 0x1f, 0x1f, 0x0f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x1f, 0x1f,
2020x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f,
2030x1f, 0x1f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x1f,
2040x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f,
2050x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1e, 0x1c, 0x00, 0x00, 0x00, 0x1f,
2060x1f, 0x1f, 0x0f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2070x01, 0x03, 0x07, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f
208};
209
210/* Logo #2 - Digital Segments (by Zakk Roberts) */
211const unsigned char clocklogo_2[] = {
2120x00, 0x00, 0x00, 0x00, 0xfe, 0xfd, 0xfb, 0xf7, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
2130x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00,
2140xfe, 0xfc, 0xf8, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2150x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfd, 0xfb, 0xf7,
2160x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf7, 0xfb,
2170xfd, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xfd, 0xfb, 0xf7, 0x0f, 0x0f, 0x0f, 0x0f,
2180x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00,
2190x00, 0xfe, 0xfc, 0xf8, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
2200xe0, 0xf0, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00,
2210x00, 0x00, 0x00, 0x00, 0xbf, 0x1f, 0x0f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
2220x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2230xbf, 0x1f, 0x0f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2240x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, 0x1f, 0x0f, 0x07,
2250x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0f,
2260x1f, 0xbf, 0x00, 0x00, 0x00, 0xbf, 0x1f, 0x0f, 0x07, 0x00, 0x00, 0x00, 0x00,
2270x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2280x00, 0xbf, 0x5f, 0xef, 0xf7, 0xf0, 0xf0, 0xf0, 0xe0, 0x40, 0x00, 0x06, 0x07,
2290x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2300x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00,
2310x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2320xff, 0xff, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2330x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfe, 0xfc,
2340x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe,
2350xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x00,
2360x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2370x00, 0xff, 0xff, 0xfe, 0xfd, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x3c,
2380xfc, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
2390xc0, 0x00, 0x40, 0x40, 0x4f, 0x17, 0x1b, 0xdd, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
2400x1e, 0x1e, 0x1e, 0xde, 0x1e, 0x5e, 0x5c, 0x58, 0x10, 0xc0, 0x00, 0x00, 0xc0,
2410x0f, 0x57, 0x5b, 0x5d, 0x1e, 0x1e, 0x1e, 0x1e, 0xde, 0x1e, 0x1e, 0x1e, 0x9e,
2420x1e, 0x1e, 0x1c, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xd7, 0x1b, 0x5d,
2430x5e, 0x5e, 0x1e, 0xde, 0x1e, 0x1e, 0xde, 0x1e, 0x5e, 0x5e, 0x5e, 0x1d, 0xdb,
2440x17, 0x0f, 0xc0, 0x00, 0x40, 0x4f, 0x57, 0x1b, 0x1d, 0x1e, 0x1e, 0xde, 0x1e,
2450x1e, 0x1e, 0x9e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1c, 0x18, 0x10, 0x00, 0x00, 0x00,
2460x00, 0x0f, 0x07, 0x03, 0x01, 0x40, 0x40, 0x40, 0x00, 0xc0, 0x00, 0x00, 0x00,
2470x00, 0xc1, 0x01, 0x41, 0x40, 0x40, 0x00, 0xc0,
2480x1d, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x1d, 0x00, 0x10, 0x10, 0x10, 0x00,
2490x00, 0x00, 0x00, 0x1d, 0x00, 0x10, 0x10, 0x10, 0x00, 0x1d, 0x00, 0x00, 0x1d,
2500x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x02, 0x00, 0x0d,
2510x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x02,
2520x00, 0x02, 0x05, 0x18, 0x00, 0x00, 0x1d, 0x00, 0x10, 0x10, 0x10, 0x00, 0x1d,
2530x00, 0x00, 0x1d, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x00,
2540x02, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2550x00, 0x00, 0x00, 0x1c, 0x00, 0x12, 0x10, 0x12, 0x00, 0x01, 0x00, 0x10, 0x10,
2560x00, 0x1d, 0x00, 0x14, 0x10, 0x11, 0x00, 0x1d
257};
258
259/* Logo #3 - Electroplate (by Adam S. & Zakk Roberts)
260 * Definition: (N) any artifact that has been plated with a thin coat of metal by electrolysis */
261const unsigned char clocklogo_3[] = {
2620x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2630x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1c, 0x3c, 0xfc,
2640xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0x5c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2650x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfc, 0xf8,
2660x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2670x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2680x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0c, 0x1c, 0x3c, 0xfc, 0xfc, 0xfc,
2690xfc, 0xf8, 0xe8, 0xb8, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2700x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2710x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf0, 0xb0,
2720xf0, 0xd0, 0x70, 0x50, 0x70, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
2730xff, 0xff, 0xff, 0xff, 0xff, 0x55, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2740x00, 0x80, 0xc0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, 0xff, 0xff, 0xff,
2750xf8, 0xf0, 0xf0, 0xf0, 0xa0, 0xe0, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
2760x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xf0, 0xf0, 0xf0, 0x70, 0xf0,
2770xb0, 0xf0, 0x70, 0x70, 0x70, 0x60, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
2780xff, 0xff, 0xff, 0xaa, 0xff, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0,
2790xe0, 0xe0, 0x60, 0xe0, 0x20, 0x00, 0x00, 0x00,
2800x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xaf, 0xfb, 0x0e, 0x01, 0x00,
2810x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
2820xff, 0xff, 0xff, 0xff, 0xff, 0x55, 0xff, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xfe,
2830xff, 0xff, 0xff, 0xff, 0xff, 0x6b, 0x0f, 0x02, 0x01, 0x00, 0xff, 0xff, 0xff,
2840xe0, 0xe0, 0xe1, 0xe3, 0xef, 0xff, 0xff, 0xff, 0xfd, 0xf6, 0xf8, 0xe0, 0xe0,
2850xc0, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xfd, 0x0f, 0x01, 0x00,
2860x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
2870xff, 0xff, 0xff, 0xaa, 0xff, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0x5f, 0xf7,
2880x3f, 0x05, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
2890x00, 0x00, 0x03, 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xfe, 0xfb, 0xee, 0xf8, 0xd0,
2900xe0, 0xa0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f,
2910xff, 0xff, 0xff, 0xff, 0x7f, 0xd5, 0xff, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07,
2920x1f, 0x3f, 0x7f, 0xff, 0xff, 0xfd, 0xf6, 0xf8, 0xf0, 0xf0, 0xf0, 0xf1, 0xf1,
2930xf1, 0xf1, 0xf1, 0xb9, 0xfd, 0x5f, 0x7f, 0x2f, 0x3f, 0x0b, 0x07, 0x01, 0x01,
2940x00, 0x00, 0x03, 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xfe, 0xfb, 0xee, 0xf8, 0xd0,
2950xe0, 0xe0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff,
2960xff, 0x7f, 0xff, 0xaa, 0x7f, 0x03, 0x03, 0x0f, 0x3f, 0x7f, 0x7f, 0xff, 0xfd,
2970xf6, 0xfc, 0xd8, 0xe0, 0x40, 0x00, 0x00, 0x00,
2980x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
2990x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3000x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3010x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
3020x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3030x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
3040x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3050x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3060x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
307};
308
309/* Logo #4 - "Clockbox" (by Adam S.) */
310const unsigned char clocklogo_4[] = {
3110x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xf0, 0xf0, 1730x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xe0, 0xf0, 0xf0,
3120x78, 0x78, 0x3c, 0x3c, 0xfc, 0xfc, 0xfc, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 1740x78, 0x78, 0x3c, 0x3c, 0xfc, 0xfc, 0xfc, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
3130x1e, 0x3c, 0x3c, 0x3c, 0x7c, 0x7c, 0xf8, 0xf8, 0xf0, 0x30, 0x00, 0x00, 0x00, 1750x1e, 0x3c, 0x3c, 0x3c, 0x7c, 0x7c, 0xf8, 0xf8, 0xf0, 0x30, 0x00, 0x00, 0x00,
@@ -352,8 +214,7 @@ const unsigned char clocklogo_4[] = {
3520x0f, 0x1f, 0x1f, 0x1e, 0x1c, 0x1c, 0x1c, 0x1e, 0x1f, 0x0f, 0x07, 0x07, 0x01, 2140x0f, 0x1f, 0x1f, 0x1e, 0x1c, 0x1c, 0x1c, 0x1e, 0x1f, 0x0f, 0x07, 0x07, 0x01,
3530x00, 0x00, 0x00, 0x10, 0x1c, 0x1e, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x01, 0x07, 2150x00, 0x00, 0x00, 0x10, 0x1c, 0x1e, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x01, 0x07,
3540x1f, 0x1f, 0x1f, 0x1c, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2160x1f, 0x1f, 0x1f, 0x1c, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3550x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 2170x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
356};
357 218
358/****************** 219/******************
359 * Time's Up bitmap 220 * Time's Up bitmap
@@ -421,8 +282,7 @@ const unsigned char timesup[] = {
4210x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2820x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4220x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2830x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4230x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2840x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4240x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 2850x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
425};
426 286
427/* settings saved to this location */ 287/* settings saved to this location */
428static char default_filename[] = "/.rockbox/rocks/.clock_settings"; 288static char default_filename[] = "/.rockbox/rocks/.clock_settings";
@@ -460,7 +320,6 @@ char* jobs[] = {
460}; 320};
461 321
462bool done = false; /* This bool is used for most of the while loops */ 322bool done = false; /* This bool is used for most of the while loops */
463int logo = 4; /* must be set before we show the logo */
464 323
465/*********************************** 324/***********************************
466 * This is saved to default_filename 325 * This is saved to default_filename
@@ -538,8 +397,10 @@ void save_settings(void)
538 rb->lcd_clear_display(); 397 rb->lcd_clear_display();
539 398
540 /* display information */ 399 /* display information */
400 rb->snprintf(buf, sizeof(buf), "Saving Settings");
401 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
402 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 56, buf);
541 show_logo(true, true); 403 show_logo(true, true);
542 rb->lcd_puts(0, 7, "Saving...");
543 404
544 rb->lcd_update(); 405 rb->lcd_update();
545 406
@@ -550,10 +411,19 @@ void save_settings(void)
550 { 411 {
551 rb->write (fd, &settings, sizeof(struct saved_settings)); 412 rb->write (fd, &settings, sizeof(struct saved_settings));
552 rb->close(fd); 413 rb->close(fd);
553 rb->lcd_puts(0, 7, "Save Succeeded"); 414
415 rb->lcd_clearrect(0, 56, 112, 8);
416 rb->snprintf(buf, sizeof(buf), "Saved Settings");
417 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
418 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 56, buf);
554 } 419 }
555 else 420 else
556 rb->lcd_puts(0, 7, "Save Failed"); 421 {
422 rb->lcd_clearrect(0, 56, 112, 8);
423 rb->snprintf(buf, sizeof(buf), "Save Failed");
424 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
425 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 56, buf);
426 }
557 427
558 rb->lcd_update(); 428 rb->lcd_update();
559 429
@@ -573,35 +443,57 @@ void load_settings(void)
573 443
574 rb->lcd_setfont(FONT_SYSFIXED); 444 rb->lcd_setfont(FONT_SYSFIXED);
575 445
576 rb->lcd_puts(0, 6, "Clock " CLOCK_VERSION); 446 rb->snprintf(buf, sizeof(buf), "Clock %s", CLOCK_VERSION);
447 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
448 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 48, buf);
449
450 rb->snprintf(buf, sizeof(buf), "Loading Settings");
451 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
452 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 56, buf);
453 show_logo(true, true);
454 rb->lcd_update();
577 455
578 if(fd >= 0) /* does file exist? */ 456 if(fd >= 0) /* does file exist? */
579 { 457 {
580 if(rb->filesize(fd) == sizeof(struct saved_settings)) /* if so, is it the right size? */ 458 if(rb->filesize(fd) == sizeof(struct saved_settings)) /* if so, is it the right size? */
581 { 459 {
582 rb->lcd_puts(0, 7, "Loading...");
583 rb->read(fd, &settings, sizeof(struct saved_settings)); 460 rb->read(fd, &settings, sizeof(struct saved_settings));
584 rb->close(fd); 461 rb->close(fd);
585 show_logo(true, true); 462
586 rb->lcd_puts(0, 6, "Clock " CLOCK_VERSION); 463 rb->lcd_clearrect(0, 56, 112, 8);
587 rb->lcd_puts(0, 7, "Loaded settings"); 464 rb->snprintf(buf, sizeof(buf), "Loaded Settings");
465 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
466 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 56, buf);
588 } 467 }
589 else /* bail out */ 468 else /* bail out */
590 { 469 {
591 rb->lcd_puts(0, 7, "Old settings file"); 470 rb->lcd_clearrect(0, 56, 112, 8);
471 rb->snprintf(buf, sizeof(buf), "Old Settings File");
472 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
473 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 56, buf);
592 reset_settings(); 474 reset_settings();
593 } 475 }
594 } 476 }
595 else /* bail out */ 477 else /* bail out */
596 { 478 {
597 rb->lcd_puts(0, 7, "Can't find settings"); 479 rb->lcd_clearrect(0, 56, 112, 8);
480 rb->snprintf(buf, sizeof(buf), "No Settings File");
481 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
482 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 56, buf);
483
484 /* use the default in this case */
598 reset_settings(); 485 reset_settings();
599 } 486 }
600 487
601 rb->lcd_update(); 488 rb->lcd_update();
602 489
490#ifndef SIMULATOR
491 rb->ata_sleep();
492#endif
493
603 rb->sleep(HZ*2); 494 rb->sleep(HZ*2);
604 495
496 /* make the logo fly out */
605 exit_logo(); 497 exit_logo();
606} 498}
607 499
@@ -811,7 +703,7 @@ bool colon, bool lcd)
811{ 703{
812 int xpos = x; 704 int xpos = x;
813 705
814 /* Draw PM indicator */ 706 /* Draw AM/PM indicator */
815 if(settings.clock == 2) 707 if(settings.clock == 2)
816 { 708 {
817 if(settings.digital_12h) 709 if(settings.digital_12h)
@@ -837,14 +729,22 @@ bool colon, bool lcd)
837 if(settings.clock == 2) 729 if(settings.clock == 2)
838 { 730 {
839 if(settings.digital_12h) 731 if(settings.digital_12h)
732 {
840 if(hour > 12) 733 if(hour > 12)
841 hour -= 12; 734 hour -= 12;
735 if(hour == 0)
736 hour = 12;
737 }
842 } 738 }
843 else 739 else
844 { 740 {
845 if(settings.lcd_12h) 741 if(settings.lcd_12h)
742 {
846 if(hour > 12) 743 if(hour > 12)
847 hour -= 12; 744 hour -= 12;
745 if(hour == 0)
746 hour = 12;
747 }
848 } 748 }
849 749
850 draw_7seg_digit(hour / 10, xpos, y, width, height, lcd); 750 draw_7seg_digit(hour / 10, xpos, y, width, height, lcd);
@@ -1043,48 +943,53 @@ void binary(int hour, int minute, int second)
1043 ***************/ 943 ***************/
1044void show_logo(bool animate, bool show_clock_text) 944void show_logo(bool animate, bool show_clock_text)
1045{ 945{
1046 int x_position; 946 int y_position;
1047 947
1048 unsigned char *clogo = 0; 948 unsigned char *clogo = 0;
1049 clogo = (unsigned char *)clocklogo_4; 949 clogo = (unsigned char *)clocklogo;
950
951 rb->snprintf(buf, sizeof(buf), "Clock %s", CLOCK_VERSION);
952 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
1050 953
1051 /* animate logo */ 954 /* animate logo */
1052 if(animate) 955 if(animate)
1053 { 956 {
1054 /* move down the screen */ 957 /* move down the screen */
1055 for(x_position = 0; x_position <= 25; x_position++) 958 for(y_position = 0; y_position <= 25; y_position++)
1056 { 959 {
1057 rb->lcd_clearline(0, x_position/2-1, 111, x_position/2-1); 960 rb->lcd_clearline(0, y_position/2-1, 111, y_position/2-1);
1058 rb->lcd_clearline(0, x_position/2+38, 111, x_position/2+38); 961 rb->lcd_clearline(0, y_position/2+38, 111, y_position/2+38);
1059 rb->lcd_bitmap(clogo, 0, x_position/2, 112, 37, true); 962 rb->lcd_bitmap(clogo, 0, y_position/2, 112, 37, true);
1060 if(show_clock_text) 963 if(show_clock_text)
1061 rb->lcd_puts(0, 6, "Clock " CLOCK_VERSION); 964 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 48, buf);
1062 rb->lcd_update(); 965 rb->lcd_update();
1063 } 966 }
1064 /* bounce back up a little */ 967 /* bounce back up a little */
1065 for(x_position = 25; x_position >= 18; x_position--) 968 for(y_position = 25; y_position >= 18; y_position--)
1066 { 969 {
1067 rb->lcd_clearline(0, x_position/2-1, 111, x_position/2-1); 970 rb->lcd_clearline(0, y_position/2-1, 111, y_position/2-1);
1068 rb->lcd_clearline(0, x_position/2+38, 111, x_position/2+38); 971 rb->lcd_clearline(0, y_position/2+38, 111, y_position/2+38);
1069 rb->lcd_bitmap(clogo, 0, x_position/2, 112, 37, true); 972 rb->lcd_bitmap(clogo, 0, y_position/2, 112, 37, true);
1070 if(show_clock_text) 973 if(show_clock_text)
1071 rb->lcd_puts(0, 6, "Clock " CLOCK_VERSION); 974 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 48, buf);
1072 rb->lcd_update(); 975 rb->lcd_update();
1073 } 976 }
1074 /* and go back down again */ 977 /* and go back down again */
1075 for(x_position = 18; x_position <= 20; x_position++) 978 for(y_position = 18; y_position <= 20; y_position++)
1076 { 979 {
1077 rb->lcd_clearline(0, x_position/2-1, 111, x_position/2-1); 980 rb->lcd_clearline(0, y_position/2-1, 111, y_position/2-1);
1078 rb->lcd_clearline(0, x_position/2+38, 111, x_position/2+38); 981 rb->lcd_clearline(0, y_position/2+38, 111, y_position/2+38);
1079 rb->lcd_bitmap(clogo, 0, x_position/2, 112, 37, true); 982 rb->lcd_bitmap(clogo, 0, y_position/2, 112, 37, true);
1080 if(show_clock_text) 983 if(show_clock_text)
1081 rb->lcd_puts(0, 6, "Clock " CLOCK_VERSION); 984 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 48, buf);
1082 rb->lcd_update(); 985 rb->lcd_update();
1083 } 986 }
1084 } 987 }
1085 else /* don't animate, just show */ 988 else /* don't animate, just show */
1086 { 989 {
1087 rb->lcd_bitmap(clogo, 0, 10, 112, 37, true); 990 rb->lcd_bitmap(clogo, 0, 10, 112, 37, true);
991 if(show_clock_text)
992 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 48, buf);
1088 rb->lcd_update(); 993 rb->lcd_update();
1089 } 994 }
1090} 995}
@@ -1094,28 +999,28 @@ void show_logo(bool animate, bool show_clock_text)
1094 *******************/ 999 *******************/
1095void exit_logo(void) 1000void exit_logo(void)
1096{ 1001{
1097 int x_position; 1002 int y_position;
1098 1003
1099 unsigned char *clogo = 0; 1004 unsigned char *clogo = 0;
1100 clogo = (unsigned char *)clocklogo_4; 1005 clogo = (unsigned char *)clocklogo;
1101 1006
1102 /* fly downwards */ 1007 /* fly downwards */
1103 for(x_position = 20; x_position <= 128; x_position++) 1008 for(y_position = 20; y_position <= 128; y_position++)
1104 { 1009 {
1105 rb->lcd_clearline(0, x_position/2-1, 111, x_position/2-1); 1010 rb->lcd_clearline(0, y_position/2-1, 111, y_position/2-1);
1106 rb->lcd_bitmap(clogo, 0, x_position/2, 112, 37, true); 1011 rb->lcd_bitmap(clogo, 0, y_position/2, 112, 37, true);
1107 rb->lcd_update(); 1012 rb->lcd_update();
1108 } 1013 }
1109} 1014}
1110 1015
1111/******************** 1016/*******************
1112 * Rolls the credits 1017 * Rolls the credits
1113 ********************/ 1018 ******************/
1114/* The following function is pretty confusing, so 1019/* The following function is pretty confusing, so
1115 * it's extra well commented. */ 1020 * it's extra well commented. */
1116bool roll_credits(void) 1021bool roll_credits(void)
1117{ 1022{
1118 int j, namepos, jobpos; /* namepos/jobpos are x coords for strings of text */ 1023 int j=0, namepos, jobpos; /* namepos/jobpos are x coords for strings of text */
1119 int btn; 1024 int btn;
1120 int numnames = 12; /* amount of people in the credits array */ 1025 int numnames = 12; /* amount of people in the credits array */
1121 int pause; 1026 int pause;
@@ -1125,10 +1030,33 @@ bool roll_credits(void)
1125 char job[15]; 1030 char job[15];
1126 int name_w, name_h; 1031 int name_w, name_h;
1127 int job_w, job_h; 1032 int job_w, job_h;
1033 int credits_w, credits_h, credits_pos;
1034 int progress_pos, progress_percent=0;
1128 1035
1129 /* Shows "[Credits] X/X" */ 1036 /* shows "[Credits] XX/XX" */
1130 char elapsednames[16]; 1037 char elapsednames[16];
1131 1038
1039 /* put text into variable, and save the width and height of the text */
1040 rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %02d/%02d", j+1, numnames);
1041 rb->lcd_getstringsize(elapsednames, &credits_w, &credits_h);
1042
1043 /* fly in text from the left */
1044 for(credits_pos = 0 - credits_w; credits_pos <= (LCD_WIDTH/2)-(credits_w/2); credits_pos++)
1045 {
1046 rb->lcd_clearline(credits_pos-1, 0, credits_pos-1, 8);
1047 rb->lcd_putsxy(credits_pos, 0, elapsednames);
1048 rb->lcd_update(); /* update the whole lcd to slow down the loop */
1049 }
1050
1051 /* unfold progressbar from the right */
1052 for(progress_pos = LCD_WIDTH; progress_pos >= 40; progress_pos--)
1053 {
1054 rb->scrollbar(progress_pos, 9, LCD_WIDTH-progress_pos, 7, numnames*4, 0, progress_percent, HORIZONTAL);
1055 rb->lcd_clearline(0, 0, 0, 30);
1056 rb->lcd_update(); /* update the whole lcd to slow down the loop */
1057 }
1058
1059 /* now roll the credits */
1132 for(j=0; j < numnames; j++) 1060 for(j=0; j < numnames; j++)
1133 { 1061 {
1134 rb->lcd_clear_display(); 1062 rb->lcd_clear_display();
@@ -1136,7 +1064,7 @@ bool roll_credits(void)
1136 show_logo(false, false); 1064 show_logo(false, false);
1137 1065
1138 rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %02d/%02d", j+1, numnames); 1066 rb->snprintf(elapsednames, sizeof(elapsednames), "[Credits] %02d/%02d", j+1, numnames);
1139 rb->lcd_puts(0, 0, elapsednames); 1067 rb->lcd_putsxy(credits_pos-1, 0, elapsednames);
1140 1068
1141 /* used to center the text */ 1069 /* used to center the text */
1142 rb->snprintf(name, sizeof(name), "%s", credits[j]); 1070 rb->snprintf(name, sizeof(name), "%s", credits[j]);
@@ -1144,6 +1072,8 @@ bool roll_credits(void)
1144 rb->lcd_getstringsize(name, &name_w, &name_h); 1072 rb->lcd_getstringsize(name, &name_w, &name_h);
1145 rb->lcd_getstringsize(job, &job_w, &job_h); 1073 rb->lcd_getstringsize(job, &job_w, &job_h);
1146 1074
1075 rb->scrollbar(progress_pos, 9, LCD_WIDTH-progress_pos, 7, numnames*4, 0, progress_percent, HORIZONTAL);
1076
1147 /* line 1 flies in */ 1077 /* line 1 flies in */
1148 for (namepos=0-name_w; namepos < (LCD_WIDTH/2)-(name_w/2)-2; namepos++) 1078 for (namepos=0-name_w; namepos < (LCD_WIDTH/2)-(name_w/2)-2; namepos++)
1149 { 1079 {
@@ -1157,6 +1087,10 @@ bool roll_credits(void)
1157 return false; 1087 return false;
1158 } 1088 }
1159 1089
1090 progress_percent++;
1091 rb->scrollbar(progress_pos, 9, LCD_WIDTH-progress_pos, 7, numnames*4, 0, progress_percent, HORIZONTAL);
1092 rb->lcd_update_rect(progress_pos, 8, 112-progress_pos, 8);
1093
1160 /* now line 2 flies in */ 1094 /* now line 2 flies in */
1161 for(jobpos=LCD_WIDTH; jobpos > (LCD_WIDTH/2)-(job_w+2)/2; jobpos--) /* we use (job_w+2) to ensure it fits on the LCD */ 1095 for(jobpos=LCD_WIDTH; jobpos > (LCD_WIDTH/2)-(job_w+2)/2; jobpos--) /* we use (job_w+2) to ensure it fits on the LCD */
1162 { 1096 {
@@ -1170,6 +1104,10 @@ bool roll_credits(void)
1170 return false; 1104 return false;
1171 } 1105 }
1172 1106
1107 progress_percent++;
1108 rb->scrollbar(progress_pos, 9, LCD_WIDTH-progress_pos, 7, numnames*4, 0, progress_percent, HORIZONTAL);
1109 rb->lcd_update_rect(progress_pos, 8, 112-progress_pos, 8);
1110
1173 /* pause (2s) and scan for button presses */ 1111 /* pause (2s) and scan for button presses */
1174 for (pause = 0; pause < 10; pause++) 1112 for (pause = 0; pause < 10; pause++)
1175 { 1113 {
@@ -1188,6 +1126,10 @@ bool roll_credits(void)
1188 return false; 1126 return false;
1189 } 1127 }
1190 1128
1129 progress_percent++;
1130 rb->scrollbar(progress_pos, 9, LCD_WIDTH-progress_pos, 7, numnames*4, 0, progress_percent, HORIZONTAL);
1131 rb->lcd_update_rect(progress_pos, 8, 112-progress_pos, 8);
1132
1191 /* fly out both lines at same time */ 1133 /* fly out both lines at same time */
1192 namepos=((LCD_WIDTH/2)-(name_w/2))+8; 1134 namepos=((LCD_WIDTH/2)-(name_w/2))+8;
1193 jobpos=((LCD_WIDTH/2)-(job_w+2)/2)-8; 1135 jobpos=((LCD_WIDTH/2)-(job_w+2)/2)-8;
@@ -1207,6 +1149,9 @@ bool roll_credits(void)
1207 jobpos--; 1149 jobpos--;
1208 } 1150 }
1209 1151
1152 progress_percent++;
1153 rb->scrollbar(progress_pos, 9, LCD_WIDTH-progress_pos, 7, numnames*4, 0, progress_percent, HORIZONTAL);
1154
1210 /* pause (.2s) */ 1155 /* pause (.2s) */
1211 rb->sleep(HZ/2); 1156 rb->sleep(HZ/2);
1212 1157
@@ -1215,6 +1160,23 @@ bool roll_credits(void)
1215 if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) 1160 if (btn != BUTTON_NONE && !(btn & BUTTON_REL))
1216 return false; 1161 return false;
1217 } 1162 }
1163
1164 /* now make the text exit to the right */
1165 for(credits_pos = (LCD_WIDTH/2)-(credits_w/2); credits_pos <= 112; credits_pos++)
1166 {
1167 rb->lcd_clearline(credits_pos-1, 0, credits_pos-1, 8);
1168 rb->lcd_putsxy(credits_pos, 0, elapsednames);
1169 rb->lcd_update();
1170 }
1171
1172 /* fold progressbar in to the right */
1173 for(progress_pos = 42; progress_pos < 112; progress_pos++)
1174 {
1175 rb->lcd_clearline(progress_pos-1, 8, progress_pos-1, 16);
1176 rb->scrollbar(progress_pos, 9, LCD_WIDTH-progress_pos, 7, numnames*4, 0, progress_percent, HORIZONTAL);
1177 rb->lcd_update(); /* update the whole lcd to slow down the loop */
1178 }
1179
1218 exit_logo(); 1180 exit_logo();
1219 1181
1220 return true; 1182 return true;
@@ -1230,7 +1192,9 @@ bool show_credits(void)
1230 1192
1231 rb->lcd_clear_display(); 1193 rb->lcd_clear_display();
1232 1194
1233 rb->lcd_puts(0, 7, "Credit Roll..."); 1195 rb->snprintf(buf, sizeof(buf), "Credits");
1196 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
1197 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 56, buf);
1234 1198
1235 /* show the logo with an animation and the clock version text */ 1199 /* show the logo with an animation and the clock version text */
1236 show_logo(true, true); 1200 show_logo(true, true);
@@ -1292,10 +1256,10 @@ bool f1_screen(void)
1292 rb->lcd_puts(0, 0, "At any mode, [F3]"); 1256 rb->lcd_puts(0, 0, "At any mode, [F3]");
1293 rb->lcd_puts(0, 1, "opens the Options"); 1257 rb->lcd_puts(0, 1, "opens the Options");
1294 rb->lcd_puts(0, 2, "screen. In Options"); 1258 rb->lcd_puts(0, 2, "screen. In Options");
1295 rb->lcd_puts(0, 3, "move the cursor"); 1259 rb->lcd_puts(0, 3, "use UP/DN to move");
1296 rb->lcd_puts(0, 4, "with UP/DOWN and"); 1260 rb->lcd_puts(0, 4, "and PLAY to toggle.");
1297 rb->lcd_puts(0, 5, "use PLAY to toggle"); 1261 rb->lcd_puts(0, 5, "[ON+F3] shows you");
1298 rb->lcd_puts(0, 6, "selected option."); 1262 rb->lcd_puts(0, 6, "General Settings.");
1299 rb->lcd_puts(0, 7, "<< BACK 3/9 NEXT >>"); 1263 rb->lcd_puts(0, 7, "<< BACK 3/9 NEXT >>");
1300 } 1264 }
1301 else if(screen == 4) 1265 else if(screen == 4)
@@ -1393,76 +1357,6 @@ bool f1_screen(void)
1393 return true; 1357 return true;
1394} 1358}
1395 1359
1396/*************************
1397 * F2 Screen - Pick a Logo
1398 * [[ NO LONGER USED ]]
1399 ************************/
1400void f2_screen(void)
1401{
1402 rb->lcd_clear_display();
1403 rb->splash(HZ, true, "LEFT/RIGHT to choose logo");
1404 rb->lcd_update();
1405 rb->lcd_clear_display();
1406 rb->splash(HZ, true, "F2 to select and exit");
1407 rb->lcd_update();
1408 rb->lcd_clear_display();
1409
1410 /* let's make sure that the logo isn't invalid */
1411 if(logo > 4)
1412 logo = 1;
1413
1414 done = false;
1415
1416 while(!done)
1417 {
1418 show_logo(false, false);
1419
1420 rb->lcd_clearrect(0, 48, 112, 16);
1421
1422 if(logo == 1)
1423 {
1424 rb->lcd_puts(0, 0, "1) 'Default'");
1425 rb->lcd_puts(0, 6, "By Zakk Roberts");
1426 }
1427 else if(logo == 2)
1428 {
1429 rb->lcd_puts(0, 0, "2) 'Digital'");
1430 rb->lcd_puts(0, 6, "By Zakk Roberts");
1431 }
1432 else if(logo == 3)
1433 {
1434 rb->lcd_puts(0, 0, "3) 'Electroplate'");
1435 rb->lcd_puts(0, 6, "By Adam S. and");
1436 rb->lcd_puts(0, 7, "Zakk Roberts");
1437 }
1438 else
1439 {
1440 rb->lcd_puts(0, 0, "4) 'Clockbox'");
1441 rb->lcd_puts(0, 6, "By Adam S.");
1442 }
1443
1444 rb->lcd_update();
1445
1446 switch(rb->button_get_w_tmo(HZ/4))
1447 {
1448 case BUTTON_F2:
1449 case BUTTON_OFF:
1450 done = true;
1451 break;
1452
1453 case BUTTON_RIGHT:
1454 if(logo < 4)
1455 logo++;
1456 break;
1457
1458 case BUTTON_LEFT:
1459 if(logo > 1)
1460 logo--;
1461 break;
1462 }
1463 }
1464}
1465
1466/********************* 1360/*********************
1467 * F3 Screen - OPTIONS 1361 * F3 Screen - OPTIONS
1468 ********************/ 1362 ********************/
@@ -1856,6 +1750,116 @@ bool f3_screen(void)
1856 return true; 1750 return true;
1857} 1751}
1858 1752
1753/**********************************
1754 * Confirm resetting of settings,
1755 * used in general_settings() */
1756void confirm_reset(void)
1757{
1758 bool ask_reset_done = false;
1759
1760 while(!ask_reset_done)
1761 {
1762 rb->lcd_clear_display();
1763
1764 rb->snprintf(buf, sizeof(buf), "Reset Settings?");
1765 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
1766 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 0, buf);
1767
1768 rb->lcd_puts(0, 2, "PLAY = Yes");
1769 rb->lcd_puts(0, 3, "Any Other = No");
1770
1771 rb->lcd_update();
1772
1773 switch(rb->button_get_w_tmo(HZ/4))
1774 {
1775 case BUTTON_PLAY:
1776 reset_settings();
1777 rb->splash(HZ*2, true, "Settings Reset");
1778 ask_reset_done = true;
1779 break;
1780
1781 case BUTTON_F1 :
1782 ask_reset_done = true;
1783 break;
1784 }
1785 }
1786}
1787
1788/************************************
1789 * General settings. Reset, save, etc
1790 ***********************************/
1791void general_settings(void)
1792{
1793 int cursorpos = 1;
1794
1795 done = false;
1796
1797 while(!done)
1798 {
1799 rb->lcd_clear_display();
1800
1801 rb->snprintf(buf, sizeof(buf), "General Settings");
1802 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
1803 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 0, buf);
1804
1805 rb->lcd_puts(2, 2, "Reset Settings");
1806 rb->lcd_puts(2, 3, "Save Settings");
1807 rb->lcd_puts(2, 4, "Show Counter");
1808
1809 rb->snprintf(buf, sizeof(buf), "UP/DOWN to move");
1810 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
1811 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 48, buf);
1812 rb->snprintf(buf, sizeof(buf), "PLAY to select");
1813 rb->lcd_getstringsize(buf, &buf_w, &buf_h);
1814 rb->lcd_putsxy(LCD_WIDTH/2-buf_w/2, 56, buf);
1815
1816 rb->lcd_bitmap(arrow, 1, 17, 8, 6, true);
1817 rb->lcd_bitmap(arrow, 1, 25, 8, 6, true);
1818 rb->checkbox(1, 33, 8, 6, display_counter);
1819
1820 switch(cursorpos)
1821 {
1822 case 1:
1823 rb->lcd_invertrect(0, 16, 112, 8); break;
1824
1825 case 2:
1826 rb->lcd_invertrect(0, 24, 112, 8); break;
1827
1828 case 3:
1829 rb->lcd_invertrect(0, 32, 112, 8); break;
1830 }
1831
1832 rb->lcd_update();
1833
1834 switch(rb->button_get_w_tmo(HZ/4))
1835 {
1836 case BUTTON_OFF:
1837 case BUTTON_F3:
1838 done = true;
1839 break;
1840
1841 case BUTTON_UP:
1842 if(cursorpos > 1)
1843 cursorpos--;
1844 break;
1845
1846 case BUTTON_DOWN:
1847 if(cursorpos < 3)
1848 cursorpos++;
1849 break;
1850
1851 case BUTTON_PLAY:
1852 if(cursorpos == 1)
1853 confirm_reset();
1854 else if(cursorpos == 2)
1855 save_settings();
1856 else
1857 display_counter = !display_counter;
1858 break;
1859 }
1860 }
1861}
1862
1859/**************************************** 1863/****************************************
1860 * Draws the extras, IE border, digits... 1864 * Draws the extras, IE border, digits...
1861 ***************************************/ 1865 ***************************************/
@@ -2024,11 +2028,6 @@ void draw_extras(int year, int day, int month, int hour, int minute, int second)
2024void select_mode(void) 2028void select_mode(void)
2025{ 2029{
2026 int cursorpos = settings.clock; 2030 int cursorpos = settings.clock;
2027 bool a = false; /* (a)nalog */
2028 bool d = false; /* (d)igital */
2029 bool l = false; /* (l)cd */
2030 bool f = false; /* (f)ullscreen */
2031 bool b = false; /* (b)inary */
2032 2031
2033 done = false; 2032 done = false;
2034 2033
@@ -2045,21 +2044,12 @@ void select_mode(void)
2045 rb->lcd_puts(0, 6, "UP/DOWN: Choose"); 2044 rb->lcd_puts(0, 6, "UP/DOWN: Choose");
2046 rb->lcd_puts(0, 7, "PLAY:Go|OFF:Cancel"); 2045 rb->lcd_puts(0, 7, "PLAY:Go|OFF:Cancel");
2047 2046
2048 switch(settings.clock) 2047 /* draw an arrow next to all of them */
2049 { 2048 rb->lcd_bitmap(arrow, 1, 9, 8, 6, true);
2050 case 1: a=true; d=l=f=b=false; break; 2049 rb->lcd_bitmap(arrow, 1, 17, 8, 6, true);
2051 case 2: d=true; a=l=f=b=false; break; 2050 rb->lcd_bitmap(arrow, 1, 25, 8, 6, true);
2052 case 3: l=true; a=d=f=b=false; break; 2051 rb->lcd_bitmap(arrow, 1, 33, 8, 6, true);
2053 case 4: f=true; a=d=l=b=false; break; 2052 rb->lcd_bitmap(arrow, 1, 41, 8, 6, true);
2054 case 5: b=true; a=d=l=f=false; break;
2055 }
2056
2057 /* draw a checkbox next to current mode */
2058 rb->checkbox(1, 9, 8, 6, a);
2059 rb->checkbox(1, 17, 8, 6, d);
2060 rb->checkbox(1, 25, 8, 6, l);
2061 rb->checkbox(1, 33, 8, 6, f);
2062 rb->checkbox(1, 41, 8, 6, b);
2063 2053
2064 /* draw line selector */ 2054 /* draw line selector */
2065 switch(cursorpos) 2055 switch(cursorpos)
@@ -2109,6 +2099,7 @@ void counter_finished(void)
2109 int btn; 2099 int btn;
2110 int xpos = 0; 2100 int xpos = 0;
2111 bool bouncing_up = false; 2101 bool bouncing_up = false;
2102 bool led_on = true;
2112 unsigned char *times_up = 0; 2103 unsigned char *times_up = 0;
2113 times_up = (unsigned char *)timesup; 2104 times_up = (unsigned char *)timesup;
2114 2105
@@ -2127,7 +2118,7 @@ void counter_finished(void)
2127 rb->lcd_update(); 2118 rb->lcd_update();
2128 2119
2129 /* pause */ 2120 /* pause */
2130 rb->sleep(HZ/15); 2121 rb->sleep(HZ/25);
2131 2122
2132 /* move bitmap up/down 1px */ 2123 /* move bitmap up/down 1px */
2133 if(bouncing_up) 2124 if(bouncing_up)
@@ -2136,6 +2127,8 @@ void counter_finished(void)
2136 xpos--; 2127 xpos--;
2137 else 2128 else
2138 bouncing_up = false; 2129 bouncing_up = false;
2130
2131 led_on = true;
2139 } 2132 }
2140 else 2133 else
2141 { 2134 {
@@ -2143,12 +2136,27 @@ void counter_finished(void)
2143 xpos++; 2136 xpos++;
2144 else 2137 else
2145 bouncing_up = true; 2138 bouncing_up = true;
2139
2140 led_on = false;
2146 } 2141 }
2147 2142
2143 /* turn red led on and off */
2144#ifndef SIMULATOR
2145 if(led_on)
2146 or_b(0x40, &PBDRL);
2147 else
2148 and_b(~0x40, &PBDRL);
2149#endif
2150
2148 /* exit on keypress */ 2151 /* exit on keypress */
2149 btn = rb->button_get(false); 2152 btn = rb->button_get(false);
2150 if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) 2153 if (btn != BUTTON_NONE && !(btn & BUTTON_REL))
2154 {
2155#ifndef SIMULATOR
2156 and_b(~0x40, &PBDRL); /* shut off the red led */
2157#endif
2151 done = true; 2158 done = true;
2159 }
2152 } 2160 }
2153} 2161}
2154 2162
@@ -2255,7 +2263,6 @@ void counter_options(void)
2255 rb->checkbox(1, 17, 8, 6, counting_up); 2263 rb->checkbox(1, 17, 8, 6, counting_up);
2256 rb->checkbox(1, 25, 8, 6, !counting_up); 2264 rb->checkbox(1, 25, 8, 6, !counting_up);
2257 2265
2258
2259 /* draw a cursor */ 2266 /* draw a cursor */
2260 switch(cursorpos) 2267 switch(cursorpos)
2261 { 2268 {
@@ -2276,8 +2283,7 @@ void counter_options(void)
2276 /* button scan */ 2283 /* button scan */
2277 switch(rb->button_get_w_tmo(HZ/4)) 2284 switch(rb->button_get_w_tmo(HZ/4))
2278 { 2285 {
2279 case BUTTON_F2: /* exit screen */ 2286 case BUTTON_OFF: /* exit screen */
2280 case BUTTON_OFF:
2281 current = counting_up; 2287 current = counting_up;
2282 if(current != original) 2288 if(current != original)
2283 counter = 0; 2289 counter = 0;
@@ -2429,11 +2435,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
2429 { 2435 {
2430 rb->lcd_clear_display(); 2436 rb->lcd_clear_display();
2431 2437
2432 /* flash counter if needed */ 2438 /* flash counter if needed
2433 if(!counting && displayed_value != 0) 2439 if(!counting && displayed_value != 0)
2434 display_counter = !display_counter; 2440 display_counter = !display_counter;
2435 else 2441 else
2436 display_counter = true; 2442 display_counter = true; */
2437 2443
2438 /* and then print it */ 2444 /* and then print it */
2439 show_counter(); 2445 show_counter();
@@ -2515,8 +2521,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
2515 rb->lcd_drawline((LCD_WIDTH/2)-1, (LCD_HEIGHT/2)-3, 2521 rb->lcd_drawline((LCD_WIDTH/2)-1, (LCD_HEIGHT/2)-3,
2516 (LCD_WIDTH/2)+1, (LCD_HEIGHT/2)-3); 2522 (LCD_WIDTH/2)+1, (LCD_HEIGHT/2)-3);
2517 rb->lcd_drawpixel(LCD_WIDTH/2, LCD_HEIGHT/2); 2523 rb->lcd_drawpixel(LCD_WIDTH/2, LCD_HEIGHT/2);
2518
2519
2520 } 2524 }
2521 /************** 2525 /**************
2522 * Digital mode 2526 * Digital mode
@@ -2615,6 +2619,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
2615 } 2619 }
2616 } 2620 }
2617 2621
2622 if(settings.analog_time == 2 && temphour == 0)
2623 temphour = 12;
2618 if(settings.analog_time == 2 && temphour > 12) 2624 if(settings.analog_time == 2 && temphour > 12)
2619 temphour -= 12; 2625 temphour -= 12;
2620 2626
@@ -2636,7 +2642,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
2636 /* restore set backlight timeout */ 2642 /* restore set backlight timeout */
2637 rb->backlight_set_timeout( 2643 rb->backlight_set_timeout(
2638 rb->global_settings->backlight_timeout); 2644 rb->global_settings->backlight_timeout);
2639 2645
2640 return PLUGIN_OK; 2646 return PLUGIN_OK;
2641 2647
2642 case BUTTON_ON | BUTTON_REL: /* credit roll */ 2648 case BUTTON_ON | BUTTON_REL: /* credit roll */
@@ -2647,15 +2653,18 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
2647 counter_options(); 2653 counter_options();
2648 break; 2654 break;
2649 2655
2656 case BUTTON_ON | BUTTON_F3: /* general settings */
2657 general_settings();
2658 break;
2659
2650 case BUTTON_F1 | BUTTON_REL: /* help */ 2660 case BUTTON_F1 | BUTTON_REL: /* help */
2651 f1_screen(); 2661 f1_screen();
2652 break; 2662 break;
2653 2663
2654 case BUTTON_F2 | BUTTON_REL: /* start/stop counter */ 2664 case BUTTON_F2 | BUTTON_REL: /* start/stop counter */
2655 if(settings.clock != 5) 2665 if(display_counter)
2656 { 2666 {
2657 /* Ignore if the counter was reset */ 2667 if(!f2_held) /* Ignore if the counter was reset */
2658 if(!f2_held)
2659 { 2668 {
2660 if(counting) 2669 if(counting)
2661 { 2670 {
@@ -2673,9 +2682,12 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
2673 break; 2682 break;
2674 2683
2675 case BUTTON_F2 | BUTTON_REPEAT: /* reset counter */ 2684 case BUTTON_F2 | BUTTON_REPEAT: /* reset counter */
2676 f2_held = true; /* Ignore the release event */ 2685 if(display_counter)
2677 counter = 0; 2686 {
2678 start_tick = *rb->current_tick; 2687 f2_held = true; /* Ignore the release event */
2688 counter = 0;
2689 start_tick = *rb->current_tick;
2690 }
2679 break; 2691 break;
2680 2692
2681 case BUTTON_F3: /* options */ 2693 case BUTTON_F3: /* options */