/* write */ void display_write_bitmap(const byte bm[8], byte x, byte y, byte cont) { register byte i __asm("r16"); /* Multiply the coordinates by 8 to convert from tile coords to absolute. */ /* This only needs to be done for the x-axis as a page size (y-axis) */ /* is already 8-bits tall */ x <<= 3; /* Select the relevant display chip */ display_set_side(x >= 64 ? SIDE2 : SIDE1); if (!cont) { /* Set the coordinates */ display_send(INSTR_SET_ADDR(x)); display_send(INSTR_SET_PAGE(y)); } /* Write the bitmap to the display memory */ for (i = 0; i < 8; i++) { /* Write a single byte from the bitmap */ display_send(INSTR_WRITE_DISP(bm[i])); } }
/* Read a raw byte of video memory from the display */ byte display_read(byte col, byte row) { display_set_side(col >= 64 ? SIDE2 : SIDE1); /* Set the coordinates */ display_send(INSTR_SET_PAGE(row)); display_send(INSTR_SET_ADDR(col)); /* Return the display data at the specified address */ return display_send(INSTR_READ_DISP); }
static void display_chip_enable(byte c, byte c_old) { /* Deselect the previous chip */ PORTL &= ~c_old; /* Select the current chip */ PORTL |= c; /* Send the power-on command to the chip */ display_send(INSTR_POWER(1)); display_send(INSTR_SET_START_LINE(0)); /* Start at line 0 */ _delay_ms(10); }
/* Write a raw byte of video memory to the display */ void display_write(byte col, byte row, byte data, byte cont) { /* Set the screen side */ display_set_side(col >= 64 ? SIDE2 : SIDE1); if (!cont) { /* Set the coordinates */ display_send(INSTR_SET_ADDR(col)); display_send(INSTR_SET_PAGE(row)); } /* Write the data to the display */ display_send(INSTR_WRITE_DISP(data)); }
static void hilite_callback(mvp_widget_t *widget, char *item, void *key, bool hilite) { char path[1024], str[1024], date[64]; struct stat64 sb; if (hilite) { sprintf(path, "%s/%s", cwd, item); stat64(path, &sb); ctime_r(&sb.st_mtime, date); snprintf(str, sizeof(str), "File: %s\nSize: %lld\nDate: %s", item, (long long)sb.st_size, date); mvpw_set_text_str(fb_program_widget, str); if (current_hilite) free(current_hilite); current_hilite = strdup(item); /* * Send the currently hilighted text to the display. */ snprintf(display_message, sizeof(display_message), "File:%s\n", current_hilite); display_send(display_message); } }
static void select_callback(mvp_widget_t *widget, char *item, void *key) { char path[1024], *ptr; struct stat64 sb; sprintf(path, "%s/%s", cwd, item); if (stat64(path, &sb)!=0) { printf("Could not stat %s error %d\n",item,errno); if (strcmp(item,"../")==0 ) { // probably lost network put you back in root strcpy(cwd,"/"); strcpy(path,"/"); stat64(path, &sb); } } if (current_pl && !is_playlist(item)) { free(current_pl); current_pl = NULL; } if (current_pl && (playlist == NULL)) { free(current_pl); current_pl = NULL; } printf("%s(): path '%s'\n", __FUNCTION__, path); if (current && (strcmp(path, current) == 0)) { printf("selected current item\n"); if (is_video(item) || (is_streaming(item) > 100)) { mvpw_hide(widget); mvpw_hide(fb_progress); av_move(0, 0, 0); screensaver_disable(); return; } } if (current_pl && (strcmp(path, current_pl) == 0)) { if (is_playlist(item)) { mvpw_show(fb_progress); mvpw_set_timer(fb_progress, fb_osd_update, 500); mvpw_hide(widget); printf("Show playlist menu\n"); mvpw_show(playlist_widget); mvpw_focus(playlist_widget); return; } } if (S_ISDIR(sb.st_mode)) { if (strcmp(item, "../") == 0) { strcpy(path, cwd); if (path[strlen(path)-1] == '/') path[strlen(path)-1] = '\0'; if ((ptr=strrchr(path, '/')) != NULL) *ptr = '\0'; if (path[0] == '\0') sprintf(path, "/"); } else { if ((ptr=strrchr(path, '/')) != NULL) *ptr = '\0'; } if (strstr(path,"/uPnP")!=NULL && strstr(cwd,"/uPnP")==NULL ){ mount_djmount(path); } else if (strstr(path,"/uPnP")==NULL && strstr(cwd,"/uPnP")!=NULL ) { unmount_djmount(); } strncpy(cwd, path, sizeof(cwd)); while ((cwd[0] == '/') && (cwd[1] == '/')) memmove(cwd, cwd+1, strlen(cwd)); mvpw_clear_menu(widget); mvpw_set_menu_title(widget, cwd); busy_start(); add_dirs(widget); add_files(widget); busy_end(); mvpw_expose(widget); } else { switch_hw_state(MVPMC_STATE_FILEBROWSER); if (current) free(current); current = NULL; audio_stop = 1; pthread_kill(audio_thread, SIGURG); while (audio_playing) usleep(1000); current = strdup(path); if (is_streaming(item) > 100) { // Use VLC callbacks for streaming items video_functions = &vlc_functions; // Allow broadcast messages to be sent so // we can tell VLC to start the stream vlc_broadcast_enabled = 1; } else { video_functions = &file_functions; } add_osd_widget(fb_program_widget, OSD_PROGRAM, osd_settings.program, NULL); mvpw_set_text_str(fb_name, item); /* * This code sends the currently playing file name to the display. */ snprintf(display_message, sizeof(display_message), "File:%s\n", item); display_send(display_message); audio_clear(); video_clear(); playlist_clear(); if (is_video(item)) { if (key != NULL) { mvpw_hide(widget); mvpw_hide(fb_progress); av_move(0, 0, 0); } else { mvpw_show(fb_progress); } mvpw_set_timer(fb_progress, fb_osd_update, 500); video_play(NULL); mvpw_show(root); mvpw_expose(root); mvpw_focus(root); } else if (is_audio(item) || is_streaming(item)>=0 ) { mvpw_show(fb_progress); mvpw_set_timer(fb_progress, fb_osd_update, 500); audio_play(NULL); } else if (is_image(item)) { mvpw_hide(widget); printf("Displaying image '%s'\n", path); if (mvpw_load_image_jpeg(iw, path) == 0) { mvpw_show_image_jpeg(iw); av_wss_update_aspect(WSS_ASPECT_UNKNOWN); } else { mvpw_set_image(iw, path); } mvpw_show(iw); mvpw_focus(iw); loaded_offset = 0; loaded_status = 0; fb_next_image(1); } else if (is_playlist(item)) { if (current_pl) free(current_pl); current_pl = strdup(path); mvpw_show(fb_progress); mvpw_set_timer(fb_progress, fb_osd_update, 500); mvpw_hide(widget); printf("Show playlist menu\n"); mvpw_show(playlist_widget); mvpw_focus(playlist_widget); playlist_clear(); playlist_play(NULL); } } }