📄 lcd-player.c
字号:
void lcd_unlock_pattern(unsigned char pat){ lcd_ascii[pat]=RESERVED_CHAR; lcd_free_pat(pat);}void lcd_define_pattern(int pat, char *pattern){ int i; for (i=0; i<7; i++) { extended_font_player[pat][i]=pattern[i]; } if (extended_chars_mapped[pat]!=NO_CHAR) { lcd_define_hw_pattern(extended_chars_mapped[pat]*8, pattern, 7); }}#ifndef SIMULATORvoid lcd_define_hw_pattern (int which,char *pattern,int length){ int i; lcd_write(true,lcd_pram | which); for (i=0;i<length;i++) lcd_write(false,pattern[i]);}void lcd_double_height(bool on){ if(new_lcd) lcd_write(true,on?9:8);}static char icon_pos[] ={ 0, 0, 0, 0, /* Battery */ 2, /* USB */ 3, /* Play */ 4, /* Record */ 5, /* Pause */ 5, /* Audio */ 6, /* Repeat */ 7, /* 1 */ 9, /* Volume */ 9, /* Volume 1 */ 9, /* Volume 2 */ 10, /* Volume 3 */ 10, /* Volume 4 */ 10, /* Volume 5 */ 10, /* Param */};static char icon_mask[] ={ 0x02, 0x08, 0x04, 0x10, /* Battery */ 0x04, /* USB */ 0x10, /* Play */ 0x10, /* Record */ 0x02, /* Pause */ 0x10, /* Audio */ 0x02, /* Repeat */ 0x01, /* 1 */ 0x04, /* Volume */ 0x02, /* Volume 1 */ 0x01, /* Volume 2 */ 0x08, /* Volume 3 */ 0x04, /* Volume 4 */ 0x01, /* Volume 5 */ 0x10, /* Param */};void lcd_icon(int icon, bool enable){ static unsigned char icon_mirror[11] = {0}; int pos, mask; pos = icon_pos[icon]; mask = icon_mask[icon]; lcd_write(true, LCD_ICON(pos)); if(enable) icon_mirror[pos] |= mask; else icon_mirror[pos] &= ~mask; lcd_write(false, icon_mirror[pos]);}void lcd_set_contrast(int val){ lcd_write(true, lcd_contrast_set); lcd_write(false, 31-val);}#endif /* SIMULATOR */void lcd_init (void){#ifdef HAVE_NEO_LCD new_lcd = true;#else new_lcd = has_new_lcd();#endif memset(extended_chars_mapped, NO_CHAR, sizeof(extended_chars_mapped)); memset(extended_pattern_content, NO_CHAR,sizeof(extended_pattern_content)); memset(extended_pattern_usage, 0, sizeof(extended_pattern_usage)); if(new_lcd) { lcd_ascii = new_lcd_rocklatin1_to_xlcd; lcd_contrast_set = NEW_LCD_CONTRAST_SET; lcd_cram = NEW_LCD_CRAM; lcd_pram = NEW_LCD_PRAM; lcd_iram = NEW_LCD_IRAM; pattern_size=7; /* Last pattern, 7 for new LCD */ } else { lcd_ascii = old_lcd_rocklatin1_to_xlcd; lcd_contrast_set = OLD_LCD_CONTRAST_SET; lcd_cram = OLD_LCD_CRAM; lcd_pram = OLD_LCD_PRAM; lcd_iram = OLD_LCD_IRAM; pattern_size=3; /* Last pattern, 3 for old LCD */ } lcd_set_contrast(lcd_default_contrast()); create_thread(scroll_thread, scroll_stack, sizeof(scroll_stack), scroll_name);}void lcd_jump_scroll (int mode) /* 0=off, 1=once, ..., JUMP_SCROLL_ALWAYS */{ jump_scroll=mode;}void lcd_bidir_scroll(int percent){ bidir_limit = percent;}void lcd_puts_scroll(int x, int y, unsigned char* string ){ struct scrollinfo* s; int i; DEBUGF("lcd_puts_scroll(%d, %d, %s)\n", x, y, string); s = &scroll[y]; lcd_puts_cont_scroll(x,y,string); s->textlen = strlen(string); if ( s->textlen > 11-x ) { s->mode = SCROLL_MODE_RUN; s->scroll_start_tick = current_tick + scroll_delay; s->offset=0; s->startx=x; s->starty=y; s->direction=+1; s->jump_scroll=0; s->jump_scroll_steps=0; if (jump_scroll && jump_scroll_delay<(HZ/scroll_speed)*(s->textlen-11+x)) { s->jump_scroll_steps=11-x; s->jump_scroll=jump_scroll; } strncpy(s->text,string,sizeof s->text); s->turn_offset=-1; if (bidir_limit && (s->textlen < ((11-x)*(100+bidir_limit))/100)) { s->turn_offset=s->textlen+x-11; } else { for (i=0; i<scroll_spacing && s->textlen<(int)sizeof(s->text); i++) { s->text[s->textlen++]=' '; } } if (s->textlen<(int)sizeof(s->text)) s->text[s->textlen]=' '; s->text[sizeof s->text - 1] = 0; } else s->mode = SCROLL_MODE_OFF;}void lcd_stop_scroll(void){ struct scrollinfo* s; int index; for ( index = 0; index < SCROLLABLE_LINES; index++ ) { s = &scroll[index]; if ( s->mode == SCROLL_MODE_RUN || s->mode == SCROLL_MODE_PAUSE ) { /* restore scrolled row */ lcd_puts(s->startx, s->starty, s->text); } } lcd_update();}void lcd_allow_bidirectional_scrolling(bool on){ allow_bidirectional_scrolling=on;}void lcd_scroll_speed(int speed){ scroll_speed = speed;}void lcd_scroll_delay(int ms){ scroll_delay = ms / (HZ / 10); DEBUGF("scroll_delay=%d (ms=%d, HZ=%d)\n", scroll_delay, ms, HZ);}void lcd_jump_scroll_delay(int ms){ jump_scroll_delay = ms / (HZ / 10); DEBUGF("jump_scroll_delay=%d (ms=%d, HZ=%d)\n", jump_scroll_delay, ms, HZ);}static void scroll_thread(void){ struct scrollinfo* s; int index; int i, o; bool update; /* initialize scroll struct array */ for (index = 0; index < SCROLLABLE_LINES; index++) { scroll[index].mode = SCROLL_MODE_OFF; } while ( 1 ) { update = false; for ( index = 0; index < SCROLLABLE_LINES; index++ ) { s = &scroll[index]; if ( s->mode == SCROLL_MODE_RUN ) { if ( TIME_AFTER(current_tick, s->scroll_start_tick) ) { char buffer[12]; int jumping_scroll=s->jump_scroll; update = true; if (s->jump_scroll) { /* Find new position to start jump scroll by * finding last white space within * jump_scroll_steps */ int i; o = s->offset = s->offset + s->jump_scroll_steps; for (i = 0; i < s->jump_scroll_steps; i++, o--) { if (o < s->textlen && ((0x20 <= s->text[o] && s->text[o] <= 0x2f) || s->text[o] == '_')) { s->offset = o; break; } } s->scroll_start_tick = current_tick + jump_scroll_delay; /* Eat space */ while (s->offset < s->textlen && ((0x20 <= s->text[s->offset] && s->text[s->offset] <= 0x2f) || s->text[s->offset] == '_')) { s->offset++; } if (s->offset >= s->textlen) { s->offset=0; s->scroll_start_tick = current_tick + scroll_delay; if (s->jump_scroll != JUMP_SCROLL_ALWAYS) { s->jump_scroll--; s->direction=1; } } } else { if ( s->offset < s->textlen-1 ) { s->offset+=s->direction; if (s->offset==0) { s->direction=+1; s->scroll_start_tick = current_tick + scroll_delay; } else { if (s->offset == s->turn_offset) { s->direction=-1; s->scroll_start_tick = current_tick + scroll_delay; } } } else { s->offset = 0; } } i=0; o=s->offset; while (i<11) { buffer[i++]=s->text[o++]; if (o==s->textlen /* || (jump_scroll && buffer[i-1] == ' ') */) break; } o=0; if (s->turn_offset == -1 && !jumping_scroll) { while (i<11) { buffer[i++]=s->text[o++]; } } else { while (i<11) { buffer[i++]=' '; } } buffer[11]=0; lcd_puts_cont_scroll(s->startx, s->starty, buffer); } } if (cursor.len>0) { if (cursor.downcount--<0) { cursor.downcount=cursor.divider; cursor.textpos++; if (cursor.textpos>=cursor.len) cursor.textpos=0; update|=lcdx_putc(cursor.x_pos, cursor.y_pos, cursor.text[cursor.textpos]); } } if (update) { lcd_update(); } } sleep(HZ/scroll_speed); }}#ifdef HAVE_NEO_LCD/* * Function use by the Neo code, but could/should be made a generic one. */void lcd_cursor(int x, int y){ /* If we make sure the display size is setup with proper defines in the config-*.h files, this should work on all displays */ if ((cursor.y_pos==y && cursor.x_pos==x) || x>=20 || y>3 || x<0 || y<0) { DEBUGF("ignoring request for cursor to %d,%d - currently %d,%d\n", x,y,cursor.x_pos,cursor.y_pos); return; } char value=0; cursor.y_pos=y; cursor.x_pos=x; switch (y) { case 0: value=0x80|x; break; case 1: value=0x80|(x+0x40); break; case 2: value=0x80|(x+0x14); break; case 3: value=0x80|(x+0x54); break; } lcd_write(true,value);}#endif#endif /* HAVE_LCD_CHARCELLS */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -