void lcd_remote_init_device(void) { #ifdef IRIVER_H300_SERIES or_l(0x10010000, &GPIO_FUNCTION); /* GPIO16: RS GPIO28: CLK */ or_l(0x00040006, &GPIO1_FUNCTION); /* GPO33: Backlight GPIO34: CS GPIO50: Data */ or_l(0x10010000, &GPIO_ENABLE); or_l(0x00040006, &GPIO1_ENABLE); #else or_l(0x10010800, &GPIO_FUNCTION); /* GPIO11: Backlight GPIO16: RS GPIO28: CLK */ or_l(0x00040004, &GPIO1_FUNCTION); /* GPIO34: CS GPIO50: Data */ or_l(0x10010800, &GPIO_ENABLE); or_l(0x00040004, &GPIO1_ENABLE); #endif lcd_remote_clear_display(); if (remote_detect()) lcd_remote_on(); #ifndef BOOTLOADER tick_add_task(remote_tick); #endif }
static void displayremote(void) { /* TODO: we should have a debug option that enables/disables this! */ int w, h; int lines; int columns; int i; int index; lcd_remote_getstringsize("A", &w, &h); lines = LCD_REMOTE_HEIGHT/h; columns = LCD_REMOTE_WIDTH/w; lcd_remote_setmargins(0, 0); lcd_remote_clear_display(); index = logfindex; for(i = lines-1; i>=0; i--) { unsigned char buffer[columns+1]; if(--index < 0) { if(logfwrap) index = MAX_LOGF_LINES-1; else break; /* done */ } memcpy(buffer, logfbuffer[index], columns); buffer[columns]=0; lcd_remote_puts(0, i, buffer); } lcd_remote_update(); }
void reset_screen(void) { lcd_clear_display(); line = 0; #ifdef HAVE_REMOTE_LCD lcd_remote_clear_display(); remote_line = 0; #endif }
void lcd_remote_init_device(void) { lcd_remote_clear_display(); if (remote_detect()) lcd_remote_on(); lcd_remote_update(); /* put the remote control in the tick task */ tick_add_task(remote_tick); }
int plugin_load(const char* plugin, const void* parameter) { struct plugin_header *p_hdr; struct lc_header *hdr; if (current_plugin_handle && pfn_tsr_exit) { /* if we have a resident old plugin and a callback */ if (pfn_tsr_exit(!strcmp(current_plugin, plugin)) == false ) { /* not allowing another plugin to load */ return PLUGIN_OK; } lc_close(current_plugin_handle); current_plugin_handle = pfn_tsr_exit = NULL; if (plugin_buffer_handle > 0) plugin_buffer_handle = core_free(plugin_buffer_handle); } splash(0, ID2P(LANG_WAIT)); strcpy(current_plugin, plugin); current_plugin_handle = lc_open(plugin, pluginbuf, PLUGIN_BUFFER_SIZE); if (current_plugin_handle == NULL) { splashf(HZ*2, str(LANG_PLUGIN_CANT_OPEN), plugin); return -1; } p_hdr = lc_get_header(current_plugin_handle); hdr = p_hdr ? &p_hdr->lc_hdr : NULL; if (hdr == NULL || hdr->magic != PLUGIN_MAGIC || hdr->target_id != TARGET_ID #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || hdr->load_addr != pluginbuf || hdr->end_addr > pluginbuf + PLUGIN_BUFFER_SIZE #endif ) { lc_close(current_plugin_handle); splash(HZ*2, str(LANG_PLUGIN_WRONG_MODEL)); return -1; } if (hdr->api_version > PLUGIN_API_VERSION || hdr->api_version < PLUGIN_MIN_API_VERSION) { lc_close(current_plugin_handle); splash(HZ*2, str(LANG_PLUGIN_WRONG_VERSION)); return -1; } #if (CONFIG_PLATFORM & PLATFORM_NATIVE) plugin_size = hdr->end_addr - pluginbuf; #else plugin_size = 0; #endif *(p_hdr->api) = &rockbox_api; lcd_clear_display(); lcd_update(); #ifdef HAVE_REMOTE_LCD lcd_remote_clear_display(); lcd_remote_update(); #endif push_current_activity(ACTIVITY_PLUGIN); /* some plugins assume the entry cache doesn't move and save pointers to it * they should be fixed properly instead of this lock */ tree_lock_cache(tree_get_context()); FOR_NB_SCREENS(i) viewportmanager_theme_enable(i, false, NULL); #ifdef HAVE_TOUCHSCREEN touchscreen_set_mode(TOUCHSCREEN_BUTTON); #endif /* allow voice to back off if the plugin needs lots of memory */ talk_buffer_set_policy(TALK_BUFFER_LOOSE); plugin_check_open_close__enter(); int rc = p_hdr->entry_point(parameter); tree_unlock_cache(tree_get_context()); pop_current_activity(); if (!pfn_tsr_exit) { /* close handle if plugin is no tsr one */ lc_close(current_plugin_handle); current_plugin_handle = NULL; if (plugin_buffer_handle > 0) plugin_buffer_handle = core_free(plugin_buffer_handle); } talk_buffer_set_policy(TALK_BUFFER_DEFAULT); /* Go back to the global setting in case the plugin changed it */ #ifdef HAVE_TOUCHSCREEN touchscreen_set_mode(global_settings.touch_mode); #endif #ifdef HAVE_LCD_BITMAP screen_helper_setfont(FONT_UI); #if LCD_DEPTH > 1 #ifdef HAVE_LCD_COLOR lcd_set_drawinfo(DRMODE_SOLID, global_settings.fg_color, global_settings.bg_color); #else lcd_set_drawinfo(DRMODE_SOLID, LCD_DEFAULT_FG, LCD_DEFAULT_BG); #endif #else /* LCD_DEPTH == 1 */ lcd_set_drawmode(DRMODE_SOLID); #endif /* LCD_DEPTH */ #endif /* HAVE_LCD_BITMAP */ #ifdef HAVE_REMOTE_LCD #if LCD_REMOTE_DEPTH > 1 lcd_remote_set_drawinfo(DRMODE_SOLID, LCD_REMOTE_DEFAULT_FG, LCD_REMOTE_DEFAULT_BG); #else lcd_remote_set_drawmode(DRMODE_SOLID); #endif #endif lcd_clear_display(); #ifdef HAVE_REMOTE_LCD lcd_remote_clear_display(); #endif FOR_NB_SCREENS(i) viewportmanager_theme_undo(i, true); plugin_check_open_close__exit(); if (rc == PLUGIN_ERROR) splash(HZ*2, str(LANG_PLUGIN_ERROR)); return rc; }
int plugin_load(const char* plugin, const void* parameter) { struct plugin_header *p_hdr; struct lc_header *hdr; if (current_plugin_handle && pfn_tsr_exit) { /* if we have a resident old plugin and a callback */ if (pfn_tsr_exit(!strcmp(current_plugin, plugin)) == false ) { /* not allowing another plugin to load */ return PLUGIN_OK; } lc_close(current_plugin_handle); current_plugin_handle = pfn_tsr_exit = NULL; } splash(0, ID2P(LANG_WAIT)); strcpy(current_plugin, plugin); current_plugin_handle = lc_open(plugin, pluginbuf, PLUGIN_BUFFER_SIZE); if (current_plugin_handle == NULL) { splashf(HZ*2, str(LANG_PLUGIN_CANT_OPEN), plugin); return -1; } p_hdr = lc_get_header(current_plugin_handle); hdr = p_hdr ? &p_hdr->lc_hdr : NULL; if (hdr == NULL || hdr->magic != PLUGIN_MAGIC || hdr->target_id != TARGET_ID #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || hdr->load_addr != pluginbuf || hdr->end_addr > pluginbuf + PLUGIN_BUFFER_SIZE #endif ) { lc_close(current_plugin_handle); splash(HZ*2, str(LANG_PLUGIN_WRONG_MODEL)); return -1; } if (hdr->api_version > PLUGIN_API_VERSION || hdr->api_version < PLUGIN_MIN_API_VERSION) { lc_close(current_plugin_handle); splash(HZ*2, str(LANG_PLUGIN_WRONG_VERSION)); return -1; } #if (CONFIG_PLATFORM & PLATFORM_NATIVE) plugin_size = hdr->end_addr - pluginbuf; #else plugin_size = 0; #endif *(p_hdr->api) = &rockbox_api; lcd_clear_display(); lcd_update(); #ifdef HAVE_REMOTE_LCD lcd_remote_clear_display(); lcd_remote_update(); #endif push_current_activity(ACTIVITY_PLUGIN); /* some plugins assume the entry cache doesn't move and save pointers to it * they should be fixed properly instead of this lock */ tree_lock_cache(tree_get_context()); FOR_NB_SCREENS(i) viewportmanager_theme_enable(i, false, NULL); #ifdef HAVE_TOUCHSCREEN touchscreen_set_mode(TOUCHSCREEN_BUTTON); #endif #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE open_files = 0; #endif int rc = p_hdr->entry_point(parameter); tree_unlock_cache(tree_get_context()); pop_current_activity(); if (!pfn_tsr_exit) { /* close handle if plugin is no tsr one */ lc_close(current_plugin_handle); current_plugin_handle = NULL; } /* Go back to the global setting in case the plugin changed it */ #ifdef HAVE_TOUCHSCREEN touchscreen_set_mode(global_settings.touch_mode); #endif #ifdef HAVE_LCD_BITMAP screen_helper_setfont(FONT_UI); #if LCD_DEPTH > 1 #ifdef HAVE_LCD_COLOR lcd_set_drawinfo(DRMODE_SOLID, global_settings.fg_color, global_settings.bg_color); #else lcd_set_drawinfo(DRMODE_SOLID, LCD_DEFAULT_FG, LCD_DEFAULT_BG); #endif #else /* LCD_DEPTH == 1 */ lcd_set_drawmode(DRMODE_SOLID); #endif /* LCD_DEPTH */ #endif /* HAVE_LCD_BITMAP */ #ifdef HAVE_REMOTE_LCD #if LCD_REMOTE_DEPTH > 1 lcd_remote_set_drawinfo(DRMODE_SOLID, LCD_REMOTE_DEFAULT_FG, LCD_REMOTE_DEFAULT_BG); #else lcd_remote_set_drawmode(DRMODE_SOLID); #endif #endif lcd_clear_display(); #ifdef HAVE_REMOTE_LCD lcd_remote_clear_display(); #endif FOR_NB_SCREENS(i) viewportmanager_theme_undo(i, true); #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE if(open_files != 0 && !current_plugin_handle) { int fd; logf("Plugin '%s' leaks file handles", plugin); static const char *lines[] = { ID2P(LANG_PLUGIN_ERROR), "#leak-file-handles" }; static const struct text_message message={ lines, 2 }; button_clear_queue(); /* Empty the keyboard buffer */ gui_syncyesno_run(&message, NULL, NULL); for(fd=0; fd < MAX_OPEN_FILES; fd++) if(open_files & (1<<fd)) close_wrapper(fd); } #endif if (rc == PLUGIN_ERROR) splash(HZ*2, str(LANG_PLUGIN_ERROR)); return rc; }
static void displayremote(void) { /* TODO: we should have a debug option that enables/disables this! */ int w, h, i; int fontnr; int cur_x, cur_y, delta_y, delta_x; struct font* font; int nb_lines; char buf[2]; /* Memorize the pointer to the beginning of the last ... lines I assume delta_y >= 6 to avoid wasting memory and allocating memory dynamically I hope there is no font with height < 6 ! */ const int NB_ENTRIES=LCD_REMOTE_HEIGHT / 6; int line_start_ptr[NB_ENTRIES]; fontnr = lcd_getfont(); font = font_get(fontnr); /* get the horizontal size of each line */ font_getstringsize("A", NULL, &delta_y, fontnr); /* font too small ? */ if(delta_y < 6) return; /* nothing to print ? */ if(logfindex == 0 && !logfwrap) return; w = LCD_REMOTE_WIDTH; h = LCD_REMOTE_HEIGHT; nb_lines = 0; if(logfwrap) i = logfindex; else i = 0; cur_x = 0; line_start_ptr[0] = i; do { if(logfbuffer[i] == '\0') { line_start_ptr[++nb_lines % NB_ENTRIES] = i+1; cur_x = 0; } else { /* does character fit on this line ? */ delta_x = font_get_width(font, logfbuffer[i]); if(cur_x + delta_x > w) { cur_x = 0; line_start_ptr[++nb_lines % NB_ENTRIES] = i; } /* update pointer */ cur_x += delta_x; } i++; if(i >= MAX_LOGF_SIZE) i = 0; } while(i != logfindex); lcd_remote_clear_display(); i = line_start_ptr[ MAX(nb_lines - h / delta_y, 0) % NB_ENTRIES]; cur_x = 0; cur_y = 0; buf[1] = '\0'; do { if(logfbuffer[i] == '\0') { cur_y += delta_y; cur_x = 0; } else { /* does character fit on this line ? */ delta_x = font_get_width(font, logfbuffer[i]); if(cur_x + delta_x > w) { cur_y += delta_y; cur_x = 0; } buf[0] = logfbuffer[i]; lcd_remote_putsxy(cur_x, cur_y, buf); cur_x += delta_x; } i++; if(i >= MAX_LOGF_SIZE) i = 0; } while(i != logfindex); lcd_remote_update(); }
static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar) { int i; /* Clear main and remote screens to remove scrolling line artifacts */ lcd_clear_display(); #ifdef HAVE_LCD_REMOTE lcd_remote_clear_display(); #endif FOR_NB_SCREENS(i) { struct screen *screen = &screens[i]; struct usb_screen_vps_t *usb_screen_vps = &usb_screen_vps_ar[i]; struct viewport *parent = &usb_screen_vps->parent; #ifdef HAVE_LCD_BITMAP struct viewport *logo = &usb_screen_vps->logo; #endif screen->set_viewport(parent); screen->clear_viewport(); screen->backlight_on(); #ifdef HAVE_LCD_BITMAP screen->set_viewport(logo); #ifdef HAVE_REMOTE_LCD if (i == SCREEN_REMOTE) { screen->bitmap(remote_usblogo, 0, 0, logo->width, logo->height); } else #endif { screen->transparent_bitmap(usblogo, 0, 0, logo->width, logo->height); #ifdef USB_ENABLE_HID if (usb_hid) { char modestring[100]; screen->set_viewport(&usb_screen_vps->title); usb_screen_vps->title.flags |= VP_FLAG_ALIGN_CENTER; snprintf(modestring, sizeof(modestring), "%s: %s", str(LANG_USB_KEYPAD_MODE), str(keypad_mode_name_get())); screen->puts_scroll(0, 0, modestring); } #endif /* USB_ENABLE_HID */ } screen->set_viewport(parent); #else /* HAVE_LCD_BITMAP */ screen->double_height(false); screen->puts_scroll(0, 0, "[USB Mode]"); status_set_param(false); status_set_audio(false); status_set_usb(true); #endif /* HAVE_LCD_BITMAP */ screen->set_viewport(NULL); screen->update_viewport(); } }