void init(char *name){ WindowWidth = lcd_getwidth()/8; WindowHeight = lcd_getheight()/16; cursor.relative.x = 0; cursor.relative.y = 0; cursor.absolute.x = 0; cursor.absolute.y = 0; File_open(name); cursor.str = head; View_redraw(&cursor); lcd_locate(0, 0); }
void cmd_lcd_terminal(uint_least16_t fgcolor, uint_least16_t bgcolor, uint_least8_t size) { uint_least16_t x=2, y=2; uint_least8_t c; lcd_clear(bgcolor); do { if(if_available() == 0) { continue; } c = if_read8(); switch(c) { case '\n': case '\r': if(x > 0) { x = 2; y += FONT_HEIGHT*size; } break; case '\t': c = ' '; default: x = lcd_drawchar(x, y, c, size, fgcolor, bgcolor, 1); break; } if(x >= lcd_getwidth()) { x = 2; y += FONT_HEIGHT*size; } if((y+FONT_HEIGHT*size) >= lcd_getheight()) { y = 2; lcd_clear(bgcolor); } }while(c != 0); lcd_clear(bgcolor); return; }
bool dbg_hw_info_clkctrl(void) { lcd_setfont(FONT_SYSFIXED); while(1) { int button = get_action(CONTEXT_STD, HZ / 10); switch(button) { case ACTION_STD_NEXT: case ACTION_STD_PREV: case ACTION_STD_OK: case ACTION_STD_MENU: lcd_setfont(FONT_UI); return true; case ACTION_STD_CANCEL: lcd_setfont(FONT_UI); return false; } lcd_clear_display(); /* 012345678901234567890123456789 */ lcd_putsf(0, 0, "name en by idiv fdiv frequency"); for(unsigned i = 0; i < ARRAYLEN(dbg_clk); i++) { #define c dbg_clk[i] lcd_putsf(0, i + 1, "%4s", c.name); if(c.has_enable) lcd_putsf(5, i + 1, "%2d", imx233_clkctrl_is_clock_enabled(c.clk)); if(c.has_bypass) lcd_putsf(8, i + 1, "%2d", imx233_clkctrl_get_bypass_pll(c.clk)); if(c.has_idiv && imx233_clkctrl_get_clock_divisor(c.clk) != 0) lcd_putsf(10, i + 1, "%4d", imx233_clkctrl_get_clock_divisor(c.clk)); if(c.has_fdiv && imx233_clkctrl_get_fractional_divisor(c.clk) != 0) lcd_putsf(16, i + 1, "%4d", imx233_clkctrl_get_fractional_divisor(c.clk)); if(c.has_freq) lcd_putsf(21, i + 1, "%9d", imx233_clkctrl_get_clock_freq(c.clk)); #undef c } int line = ARRAYLEN(dbg_clk) + 1; lcd_putsf(0, line, "as: %d/%d emi sync: %d", imx233_clkctrl_is_auto_slow_enabled(), 1 << imx233_clkctrl_get_auto_slow_divisor(), imx233_clkctrl_is_emi_sync_enabled()); line++; lcd_putsf(0, line, "as monitor: "); int x_off = 12; bool first = true; unsigned line_w = lcd_getwidth() / font_get_width(font_get(lcd_getfont()), ' '); for(unsigned i = 0; i < ARRAYLEN(dbg_as_monitor); i++) { if(!imx233_clkctrl_is_auto_slow_monitor_enabled(dbg_as_monitor[i].monitor)) continue; if(!first) { lcd_putsf(x_off, line, ", "); x_off += 2; } first = false; if((x_off + strlen(dbg_as_monitor[i].name)) > line_w) { x_off = 1; line++; } lcd_putsf(x_off, line, "%s", dbg_as_monitor[i].name); x_off += strlen(dbg_as_monitor[i].name); } line++; lcd_update(); yield(); } }