summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2009-10-17 13:00:58 +0000
committerNils Wallménius <nils@rockbox.org>2009-10-17 13:00:58 +0000
commita97133469b58deca0ad3cf069d48fb7b69972983 (patch)
tree658503b9b62ca4513202dbb1aca1d73fa019956c
parentfb7c285b4ecc68d4e8ad1c073ea50dfc75dd0d8d (diff)
downloadrockbox-a97133469b58deca0ad3cf069d48fb7b69972983.tar.gz
rockbox-a97133469b58deca0ad3cf069d48fb7b69972983.zip
Use a wrapper function for the very common snprintf(); lcd_puts() sequence to save some binsize
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23225 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c607
1 files changed, 215 insertions, 392 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 7aed5edd70..8f28788585 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -122,6 +122,17 @@
122#include "usb_core.h" 122#include "usb_core.h"
123#endif 123#endif
124 124
125/* wrapper function to format a string and print it */
126static void debug_printf(int y, const unsigned char *fmt, ...)
127{
128 va_list ap;
129 char buf[128];
130 va_start(ap, fmt);
131 vsnprintf(buf, sizeof (buf), fmt, ap);
132 va_end(ap);
133 lcd_puts(0, y, buf);
134}
135
125/*---------------------------------------------------*/ 136/*---------------------------------------------------*/
126/* SPECIAL DEBUG STUFF */ 137/* SPECIAL DEBUG STUFF */
127/*---------------------------------------------------*/ 138/*---------------------------------------------------*/
@@ -234,7 +245,6 @@ static bool dbg_os(void)
234#ifndef SIMULATOR 245#ifndef SIMULATOR
235static bool dbg_audio_thread(void) 246static bool dbg_audio_thread(void)
236{ 247{
237 char buf[32];
238 struct audio_debug d; 248 struct audio_debug d;
239 249
240 lcd_setfont(FONT_SYSFIXED); 250 lcd_setfont(FONT_SYSFIXED);
@@ -248,18 +258,12 @@ static bool dbg_audio_thread(void)
248 258
249 lcd_clear_display(); 259 lcd_clear_display();
250 260
251 snprintf(buf, sizeof(buf), "read: %x", d.audiobuf_read); 261 debug_printf(0, "read: %x", d.audiobuf_read);
252 lcd_puts(0, 0, buf); 262 debug_printf(1, "write: %x", d.audiobuf_write);
253 snprintf(buf, sizeof(buf), "write: %x", d.audiobuf_write); 263 debug_printf(2, "swap: %x", d.audiobuf_swapwrite);
254 lcd_puts(0, 1, buf); 264 debug_printf(3, "playing: %d", d.playing);
255 snprintf(buf, sizeof(buf), "swap: %x", d.audiobuf_swapwrite); 265 debug_printf(4, "playable: %x", d.playable_space);
256 lcd_puts(0, 2, buf); 266 debug_printf(5, "unswapped: %x", d.unswapped_space);
257 snprintf(buf, sizeof(buf), "playing: %d", d.playing);
258 lcd_puts(0, 3, buf);
259 snprintf(buf, sizeof(buf), "playable: %x", d.playable_space);
260 lcd_puts(0, 4, buf);
261 snprintf(buf, sizeof(buf), "unswapped: %x", d.unswapped_space);
262 lcd_puts(0, 5, buf);
263 267
264 /* Playable space left */ 268 /* Playable space left */
265 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, 6*8, 112, 4, d.audiobuflen, 0, 269 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, 6*8, 112, 4, d.audiobuflen, 0,
@@ -269,9 +273,8 @@ static bool dbg_audio_thread(void)
269 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, 6*8+4, 112, 4, d.audiobuflen, 0, 273 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, 6*8+4, 112, 4, d.audiobuflen, 0,
270 d.low_watermark_level, HORIZONTAL); 274 d.low_watermark_level, HORIZONTAL);
271 275
272 snprintf(buf, sizeof(buf), "wm: %x - %x", 276 debug_printf(7, "wm: %x - %x",
273 d.low_watermark_level, d.lowest_watermark_level); 277 d.low_watermark_level, d.lowest_watermark_level);
274 lcd_puts(0, 7, buf);
275 278
276 lcd_update(); 279 lcd_update();
277 } 280 }
@@ -297,7 +300,6 @@ static void dbg_audio_task(void)
297 300
298static bool dbg_buffering_thread(void) 301static bool dbg_buffering_thread(void)
299{ 302{
300 char buf[32];
301 int button; 303 int button;
302 int line; 304 int line;
303 bool done = false; 305 bool done = false;
@@ -334,34 +336,30 @@ static bool dbg_buffering_thread(void)
334 336
335 bufused = bufsize - pcmbuf_free(); 337 bufused = bufsize - pcmbuf_free();
336 338
337 snprintf(buf, sizeof(buf), "pcm: %6ld/%ld", (long) bufused, (long) bufsize); 339 debug_printf(line++, "pcm: %6ld/%ld", (long) bufused, (long) bufsize);
338 lcd_puts(0, line++, buf);
339 340
340 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6, 341 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6,
341 bufsize, 0, bufused, HORIZONTAL); 342 bufsize, 0, bufused, HORIZONTAL);
342 line++; 343 line++;
343 344
344 snprintf(buf, sizeof(buf), "alloc: %6ld/%ld", audio_filebufused(), 345 debug_printf(line++, "alloc: %6ld/%ld", audio_filebufused(),
345 (long) filebuflen); 346 (long) filebuflen);
346 lcd_puts(0, line++, buf);
347 347
348#if LCD_HEIGHT > 80 348#if LCD_HEIGHT > 80
349 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6, 349 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6,
350 filebuflen, 0, audio_filebufused(), HORIZONTAL); 350 filebuflen, 0, audio_filebufused(), HORIZONTAL);
351 line++; 351 line++;
352 352
353 snprintf(buf, sizeof(buf), "real: %6ld/%ld", (long)d.buffered_data, 353 debug_printf(line++, "real: %6ld/%ld", (long)d.buffered_data,
354 (long)filebuflen); 354 (long)filebuflen);
355 lcd_puts(0, line++, buf);
356 355
357 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6, 356 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6,
358 filebuflen, 0, (long)d.buffered_data, HORIZONTAL); 357 filebuflen, 0, (long)d.buffered_data, HORIZONTAL);
359 line++; 358 line++;
360#endif 359#endif
361 360
362 snprintf(buf, sizeof(buf), "usefl: %6ld/%ld", (long)(d.useful_data), 361 debug_printf(line++, "usefl: %6ld/%ld", (long)(d.useful_data),
363 (long)filebuflen); 362 (long)filebuflen);
364 lcd_puts(0, line++, buf);
365 363
366#if LCD_HEIGHT > 80 364#if LCD_HEIGHT > 80
367 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6, 365 gui_scrollbar_draw(&screens[SCREEN_MAIN],0, line*8, LCD_WIDTH, 6,
@@ -369,36 +367,29 @@ static bool dbg_buffering_thread(void)
369 line++; 367 line++;
370#endif 368#endif
371 369
372 snprintf(buf, sizeof(buf), "data_rem: %ld", (long)d.data_rem); 370 debug_printf(line++, "data_rem: %ld", (long)d.data_rem);
373 lcd_puts(0, line++, buf);
374 371
375 snprintf(buf, sizeof(buf), "track count: %2d", audio_track_count()); 372 debug_printf(line++, "track count: %2d", audio_track_count());
376 lcd_puts(0, line++, buf);
377 373
378 snprintf(buf, sizeof(buf), "handle count: %d", (int)d.num_handles); 374 debug_printf(line++, "handle count: %d", (int)d.num_handles);
379 lcd_puts(0, line++, buf);
380 375
381#ifndef SIMULATOR 376#ifndef SIMULATOR
382 snprintf(buf, sizeof(buf), "cpu freq: %3dMHz", 377 debug_printf(line++, "cpu freq: %3dMHz",
383 (int)((FREQ + 500000) / 1000000)); 378 (int)((FREQ + 500000) / 1000000));
384 lcd_puts(0, line++, buf);
385#endif 379#endif
386 380
387 if (ticks > 0) 381 if (ticks > 0)
388 { 382 {
389 int boostquota = boost_ticks * 1000 / ticks; /* in 0.1 % */ 383 int boostquota = boost_ticks * 1000 / ticks; /* in 0.1 % */
390 int avgclock = freq_sum * 10 / ticks; /* in 100 kHz */ 384 int avgclock = freq_sum * 10 / ticks; /* in 100 kHz */
391 snprintf(buf, sizeof(buf), "boost:%3d.%d%% (%d.%dMHz)", 385 debug_printf(line++, "boost:%3d.%d%% (%d.%dMHz)",
392 boostquota/10, boostquota%10, avgclock/10, avgclock%10); 386 boostquota/10, boostquota%10, avgclock/10, avgclock%10);
393 lcd_puts(0, line++, buf);
394 } 387 }
395 388
396 snprintf(buf, sizeof(buf), "pcmbufdesc: %2d/%2d", 389 debug_printf(line++, "pcmbufdesc: %2d/%2d",
397 pcmbuf_used_descs(), pcmbufdescs); 390 pcmbuf_used_descs(), pcmbufdescs);
398 lcd_puts(0, line++, buf); 391 debug_printf(line++, "watermark: %6d",
399 snprintf(buf, sizeof(buf), "watermark: %6d",
400 (int)(d.watermark)); 392 (int)(d.watermark));
401 lcd_puts(0, line++, buf);
402 393
403 lcd_update(); 394 lcd_update();
404 } 395 }
@@ -509,7 +500,6 @@ static int perfcheck(void)
509static bool dbg_hw_info(void) 500static bool dbg_hw_info(void)
510{ 501{
511#if CONFIG_CPU == SH7034 502#if CONFIG_CPU == SH7034
512 char buf[32];
513 int bitmask = HW_MASK; 503 int bitmask = HW_MASK;
514 int rom_version = ROM_VERSION; 504 int rom_version = ROM_VERSION;
515 unsigned manu, id; /* flash IDs */ 505 unsigned manu, id; /* flash IDs */
@@ -540,37 +530,32 @@ static bool dbg_hw_info(void)
540 530
541 lcd_puts(0, 0, "[Hardware info]"); 531 lcd_puts(0, 0, "[Hardware info]");
542 532
543 snprintf(buf, 32, "ROM: %d.%02d", rom_version/100, rom_version%100); 533 debug_printf(1, "ROM: %d.%02d", rom_version/100, rom_version%100);
544 lcd_puts(0, 1, buf);
545 534
546 snprintf(buf, 32, "Mask: 0x%04x", bitmask); 535 debug_printf(2, "Mask: 0x%04x", bitmask);
547 lcd_puts(0, 2, buf);
548 536
549 if (got_id) 537 if (got_id)
550 snprintf(buf, 32, "Flash: M=%02x D=%02x", manu, id); 538 debug_printf(3, "Flash: M=%02x D=%02x", manu, id);
551 else 539 else
552 snprintf(buf, 32, "Flash: M=?? D=??"); /* unknown, sorry */ 540 lcd_puts(0, 3, "Flash: M=?? D=??"); /* unknown, sorry */
553 lcd_puts(0, 3, buf);
554 541
555 if (has_bootrom) 542 if (has_bootrom)
556 { 543 {
557 if (rom_crc == 0x56DBA4EE) /* known Version 1 */ 544 if (rom_crc == 0x56DBA4EE) /* known Version 1 */
558 snprintf(buf, 32, "Boot ROM: V1"); 545 lcd_puts(0, 4, "Boot ROM: V1");
559 else 546 else
560 snprintf(buf, 32, "ROMcrc: 0x%08x", rom_crc); 547 debug_printf(4, "ROMcrc: 0x%08x", rom_crc);
561 } 548 }
562 else 549 else
563 { 550 {
564 snprintf(buf, 32, "Boot ROM: none"); 551 lcd_puts(0, 4, "Boot ROM: none");
565 } 552 }
566 lcd_puts(0, 4, buf);
567 553
568 lcd_update(); 554 lcd_update();
569 555
570 while (!(action_userabort(TIMEOUT_BLOCK))); 556 while (!(action_userabort(TIMEOUT_BLOCK)));
571 557
572#elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250 558#elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
573 char buf[32];
574 unsigned manu, id; /* flash IDs */ 559 unsigned manu, id; /* flash IDs */
575 int got_id; /* flag if we managed to get the flash IDs */ 560 int got_id; /* flag if we managed to get the flash IDs */
576 int oldmode; /* saved memory guard mode */ 561 int oldmode; /* saved memory guard mode */
@@ -591,10 +576,9 @@ static bool dbg_hw_info(void)
591 lcd_puts(0, line++, "[Hardware info]"); 576 lcd_puts(0, line++, "[Hardware info]");
592 577
593 if (got_id) 578 if (got_id)
594 snprintf(buf, 32, "Flash: M=%04x D=%04x", manu, id); 579 debug_printf(line++, "Flash: M=%04x D=%04x", manu, id);
595 else 580 else
596 snprintf(buf, 32, "Flash: M=???? D=????"); /* unknown, sorry */ 581 lcd_puts(0, line++, "Flash: M=???? D=????"); /* unknown, sorry */
597 lcd_puts(0, line++, buf);
598 582
599#ifdef IAUDIO_X5 583#ifdef IAUDIO_X5
600 { 584 {
@@ -606,20 +590,16 @@ static bool dbg_hw_info(void)
606 590
607 if (got_id == DS2411_OK) 591 if (got_id == DS2411_OK)
608 { 592 {
609 snprintf(buf, 32, " FC=%02x", (unsigned)id.family_code); 593 debug_printf(++line, " FC=%02x", (unsigned)id.family_code);
610 lcd_puts(0, ++line, buf); 594 debug_printf(++line, " ID=%02X %02X %02X %02X %02X %02X",
611 snprintf(buf, 32, " ID=%02X %02X %02X %02X %02X %02X",
612 (unsigned)id.uid[0], (unsigned)id.uid[1], (unsigned)id.uid[2], 595 (unsigned)id.uid[0], (unsigned)id.uid[1], (unsigned)id.uid[2],
613 (unsigned)id.uid[3], (unsigned)id.uid[4], (unsigned)id.uid[5]); 596 (unsigned)id.uid[3], (unsigned)id.uid[4], (unsigned)id.uid[5]);
614 lcd_puts(0, ++line, buf); 597 debug_printf(++line, " CRC=%02X", (unsigned)id.crc);
615 snprintf(buf, 32, " CRC=%02X", (unsigned)id.crc);
616 } 598 }
617 else 599 else
618 { 600 {
619 snprintf(buf, 32, "READ ERR=%d", got_id); 601 debug_printf(++line, "READ ERR=%d", got_id);
620 } 602 }
621
622 lcd_puts(0, ++line, buf);
623 } 603 }
624#endif 604#endif
625 605
@@ -629,7 +609,6 @@ static bool dbg_hw_info(void)
629 609
630#elif defined(CPU_PP502x) 610#elif defined(CPU_PP502x)
631 int line = 0; 611 int line = 0;
632 char buf[32];
633 char pp_version[] = { (PP_VER2 >> 24) & 0xff, (PP_VER2 >> 16) & 0xff, 612 char pp_version[] = { (PP_VER2 >> 24) & 0xff, (PP_VER2 >> 16) & 0xff,
634 (PP_VER2 >> 8) & 0xff, (PP_VER2) & 0xff, 613 (PP_VER2 >> 8) & 0xff, (PP_VER2) & 0xff,
635 (PP_VER1 >> 24) & 0xff, (PP_VER1 >> 16) & 0xff, 614 (PP_VER1 >> 24) & 0xff, (PP_VER1 >> 16) & 0xff,
@@ -641,22 +620,18 @@ static bool dbg_hw_info(void)
641 lcd_puts(0, line++, "[Hardware info]"); 620 lcd_puts(0, line++, "[Hardware info]");
642 621
643#ifdef IPOD_ARCH 622#ifdef IPOD_ARCH
644 snprintf(buf, sizeof(buf), "HW rev: 0x%08lx", IPOD_HW_REVISION); 623 debug_printf(line++, "HW rev: 0x%08lx", IPOD_HW_REVISION);
645 lcd_puts(0, line++, buf);
646#endif 624#endif
647 625
648#ifdef IPOD_COLOR 626#ifdef IPOD_COLOR
649 extern int lcd_type; /* Defined in lcd-colornano.c */ 627 extern int lcd_type; /* Defined in lcd-colornano.c */
650 628
651 snprintf(buf, sizeof(buf), "LCD type: %d", lcd_type); 629 debug_printf(line++, "LCD type: %d", lcd_type);
652 lcd_puts(0, line++, buf);
653#endif 630#endif
654 631
655 snprintf(buf, sizeof(buf), "PP version: %s", pp_version); 632 debug_printf(line++, "PP version: %s", pp_version);
656 lcd_puts(0, line++, buf);
657 633
658 snprintf(buf, sizeof(buf), "Est. clock (kHz): %d", perfcheck()); 634 debug_printf(line++, "Est. clock (kHz): %d", perfcheck());
659 lcd_puts(0, line++, buf);
660 635
661 lcd_update(); 636 lcd_update();
662 637
@@ -664,7 +639,6 @@ static bool dbg_hw_info(void)
664 639
665#elif CONFIG_CPU == PP5002 640#elif CONFIG_CPU == PP5002
666 int line = 0; 641 int line = 0;
667 char buf[32];
668 char pp_version[] = { (PP_VER4 >> 8) & 0xff, PP_VER4 & 0xff, 642 char pp_version[] = { (PP_VER4 >> 8) & 0xff, PP_VER4 & 0xff,
669 (PP_VER3 >> 8) & 0xff, PP_VER3 & 0xff, 643 (PP_VER3 >> 8) & 0xff, PP_VER3 & 0xff,
670 (PP_VER2 >> 8) & 0xff, PP_VER2 & 0xff, 644 (PP_VER2 >> 8) & 0xff, PP_VER2 & 0xff,
@@ -677,15 +651,12 @@ static bool dbg_hw_info(void)
677 lcd_puts(0, line++, "[Hardware info]"); 651 lcd_puts(0, line++, "[Hardware info]");
678 652
679#ifdef IPOD_ARCH 653#ifdef IPOD_ARCH
680 snprintf(buf, sizeof(buf), "HW rev: 0x%08lx", IPOD_HW_REVISION); 654 debug_printf(line++, "HW rev: 0x%08lx", IPOD_HW_REVISION);
681 lcd_puts(0, line++, buf);
682#endif 655#endif
683 656
684 snprintf(buf, sizeof(buf), "PP version: %s", pp_version); 657 debug_printf(line++, "PP version: %s", pp_version);
685 lcd_puts(0, line++, buf);
686 658
687 snprintf(buf, sizeof(buf), "Est. clock (kHz): %d", perfcheck()); 659 debug_printf(line++, "Est. clock (kHz): %d", perfcheck());
688 lcd_puts(0, line++, buf);
689 660
690 lcd_update(); 661 lcd_update();
691 662
@@ -701,7 +672,6 @@ static bool dbg_hw_info(void)
701#else /* !HAVE_LCD_BITMAP */ 672#else /* !HAVE_LCD_BITMAP */
702static bool dbg_hw_info(void) 673static bool dbg_hw_info(void)
703{ 674{
704 char buf[32];
705 int button; 675 int button;
706 int currval = 0; 676 int currval = 0;
707 int rom_version = ROM_VERSION; 677 int rom_version = ROM_VERSION;
@@ -736,31 +706,30 @@ static bool dbg_hw_info(void)
736 switch(currval) 706 switch(currval)
737 { 707 {
738 case 0: 708 case 0:
739 snprintf(buf, 32, "ROM: %d.%02d", 709 debug_printf(1, "ROM: %d.%02d",
740 rom_version/100, rom_version%100); 710 rom_version/100, rom_version%100);
741 break; 711 break;
742 case 1: 712 case 1:
743 if (got_id) 713 if (got_id)
744 snprintf(buf, 32, "Flash:%02x,%02x", manu, id); 714 debug_printf(1, "Flash:%02x,%02x", manu, id);
745 else 715 else
746 snprintf(buf, 32, "Flash:??,??"); /* unknown, sorry */ 716 lcd_puts(0, 1, "Flash:??,??"); /* unknown, sorry */
747 break; 717 break;
748 case 2: 718 case 2:
749 if (has_bootrom) 719 if (has_bootrom)
750 { 720 {
751 if (rom_crc == 0x56DBA4EE) /* known Version 1 */ 721 if (rom_crc == 0x56DBA4EE) /* known Version 1 */
752 snprintf(buf, 32, "BootROM: V1"); 722 lcd_puts(0, 1, "BootROM: V1");
753 else if (rom_crc == 0x358099E8) 723 else if (rom_crc == 0x358099E8)
754 snprintf(buf, 32, "BootROM: V2"); 724 lcd_puts(0, 1, "BootROM: V2");
755 /* alternative boot ROM found in one single player so far */ 725 /* alternative boot ROM found in one single player so far */
756 else 726 else
757 snprintf(buf, 32, "R: %08x", rom_crc); 727 debug_printf(1, "R: %08x", rom_crc);
758 } 728 }
759 else 729 else
760 snprintf(buf, 32, "BootROM: no"); 730 lcd_puts(0, 1, "BootROM: no");
761 } 731 }
762 732
763 lcd_puts(0, 1, buf);
764 lcd_update(); 733 lcd_update();
765 734
766 button = get_action(CONTEXT_SETTINGS,TIMEOUT_BLOCK); 735 button = get_action(CONTEXT_SETTINGS,TIMEOUT_BLOCK);
@@ -821,7 +790,6 @@ bool dbg_partitions(void)
821#if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT) 790#if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
822static bool dbg_spdif(void) 791static bool dbg_spdif(void)
823{ 792{
824 char buf[128];
825 int line; 793 int line;
826 unsigned int control; 794 unsigned int control;
827 int x; 795 int x;
@@ -854,31 +822,26 @@ static bool dbg_spdif(void)
854 symbolerr = (interruptstat & 0x00800000)?true:false; 822 symbolerr = (interruptstat & 0x00800000)?true:false;
855 parityerr = (interruptstat & 0x00400000)?true:false; 823 parityerr = (interruptstat & 0x00400000)?true:false;
856 824
857 snprintf(buf, sizeof(buf), "Val: %s Sym: %s Par: %s", 825 debug_printf(line++, "Val: %s Sym: %s Par: %s",
858 valnogood?"--":"OK", 826 valnogood?"--":"OK",
859 symbolerr?"--":"OK", 827 symbolerr?"--":"OK",
860 parityerr?"--":"OK"); 828 parityerr?"--":"OK");
861 lcd_puts(0, line++, buf);
862 829
863 snprintf(buf, sizeof(buf), "Status word: %08x", (int)control); 830 debug_printf(line++, "Status word: %08x", (int)control);
864 lcd_puts(0, line++, buf);
865 831
866 line++; 832 line++;
867 833
868 x = control >> 31; 834 x = control >> 31;
869 snprintf(buf, sizeof(buf), "PRO: %d (%s)", 835 debug_printf(line++, "PRO: %d (%s)",
870 x, x?"Professional":"Consumer"); 836 x, x?"Professional":"Consumer");
871 lcd_puts(0, line++, buf);
872 837
873 x = (control >> 30) & 1; 838 x = (control >> 30) & 1;
874 snprintf(buf, sizeof(buf), "Audio: %d (%s)", 839 debug_printf(line++, "Audio: %d (%s)",
875 x, x?"Non-PCM":"PCM"); 840 x, x?"Non-PCM":"PCM");
876 lcd_puts(0, line++, buf);
877 841
878 x = (control >> 29) & 1; 842 x = (control >> 29) & 1;
879 snprintf(buf, sizeof(buf), "Copy: %d (%s)", 843 debug_printf(line++, "Copy: %d (%s)",
880 x, x?"Permitted":"Inhibited"); 844 x, x?"Permitted":"Inhibited");
881 lcd_puts(0, line++, buf);
882 845
883 x = (control >> 27) & 7; 846 x = (control >> 27) & 7;
884 switch(x) 847 switch(x)
@@ -893,12 +856,10 @@ static bool dbg_spdif(void)
893 s = "Reserved"; 856 s = "Reserved";
894 break; 857 break;
895 } 858 }
896 snprintf(buf, sizeof(buf), "Preemphasis: %d (%s)", x, s); 859 debug_printf(line++, "Preemphasis: %d (%s)", x, s);
897 lcd_puts(0, line++, buf);
898 860
899 x = (control >> 24) & 3; 861 x = (control >> 24) & 3;
900 snprintf(buf, sizeof(buf), "Mode: %d", x); 862 debug_printf(line++, "Mode: %d", x);
901 lcd_puts(0, line++, buf);
902 863
903 category = (control >> 17) & 127; 864 category = (control >> 17) & 127;
904 switch(category) 865 switch(category)
@@ -912,8 +873,7 @@ static bool dbg_spdif(void)
912 default: 873 default:
913 s = "Unknown"; 874 s = "Unknown";
914 } 875 }
915 snprintf(buf, sizeof(buf), "Category: 0x%02x (%s)", category, s); 876 debug_printf(line++, "Category: 0x%02x (%s)", category, s);
916 lcd_puts(0, line++, buf);
917 877
918 x = (control >> 16) & 1; 878 x = (control >> 16) & 1;
919 generation = x; 879 generation = x;
@@ -923,13 +883,12 @@ static bool dbg_spdif(void)
923 { 883 {
924 generation = !generation; 884 generation = !generation;
925 } 885 }
926 snprintf(buf, sizeof(buf), "Generation: %d (%s)", 886 debug_printf(line++, "Generation: %d (%s)",
927 x, generation?"Original":"No ind."); 887 x, generation?"Original":"No ind.");
928 lcd_puts(0, line++, buf);
929 888
930 x = (control >> 12) & 15; 889 x = (control >> 12) & 15;
931 snprintf(buf, sizeof(buf), "Source: %d", x); 890 debug_printf(line++, "Source: %d", x);
932 lcd_puts(0, line++, buf); 891
933 892
934 x = (control >> 8) & 15; 893 x = (control >> 8) & 15;
935 switch(x) 894 switch(x)
@@ -947,8 +906,7 @@ static bool dbg_spdif(void)
947 s = ""; 906 s = "";
948 break; 907 break;
949 } 908 }
950 snprintf(buf, sizeof(buf), "Channel: %d (%s)", x, s); 909 debug_printf(line++, "Channel: %d (%s)", x, s);
951 lcd_puts(0, line++, buf);
952 910
953 x = (control >> 4) & 15; 911 x = (control >> 4) & 15;
954 switch(x) 912 switch(x)
@@ -963,18 +921,15 @@ static bool dbg_spdif(void)
963 s = "32kHz"; 921 s = "32kHz";
964 break; 922 break;
965 } 923 }
966 snprintf(buf, sizeof(buf), "Frequency: %d (%s)", x, s); 924 debug_printf(line++, "Frequency: %d (%s)", x, s);
967 lcd_puts(0, line++, buf);
968 925
969 x = (control >> 2) & 3; 926 x = (control >> 2) & 3;
970 snprintf(buf, sizeof(buf), "Clock accuracy: %d", x); 927 debug_printf(line++, "Clock accuracy: %d", x);
971 lcd_puts(0, line++, buf);
972 line++; 928 line++;
973 929
974#ifndef SIMULATOR 930#ifndef SIMULATOR
975 snprintf(buf, sizeof(buf), "Measured freq: %ldHz", 931 debug_printf(line++, "Measured freq: %ldHz",
976 spdif_measure_frequency()); 932 spdif_measure_frequency());
977 lcd_puts(0, line++, buf);
978#endif 933#endif
979 934
980 lcd_update(); 935 lcd_update();
@@ -1046,7 +1001,6 @@ static bool dbg_spdif(void)
1046bool dbg_ports(void) 1001bool dbg_ports(void)
1047{ 1002{
1048#if CONFIG_CPU == SH7034 1003#if CONFIG_CPU == SH7034
1049 char buf[32];
1050 int adc_battery_voltage, adc_battery_level; 1004 int adc_battery_voltage, adc_battery_level;
1051 1005
1052 lcd_setfont(FONT_SYSFIXED); 1006 lcd_setfont(FONT_SYSFIXED);
@@ -1054,24 +1008,17 @@ bool dbg_ports(void)
1054 1008
1055 while(1) 1009 while(1)
1056 { 1010 {
1057 snprintf(buf, 32, "PADR: %04x", (unsigned short)PADR); 1011 debug_printf(0, "PADR: %04x", (unsigned short)PADR);
1058 lcd_puts(0, 0, buf); 1012 debug_printf(1, "PBDR: %04x", (unsigned short)PBDR);
1059 snprintf(buf, 32, "PBDR: %04x", (unsigned short)PBDR); 1013
1060 lcd_puts(0, 1, buf); 1014 debug_printf(2, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
1061 1015 debug_printf(3, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1062 snprintf(buf, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4)); 1016 debug_printf(4, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1063 lcd_puts(0, 2, buf); 1017 debug_printf(5, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1064 snprintf(buf, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1065 lcd_puts(0, 3, buf);
1066 snprintf(buf, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1067 lcd_puts(0, 4, buf);
1068 snprintf(buf, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1069 lcd_puts(0, 5, buf);
1070 1018
1071 battery_read_info(&adc_battery_voltage, &adc_battery_level); 1019 battery_read_info(&adc_battery_voltage, &adc_battery_level);
1072 snprintf(buf, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage / 1000, 1020 debug_printf(6, "Batt: %d.%03dV %d%% ", adc_battery_voltage / 1000,
1073 adc_battery_voltage % 1000, adc_battery_level); 1021 adc_battery_voltage % 1000, adc_battery_level);
1074 lcd_puts(0, 6, buf);
1075 1022
1076 lcd_update(); 1023 lcd_update();
1077 if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) 1024 if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
@@ -1091,7 +1038,6 @@ bool dbg_ports(void)
1091 unsigned int gpio1_enable; 1038 unsigned int gpio1_enable;
1092 int adc_buttons, adc_remote; 1039 int adc_buttons, adc_remote;
1093 int adc_battery_voltage, adc_battery_level; 1040 int adc_battery_voltage, adc_battery_level;
1094 char buf[128];
1095 int line; 1041 int line;
1096 1042
1097 lcd_clear_display(); 1043 lcd_clear_display();
@@ -1109,54 +1055,41 @@ bool dbg_ports(void)
1109 gpio_enable = GPIO_ENABLE; 1055 gpio_enable = GPIO_ENABLE;
1110 gpio1_enable = GPIO1_ENABLE; 1056 gpio1_enable = GPIO1_ENABLE;
1111 1057
1112 snprintf(buf, sizeof(buf), "GPIO_READ: %08x", gpio_read); 1058 debug_printf(line++, "GPIO_READ: %08x", gpio_read);
1113 lcd_puts(0, line++, buf); 1059 debug_printf(line++, "GPIO_OUT: %08x", gpio_out);
1114 snprintf(buf, sizeof(buf), "GPIO_OUT: %08x", gpio_out); 1060 debug_printf(line++, "GPIO_FUNC: %08x", gpio_function);
1115 lcd_puts(0, line++, buf); 1061 debug_printf(line++, "GPIO_ENA: %08x", gpio_enable);
1116 snprintf(buf, sizeof(buf), "GPIO_FUNC: %08x", gpio_function); 1062
1117 lcd_puts(0, line++, buf); 1063 debug_printf(line++, "GPIO1_READ: %08x", gpio1_read);
1118 snprintf(buf, sizeof(buf), "GPIO_ENA: %08x", gpio_enable); 1064 debug_printf(line++, "GPIO1_OUT: %08x", gpio1_out);
1119 lcd_puts(0, line++, buf); 1065 debug_printf(line++, "GPIO1_FUNC: %08x", gpio1_function);
1120 1066 debug_printf(line++, "GPIO1_ENA: %08x", gpio1_enable);
1121 snprintf(buf, sizeof(buf), "GPIO1_READ: %08x", gpio1_read);
1122 lcd_puts(0, line++, buf);
1123 snprintf(buf, sizeof(buf), "GPIO1_OUT: %08x", gpio1_out);
1124 lcd_puts(0, line++, buf);
1125 snprintf(buf, sizeof(buf), "GPIO1_FUNC: %08x", gpio1_function);
1126 lcd_puts(0, line++, buf);
1127 snprintf(buf, sizeof(buf), "GPIO1_ENA: %08x", gpio1_enable);
1128 lcd_puts(0, line++, buf);
1129 1067
1130 adc_buttons = adc_read(ADC_BUTTONS); 1068 adc_buttons = adc_read(ADC_BUTTONS);
1131 adc_remote = adc_read(ADC_REMOTE); 1069 adc_remote = adc_read(ADC_REMOTE);
1132 battery_read_info(&adc_battery_voltage, &adc_battery_level); 1070 battery_read_info(&adc_battery_voltage, &adc_battery_level);
1133#if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES) 1071#if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1134 snprintf(buf, sizeof(buf), "ADC_BUTTONS (%c): %02x", 1072 debug_printf(line++, "ADC_BUTTONS (%c): %02x",
1135 button_scan_enabled() ? '+' : '-', adc_buttons); 1073 button_scan_enabled() ? '+' : '-', adc_buttons);
1136#else 1074#else
1137 snprintf(buf, sizeof(buf), "ADC_BUTTONS: %02x", adc_buttons); 1075 debug_printf(line++, "ADC_BUTTONS: %02x", adc_buttons);
1138#endif 1076#endif
1139 lcd_puts(0, line++, buf);
1140#if defined(IAUDIO_X5) || defined(IAUDIO_M5) 1077#if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1141 snprintf(buf, sizeof(buf), "ADC_REMOTE (%c): %02x", 1078 debug_printf(line++, "ADC_REMOTE (%c): %02x",
1142 remote_detect() ? '+' : '-', adc_remote); 1079 remote_detect() ? '+' : '-', adc_remote);
1143#else 1080#else
1144 snprintf(buf, sizeof(buf), "ADC_REMOTE: %02x", adc_remote); 1081 debug_printf(line++, "ADC_REMOTE: %02x", adc_remote);
1145#endif 1082#endif
1146 lcd_puts(0, line++, buf);
1147#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) 1083#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1148 snprintf(buf, sizeof(buf), "ADC_REMOTEDETECT: %02x", 1084 debug_printf(line++, "ADC_REMOTEDETECT: %02x",
1149 adc_read(ADC_REMOTEDETECT)); 1085 adc_read(ADC_REMOTEDETECT));
1150 lcd_puts(0, line++, buf);
1151#endif 1086#endif
1152 1087
1153 snprintf(buf, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage / 1000, 1088 debug_printf(line++, "Batt: %d.%03dV %d%% ", adc_battery_voltage / 1000,
1154 adc_battery_voltage % 1000, adc_battery_level); 1089 adc_battery_voltage % 1000, adc_battery_level);
1155 lcd_puts(0, line++, buf);
1156 1090
1157#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) 1091#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1158 snprintf(buf, sizeof(buf), "remotetype: %d", remote_type()); 1092 debug_printf(line++, "remotetype: %d", remote_type());
1159 lcd_puts(0, line++, buf);
1160#endif 1093#endif
1161 1094
1162 lcd_update(); 1095 lcd_update();
@@ -1168,8 +1101,6 @@ bool dbg_ports(void)
1168 } 1101 }
1169 1102
1170#elif defined(CPU_PP502x) 1103#elif defined(CPU_PP502x)
1171
1172 char buf[128];
1173 int line; 1104 int line;
1174 1105
1175 lcd_clear_display(); 1106 lcd_clear_display();
@@ -1179,95 +1110,66 @@ bool dbg_ports(void)
1179 { 1110 {
1180 line = 0; 1111 line = 0;
1181 lcd_puts(0, line++, "GPIO STATES:"); 1112 lcd_puts(0, line++, "GPIO STATES:");
1182 snprintf(buf, sizeof(buf), "A: %02x E: %02x I: %02x", 1113 debug_printf(line++, "A: %02x E: %02x I: %02x",
1183 (unsigned int)GPIOA_INPUT_VAL, 1114 (unsigned int)GPIOA_INPUT_VAL,
1184 (unsigned int)GPIOE_INPUT_VAL, 1115 (unsigned int)GPIOE_INPUT_VAL,
1185 (unsigned int)GPIOI_INPUT_VAL); 1116 (unsigned int)GPIOI_INPUT_VAL);
1186 lcd_puts(0, line++, buf); 1117 debug_printf(line++, "B: %02x F: %02x J: %02x",
1187 snprintf(buf, sizeof(buf), "B: %02x F: %02x J: %02x", 1118 (unsigned int)GPIOB_INPUT_VAL,
1188 (unsigned int)GPIOB_INPUT_VAL, 1119 (unsigned int)GPIOF_INPUT_VAL,
1189 (unsigned int)GPIOF_INPUT_VAL, 1120 (unsigned int)GPIOJ_INPUT_VAL);
1190 (unsigned int)GPIOJ_INPUT_VAL); 1121 debug_printf(line++, "C: %02x G: %02x K: %02x",
1191 lcd_puts(0, line++, buf); 1122 (unsigned int)GPIOC_INPUT_VAL,
1192 snprintf(buf, sizeof(buf), "C: %02x G: %02x K: %02x", 1123 (unsigned int)GPIOG_INPUT_VAL,
1193 (unsigned int)GPIOC_INPUT_VAL, 1124 (unsigned int)GPIOK_INPUT_VAL);
1194 (unsigned int)GPIOG_INPUT_VAL, 1125 debug_printf(line++, "D: %02x H: %02x L: %02x",
1195 (unsigned int)GPIOK_INPUT_VAL); 1126 (unsigned int)GPIOD_INPUT_VAL,
1196 lcd_puts(0, line++, buf); 1127 (unsigned int)GPIOH_INPUT_VAL,
1197 snprintf(buf, sizeof(buf), "D: %02x H: %02x L: %02x", 1128 (unsigned int)GPIOL_INPUT_VAL);
1198 (unsigned int)GPIOD_INPUT_VAL,
1199 (unsigned int)GPIOH_INPUT_VAL,
1200 (unsigned int)GPIOL_INPUT_VAL);
1201 lcd_puts(0, line++, buf);
1202 line++; 1129 line++;
1203 snprintf(buf, sizeof(buf), "GPO32_VAL: %08lx", GPO32_VAL); 1130 debug_printf(line++, "GPO32_VAL: %08lx", GPO32_VAL);
1204 lcd_puts(0, line++, buf); 1131 debug_printf(line++, "GPO32_EN: %08lx", GPO32_ENABLE);
1205 snprintf(buf, sizeof(buf), "GPO32_EN: %08lx", GPO32_ENABLE); 1132 debug_printf(line++, "DEV_EN: %08lx", DEV_EN);
1206 lcd_puts(0, line++, buf); 1133 debug_printf(line++, "DEV_EN2: %08lx", DEV_EN2);
1207 snprintf(buf, sizeof(buf), "DEV_EN: %08lx", DEV_EN); 1134 debug_printf(line++, "DEV_EN3: %08lx", inl(0x60006044)); /* to be verified */
1208 lcd_puts(0, line++, buf); 1135 debug_printf(line++, "DEV_INIT1: %08lx", DEV_INIT1);
1209 snprintf(buf, sizeof(buf), "DEV_EN2: %08lx", DEV_EN2); 1136 debug_printf(line++, "DEV_INIT2: %08lx", DEV_INIT2);
1210 lcd_puts(0, line++, buf);
1211 snprintf(buf, sizeof(buf), "DEV_EN3: %08lx", inl(0x60006044));
1212 lcd_puts(0, line++, buf); /* to be verified */
1213 snprintf(buf, sizeof(buf), "DEV_INIT1: %08lx", DEV_INIT1);
1214 lcd_puts(0, line++, buf);
1215 snprintf(buf, sizeof(buf), "DEV_INIT2: %08lx", DEV_INIT2);
1216 lcd_puts(0, line++, buf);
1217#ifdef ADC_ACCESSORY 1137#ifdef ADC_ACCESSORY
1218 snprintf(buf, sizeof(buf), "ACCESSORY: %d", adc_read(ADC_ACCESSORY)); 1138 debug_printf(line++, "ACCESSORY: %d", adc_read(ADC_ACCESSORY));
1219 lcd_puts(0, line++, buf);
1220#endif 1139#endif
1221 1140
1222#if defined(IPOD_ACCESSORY_PROTOCOL) 1141#if defined(IPOD_ACCESSORY_PROTOCOL)
1223extern unsigned char serbuf[]; 1142extern unsigned char serbuf[];
1224 snprintf(buf, sizeof(buf), "IAP PACKET: %02x %02x %02x %02x %02x %02x %02x %02x", 1143 debug_printf(line++, "IAP PACKET: %02x %02x %02x %02x %02x %02x %02x %02x",
1225 serbuf[0], serbuf[1], serbuf[2], serbuf[3], serbuf[4], serbuf[5], 1144 serbuf[0], serbuf[1], serbuf[2], serbuf[3], serbuf[4], serbuf[5],
1226 serbuf[6], serbuf[7]); 1145 serbuf[6], serbuf[7]);
1227 lcd_puts(0, line++, buf);
1228#endif 1146#endif
1229 1147
1230#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB) 1148#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1231 line++; 1149 line++;
1232 snprintf(buf, sizeof(buf), "BATT: %03x UNK1: %03x", 1150 debug_printf(line++, "BATT: %03x UNK1: %03x",
1233 adc_read(ADC_BATTERY), adc_read(ADC_UNKNOWN_1)); 1151 adc_read(ADC_BATTERY), adc_read(ADC_UNKNOWN_1));
1234 lcd_puts(0, line++, buf); 1152 debug_printf(line++, "REM: %03x PAD: %03x",
1235 snprintf(buf, sizeof(buf), "REM: %03x PAD: %03x",
1236 adc_read(ADC_REMOTE), adc_read(ADC_SCROLLPAD)); 1153 adc_read(ADC_REMOTE), adc_read(ADC_SCROLLPAD));
1237 lcd_puts(0, line++, buf);
1238#elif defined(PHILIPS_HDD1630) 1154#elif defined(PHILIPS_HDD1630)
1239 line++; 1155 line++;
1240 snprintf(buf, sizeof(buf), "BATT: %03x UNK1: %03x", 1156 debug_printf(line++, "BATT: %03x UNK1: %03x",
1241 adc_read(ADC_BATTERY), adc_read(ADC_UNKNOWN_1)); 1157 adc_read(ADC_BATTERY), adc_read(ADC_UNKNOWN_1));
1242 lcd_puts(0, line++, buf);
1243#elif defined(SANSA_E200) || defined(PHILIPS_SA9200) 1158#elif defined(SANSA_E200) || defined(PHILIPS_SA9200)
1244 snprintf(buf, sizeof(buf), "ADC_BVDD: %4d", adc_read(ADC_BVDD)); 1159 debug_printf(line++, "ADC_BVDD: %4d", adc_read(ADC_BVDD));
1245 lcd_puts(0, line++, buf); 1160 debug_printf(line++, "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP));
1246 snprintf(buf, sizeof(buf), "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP)); 1161 debug_printf(line++, "ADC_UVDD: %4d", adc_read(ADC_UVDD));
1247 lcd_puts(0, line++, buf); 1162 debug_printf(line++, "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN));
1248 snprintf(buf, sizeof(buf), "ADC_UVDD: %4d", adc_read(ADC_UVDD)); 1163 debug_printf(line++, "ADC_CVDD: %4d", adc_read(ADC_CVDD));
1249 lcd_puts(0, line++, buf); 1164 debug_printf(line++, "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP));
1250 snprintf(buf, sizeof(buf), "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN)); 1165 debug_printf(line++, "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1));
1251 lcd_puts(0, line++, buf); 1166 debug_printf(line++, "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2));
1252 snprintf(buf, sizeof(buf), "ADC_CVDD: %4d", adc_read(ADC_CVDD)); 1167 debug_printf(line++, "ADC_VBE1: %4d", adc_read(ADC_VBE1));
1253 lcd_puts(0, line++, buf); 1168 debug_printf(line++, "ADC_VBE2: %4d", adc_read(ADC_VBE2));
1254 snprintf(buf, sizeof(buf), "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP)); 1169 debug_printf(line++, "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1));
1255 lcd_puts(0, line++, buf);
1256 snprintf(buf, sizeof(buf), "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1));
1257 lcd_puts(0, line++, buf);
1258 snprintf(buf, sizeof(buf), "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2));
1259 lcd_puts(0, line++, buf);
1260 snprintf(buf, sizeof(buf), "ADC_VBE1: %4d", adc_read(ADC_VBE1));
1261 lcd_puts(0, line++, buf);
1262 snprintf(buf, sizeof(buf), "ADC_VBE2: %4d", adc_read(ADC_VBE2));
1263 lcd_puts(0, line++, buf);
1264 snprintf(buf, sizeof(buf), "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1));
1265 lcd_puts(0, line++, buf);
1266#if !defined(PHILIPS_SA9200) 1170#if !defined(PHILIPS_SA9200)
1267 snprintf(buf, sizeof(buf), "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2)); 1171 debug_printf(line++, "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2));
1268 lcd_puts(0, line++, buf); 1172 debug_printf(line++, "ADC_VBAT: %4d", adc_read(ADC_VBAT));
1269 snprintf(buf, sizeof(buf), "ADC_VBAT: %4d", adc_read(ADC_VBAT));
1270 lcd_puts(0, line++, buf);
1271#endif 1173#endif
1272#endif 1174#endif
1273 lcd_update(); 1175 lcd_update();
@@ -1279,7 +1181,6 @@ extern unsigned char serbuf[];
1279 } 1181 }
1280 1182
1281#elif CONFIG_CPU == PP5002 1183#elif CONFIG_CPU == PP5002
1282 char buf[128];
1283 int line; 1184 int line;
1284 1185
1285 lcd_clear_display(); 1186 lcd_clear_display();
@@ -1288,29 +1189,19 @@ extern unsigned char serbuf[];
1288 while(1) 1189 while(1)
1289 { 1190 {
1290 line = 0; 1191 line = 0;
1291 snprintf(buf, sizeof(buf), "GPIO_A: %02x GPIO_B: %02x", 1192 debug_printf(line++, "GPIO_A: %02x GPIO_B: %02x",
1292 (unsigned int)GPIOA_INPUT_VAL, (unsigned int)GPIOB_INPUT_VAL); 1193 (unsigned int)GPIOA_INPUT_VAL, (unsigned int)GPIOB_INPUT_VAL);
1293 lcd_puts(0, line++, buf); 1194 debug_printf(line++, "GPIO_C: %02x GPIO_D: %02x",
1294 snprintf(buf, sizeof(buf), "GPIO_C: %02x GPIO_D: %02x",
1295 (unsigned int)GPIOC_INPUT_VAL, (unsigned int)GPIOD_INPUT_VAL); 1195 (unsigned int)GPIOC_INPUT_VAL, (unsigned int)GPIOD_INPUT_VAL);
1296 lcd_puts(0, line++, buf); 1196
1297 1197 debug_printf(line++, "DEV_EN: %08lx", DEV_EN);
1298 snprintf(buf, sizeof(buf), "DEV_EN: %08lx", DEV_EN); 1198 debug_printf(line++, "CLOCK_ENABLE: %08lx", CLOCK_ENABLE);
1299 lcd_puts(0, line++, buf); 1199 debug_printf(line++, "CLOCK_SOURCE: %08lx", CLOCK_SOURCE);
1300 snprintf(buf, sizeof(buf), "CLOCK_ENABLE: %08lx", CLOCK_ENABLE); 1200 debug_printf(line++, "PLL_CONTROL: %08lx", PLL_CONTROL);
1301 lcd_puts(0, line++, buf); 1201 debug_printf(line++, "PLL_DIV: %08lx", PLL_DIV);
1302 snprintf(buf, sizeof(buf), "CLOCK_SOURCE: %08lx", CLOCK_SOURCE); 1202 debug_printf(line++, "PLL_MULT: %08lx", PLL_MULT);
1303 lcd_puts(0, line++, buf); 1203 debug_printf(line++, "TIMING1_CTL: %08lx", TIMING1_CTL);
1304 snprintf(buf, sizeof(buf), "PLL_CONTROL: %08lx", PLL_CONTROL); 1204 debug_printf(line++, "TIMING2_CTL: %08lx", TIMING2_CTL);
1305 lcd_puts(0, line++, buf);
1306 snprintf(buf, sizeof(buf), "PLL_DIV: %08lx", PLL_DIV);
1307 lcd_puts(0, line++, buf);
1308 snprintf(buf, sizeof(buf), "PLL_MULT: %08lx", PLL_MULT);
1309 lcd_puts(0, line++, buf);
1310 snprintf(buf, sizeof(buf), "TIMING1_CTL: %08lx", TIMING1_CTL);
1311 lcd_puts(0, line++, buf);
1312 snprintf(buf, sizeof(buf), "TIMING2_CTL: %08lx", TIMING2_CTL);
1313 lcd_puts(0, line++, buf);
1314 1205
1315 lcd_update(); 1206 lcd_update();
1316 if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) 1207 if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
@@ -1373,9 +1264,8 @@ bool dbg_ports(void)
1373 lcd_puts(0, 0, buf); 1264 lcd_puts(0, 0, buf);
1374 1265
1375 battery_read_info(&adc_battery_voltage, NULL); 1266 battery_read_info(&adc_battery_voltage, NULL);
1376 snprintf(buf, 32, "Batt: %d.%03dV", adc_battery_voltage / 1000, 1267 debug_printf(1, "Batt: %d.%03dV", adc_battery_voltage / 1000,
1377 adc_battery_voltage % 1000); 1268 adc_battery_voltage % 1000);
1378 lcd_puts(0, 1, buf);
1379 lcd_update(); 1269 lcd_update();
1380 1270
1381 button = get_action(CONTEXT_SETTINGS,HZ/5); 1271 button = get_action(CONTEXT_SETTINGS,HZ/5);
@@ -1406,7 +1296,6 @@ bool dbg_ports(void)
1406#if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR) 1296#if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
1407static bool dbg_pcf(void) 1297static bool dbg_pcf(void)
1408{ 1298{
1409 char buf[128];
1410 int line; 1299 int line;
1411 1300
1412#ifdef HAVE_LCD_BITMAP 1301#ifdef HAVE_LCD_BITMAP
@@ -1418,33 +1307,19 @@ static bool dbg_pcf(void)
1418 { 1307 {
1419 line = 0; 1308 line = 0;
1420 1309
1421 snprintf(buf, sizeof(buf), "DCDC1: %02x", pcf50605_read(0x1b)); 1310 debug_printf(line++, "DCDC1: %02x", pcf50605_read(0x1b));
1422 lcd_puts(0, line++, buf); 1311 debug_printf(line++, "DCDC2: %02x", pcf50605_read(0x1c));
1423 snprintf(buf, sizeof(buf), "DCDC2: %02x", pcf50605_read(0x1c)); 1312 debug_printf(line++, "DCDC3: %02x", pcf50605_read(0x1d));
1424 lcd_puts(0, line++, buf); 1313 debug_printf(line++, "DCDC4: %02x", pcf50605_read(0x1e));
1425 snprintf(buf, sizeof(buf), "DCDC3: %02x", pcf50605_read(0x1d)); 1314 debug_printf(line++, "DCDEC1: %02x", pcf50605_read(0x1f));
1426 lcd_puts(0, line++, buf); 1315 debug_printf(line++, "DCDEC2: %02x", pcf50605_read(0x20));
1427 snprintf(buf, sizeof(buf), "DCDC4: %02x", pcf50605_read(0x1e)); 1316 debug_printf(line++, "DCUDC1: %02x", pcf50605_read(0x21));
1428 lcd_puts(0, line++, buf); 1317 debug_printf(line++, "DCUDC2: %02x", pcf50605_read(0x22));
1429 snprintf(buf, sizeof(buf), "DCDEC1: %02x", pcf50605_read(0x1f)); 1318 debug_printf(line++, "IOREGC: %02x", pcf50605_read(0x23));
1430 lcd_puts(0, line++, buf); 1319 debug_printf(line++, "D1REGC: %02x", pcf50605_read(0x24));
1431 snprintf(buf, sizeof(buf), "DCDEC2: %02x", pcf50605_read(0x20)); 1320 debug_printf(line++, "D2REGC: %02x", pcf50605_read(0x25));
1432 lcd_puts(0, line++, buf); 1321 debug_printf(line++, "D3REGC: %02x", pcf50605_read(0x26));
1433 snprintf(buf, sizeof(buf), "DCUDC1: %02x", pcf50605_read(0x21)); 1322 debug_printf(line++, "LPREG1: %02x", pcf50605_read(0x27));
1434 lcd_puts(0, line++, buf);
1435 snprintf(buf, sizeof(buf), "DCUDC2: %02x", pcf50605_read(0x22));
1436 lcd_puts(0, line++, buf);
1437 snprintf(buf, sizeof(buf), "IOREGC: %02x", pcf50605_read(0x23));
1438 lcd_puts(0, line++, buf);
1439 snprintf(buf, sizeof(buf), "D1REGC: %02x", pcf50605_read(0x24));
1440 lcd_puts(0, line++, buf);
1441 snprintf(buf, sizeof(buf), "D2REGC: %02x", pcf50605_read(0x25));
1442 lcd_puts(0, line++, buf);
1443 snprintf(buf, sizeof(buf), "D3REGC: %02x", pcf50605_read(0x26));
1444 lcd_puts(0, line++, buf);
1445 snprintf(buf, sizeof(buf), "LPREG1: %02x", pcf50605_read(0x27));
1446 lcd_puts(0, line++, buf);
1447
1448 lcd_update(); 1323 lcd_update();
1449 if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) 1324 if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
1450 { 1325 {
@@ -1461,7 +1336,6 @@ static bool dbg_pcf(void)
1461#ifdef HAVE_ADJUSTABLE_CPU_FREQ 1336#ifdef HAVE_ADJUSTABLE_CPU_FREQ
1462static bool dbg_cpufreq(void) 1337static bool dbg_cpufreq(void)
1463{ 1338{
1464 char buf[128];
1465 int line; 1339 int line;
1466 int button; 1340 int button;
1467 1341
@@ -1474,11 +1348,8 @@ static bool dbg_cpufreq(void)
1474 { 1348 {
1475 line = 0; 1349 line = 0;
1476 1350
1477 snprintf(buf, sizeof(buf), "Frequency: %ld", FREQ); 1351 debug_printf(line++, "Frequency: %ld", FREQ);
1478 lcd_puts(0, line++, buf); 1352 debug_printf(line++, "boost_counter: %d", get_cpu_boost_counter());
1479
1480 snprintf(buf, sizeof(buf), "boost_counter: %d", get_cpu_boost_counter());
1481 lcd_puts(0, line++, buf);
1482 1353
1483 lcd_update(); 1354 lcd_update();
1484 button = get_action(CONTEXT_STD,HZ/10); 1355 button = get_action(CONTEXT_STD,HZ/10);
@@ -1595,7 +1466,6 @@ static bool view_battery(void)
1595 int view = 0; 1466 int view = 0;
1596 int i, x, y; 1467 int i, x, y;
1597 unsigned short maxv, minv; 1468 unsigned short maxv, minv;
1598 char buf[32];
1599 1469
1600 lcd_setfont(FONT_SYSFIXED); 1470 lcd_setfont(FONT_SYSFIXED);
1601 1471
@@ -1614,12 +1484,10 @@ static bool view_battery(void)
1614 minv = power_history[i]; 1484 minv = power_history[i];
1615 } 1485 }
1616 1486
1617 snprintf(buf, 30, "Battery %d.%03d", power_history[0] / 1000, 1487 debug_printf(0, "Battery %d.%03d", power_history[0] / 1000,
1618 power_history[0] % 1000); 1488 power_history[0] % 1000);
1619 lcd_puts(0, 0, buf); 1489 debug_printf(1, "scale %d.%03d-%d.%03dV",
1620 snprintf(buf, 30, "scale %d.%03d-%d.%03dV",
1621 minv / 1000, minv % 1000, maxv / 1000, maxv % 1000); 1490 minv / 1000, minv % 1000, maxv / 1000, maxv % 1000);
1622 lcd_puts(0, 1, buf);
1623 1491
1624 x = 0; 1492 x = 0;
1625 for (i = BAT_LAST_VAL - 1; i >= 0; i--) { 1493 for (i = BAT_LAST_VAL - 1; i >= 0; i--) {
@@ -1638,31 +1506,24 @@ static bool view_battery(void)
1638 lcd_puts(0, 0, "Power status:"); 1506 lcd_puts(0, 0, "Power status:");
1639 1507
1640 battery_read_info(&y, NULL); 1508 battery_read_info(&y, NULL);
1641 snprintf(buf, 30, "Battery: %d.%03d V", y / 1000, y % 1000); 1509 debug_printf(1, "Battery: %d.%03d V", y / 1000, y % 1000);
1642 lcd_puts(0, 1, buf);
1643#ifdef ADC_EXT_POWER 1510#ifdef ADC_EXT_POWER
1644 y = (adc_read(ADC_EXT_POWER) * EXT_SCALE_FACTOR) / 1000; 1511 y = (adc_read(ADC_EXT_POWER) * EXT_SCALE_FACTOR) / 1000;
1645 snprintf(buf, 30, "External: %d.%03d V", y / 1000, y % 1000); 1512 debug_printf(2, "External: %d.%03d V", y / 1000, y % 1000);
1646 lcd_puts(0, 2, buf);
1647#endif 1513#endif
1648#if CONFIG_CHARGING 1514#if CONFIG_CHARGING
1649#if defined ARCHOS_RECORDER 1515#if defined ARCHOS_RECORDER
1650 snprintf(buf, 30, "Chgr: %s %s", 1516 debug_printf(3, "Chgr: %s %s",
1651 charger_inserted() ? "present" : "absent", 1517 charger_inserted() ? "present" : "absent",
1652 charger_enabled() ? "on" : "off"); 1518 charger_enabled() ? "on" : "off");
1653 lcd_puts(0, 3, buf); 1519 debug_printf(5, "short delta: %d", short_delta);
1654 snprintf(buf, 30, "short delta: %d", short_delta); 1520 debug_printf(6, "long delta: %d", long_delta);
1655 lcd_puts(0, 5, buf);
1656 snprintf(buf, 30, "long delta: %d", long_delta);
1657 lcd_puts(0, 6, buf);
1658 lcd_puts(0, 7, power_message); 1521 lcd_puts(0, 7, power_message);
1659 snprintf(buf, 30, "USB Inserted: %s", 1522 debug_printf(8, "USB Inserted: %s",
1660 usb_inserted() ? "yes" : "no"); 1523 usb_inserted() ? "yes" : "no");
1661 lcd_puts(0, 8, buf);
1662#elif defined IRIVER_H300_SERIES 1524#elif defined IRIVER_H300_SERIES
1663 snprintf(buf, 30, "USB Charging Enabled: %s", 1525 debug_printf(9, "USB Charging Enabled: %s",
1664 usb_charging_enabled() ? "yes" : "no"); 1526 usb_charging_enabled() ? "yes" : "no");
1665 lcd_puts(0, 9, buf);
1666#elif defined IPOD_NANO || defined IPOD_VIDEO 1527#elif defined IPOD_NANO || defined IPOD_VIDEO
1667 int usb_pwr = (GPIOL_INPUT_VAL & 0x10)?true:false; 1528 int usb_pwr = (GPIOL_INPUT_VAL & 0x10)?true:false;
1668 int ext_pwr = (GPIOL_INPUT_VAL & 0x08)?false:true; 1529 int ext_pwr = (GPIOL_INPUT_VAL & 0x08)?false:true;
@@ -1670,21 +1531,16 @@ static bool view_battery(void)
1670 int charging = (GPIOB_INPUT_VAL & 0x01)?false:true; 1531 int charging = (GPIOB_INPUT_VAL & 0x01)?false:true;
1671 int headphone= (GPIOA_INPUT_VAL & 0x80)?true:false; 1532 int headphone= (GPIOA_INPUT_VAL & 0x80)?true:false;
1672 1533
1673 snprintf(buf, 30, "USB pwr: %s", 1534 debug_printf(3, "USB pwr: %s",
1674 usb_pwr ? "present" : "absent"); 1535 usb_pwr ? "present" : "absent");
1675 lcd_puts(0, 3, buf); 1536 debug_printf(4, "EXT pwr: %s",
1676 snprintf(buf, 30, "EXT pwr: %s", 1537 ext_pwr ? "present" : "absent");
1677 ext_pwr ? "present" : "absent"); 1538 debug_printf(5, "Battery: %s",
1678 lcd_puts(0, 4, buf);
1679 snprintf(buf, 30, "Battery: %s",
1680 charging ? "charging" : (usb_pwr||ext_pwr) ? "charged" : "discharging"); 1539 charging ? "charging" : (usb_pwr||ext_pwr) ? "charged" : "discharging");
1681 lcd_puts(0, 5, buf); 1540 debug_printf(6, "Dock mode: %s",
1682 snprintf(buf, 30, "Dock mode: %s",
1683 dock ? "enabled" : "disabled"); 1541 dock ? "enabled" : "disabled");
1684 lcd_puts(0, 6, buf); 1542 debug_printf(7, "Headphone: %s",
1685 snprintf(buf, 30, "Headphone: %s",
1686 headphone ? "connected" : "disconnected"); 1543 headphone ? "connected" : "disconnected");
1687 lcd_puts(0, 7, buf);
1688#elif defined TOSHIBA_GIGABEAT_S 1544#elif defined TOSHIBA_GIGABEAT_S
1689 int line = 3; 1545 int line = 3;
1690 unsigned int st; 1546 unsigned int st;
@@ -1700,19 +1556,16 @@ static bool view_battery(void)
1700 "<unknown>", 1556 "<unknown>",
1701 }; 1557 };
1702 1558
1703 snprintf(buf, 30, "Charger: %s", 1559 debug_printf(line++, "Charger: %s",
1704 charger_inserted() ? "present" : "absent"); 1560 charger_inserted() ? "present" : "absent");
1705 lcd_puts(0, line++, buf);
1706 1561
1707 st = power_input_status() & 1562 st = power_input_status() &
1708 (POWER_INPUT_CHARGER | POWER_INPUT_BATTERY); 1563 (POWER_INPUT_CHARGER | POWER_INPUT_BATTERY);
1709 snprintf(buf, 30, "%s%s", 1564 debug_printf(line++, "%s%s",
1710 (st & POWER_INPUT_MAIN_CHARGER) ? " Main" : "", 1565 (st & POWER_INPUT_MAIN_CHARGER) ? " Main" : "",
1711 (st & POWER_INPUT_USB_CHARGER) ? " USB" : ""); 1566 (st & POWER_INPUT_USB_CHARGER) ? " USB" : "");
1712 lcd_puts(0, line++, buf);
1713 1567
1714 snprintf(buf, 30, "IUSB Max: %d", usb_allowed_current()); 1568 debug_printf(line++, "IUSB Max: %d", usb_allowed_current());
1715 lcd_puts(0, line++, buf);
1716 1569
1717 y = ARRAYLEN(chrgstate_strings) - 1; 1570 y = ARRAYLEN(chrgstate_strings) - 1;
1718 1571
@@ -1727,50 +1580,42 @@ static bool view_battery(void)
1727 default:; 1580 default:;
1728 } 1581 }
1729 1582
1730 snprintf(buf, 30, "State: %s", chrgstate_strings[y]); 1583 debug_printf(line++, "State: %s", chrgstate_strings[y]);
1731 lcd_puts(0, line++, buf);
1732 1584
1733 snprintf(buf, 30, "Battery Switch: %s", 1585 debug_printf(line++, "Battery Switch: %s",
1734 (st & POWER_INPUT_BATTERY) ? "On" : "Off"); 1586 (st & POWER_INPUT_BATTERY) ? "On" : "Off");
1735 lcd_puts(0, line++, buf);
1736 1587
1737 y = chrgraw_adc_voltage(); 1588 y = chrgraw_adc_voltage();
1738 snprintf(buf, 30, "CHRGRAW: %d.%03d V", 1589 debug_printf(line++, "CHRGRAW: %d.%03d V",
1739 y / 1000, y % 1000); 1590 y / 1000, y % 1000);
1740 lcd_puts(0, line++, buf);
1741 1591
1742 y = application_supply_adc_voltage(); 1592 y = application_supply_adc_voltage();
1743 snprintf(buf, 30, "BP : %d.%03d V", 1593 debug_printf(line++, "BP : %d.%03d V",
1744 y / 1000, y % 1000); 1594 y / 1000, y % 1000);
1745 lcd_puts(0, line++, buf);
1746 1595
1747 y = battery_adc_charge_current(); 1596 y = battery_adc_charge_current();
1748 if (y < 0) x = '-', y = -y; 1597 if (y < 0) x = '-', y = -y;
1749 else x = ' '; 1598 else x = ' ';
1750 snprintf(buf, 30, "CHRGISN:%c%d mA", x, y); 1599 debug_printf(line++, "CHRGISN:%c%d mA", x, y);
1751 lcd_puts(0, line++, buf);
1752 1600
1753 y = cccv_regulator_dissipation(); 1601 y = cccv_regulator_dissipation();
1754 snprintf(buf, 30, "P CCCV : %d mW", y); 1602 debug_printf(line++, "P CCCV : %d mW", y);
1755 lcd_puts(0, line++, buf);
1756 1603
1757 y = battery_charge_current(); 1604 y = battery_charge_current();
1758 if (y < 0) x = '-', y = -y; 1605 if (y < 0) x = '-', y = -y;
1759 else x = ' '; 1606 else x = ' ';
1760 snprintf(buf, 30, "I Charge:%c%d mA", x, y); 1607 debug_printf(line++, "I Charge:%c%d mA", x, y);
1761 lcd_puts(0, line++, buf);
1762 1608
1763 y = battery_adc_temp(); 1609 y = battery_adc_temp();
1764 1610
1765 if (y != INT_MIN) { 1611 if (y != INT_MIN) {
1766 snprintf(buf, 30, "T Battery: %dC (%dF)", y, 1612 debug_printf(line++, "T Battery: %dC (%dF)", y,
1767 (9*y + 160) / 5); 1613 (9*y + 160) / 5);
1768 } else { 1614 } else {
1769 /* Conversion disabled */ 1615 /* Conversion disabled */
1770 snprintf(buf, 30, "T Battery: ?"); 1616 lcd_puts(0, line++, "T Battery: ?");
1771 } 1617 }
1772 1618
1773 lcd_puts(0, line++, buf);
1774#elif defined(SANSA_E200) || defined(SANSA_C200) || defined(SANSA_CLIP) || defined(SANSA_FUZE) 1619#elif defined(SANSA_E200) || defined(SANSA_C200) || defined(SANSA_CLIP) || defined(SANSA_FUZE)
1775 const int first = CHARGE_STATE_DISABLED; 1620 const int first = CHARGE_STATE_DISABLED;
1776 static const char * const chrgstate_strings[] = 1621 static const char * const chrgstate_strings[] =
@@ -1782,29 +1627,24 @@ static bool view_battery(void)
1782 }; 1627 };
1783 const char *str = NULL; 1628 const char *str = NULL;
1784 1629
1785 snprintf(buf, 30, "Charger: %s", 1630 debug_printf(3, "Charger: %s",
1786 charger_inserted() ? "present" : "absent"); 1631 charger_inserted() ? "present" : "absent");
1787 lcd_puts(0, 3, buf);
1788 1632
1789 y = charge_state - first; 1633 y = charge_state - first;
1790 if ((unsigned)y < ARRAYLEN(chrgstate_strings)) 1634 if ((unsigned)y < ARRAYLEN(chrgstate_strings))
1791 str = chrgstate_strings[y]; 1635 str = chrgstate_strings[y];
1792 1636
1793 snprintf(buf, sizeof(buf), "State: %s", 1637 debug_printf(4, "State: %s",
1794 str ? str : "<unknown>"); 1638 str ? str : "<unknown>");
1795 lcd_puts(0, 4, buf);
1796 1639
1797 snprintf(buf, sizeof(buf), "CHARGER: %02X", 1640 debug_printf(5, "CHARGER: %02X",
1798 ascodec_read(AS3514_CHARGER)); 1641 ascodec_read(AS3514_CHARGER));
1799 lcd_puts(0, 5, buf);
1800#elif defined(IPOD_NANO2G) 1642#elif defined(IPOD_NANO2G)
1801 y = pmu_read_battery_current(); 1643 y = pmu_read_battery_current();
1802 snprintf(buf, 30, "Battery current: %d mA", y); 1644 debug_printf(2, "Battery current: %d mA", y);
1803 lcd_puts(0, 2, buf);
1804#else 1645#else
1805 snprintf(buf, 30, "Charger: %s", 1646 debug_printf(3, "Charger: %s",
1806 charger_inserted() ? "present" : "absent"); 1647 charger_inserted() ? "present" : "absent");
1807 lcd_puts(0, 3, buf);
1808#endif /* target type */ 1648#endif /* target type */
1809#endif /* CONFIG_CHARGING */ 1649#endif /* CONFIG_CHARGING */
1810 break; 1650 break;
@@ -1814,42 +1654,33 @@ static bool view_battery(void)
1814 1654
1815 for (i = 0; i <= 6; i++) { 1655 for (i = 0; i <= 6; i++) {
1816 y = power_history[i] - power_history[i+1]; 1656 y = power_history[i] - power_history[i+1];
1817 snprintf(buf, 30, "-%d min: %s%d.%03d V", i, 1657 debug_printf(i+1, "-%d min: %s%d.%03d V", i,
1818 (y < 0) ? "-" : "", ((y < 0) ? y * -1 : y) / 1000, 1658 (y < 0) ? "-" : "", ((y < 0) ? y * -1 : y) / 1000,
1819 ((y < 0) ? y * -1 : y ) % 1000); 1659 ((y < 0) ? y * -1 : y ) % 1000);
1820 lcd_puts(0, i+1, buf);
1821 } 1660 }
1822 break; 1661 break;
1823 1662
1824 case 3: /* remaining time estimation: */ 1663 case 3: /* remaining time estimation: */
1825 1664
1826#ifdef ARCHOS_RECORDER 1665#ifdef ARCHOS_RECORDER
1827 snprintf(buf, 30, "charge_state: %d", charge_state); 1666 debug_printf(0, "charge_state: %d", charge_state);
1828 lcd_puts(0, 0, buf);
1829 1667
1830 snprintf(buf, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min); 1668 debug_printf(1, "Cycle time: %d m", powermgmt_last_cycle_startstop_min);
1831 lcd_puts(0, 1, buf);
1832 1669
1833 snprintf(buf, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level); 1670 debug_printf(2, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level);
1834 lcd_puts(0, 2, buf);
1835 1671
1836 snprintf(buf, 30, "P=%2d I=%2d", pid_p, pid_i); 1672 debug_printf(3, "P=%2d I=%2d", pid_p, pid_i);
1837 lcd_puts(0, 3, buf);
1838 1673
1839 snprintf(buf, 30, "Trickle sec: %d/60", trickle_sec); 1674 debug_printf(4, "Trickle sec: %d/60", trickle_sec);
1840 lcd_puts(0, 4, buf);
1841#endif /* ARCHOS_RECORDER */ 1675#endif /* ARCHOS_RECORDER */
1842 1676
1843 snprintf(buf, 30, "Last PwrHist: %d.%03dV", 1677 debug_printf(5, "Last PwrHist: %d.%03dV",
1844 power_history[0] / 1000, 1678 power_history[0] / 1000,
1845 power_history[0] % 1000); 1679 power_history[0] % 1000);
1846 lcd_puts(0, 5, buf);
1847 1680
1848 snprintf(buf, 30, "battery level: %d%%", battery_level()); 1681 debug_printf(6, "battery level: %d%%", battery_level());
1849 lcd_puts(0, 6, buf);
1850 1682
1851 snprintf(buf, 30, "Est. remain: %d m", battery_time()); 1683 debug_printf(7, "Est. remain: %d m", battery_time());
1852 lcd_puts(0, 7, buf);
1853 break; 1684 break;
1854 } 1685 }
1855 1686
@@ -1900,7 +1731,7 @@ static int disk_callback(int btn, struct gui_synclist *lists)
1900 static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" }; 1731 static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" };
1901 static const unsigned char *nsec_units[] = { "ns", "µs", "ms" }; 1732 static const unsigned char *nsec_units[] = { "ns", "µs", "ms" };
1902#if (CONFIG_STORAGE & STORAGE_MMC) 1733#if (CONFIG_STORAGE & STORAGE_MMC)
1903 static const char *mmc_spec_vers[] = { "1.0-1.2", "1.4", "2.0-2.2", 1734 static const char * const mmc_spec_vers[] = { "1.0-1.2", "1.4", "2.0-2.2",
1904 "3.1-3.31", "4.0" }; 1735 "3.1-3.31", "4.0" };
1905#endif 1736#endif
1906 1737
@@ -2604,7 +2435,6 @@ extern unsigned int wheel_velocity;
2604 2435
2605static bool dbg_scrollwheel(void) 2436static bool dbg_scrollwheel(void)
2606{ 2437{
2607 char buf[64];
2608 unsigned int speed; 2438 unsigned int speed;
2609 2439
2610 lcd_setfont(FONT_SYSFIXED); 2440 lcd_setfont(FONT_SYSFIXED);
@@ -2617,23 +2447,16 @@ static bool dbg_scrollwheel(void)
2617 lcd_clear_display(); 2447 lcd_clear_display();
2618 2448
2619 /* show internal variables of scrollwheel driver */ 2449 /* show internal variables of scrollwheel driver */
2620 snprintf(buf, sizeof(buf), "wheel touched: %s", (wheel_is_touched) ? "true" : "false"); 2450 debug_printf(0, "wheel touched: %s", (wheel_is_touched) ? "true" : "false");
2621 lcd_puts(0, 0, buf); 2451 debug_printf(1, "new position: %2d", new_wheel_value);
2622 snprintf(buf, sizeof(buf), "new position: %2d", new_wheel_value); 2452 debug_printf(2, "old position: %2d", old_wheel_value);
2623 lcd_puts(0, 1, buf); 2453 debug_printf(3, "wheel delta: %2d", wheel_delta);
2624 snprintf(buf, sizeof(buf), "old position: %2d", old_wheel_value); 2454 debug_printf(4, "accumulated delta: %2d", accumulated_wheel_delta);
2625 lcd_puts(0, 2, buf); 2455 debug_printf(5, "velo [deg/s]: %4d", (int)wheel_velocity);
2626 snprintf(buf, sizeof(buf), "wheel delta: %2d", wheel_delta);
2627 lcd_puts(0, 3, buf);
2628 snprintf(buf, sizeof(buf), "accumulated delta: %2d", accumulated_wheel_delta);
2629 lcd_puts(0, 4, buf);
2630 snprintf(buf, sizeof(buf), "velo [deg/s]: %4d", (int)wheel_velocity);
2631 lcd_puts(0, 5, buf);
2632 2456
2633 /* show effective accelerated scrollspeed */ 2457 /* show effective accelerated scrollspeed */
2634 speed = button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity); 2458 speed = button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity);
2635 snprintf(buf, sizeof(buf), "accel. speed: %4d", speed); 2459 debug_printf(6 "accel. speed: %4d", speed);
2636 lcd_puts(0, 6, buf);
2637 2460
2638 lcd_update(); 2461 lcd_update();
2639 } 2462 }