7 #include "scroll_engine.h"
11 struct proxy_api
*xapi
;
13 void get_current_vp(struct viewport_api
*avp
);
14 /*************************************************************
16 *************************************************************/
17 #ifdef HAVE_LCD_BITMAP
18 void screen_clear_area(struct screen
* display
, int xstart
, int ystart
,
19 int width
, int height
) {
20 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
21 display
->fillrect(xstart
, ystart
, width
, height
);
22 display
->set_drawmode(DRMODE_SOLID
);
26 bool load_wps_backdrop(char* filename
) {
27 return xapi
->load_wps_backdrop(filename
);
30 bool load_remote_wps_backdrop(char* filename
) {
31 return xapi
->load_remote_wps_backdrop(filename
);
34 int read_bmp_file(const char* filename
,struct bitmap
*bm
, int maxsize
,int format
) {
35 if (!xapi
->read_bmp_file
)
37 DEBUGF1("can't read bmp file! NULL api!\n");
40 bm
->format
= 3;//FORMAT_ANY?
41 bm
->data
= (unsigned char*)malloc(255);
42 memset(bm
->data
,0,255);
43 strcpy((char*)bm
->data
,filename
);
44 //bm->data[strlen(filename)] = '\0';
45 xapi
->read_bmp_file(filename
,&bm
->width
, &bm
->height
);
49 bool load_wps_backdrop2(char* filename
) {
50 DEBUGF1("load_wps_backdrop(char* filename='%s')",filename
);
54 bool load_remote_wps_backdrop2(char* filename
) {
55 DEBUGF1("load_remote_wps_backdrop2(char* filename='%s')",filename
);
60 DEBUGF3("stop_scroll\n");
64 void puts_scroll(int x
, int y
, const unsigned char *string
) {
65 DEBUGF2("puts_scroll(int x=%d, int y=%d, const unsigned char *string='%s'\n",x
,y
,string
);
68 void putsxy(int x
, int y
, const unsigned char *str
) {
69 DEBUGF2("putsxy(int =%d, int y=%d, const unsigned char *str='%s')\n",x
,y
,str
);
76 void clear_viewport(int x
, int y
, int w
, int h
, int color
) {
77 DEBUGF3("clear_viewport(int x=%d, int y=%d, int w=%d, int h=%d, int color=%d)\n", x
, y
, w
, h
, color
);
80 int getstringsize(const unsigned char *str
, int *w
, int *h
) {
81 //DEBUGF1("getstringsize(const unsigned char *str=\"%s\", int *w=%d, int *h=%d \n",str,*w,*h);
82 *w
=strlen((char*)str
)*sysfont
.maxwidth
;
87 void set_wpsstate(struct wpsstate state
){
88 sysfont
.height
= state
.fontheight
;
89 sysfont
.maxwidth
= state
.fontwidth
;
90 global_settings
.volume
= state
.volume
;
91 battery_percent
= state
.battery_level
;
92 _audio_status
= state
.audio_status
;
95 void set_trackstate(struct trackstate state
){
96 gui_wps
[0].state
->id3
->title
= state
.title
;
97 gui_wps
[0].state
->id3
->artist
= state
.artist
;
98 gui_wps
[0].state
->id3
->album
= state
.album
;
99 gui_wps
[0].state
->id3
->elapsed
= state
.elapsed
;
100 gui_wps
[0].state
->id3
->length
= state
.length
;
103 void set_next_trackstate(struct trackstate state
)
105 gui_wps
[0].state
->nid3
->title
= state
.title
;
106 gui_wps
[0].state
->nid3
->artist
= state
.artist
;
107 gui_wps
[0].state
->nid3
->album
= state
.album
;
108 gui_wps
[0].state
->nid3
->elapsed
= state
.elapsed
;
109 gui_wps
[0].state
->nid3
->length
= state
.length
;
112 enum api_playmode playmodes
[PLAYMODES_NUM
] = {
116 API_STATUS_FASTFORWARD
,
117 API_STATUS_FASTBACKWARD
120 const char *playmodeNames
[] = {
121 "Play", "Stop", "Pause", "FastForward", "FastBackward"
125 void set_audio_status(int status
){
126 DEBUGF1("%s",playmodeNames
[status
]);
128 case API_STATUS_PLAY
:
129 _audio_status
= AUDIO_STATUS_PLAY
;
130 status_set_ffmode(STATUS_PLAY
);
132 case API_STATUS_STOP
:
134 status_set_ffmode(STATUS_STOP
);
136 case API_STATUS_PAUSE
:
137 _audio_status
= AUDIO_STATUS_PAUSE
;
138 status_set_ffmode(STATUS_PLAY
);
140 case API_STATUS_FASTFORWARD
:
141 status_set_ffmode(STATUS_FASTFORWARD
);
143 case API_STATUS_FASTBACKWARD
:
144 status_set_ffmode(STATUS_FASTBACKWARD
);
147 DEBUGF1("ERR: Unknown status");
151 void test_api(struct proxy_api
*api
) {
152 if (!api
->stop_scroll
)
153 api
->stop_scroll
=stop_scroll
;
154 if (!api
->set_viewport
)
155 api
->set_viewport
=lcd_set_viewport
;
156 if (!api
->clear_viewport
)
157 api
->clear_viewport
=clear_viewport
;
158 if (!api
->getstringsize
)
159 api
->getstringsize
=getstringsize
;
161 api
->getwidth
=lcd_getwidth
;
163 api
->getheight
=lcd_getheight
;
164 if (!api
->set_drawmode
)
165 api
->set_drawmode
=lcd_set_drawmode
;
166 if (!api
->puts_scroll
)
167 api
->puts_scroll
=puts_scroll
;
169 api
->update
=lcd_update
;
170 if (!api
->clear_display
)
171 api
->clear_display
=lcd_clear_display
;
173 api
->getfont
=lcd_getfont
;
178 if (!api
->get_foreground
)
179 api
->get_foreground
=lcd_get_foreground
;
180 if (!api
->get_background
)
181 api
->get_background
=lcd_get_background
;
183 if (!api
->load_remote_wps_backdrop
)
184 api
->load_remote_wps_backdrop
= load_remote_wps_backdrop2
;
185 if (!api
->load_wps_backdrop
)
186 api
->load_wps_backdrop
= load_wps_backdrop2
;
190 /**************************************************************
192 **************************************************************/
194 int set_api(struct proxy_api
* api
) {
197 screens
[0].screen_type
=SCREEN_MAIN
;
198 screens
[0].lcdwidth
=LCD_WIDTH
;
199 screens
[0].lcdheight
=LCD_HEIGHT
;
200 screens
[0].depth
=LCD_DEPTH
;
201 #ifdef HAVE_LCD_COLOR
202 screens
[0].is_color
=true;
204 screens
[0].is_color
=false;
207 screens
[0].getwidth
= api
->getwidth
;
208 if (api
->stop_scroll
)
209 screens
[0].stop_scroll
=api
->stop_scroll
;
210 screens
[0].scroll_stop
= lcd_scroll_stop
;
211 if (api
->set_viewport
)
212 screens
[0].set_viewport
=api
->set_viewport
;
213 if (api
->clear_viewport
)
214 screens
[0].clear_viewport
=lcd_clear_viewport
;
215 if (api
->getstringsize
)
216 screens
[0].getstringsize
=api
->getstringsize
;
218 screens
[0].getwidth
=api
->getwidth
;
220 screens
[0].getheight
=api
->getheight
;
221 if (api
->set_drawmode
)
222 screens
[0].set_drawmode
=api
->set_drawmode
;
224 screens
[0].fillrect
=api
->fillrect
;
225 if (api
->puts_scroll
)
226 screens
[0].puts_scroll
=api
->puts_scroll
;
227 if (api
->transparent_bitmap_part
)
228 screens
[0].transparent_bitmap_part
=api
->transparent_bitmap_part
;
230 screens
[0].update
=api
->update
;
231 if (api
->clear_display
)
232 screens
[0].clear_display
=api
->clear_display
;
234 screens
[0].getfont
=api
->getfont
;
236 screens
[0].hline
=api
->hline
;
238 screens
[0].vline
=api
->vline
;
240 screens
[0].drawpixel
=api
->drawpixel
;
242 screens
[0].putsxy
=api
->putsxy
;
244 if (api
->get_foreground
)
245 screens
[0].get_foreground
=api
->get_foreground
;
246 if (api
->get_background
)
247 screens
[0].get_background
=api
->get_background
;
250 screens
[0].bitmap_part
= api
->bitmap_part
;
251 /**************************
253 **************************/
254 api
->get_model_name
= get_model_name
;
255 api
->get_current_vp
= get_current_vp
;
256 api
->set_wpsstate
= set_wpsstate
;
257 api
->set_trackstate
= set_trackstate
;
258 api
->set_next_trackstate
= set_next_trackstate
;
259 api
->set_audio_status
= set_audio_status
;