📄 debug_menu.c
字号:
return false;}#ifdef HAVE_LCD_BITMAP/* Test code!!! */bool dbg_ports(void){ unsigned short porta; unsigned short portb; unsigned char portc; char buf[32]; int button; int battery_voltage; int batt_int, batt_frac;#ifdef HAVE_LCD_BITMAP lcd_setmargins(0, 0);#endif lcd_clear_display(); while(1) { porta = PADR; portb = PBDR; portc = PCDR; snprintf(buf, 32, "PADR: %04x", porta); lcd_puts(0, 0, buf); snprintf(buf, 32, "PBDR: %04x", portb); lcd_puts(0, 1, buf); snprintf(buf, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4)); lcd_puts(0, 2, buf); snprintf(buf, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5)); lcd_puts(0, 3, buf); snprintf(buf, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6)); lcd_puts(0, 4, buf); snprintf(buf, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7)); lcd_puts(0, 5, buf); battery_voltage = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000; batt_int = battery_voltage / 100; batt_frac = battery_voltage % 100; snprintf(buf, 32, "Batt: %d.%02dV %d%% ", batt_int, batt_frac, battery_level()); lcd_puts(0, 6, buf); snprintf(buf, 32, "ATA: %s, 0x%x", ata_device?"slave":"master", ata_io_address); lcd_puts(0, 7, buf); lcd_update(); button = button_get_w_tmo(HZ/10); switch(button) { case BUTTON_OFF | BUTTON_REL: return false; } } return false;}#elsebool dbg_ports(void){ unsigned short porta; unsigned short portb; unsigned char portc; char buf[32]; int button; int battery_voltage; int batt_int, batt_frac; int currval = 0;#ifdef HAVE_LCD_BITMAP lcd_setmargins(0, 0);#endif lcd_clear_display(); while(1) { porta = PADR; portb = PBDR; portc = PCDR; switch(currval) { case 0: snprintf(buf, 32, "PADR: %04x ", porta); break; case 1: snprintf(buf, 32, "PBDR: %04x ", portb); break; case 2: snprintf(buf, 32, "AN0: %03x ", adc_read(0)); break; case 3: snprintf(buf, 32, "AN1: %03x ", adc_read(1)); break; case 4: snprintf(buf, 32, "AN2: %03x ", adc_read(2)); break; case 5: snprintf(buf, 32, "AN3: %03x ", adc_read(3)); break; case 6: snprintf(buf, 32, "AN4: %03x ", adc_read(4)); break; case 7: snprintf(buf, 32, "AN5: %03x ", adc_read(5)); break; case 8: snprintf(buf, 32, "AN6: %03x ", adc_read(6)); break; case 9: snprintf(buf, 32, "AN7: %03x ", adc_read(7)); break; case 10: snprintf(buf, 32, "%s, 0x%x ", ata_device?"slv":"mst", ata_io_address); break; } lcd_puts(0, 0, buf); battery_voltage = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000; batt_int = battery_voltage / 100; batt_frac = battery_voltage % 100; snprintf(buf, 32, "Batt: %d.%02dV", batt_int, batt_frac); lcd_puts(0, 1, buf); button = button_get_w_tmo(HZ/5); switch(button) { case BUTTON_STOP | BUTTON_REL: return false; case BUTTON_LEFT: currval--; if(currval < 0) currval = 10; break; case BUTTON_RIGHT: currval++; if(currval > 10) currval = 0; break; } } return false;}#endif#ifdef HAVE_RTC/* Read RTC RAM contents and display them */bool dbg_rtc(void){ char buf[32]; unsigned char addr = 0, r, c; int i; int button;#ifdef HAVE_LCD_BITMAP lcd_setmargins(0, 0);#endif lcd_clear_display(); lcd_puts(0, 0, "RTC read:"); while(1) { for (r = 0; r < 4; r++) { snprintf(buf, 10, "0x%02x: ", addr + r*4); for (c = 0; c <= 3; c++) { i = rtc_read(addr + r*4 + c); snprintf(buf + 6 + c*2, 3, "%02x", i); } lcd_puts(1, r+1, buf); } lcd_update(); button = button_get_w_tmo(HZ/2); switch(button) { case BUTTON_DOWN: if (addr < 63-16) { addr += 16; } break; case BUTTON_UP: if (addr) { addr -= 16; } break; case BUTTON_F2: /* clear the user RAM space */ for (c = 0; c <= 43; c++) rtc_write(0x14 + c, 0); break; case BUTTON_OFF | BUTTON_REL: case BUTTON_LEFT | BUTTON_REL: return false; } } return false;}#elsebool dbg_rtc(void){ return false;}#endif#ifdef HAVE_LCD_CHARCELLS#define NUMROWS 1#else#define NUMROWS 4#endif/* Read MAS registers and display them */bool dbg_mas(void){ char buf[32]; unsigned int addr = 0, r, i;#ifdef HAVE_LCD_BITMAP lcd_setmargins(0, 0);#endif lcd_clear_display(); lcd_puts(0, 0, "MAS register read:"); while(1) { for (r = 0; r < NUMROWS; r++) { i = mas_readreg(addr + r); snprintf(buf, 30, "%02x %08x", addr + r, i); lcd_puts(0, r+1, buf); } lcd_update(); switch(button_get_w_tmo(HZ/16)) {#ifdef HAVE_RECORDER_KEYPAD case BUTTON_DOWN:#else case BUTTON_RIGHT:#endif addr += NUMROWS; break;#ifdef HAVE_RECORDER_KEYPAD case BUTTON_UP:#else case BUTTON_LEFT:#endif if(addr) addr -= NUMROWS; break;#ifdef HAVE_RECORDER_KEYPAD case BUTTON_LEFT:#else case BUTTON_DOWN:#endif return false; } } return false;}#ifdef HAVE_MAS3587Fbool dbg_mas_codec(void){ char buf[32]; unsigned int addr = 0, r, i;#ifdef HAVE_LCD_BITMAP lcd_setmargins(0, 0);#endif lcd_clear_display(); lcd_puts(0, 0, "MAS codec reg read:"); while(1) { for (r = 0; r < 4; r++) { i = mas_codec_readreg(addr + r); snprintf(buf, 30, "0x%02x: %08x", addr + r, i); lcd_puts(1, r+1, buf); } lcd_update(); switch(button_get_w_tmo(HZ/16)) { case BUTTON_DOWN: addr += 4; break; case BUTTON_UP: if (addr) { addr -= 4; } break; case BUTTON_LEFT | BUTTON_REL: case BUTTON_OFF | BUTTON_REL: return false; } } return false;}#endif#ifdef HAVE_LCD_BITMAP/* * view_battery() shows a automatically scaled graph of the battery voltage * over time. Usable for estimating battery life / charging rate. * The power_history array is updated in power_thread of powermgmt.c. */#define BAT_FIRST_VAL MAX(POWER_HISTORY_LEN - LCD_WIDTH - 1, 0)#define BAT_YSPACE (LCD_HEIGHT - 20)bool view_battery(void){ int view = 0; int i, x, y; int maxv, minv; char buf[32]; #ifdef HAVE_LCD_BITMAP lcd_setmargins(0, 0);#endif while(1) { switch (view) { case 0: /* voltage history graph */ /* Find maximum and minimum voltage for scaling */ maxv = minv = 0; for (i = BAT_FIRST_VAL; i < POWER_HISTORY_LEN; i++) { if (power_history[i] > maxv) maxv = power_history[i]; if ((minv == 0) || ((power_history[i]) && (power_history[i] < minv)) ) { minv = power_history[i]; } } if (minv < 1) minv = 1; if (maxv < 2) maxv = 2; lcd_clear_display(); lcd_puts(0, 0, "Battery voltage:"); snprintf(buf, 30, "scale %d.%02d-%d.%02d V", minv / 100, minv % 100, maxv / 100, maxv % 100); lcd_puts(0, 1, buf); x = 0; for (i = BAT_FIRST_VAL+1; i < POWER_HISTORY_LEN; i++) { y = (power_history[i] - minv) * BAT_YSPACE / (maxv - minv); lcd_clearline(x, LCD_HEIGHT-1, x, 20); lcd_drawline(x, LCD_HEIGHT-1, x, MIN(MAX(LCD_HEIGHT-1 - y, 20), LCD_HEIGHT-1)); x++; } break; case 1: /* status: */ lcd_clear_display(); lcd_puts(0, 0, "Power status:"); y = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000; snprintf(buf, 30, "Battery: %d.%02d V", y / 100, y % 100); lcd_puts(0, 1, buf); y = (adc_read(ADC_EXT_POWER) * EXT_SCALE_FACTOR) / 10000; snprintf(buf, 30, "External: %d.%02d V", y / 100, y % 100); lcd_puts(0, 2, buf); snprintf(buf, 30, "Charger: %s", charger_inserted() ? "present" : "absent"); lcd_puts(0, 3, buf);#ifdef HAVE_CHARGE_CTRL snprintf(buf, 30, "Charging: %s", charger_enabled ? "yes" : "no"); lcd_puts(0, 4, buf);#endif y = ( power_history[POWER_HISTORY_LEN-1] * 100 + power_history[POWER_HISTORY_LEN-2] * 100 - power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD+1] * 100 - power_history[POWER_HISTORY_LEN-1-CHARGE_END_NEGD] * 100 ) / CHARGE_END_NEGD / 2; snprintf(buf, 30, "short delta: %d", y); lcd_puts(0, 5, buf); y = ( power_history[POWER_HISTORY_LEN-1] * 100 + power_history[POWER_HISTORY_LEN-2] * 100 - power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD+1] * 100 - power_history[POWER_HISTORY_LEN-1-CHARGE_END_ZEROD] * 100 ) / CHARGE_END_ZEROD / 2; snprintf(buf, 30, "long delta: %d", y); lcd_puts(0, 6, buf);#ifdef HAVE_CHARGE_CTRL lcd_puts(0, 7, power_message);#endif break; case 2: /* voltage deltas: */ lcd_clear_display(); lcd_puts(0, 0, "Voltage deltas:"); for (i = 0; i <= 6; i++) { y = power_history[POWER_HISTORY_LEN-1-i] - power_history[POWER_HISTORY_LEN-1-i-1]; snprintf(buf, 30, "-%d min: %s%d.%02d V", i, (y < 0) ? "-" : "", ((y < 0) ? y * -1 : y) / 100, ((y < 0) ? y * -1 : y ) % 100); lcd_puts(0, i+1, buf); } break; case 3: /* remeining time estimation: */ lcd_clear_display();#ifdef HAVE_CHARGE_CTRL snprintf(buf, 30, "charge_state: %d", charge_state); lcd_puts(0, 0, buf); snprintf(buf, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min); lcd_puts(0, 1, buf); snprintf(buf, 30, "Lev.at cycle start: %d%%", powermgmt_last_cycle_level); lcd_puts(0, 2, buf);#endif snprintf(buf, 30, "Last PwrHist val: %d.%02d V", power_history[POWER_HISTORY_LEN-1] / 100, power_history[POWER_HISTORY_LEN-1] % 100); lcd_puts(0, 3, buf); snprintf(buf, 30, "battery level: %d%%", battery_level()); lcd_puts(0, 5, buf); snprintf(buf, 30, "Est. remaining: %d m", battery_time()); lcd_puts(0, 6, buf);#ifdef HAVE_CHARGE_CTRL snprintf(buf, 30, "Trickle sec: %d/60", trickle_sec); lcd_puts(0, 7, buf);#endif break; } lcd_update(); switch(button_get_w_tmo(HZ/2)) { case BUTTON_UP: if (view) view--; break; case BUTTON_DOWN: if (view < 3) view++; break; case BUTTON_LEFT | BUTTON_REL: case BUTTON_OFF | BUTTON_REL: return false; } } return false;}#endif#ifdef HAVE_MAS3507Dbool dbg_mas_info(void){ int button; char buf[32]; int currval = 0; unsigned long val; unsigned long pll48, pll44, config; int pll_toggle = 0; #ifdef HAVE_LCD_BITMAP lcd_setmargins(0, 0);#endif while(1) { switch(currval) { case 0: mas_readmem(MAS_BANK_D1, 0xff7, &val, 1); lcd_puts(0, 0, "Design Code"); snprintf(buf, 32, "%05x ", val); break; case 1: lcd_puts(0, 0, "DC/DC mode "); snprintf(buf, 32, "8e: %05x ", mas_readreg(0x8e) & 0xfffff); break; case 2: lcd_puts(0, 0, "Mute/Bypass"); snprintf(buf, 32, "aa: %05x ", mas_readreg(0xaa) & 0xfffff); break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -