1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Björn Stenberg
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 #include "backlight.h"
32 #include "mp3_playback.h"
40 #include "powermgmt.h"
49 #include "statusbar.h"
50 #include "screen_access.h"
56 #include "replaygain.h"
58 #if CONFIG_CODEC == SWCODEC
62 #if defined(ARCHOS_FMRECORDER) || defined(ARCHOS_RECORDERV2)
66 #if (CONFIG_STORAGE & STORAGE_MMC) && (defined(ARCHOS_ONDIOSP) || defined(ARCHOS_ONDIOFM))
67 int mmc_remove_request(void)
69 struct queue_event ev
;
71 screens
[i
].clear_display();
72 splash(0, ID2P(LANG_REMOVE_MMC
));
76 queue_wait_w_tmo(&button_queue
, &ev
, HZ
/2);
79 case SYS_HOTSWAP_EXTRACTED
:
80 return SYS_HOTSWAP_EXTRACTED
;
82 case SYS_USB_DISCONNECTED
:
83 return SYS_USB_DISCONNECTED
;
89 /* the charging screen is only used for archos targets */
90 #if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) && defined(CPU_SH)
92 #ifdef HAVE_LCD_BITMAP
93 static void charging_display_info(bool animate
)
95 unsigned char charging_logo
[36];
96 const int pox_x
= (LCD_WIDTH
- sizeof(charging_logo
)) / 2;
98 static unsigned phase
= 3;
101 #if !defined(NEED_ATA_POWER_BATT_MEASURE)
103 int battv
= battery_voltage();
104 lcd_putsf(0, 7, " Batt: %d.%02dV %d%% ", battv
/ 1000,
105 (battv
% 1000) / 10, battery_level());
107 #elif defined(ARCHOS_FMRECORDER) || defined(ARCHOS_RECORDERV2)
108 /* IDE power is normally off here, so display input current instead */
109 lcd_putsf(7, 7, "%dmA ",
110 (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 10000);
113 #ifdef ARCHOS_RECORDER
114 lcd_puts(0, 2, "Charge mode:");
117 if (charge_state
== CHARGING
)
118 s
= str(LANG_BATTERY_CHARGE
);
119 else if (charge_state
== TOPOFF
)
120 s
= str(LANG_BATTERY_TOPOFF_CHARGE
);
121 else if (charge_state
== TRICKLE
)
122 s
= str(LANG_BATTERY_TRICKLE_CHARGE
);
127 if (!charger_enabled())
129 #endif /* ARCHOS_RECORDER */
132 memset(charging_logo
+3, 0x00, 32);
133 charging_logo
[0] = 0x3C;
134 charging_logo
[1] = 0x24;
135 charging_logo
[2] = charging_logo
[35] = 0xFF;
138 { /* draw the outline */
140 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
+ 8,
141 sizeof(charging_logo
), 8);
142 lcd_set_drawmode(DRMODE_FG
);
144 charging_logo
[0] = charging_logo
[1] = 0x00;
145 memset(charging_logo
+2, 0x80, 34);
146 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
, sizeof(charging_logo
), 8);
148 memset(charging_logo
+2, 0x01, 34);
149 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
+ 16,
150 sizeof(charging_logo
), 8);
151 lcd_set_drawmode(DRMODE_SOLID
);
154 { /* animate the middle part */
155 for (i
= 3; i
<MIN(sizeof(charging_logo
)-1, phase
); i
++)
157 if ((i
-phase
) % 8 == 0)
158 { /* draw a "bubble" here */
160 bitpos
= (phase
+ i
/8) % 15; /* "bounce" effect */
162 bitpos
= 14 - bitpos
;
163 charging_logo
[i
] = BIT_N(bitpos
);
166 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
+ 8,
167 sizeof(charging_logo
), 8);
172 #else /* not HAVE_LCD_BITMAP */
174 static unsigned long logo_chars
[4];
175 static const unsigned char logo_pattern
[] = {
176 0x07, 0x04, 0x1c, 0x14, 0x1c, 0x04, 0x07, 0, /* char 1 */
177 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0, /* char 2 */
178 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0, /* char 3 */
179 0x1f, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1f, 0, /* char 4 */
182 static void logo_lock_patterns(bool on
)
188 for (i
= 0; i
< 4; i
++)
189 logo_chars
[i
] = lcd_get_locked_pattern();
193 for (i
= 0; i
< 4; i
++)
194 lcd_unlock_pattern(logo_chars
[i
]);
198 static void charging_display_info(bool animate
)
202 static unsigned phase
= 3;
205 battv
= battery_voltage();
206 lcd_putsf(4, 1, " %d.%02dV", battv
/ 1000, (battv
% 1000) / 10);
208 memcpy(buf
, logo_pattern
, 32); /* copy logo patterns */
210 if (!animate
) /* build the screen */
212 lcd_double_height(false);
213 lcd_puts(0, 0, "[Charging]");
214 for (i
= 0; i
< 4; i
++)
215 lcd_putc(i
, 1, logo_chars
[i
]);
217 else /* animate the logo */
219 for (i
= 3; i
< MIN(19, phase
); i
++)
221 if ((i
- phase
) % 5 == 0)
222 { /* draw a "bubble" here */
223 ypos
= (phase
+ i
/5) % 9; /* "bounce" effect */
226 buf
[5 - ypos
+ 8 * (i
/5)] |= 0x10u
>> (i
%5);
232 for (i
= 0; i
< 4; i
++)
233 lcd_define_pattern(logo_chars
[i
], buf
+ 8 * i
);
237 #endif /* (not) HAVE_LCD_BITMAP */
239 /* blocks while charging, returns on event:
240 1 if charger cable was removed
241 2 if Off/Stop key was pressed
242 3 if On key was pressed
243 4 if USB was connected */
245 int charging_screen(void)
250 ide_power_enable(false); /* power down the disk, else would be spinning */
253 backlight_set_timeout(global_settings
.backlight_timeout
);
254 #ifdef HAVE_REMOTE_LCD
255 remote_backlight_set_timeout(global_settings
.remote_backlight_timeout
);
257 backlight_set_timeout_plugged(global_settings
.backlight_timeout_plugged
);
259 #ifdef HAVE_LCD_CHARCELLS
260 logo_lock_patterns(true);
262 charging_display_info(false);
266 gui_syncstatusbar_draw(&statusbars
, false);
267 charging_display_info(true);
268 button
= get_action(CONTEXT_STD
,HZ
/3);
269 if (button
== ACTION_STD_OK
)
271 else if (usb_detect() == USB_INSERTED
)
273 /* do not depend on power management thread here */
274 else if (!(power_input_status() & POWER_INPUT_MAIN_CHARGER
))
278 #ifdef HAVE_LCD_CHARCELLS
279 logo_lock_patterns(false);
283 #endif /* CONFIG_CHARGING && !HAVE_POWEROFF_WHILE_CHARGING && defined(CPU_SH) */
286 void charging_splash(void)
288 splash(2*HZ
, str(LANG_BATTERY_CHARGE
));
289 button_clear_queue();
294 #if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0)
296 /* little helper function for voice output */
297 static void say_time(int cursorpos
, const struct tm
*tm
)
302 if (!global_settings
.talk_menu
)
320 value
= tm
->tm_year
+ 1900;
327 if (cursorpos
== 4) /* month */
328 talk_id(LANG_MONTH_JANUARY
+ tm
->tm_mon
, false);
330 talk_value(value
, unit
, false);
337 #define SEPARATOR ":"
340 #define IDX_MINUTES 1
341 #define IDX_SECONDS 2
347 #define OFF_MINUTES 3
348 #define OFF_SECONDS 6
352 bool set_time_screen(const char* title
, struct tm
*tm
)
354 struct viewport viewports
[NB_SCREENS
];
355 bool done
= false, usb
= false;
357 unsigned char offsets_ptr
[] =
358 { OFF_HOURS
, OFF_MINUTES
, OFF_SECONDS
, OFF_YEAR
, 0, OFF_DAY
};
362 offsets_ptr
[IDX_HOURS
] = OFF_SECONDS
;
363 offsets_ptr
[IDX_SECONDS
] = OFF_HOURS
;
364 offsets_ptr
[IDX_YEAR
] = OFF_DAY
;
365 offsets_ptr
[IDX_DAY
] = OFF_YEAR
;
368 /* speak selection when screen is entered */
369 say_time(cursorpos
, tm
);
371 #ifdef HAVE_TOUCHSCREEN
372 enum touchscreen_mode old_mode
= touchscreen_get_mode();
373 touchscreen_set_mode(TOUCHSCREEN_BUTTON
);
377 unsigned int i
, realyear
, min
, max
;
378 unsigned char *ptr
[6];
379 unsigned char buffer
[20];
381 static unsigned char daysinmonth
[] =
382 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
384 /* for easy acess in the drawing loop */
385 for (i
= 0; i
< 6; i
++)
386 ptr
[i
] = buffer
+ offsets_ptr
[i
];
387 ptr
[IDX_MONTH
] = str(LANG_MONTH_JANUARY
+ tm
->tm_mon
); /* month name */
389 /* calculate the number of days in febuary */
390 realyear
= tm
->tm_year
+ 1900;
391 if((realyear
% 4 == 0 && !(realyear
% 100 == 0)) || realyear
% 400 == 0)
396 /* fix day if month or year changed */
397 if (tm
->tm_mday
> daysinmonth
[tm
->tm_mon
])
398 tm
->tm_mday
= daysinmonth
[tm
->tm_mon
];
400 /* calculate day of week */
403 /* put all the numbers we want from the tm struct into
404 an easily printable buffer */
405 snprintf(buffer
, sizeof(buffer
),
406 "%02d " "%02d " "%02d " "%04d " "%02d",
407 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
,
408 tm
->tm_year
+1900, tm
->tm_mday
);
410 /* convert spaces in the buffer to '\0' to make it possible to work
411 directly on the buffer */
412 for(i
=0; i
< sizeof(buffer
); i
++)
421 unsigned int separator_width
, weekday_width
;
422 unsigned int j
, width
, prev_line_height
;
423 /* 6 possible cursor possitions, 2 values stored for each: x, y */
424 unsigned int cursor
[6][2];
425 struct viewport
*vp
= &viewports
[s
];
426 struct screen
*screen
= &screens
[s
];
427 static unsigned char rtl_idx
[] =
428 { IDX_SECONDS
, IDX_MINUTES
, IDX_HOURS
, IDX_DAY
, IDX_MONTH
, IDX_YEAR
};
430 viewport_set_defaults(vp
, s
);
431 screen
->set_viewport(vp
);
432 nb_lines
= viewport_get_nb_lines(vp
);
434 /* minimum lines needed is 2 + title line */
437 vp
->font
= FONT_SYSFIXED
;
438 nb_lines
= viewport_get_nb_lines(vp
);
441 /* recalculate the positions and offsets */
443 screen
->getstringsize(title
, NULL
, &prev_line_height
);
445 prev_line_height
= 0;
447 screen
->getstringsize(SEPARATOR
, &separator_width
, NULL
);
450 screen
->getstringsize(str(LANG_WEEKDAY_SUNDAY
+ tm
->tm_wday
),
451 &weekday_width
, NULL
);
452 screen
->getstringsize(" ", &separator_width
, NULL
);
454 for(i
=0, j
=0; i
< 6; i
++)
456 if(i
==3) /* second row */
458 j
= weekday_width
+ separator_width
;
459 prev_line_height
*= 2;
461 screen
->getstringsize(ptr
[i
], &width
, NULL
);
462 cursor
[i
][INDEX_Y
] = prev_line_height
;
463 cursor
[i
][INDEX_X
] = j
;
464 j
+= width
+ separator_width
;
467 /* draw the screen */
468 screen
->set_viewport(vp
);
469 screen
->clear_viewport();
470 /* display the screen title */
471 screen
->puts_scroll(0, 0, title
);
473 /* these are not selectable, so we draw them outside the loop */
474 /* name of the week day */
475 screen
->putsxy(0, cursor
[3][INDEX_Y
],
476 str(LANG_WEEKDAY_SUNDAY
+ tm
->tm_wday
));
478 pos
= lang_is_rtl() ? rtl_idx
[cursorpos
] : cursorpos
;
479 /* draw the selected item with drawmode set to
480 DRMODE_SOLID|DRMODE_INVERSEVID, all other selectable
481 items with drawmode DRMODE_SOLID */
485 vp
->drawmode
= (DRMODE_SOLID
|DRMODE_INVERSEVID
);
487 screen
->putsxy(cursor
[i
][INDEX_X
],
488 cursor
[i
][INDEX_Y
], ptr
[i
]);
490 vp
->drawmode
= DRMODE_SOLID
;
492 screen
->putsxy(cursor
[i
/4 +1][INDEX_X
] - separator_width
,
493 cursor
[0][INDEX_Y
], SEPARATOR
);
496 /* print help text */
498 screen
->puts(0, 4, str(LANG_TIME_SET_BUTTON
));
500 screen
->puts(0, 5, str(LANG_TIME_REVERT
));
501 screen
->update_viewport();
502 screen
->set_viewport(NULL
);
505 /* set the most common numbers */
508 /* calculate the minimum and maximum for the number under cursor */
512 valptr
= &tm
->tm_hour
;
515 valptr
= &tm
->tm_min
;
518 valptr
= &tm
->tm_sec
;
523 valptr
= &tm
->tm_year
;
527 valptr
= &tm
->tm_mon
;
531 max
= daysinmonth
[tm
->tm_mon
];
532 valptr
= &tm
->tm_mday
;
536 button
= get_action(CONTEXT_SETTINGS_TIME
, TIMEOUT_BLOCK
);
538 case ACTION_STD_PREV
:
539 cursorpos
= clamp_value_wrap(--cursorpos
, 5, 0);
540 say_time(cursorpos
, tm
);
542 case ACTION_STD_NEXT
:
543 cursorpos
= clamp_value_wrap(++cursorpos
, 5, 0);
544 say_time(cursorpos
, tm
);
546 case ACTION_SETTINGS_INC
:
547 case ACTION_SETTINGS_INCREPEAT
:
548 *valptr
= clamp_value_wrap(++(*valptr
), max
, min
);
549 say_time(cursorpos
, tm
);
551 case ACTION_SETTINGS_DEC
:
552 case ACTION_SETTINGS_DECREPEAT
:
553 *valptr
= clamp_value_wrap(--(*valptr
), max
, min
);
554 say_time(cursorpos
, tm
);
561 case ACTION_STD_CANCEL
:
567 if (default_event_handler(button
) == SYS_USB_CONNECTED
)
573 screens
[s
].scroll_stop(&viewports
[s
]);
574 #ifdef HAVE_TOUCHSCREEN
575 touchscreen_set_mode(old_mode
);
579 #endif /* defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0) */
581 #if (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF)
582 bool shutdown_screen(void)
586 long time_entered
= current_tick
;
590 splash(0, str(LANG_CONFIRM_SHUTDOWN
));
592 while(!done
&& TIME_BEFORE(current_tick
,time_entered
+HZ
*2))
594 button
= get_action(CONTEXT_STD
,HZ
);
597 case ACTION_STD_CANCEL
:
601 /* do nothing here, because ACTION_NONE might be caused
602 * by timeout or button release. In case of timeout the loop
603 * is terminated by TIME_BEFORE */
608 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
618 static const int id3_headers
[]=
624 LANG_ID3_ALBUMARTIST
,
635 #if CONFIG_CODEC == SWCODEC
643 struct id3view_info
{
644 struct mp3entry
* id3
;
646 int info_id
[ARRAYLEN(id3_headers
)];
649 static const char* id3_get_info(int selected_item
, void* data
,
650 char *buffer
, size_t buffer_len
)
652 struct id3view_info
*info
= (struct id3view_info
*)data
;
653 struct mp3entry
* id3
=info
->id3
;
654 int info_no
=selected_item
/2;
655 if(!(selected_item
%2))
657 snprintf(buffer
, buffer_len
,
658 "[%s]", str(id3_headers
[info
->info_id
[info_no
]]));
665 switch(id3_headers
[info
->info_id
[info_no
]])
670 case LANG_ID3_ARTIST
:
676 case LANG_ID3_ALBUMARTIST
:
677 val
=id3
->albumartist
;
679 case LANG_ID3_GROUPING
:
682 case LANG_ID3_DISCNUM
:
683 if (id3
->disc_string
)
684 val
= id3
->disc_string
;
685 else if (id3
->discnum
)
687 snprintf(buffer
, buffer_len
, "%d", id3
->discnum
);
691 case LANG_ID3_TRACKNUM
:
692 if (id3
->track_string
)
693 val
= id3
->track_string
;
694 else if (id3
->tracknum
)
696 snprintf(buffer
, buffer_len
, "%d", id3
->tracknum
);
700 case LANG_ID3_COMMENT
:
703 snprintf(buffer
, buffer_len
, "%s", id3
->comment
);
707 val
= id3
->genre_string
;
710 if (id3
->year_string
)
711 val
= id3
->year_string
;
714 snprintf(buffer
, buffer_len
, "%d", id3
->year
);
718 case LANG_ID3_LENGTH
:
719 format_time(buffer
, buffer_len
, id3
->length
);
722 case LANG_ID3_PLAYLIST
:
723 snprintf(buffer
, buffer_len
, "%d/%d",
724 playlist_get_display_index(), playlist_amount());
727 case LANG_ID3_BITRATE
:
728 snprintf(buffer
, buffer_len
, "%d kbps%s", id3
->bitrate
,
729 id3
->vbr
? str(LANG_ID3_VBR
) : (const unsigned char*) "");
732 case LANG_ID3_FREQUENCY
:
733 snprintf(buffer
, buffer_len
, "%ld Hz", id3
->frequency
);
736 #if CONFIG_CODEC == SWCODEC
737 case LANG_ID3_TRACK_GAIN
:
738 replaygain_itoa(buffer
, buffer_len
, id3
->track_level
);
739 val
=(id3
->track_level
) ? buffer
: NULL
; /* only show level!=0 */
741 case LANG_ID3_ALBUM_GAIN
:
742 replaygain_itoa(buffer
, buffer_len
, id3
->album_level
);
743 val
=(id3
->album_level
) ? buffer
: NULL
; /* only show level!=0 */
749 case LANG_ID3_COMPOSER
:
752 case LANG_FILESIZE
: /* not LANG_ID3_FILESIZE because the string is shared */
753 output_dyn_value(buffer
, buffer_len
, id3
->filesize
, byte_units
, true);
757 return val
&& *val
? val
: NULL
;
761 bool browse_id3(void)
763 struct gui_synclist id3_lists
;
764 struct mp3entry
* id3
= audio_current_track();
767 struct id3view_info info
;
771 push_current_activity(ACTIVITY_ID3SCREEN
);
772 for (i
= 0; i
< ARRAYLEN(id3_headers
); i
++)
776 if (id3_get_info((i
*2)+1, &info
, temp
, 8) != NULL
)
777 info
.info_id
[info
.count
++] = i
;
780 gui_synclist_init(&id3_lists
, &id3_get_info
, &info
, true, 2, NULL
);
781 gui_synclist_set_nb_items(&id3_lists
, info
.count
*2);
782 gui_synclist_draw(&id3_lists
);
784 key
= get_action(CONTEXT_LIST
,HZ
/2);
785 if(!gui_synclist_do_button(&id3_lists
, &key
,LIST_WRAP_UNLESS_HELD
))
787 if (key
== ACTION_STD_OK
|| key
== ACTION_STD_CANCEL
)
792 else if (key
== ACTION_STD_MENU
||
793 default_event_handler(key
) == SYS_USB_CONNECTED
)
801 pop_current_activity();
805 static const char* runtime_get_data(int selected_item
, void* data
,
806 char* buffer
, size_t buffer_len
)
810 switch (selected_item
)
812 case 0: return str(LANG_RUNNING_TIME
);
813 case 1: t
= global_status
.runtime
; break;
814 case 2: return str(LANG_TOP_TIME
);
815 case 3: t
= global_status
.topruntime
; break;
820 snprintf(buffer
, buffer_len
, "%dh %dm %ds",
821 t
/ 3600, (t
% 3600) / 60, t
% 60);
825 static int runtime_speak_data(int selected_item
, void* data
)
829 (selected_item
< 2) ? LANG_RUNNING_TIME
: LANG_TOP_TIME
,
830 TALK_ID((selected_item
< 2) ? global_status
.runtime
831 : global_status
.topruntime
, UNIT_TIME
));
836 bool view_runtime(void)
838 static const char *lines
[]={ID2P(LANG_CLEAR_TIME
)};
839 static const struct text_message message
={lines
, 1};
841 struct gui_synclist lists
;
843 gui_synclist_init(&lists
, runtime_get_data
, NULL
, false, 2, NULL
);
844 #if !defined(HAVE_LCD_CHARCELLS)
845 gui_synclist_set_title(&lists
, str(LANG_RUNNING_TIME
), NOICON
);
847 gui_synclist_set_title(&lists
, NULL
, NOICON
);
849 if(global_settings
.talk_menu
)
850 gui_synclist_set_voice_callback(&lists
, runtime_speak_data
);
851 gui_synclist_set_icon_callback(&lists
, NULL
);
852 gui_synclist_set_nb_items(&lists
, 4);
853 gui_synclist_speak_item(&lists
);
856 global_status
.runtime
+= ((current_tick
- lasttime
) / HZ
);
858 lasttime
= current_tick
;
859 gui_synclist_draw(&lists
);
860 list_do_action(CONTEXT_STD
, HZ
,
861 &lists
, &action
, LIST_WRAP_UNLESS_HELD
);
862 if(action
== ACTION_STD_CANCEL
)
864 if(action
== ACTION_STD_OK
) {
865 if(gui_syncyesno_run(&message
, NULL
, NULL
)==YESNO_YES
)
867 if (!(gui_synclist_get_sel_pos(&lists
)/2))
868 global_status
.runtime
= 0;
870 global_status
.topruntime
= 0;
871 gui_synclist_speak_item(&lists
);
874 if(default_event_handler(action
) == SYS_USB_CONNECTED
)
880 #ifdef HAVE_TOUCHSCREEN
881 static int get_sample(struct touchscreen_calibration
*cal
, int x
, int y
, int i
,
882 struct screen
* screen
)
888 screen
->drawline(x
- 10, y
, x
- 2, y
);
889 screen
->drawline(x
+ 2, y
, x
+ 10, y
);
890 screen
->drawline(x
, y
- 10, x
, y
- 2);
891 screen
->drawline(x
, y
+ 2, x
, y
+ 10);
894 /* Wait for a touchscreen press */
897 action
= get_action(CONTEXT_STD
, TIMEOUT_BLOCK
);
898 if(action
== ACTION_TOUCHSCREEN
)
900 if(action_get_touchscreen_press(&ts_x
, &ts_y
) == BUTTON_REL
)
903 else if(action
== ACTION_STD_CANCEL
)
918 short points
[3][2] = {
919 {LCD_WIDTH
/10, LCD_HEIGHT
/10},
920 {7*LCD_WIDTH
/8, LCD_HEIGHT
/2},
921 {LCD_WIDTH
/2, 7*LCD_HEIGHT
/8}
923 struct screen
* screen
= &screens
[SCREEN_MAIN
];
924 enum touchscreen_mode old_mode
= touchscreen_get_mode();
925 struct touchscreen_calibration cal
;
928 /* hide the statusbar */
929 viewportmanager_theme_enable(SCREEN_MAIN
, false, NULL
);
931 touchscreen_disable_mapping(); /* set raw mode */
932 touchscreen_set_mode(TOUCHSCREEN_POINT
);
936 screen
->clear_display();
938 if(get_sample(&cal
, points
[i
][0], points
[i
][1], i
, screen
))
946 touchscreen_calibrate(&cal
);
948 touchscreen_reset_mapping();
950 memcpy(&global_settings
.ts_calibration_data
, &calibration_parameters
,
951 sizeof(struct touchscreen_parameter
));
953 touchscreen_set_mode(old_mode
);
954 viewportmanager_theme_undo(SCREEN_MAIN
, false);
960 int reset_mapping(void)
962 touchscreen_reset_mapping();
964 memcpy(&global_settings
.ts_calibration_data
, &calibration_parameters
,
965 sizeof(struct touchscreen_parameter
));