A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Daniel Stenberg
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 **************************************************************************/
21#include "plugin.h"
22#include "time.h"
23#include "fixedpoint.h"
24#include "lib/pluginlib_actions.h"
25
26
27#define SS_TITLE "Bouncer"
28
29#define YSPEED 2
30#define XSPEED 3
31#define YADD -4
32
33/* this set the context to use with PLA */
34static const struct button_mapping *plugin_contexts[] = { pla_main_ctx };
35
36/* We set button maping with PLA */
37
38#ifdef HAVE_SCROLLWHEEL
39#define BOUNCE_LEFT PLA_SCROLL_BACK
40#define BOUNCE_LEFT_REPEAT PLA_SCROLL_BACK_REPEAT
41#define BOUNCE_RIGHT PLA_SCROLL_FWD
42#define BOUNCE_RIGHT_REPEAT PLA_SCROLL_FWD_REPEAT
43#else
44#define BOUNCE_LEFT PLA_LEFT
45#define BOUNCE_LEFT_REPEAT PLA_LEFT_REPEAT
46#define BOUNCE_RIGHT PLA_RIGHT
47#define BOUNCE_RIGHT_REPEAT PLA_RIGHT_REPEAT
48#endif
49
50#define BOUNCE_QUIT PLA_EXIT
51
52#if (CONFIG_KEYPAD == IPOD_1G2G_PAD) \
53 || (CONFIG_KEYPAD == IPOD_3G_PAD) \
54 || (CONFIG_KEYPAD == IPOD_4G_PAD)
55#define BOUNCE_QUIT2 PLA_UP
56#define BOUNCE_DOWN PLA_LEFT
57#define BOUNCE_DOWN_REPEAT PLA_LEFT_REPEAT
58#define BOUNCE_UP PLA_RIGHT
59#define BOUNCE_UP_REPEAT PLA_RIGHT_REPEAT
60#else
61#define BOUNCE_QUIT2 PLA_CANCEL
62#define BOUNCE_DOWN PLA_DOWN
63#define BOUNCE_DOWN_REPEAT PLA_DOWN_REPEAT
64#define BOUNCE_UP PLA_UP
65#define BOUNCE_UP_REPEAT PLA_UP_REPEAT
66#endif
67#define BOUNCE_MODE PLA_SELECT
68
69#define LETTER_WIDTH 11
70#define LETTER_HEIGHT 16
71
72const unsigned char char_gen_12x16[][22] =
73{
74 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
75 { 0x00,0x00,0x00,0x7c,0xff,0xff,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,0x00,0x00 },
76 { 0x00,0x00,0x3c,0x3c,0x00,0x00,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
77 { 0x00,0x10,0x90,0xf0,0x7e,0x1e,0x90,0xf0,0x7e,0x1e,0x10,0x02,0x1e,0x1f,0x03,0x02,0x1e,0x1f,0x03,0x02,0x00,0x00 },
78 { 0x00,0x78,0xfc,0xcc,0xff,0xff,0xcc,0xcc,0x88,0x00,0x00,0x00,0x04,0x0c,0x0c,0x3f,0x3f,0x0c,0x0f,0x07,0x00,0x00 },
79 { 0x00,0x38,0x38,0x38,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x38,0x38,0x38,0x00 },
80 { 0x00,0x00,0xb8,0xfc,0xc6,0xe2,0x3e,0x1c,0x00,0x00,0x00,0x00,0x1f,0x3f,0x31,0x21,0x37,0x1e,0x1c,0x36,0x22,0x00 },
81 { 0x00,0x00,0x00,0x27,0x3f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
82 { 0x00,0x00,0xf0,0xfc,0xfe,0x07,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x03,0x0f,0x1f,0x38,0x20,0x20,0x00,0x00,0x00 },
83 { 0x00,0x00,0x01,0x01,0x07,0xfe,0xfc,0xf0,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x38,0x1f,0x0f,0x03,0x00,0x00,0x00 },
84 { 0x00,0x98,0xb8,0xe0,0xf8,0xf8,0xe0,0xb8,0x98,0x00,0x00,0x00,0x0c,0x0e,0x03,0x0f,0x0f,0x03,0x0e,0x0c,0x00,0x00 },
85 { 0x00,0x80,0x80,0x80,0xf0,0xf0,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x0f,0x0f,0x01,0x01,0x01,0x00,0x00 },
86 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb8,0xf8,0x78,0x00,0x00,0x00,0x00,0x00 },
87 { 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00 },
88 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x00,0x00,0x00,0x00,0x00 },
89 { 0x00,0x00,0x00,0x00,0x80,0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x18,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00 },
90 { 0xf8,0xfe,0x06,0x03,0x83,0xc3,0x63,0x33,0x1e,0xfe,0xf8,0x07,0x1f,0x1e,0x33,0x31,0x30,0x30,0x30,0x18,0x1f,0x07 },
91 { 0x00,0x00,0x0c,0x0c,0x0e,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x3f,0x3f,0x30,0x30,0x30,0x00 },
92 { 0x1c,0x1e,0x07,0x03,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x30,0x38,0x3c,0x3e,0x37,0x33,0x31,0x30,0x30,0x30,0x30 },
93 { 0x0c,0x0e,0x07,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0x7e,0x3c,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0e },
94 { 0xc0,0xe0,0x70,0x38,0x1c,0x0e,0x07,0xff,0xff,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x3f,0x3f,0x03,0x03 },
95 { 0x3f,0x7f,0x63,0x63,0x63,0x63,0x63,0x63,0xe3,0xc3,0x83,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f },
96 { 0xc0,0xf0,0xf8,0xdc,0xce,0xc7,0xc3,0xc3,0xc3,0x80,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
97 { 0x03,0x03,0x03,0x03,0x03,0x03,0xc3,0xf3,0x3f,0x0f,0x03,0x00,0x00,0x00,0x30,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00 },
98 { 0x00,0xbc,0xfe,0xe7,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x0f,0x1f,0x39,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f },
99 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xfc,0x00,0x00,0x30,0x30,0x30,0x38,0x1c,0x0e,0x07,0x03,0x00 },
100 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00 },
101 { 0x00,0x00,0x00,0x70,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0xfc,0x7c,0x00,0x00,0x00,0x00,0x00 },
102 { 0x00,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00,0x00 },
103 { 0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00 },
104 { 0x00,0x03,0x07,0x0e,0x1c,0x38,0xf0,0xe0,0xc0,0x00,0x00,0x00,0x30,0x38,0x1c,0x0e,0x07,0x03,0x01,0x00,0x00,0x00 },
105 { 0x1c,0x1e,0x07,0x03,0x83,0xc3,0xe3,0x77,0x3e,0x1c,0x00,0x00,0x00,0x00,0x00,0x37,0x37,0x00,0x00,0x00,0x00,0x00 },
106 { 0xf8,0xfe,0x07,0xf3,0xfb,0x1b,0xfb,0xfb,0x07,0xfe,0xf8,0x0f,0x1f,0x18,0x33,0x37,0x36,0x37,0x37,0x36,0x03,0x01 },
107 { 0x00,0x00,0xe0,0xfc,0x1f,0x1f,0xfc,0xe0,0x00,0x00,0x00,0x38,0x3f,0x07,0x06,0x06,0x06,0x06,0x07,0x3f,0x38,0x00 },
108 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xe7,0xfe,0xbc,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
109 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x03,0x07,0x0e,0x0c,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x38,0x1c,0x0c,0x00 },
110 { 0xff,0xff,0x03,0x03,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
111 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
112 { 0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0x03,0x03,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
113 { 0xf0,0xfc,0x0e,0x07,0x03,0xc3,0xc3,0xc3,0xc7,0xc6,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
114 { 0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
115 { 0x00,0x00,0x03,0x03,0xff,0xff,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
116 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x0e,0x1e,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
117 { 0xff,0xff,0xc0,0xe0,0xf0,0x38,0x1c,0x0e,0x07,0x03,0x00,0x3f,0x3f,0x00,0x01,0x03,0x07,0x0e,0x1c,0x38,0x30,0x00 },
118 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00 },
119 { 0xff,0xff,0x1e,0x78,0xe0,0xe0,0x78,0x1e,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x01,0x01,0x00,0x00,0x3f,0x3f,0x00 },
120 { 0xff,0xff,0x0e,0x38,0xf0,0xc0,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x00,0x00,0x00,0x03,0x07,0x1c,0x3f,0x3f,0x00 },
121 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x30,0x38,0x1c,0x0f,0x03,0x00 },
122 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00 },
123 { 0xf0,0xfc,0x0e,0x07,0x03,0x03,0x07,0x0e,0xfc,0xf0,0x00,0x03,0x0f,0x1c,0x38,0x30,0x36,0x3e,0x1c,0x3f,0x33,0x00 },
124 { 0xff,0xff,0x83,0x83,0x83,0x83,0x83,0xc7,0xfe,0x7c,0x00,0x3f,0x3f,0x01,0x01,0x03,0x07,0x0f,0x1d,0x38,0x30,0x00 },
125 { 0x3c,0x7e,0xe7,0xc3,0xc3,0xc3,0xc3,0xc7,0x8e,0x0c,0x00,0x0c,0x1c,0x38,0x30,0x30,0x30,0x30,0x39,0x1f,0x0f,0x00 },
126 { 0x00,0x03,0x03,0x03,0xff,0xff,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
127 { 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x07,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x07,0x00 },
128 { 0x07,0x3f,0xf8,0xc0,0x00,0x00,0xc0,0xf8,0x3f,0x07,0x00,0x00,0x00,0x01,0x0f,0x3e,0x3e,0x0f,0x01,0x00,0x00,0x00 },
129 { 0xff,0xff,0x00,0x00,0x80,0x80,0x00,0x00,0xff,0xff,0x00,0x3f,0x3f,0x1c,0x06,0x03,0x03,0x06,0x1c,0x3f,0x3f,0x00 },
130 { 0x03,0x0f,0x1c,0x30,0xe0,0xe0,0x30,0x1c,0x0f,0x03,0x00,0x30,0x3c,0x0e,0x03,0x01,0x01,0x03,0x0e,0x3c,0x30,0x00 },
131 { 0x03,0x0f,0x3c,0xf0,0xc0,0xc0,0xf0,0x3c,0x0f,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
132 { 0x03,0x03,0x03,0x03,0xc3,0xe3,0x33,0x1f,0x0f,0x03,0x00,0x30,0x3c,0x3e,0x33,0x31,0x30,0x30,0x30,0x30,0x30,0x00 },
133 { 0x00,0x00,0xff,0xff,0x03,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
134 { 0x0e,0x1c,0x38,0x70,0xe0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x07,0x0e,0x1c,0x18 },
135 { 0x00,0x00,0x03,0x03,0x03,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00,0x00,0x00 },
136 { 0x60,0x70,0x38,0x1c,0x0e,0x07,0x0e,0x1c,0x38,0x70,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
137 { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 },
138 { 0x00,0x00,0x00,0x00,0x3e,0x7e,0x4e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
139 { 0x00,0x40,0x60,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x1c,0x3e,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x3f,0x00 },
140 { 0xff,0xff,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x30,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
141 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x18,0x08,0x00 },
142 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0xe0,0xc0,0xff,0xff,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x30,0x3f,0x3f,0x00 },
143 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xc0,0x80,0x00,0x0f,0x1f,0x3b,0x33,0x33,0x33,0x33,0x33,0x13,0x01,0x00 },
144 { 0xc0,0xc0,0xfc,0xfe,0xc7,0xc3,0xc3,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
145 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x03,0xc7,0xce,0xcc,0xcc,0xcc,0xcc,0xe6,0x7f,0x3f,0x00 },
146 { 0xff,0xff,0xc0,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00 },
147 { 0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
148 { 0x00,0x00,0x00,0x00,0x00,0x60,0xec,0xec,0x00,0x00,0x00,0x00,0x00,0x60,0xe0,0xc0,0xc0,0xff,0x7f,0x00,0x00,0x00 },
149 { 0x00,0xff,0xff,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x00,0x00,0x3f,0x3f,0x03,0x07,0x0f,0x1c,0x38,0x30,0x00,0x00 },
150 { 0x00,0x00,0x00,0x03,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x3f,0x3f,0x30,0x30,0x00,0x00,0x00 },
151 { 0xe0,0xc0,0xe0,0xe0,0xc0,0xc0,0xe0,0xe0,0xc0,0x80,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00,0x00,0x3f,0x3f,0x00 },
152 { 0x00,0xe0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00 },
153 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x38,0x1f,0x0f,0x00 },
154 { 0xe0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xc0,0x80,0x00,0xff,0xff,0x0c,0x18,0x18,0x18,0x18,0x1c,0x0f,0x07,0x00 },
155 { 0x80,0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x00,0x07,0x0f,0x1c,0x18,0x18,0x18,0x18,0x0c,0xff,0xff,0x00 },
156 { 0x00,0xe0,0xe0,0xc0,0x60,0x60,0x60,0x60,0xe0,0xc0,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
157 { 0xc0,0xe0,0x60,0x60,0x60,0x60,0x60,0x40,0x00,0x00,0x00,0x11,0x33,0x33,0x33,0x33,0x33,0x3f,0x1e,0x00,0x00,0x00 },
158 { 0x60,0x60,0xfe,0xfe,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x3f,0x30,0x30,0x30,0x30,0x00,0x00,0x00 },
159 { 0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0x00,0x0f,0x1f,0x38,0x30,0x30,0x30,0x30,0x18,0x3f,0x3f,0x00 },
160 { 0x60,0xe0,0x80,0x00,0x00,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x01,0x07,0x1e,0x38,0x38,0x1e,0x07,0x01,0x00,0x00 },
161 { 0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x07,0x1f,0x38,0x1c,0x0f,0x0f,0x1c,0x38,0x1f,0x07,0x00 },
162 { 0x60,0xe0,0xc0,0x80,0x00,0x80,0xc0,0xe0,0x60,0x00,0x00,0x30,0x38,0x1d,0x0f,0x07,0x0f,0x1d,0x38,0x30,0x00,0x00 },
163 { 0x00,0x60,0xe0,0x80,0x00,0x00,0x80,0xe0,0x60,0x00,0x00,0x00,0x00,0x81,0xe7,0x7e,0x1e,0x07,0x01,0x00,0x00,0x00 },
164 { 0x60,0x60,0x60,0x60,0x60,0xe0,0xe0,0x60,0x20,0x00,0x00,0x30,0x38,0x3c,0x36,0x33,0x31,0x30,0x30,0x30,0x00,0x00 },
165 { 0x00,0x80,0xc0,0xfc,0x7e,0x07,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x01,0x1f,0x3f,0x70,0x60,0x60,0x60,0x00,0x00 },
166 { 0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0x00,0x00,0x00,0x00,0x00 },
167 { 0x00,0x03,0x03,0x03,0x07,0x7e,0xfc,0xc0,0x80,0x00,0x00,0x00,0x60,0x60,0x60,0x70,0x3f,0x1f,0x01,0x00,0x00,0x00 },
168 { 0x10,0x18,0x0c,0x04,0x0c,0x18,0x10,0x18,0x0c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
169 { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00 }
170};
171
172static signed char speed[]={
173 1,2,3,3,3,2,1,0,-1,-2,-2,-2,-1,0,0,1,
174};
175
176#if LCD_WIDTH > LCD_HEIGHT /* landscape LCD */
177
178#define TABLE_SIZE LCD_HEIGHT
179#define RADIUS_MINUTE (3*LCD_HEIGHT/8)
180#define RADIUS_HOUR (LCD_HEIGHT/4)
181
182#else /* portrait (or square) LCD */
183
184#define TABLE_SIZE LCD_WIDTH
185#define RADIUS_MINUTE (3*LCD_WIDTH/8)
186#define RADIUS_HOUR (LCD_WIDTH/4)
187
188#endif /* LCD orientation */
189
190#define RADIUS_X ((LCD_WIDTH-LETTER_WIDTH)/2)
191#define RADIUS_Y ((LCD_HEIGHT-LETTER_HEIGHT)/2)
192
193#define PHASE_STEP (0xffffffff/TABLE_SIZE)
194#define PHASE_FRAC (0xffffffff%TABLE_SIZE)
195#define DIV_X (0x7ffffffe/RADIUS_X+1)
196#define DIV_Y (0x7ffffffe/RADIUS_Y+1)
197
198static int xtable[TABLE_SIZE];
199static int ytable[TABLE_SIZE];
200
201static void init_tables(void)
202{
203 int i;
204 int pfrac;
205 unsigned long phase;
206 long sin;
207
208 phase = pfrac = 0;
209
210 for (i = 0; i < TABLE_SIZE; i++) {
211 sin = fp_sincos(phase, NULL);
212 xtable[i] = RADIUS_X + sin / DIV_X;
213 ytable[i] = RADIUS_Y + sin / DIV_Y;
214
215 phase += PHASE_STEP;
216 pfrac += PHASE_FRAC;
217 if (pfrac >= TABLE_SIZE) {
218 pfrac -= TABLE_SIZE;
219 phase++;
220 }
221 }
222}
223
224enum {
225 NUM_XSANKE,
226 NUM_YSANKE,
227 NUM_XADD,
228 NUM_YADD,
229 NUM_XDIST,
230 NUM_YDIST,
231
232 NUM_LAST
233};
234
235struct counter {
236 char *what;
237 int num;
238};
239
240struct counter values[]={
241 {"xsanke", 1},
242 {"ysanke", 1},
243 {"xadd", 1},
244 {"yadd", 2},
245 {"xdist", -4},
246 {"ydist", -6},
247};
248
249#if CONFIG_RTC
250
251#define CLOCK_STEP (0xffffffff/60)
252#define CLOCK_FRAC (0xffffffff%60)
253
254#define DIV_MY (0x7ffffffe/RADIUS_MINUTE+1)
255#define DIV_HY (0x7ffffffe/RADIUS_HOUR+1)
256
257#if LCD_WIDTH == 112 && LCD_HEIGHT == 64 /* Archos LCD: non-square pixels */
258#define DIV_MX (0x7ffffffe/(5*RADIUS_MINUTE/4)+1)
259#define DIV_HX (0x7ffffffe/(5*RADIUS_HOUR/4)+1)
260#else /* Square pixels */
261#define DIV_MX DIV_MY
262#define DIV_HX DIV_HY
263#endif
264
265static int xminute[60], yminute[60];
266static int xhour[60], yhour[60];
267
268static void init_clock(void)
269{
270 int i;
271 int pfrac;
272 unsigned long phase;
273 long sin, cos;
274
275 phase = pfrac = 0;
276
277 for (i = 0; i < 60; i++) {
278 sin = fp_sincos(phase, &cos);
279 xminute[i] = LCD_WIDTH/2 + sin / DIV_MX;
280 yminute[i] = LCD_HEIGHT/2 - cos / DIV_MY;
281 xhour[i] = LCD_WIDTH/2 + sin / DIV_HX;
282 yhour[i] = LCD_HEIGHT/2 - cos / DIV_HY;
283
284 phase += CLOCK_STEP;
285 pfrac += CLOCK_FRAC;
286 if (pfrac >= 60) {
287 pfrac -= 60;
288 phase++;
289 }
290 }
291}
292
293static void addclock(void)
294{
295 int i;
296 int hour;
297 int minute;
298
299 struct tm* current_time = rb->get_time();
300 hour = current_time->tm_hour;
301 minute = current_time->tm_min;
302
303 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2,
304 xminute[minute], yminute[minute]);
305
306 hour = (hour % 12) * 5 + minute / 12;
307
308 rb->lcd_drawline(LCD_WIDTH/2, LCD_HEIGHT/2, xhour[hour], yhour[hour]);
309
310 /* draw a circle */
311 for(i = 1; i < 60; i += 3)
312 rb->lcd_drawline(xminute[i], yminute[i],
313 xminute[(i+1)%60], yminute[(i+1)%60]);
314}
315#endif /* CONFIG_RTC */
316
317#if LCD_DEPTH > 1
318static const unsigned face_colors[] =
319{
320#ifdef HAVE_LCD_COLOR
321 LCD_BLACK, LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(255, 0, 0)
322#else
323 LCD_BLACK, LCD_LIGHTGRAY, LCD_DARKGRAY
324#endif
325};
326#endif
327
328static int scrollit(void)
329{
330 int b;
331 unsigned int y=100;
332 unsigned int yy;
333 int x = LCD_WIDTH;
334 int xx;
335 unsigned int i;
336 unsigned int textpos=0;
337
338 char* rock="Rockbox! Pure pleasure. Pure fun. Oooh. What fun! ;-) ";
339 unsigned int rocklen = rb->strlen(rock);
340 int letter;
341#if LCD_DEPTH > 1
342 unsigned prev_color;
343#endif
344
345 rb->lcd_clear_display();
346 while(1)
347 {
348 b = pluginlib_getaction(HZ/10, plugin_contexts,
349 ARRAYLEN(plugin_contexts));
350 switch(b)
351 {
352 case BOUNCE_QUIT :
353 case BOUNCE_QUIT2 :
354 return 0;
355 case BOUNCE_MODE :
356 return 1;
357 default:
358 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
359 return -1;
360 }
361 rb->lcd_clear_display();
362#if CONFIG_RTC
363 addclock();
364#endif
365
366#if LCD_DEPTH > 1
367 prev_color = rb->lcd_get_foreground();
368#endif
369
370 for(i=0, yy=y, xx=x; xx < LCD_WIDTH; i++) {
371 letter = rock[(i+textpos) % rocklen ];
372#if LCD_DEPTH > 1
373 rb->lcd_set_foreground(face_colors[letter % 3]);
374#endif
375 rb->lcd_mono_bitmap(char_gen_12x16[letter-0x20],
376 xx, ytable[yy % TABLE_SIZE],
377 LETTER_WIDTH, LETTER_HEIGHT);
378 yy += YADD;
379 xx += LETTER_WIDTH;
380 }
381#if LCD_DEPTH > 1
382 rb->lcd_set_foreground(prev_color);
383#endif
384 rb->lcd_update();
385
386 x-= XSPEED;
387
388 if(x < -LETTER_WIDTH) {
389 x += LETTER_WIDTH;
390 y += YADD;
391 textpos++;
392 }
393
394 y+=YSPEED;
395 }
396}
397
398static int loopit(void)
399{
400 int b;
401 unsigned int y=100;
402 unsigned int x=100;
403 unsigned int yy,xx;
404 unsigned int i;
405 unsigned int ysanke=0;
406 unsigned int xsanke=0;
407
408 char* rock="ROCKbox";
409 unsigned int rocklen = rb->strlen(rock);
410
411 int show=0;
412 int timeout=0;
413
414 rb->lcd_clear_display();
415 while(1)
416 {
417 b = pluginlib_getaction(HZ/10, plugin_contexts,
418 ARRAYLEN(plugin_contexts));
419 if (( b == BOUNCE_QUIT ) || ( b == BOUNCE_QUIT2 ))
420 return 0;
421
422 if ( b == BOUNCE_MODE )
423 return 1;
424
425 if ( rb->default_event_handler(b) == SYS_USB_CONNECTED )
426 return -1;
427
428 if ( b != BUTTON_NONE )
429 timeout=20;
430
431 y+= speed[ysanke&15] + values[NUM_YADD].num;
432 x+= speed[xsanke&15] + values[NUM_XADD].num;
433
434 rb->lcd_clear_display();
435#if CONFIG_RTC
436 addclock();
437#endif
438 if(timeout) {
439 switch(b) {
440 case BOUNCE_LEFT:
441 case BOUNCE_LEFT_REPEAT:
442 values[show].num--;
443 break;
444 case BOUNCE_RIGHT:
445 case BOUNCE_RIGHT_REPEAT:
446 values[show].num++;
447 break;
448 case BOUNCE_UP:
449 case BOUNCE_UP_REPEAT:
450 if(++show == NUM_LAST)
451 show=0;
452 break;
453 case BOUNCE_DOWN:
454 case BOUNCE_DOWN_REPEAT:
455 if(--show < 0)
456 show=NUM_LAST-1;
457 break;
458 }
459 rb->lcd_putsxyf(0, LCD_HEIGHT - 8, "%s: %d",
460 values[show].what, values[show].num);
461 timeout--;
462 }
463 for(i=0, yy=y, xx=x;
464 i<rocklen;
465 i++, yy+=values[NUM_YDIST].num, xx+=values[NUM_XDIST].num)
466 rb->lcd_mono_bitmap(char_gen_12x16[rock[i]-0x20],
467 xtable[xx % TABLE_SIZE],
468 ytable[yy % TABLE_SIZE],
469 LETTER_WIDTH, LETTER_HEIGHT);
470 rb->lcd_update();
471
472 ysanke+= values[NUM_YSANKE].num;
473 xsanke+= values[NUM_XSANKE].num;
474 }
475}
476
477
478enum plugin_status plugin_start(const void* parameter)
479{
480 int w, h;
481 char *off =
482#if (CONFIG_KEYPAD == SAMSUNG_YH92X_PAD) || \
483 (CONFIG_KEYPAD == SAMSUNG_YH820_PAD)
484 "[Rew] to stop";
485#elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) \
486 || (CONFIG_KEYPAD == IPOD_3G_PAD) \
487 || (CONFIG_KEYPAD == IPOD_4G_PAD)
488 "[Menu] to stop";
489#else
490 "[Off] to stop";
491#endif
492
493 (void)(parameter);
494
495 rb->lcd_setfont(FONT_SYSFIXED);
496 rb->lcd_clear_display();
497
498 /* Get horizontel centering for text */
499 rb->lcd_getstringsize((unsigned char *)SS_TITLE, &w, &h);
500 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, (LCD_HEIGHT/2) - h / 2,
501 (unsigned char *)SS_TITLE);
502
503 /* Get horizontel centering for text */
504 rb->lcd_getstringsize((unsigned char *)off, &w, &h);
505 rb->lcd_putsxy((LCD_WIDTH/2) - w / 2, LCD_HEIGHT - 2 * h,
506 (unsigned char *)off);
507
508 rb->lcd_update();
509 rb->sleep(HZ);
510 rb->lcd_set_drawmode(DRMODE_FG);
511 init_tables();
512#if CONFIG_RTC
513 init_clock();
514#endif
515
516 do {
517 h = loopit();
518 if (h > 0)
519 h = scrollit();
520 } while(h > 0);
521
522 rb->lcd_set_drawmode(DRMODE_SOLID);
523 rb->lcd_setfont(FONT_UI);
524
525 return (h == 0) ? PLUGIN_OK : PLUGIN_USB_CONNECTED;
526}