A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 168 lines 5.1 kB view raw
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * $Id$ 9 * 10 * Copyright (C) 2007 Michael Sevakis 11 * 12 * LCD scrolling driver and scheduler 13 * 14 * Much collected and combined from the various Rockbox LCD drivers. 15 * 16 * This program is free software; you can redistribute it and/or 17 * modify it under the terms of the GNU General Public License 18 * as published by the Free Software Foundation; either version 2 19 * of the License, or (at your option) any later version. 20 * 21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 22 * KIND, either express or implied. 23 * 24 ****************************************************************************/ 25#ifndef __SCROLL_ENGINE_H__ 26#define __SCROLL_ENGINE_H__ 27 28#include <stdbool.h> 29#include "config.h" 30#include "file.h" 31 32struct viewport; 33struct scrollinfo; 34 35extern void scroll_init(void) INIT_ATTR; 36 37extern void lcd_bidir_scroll(int threshold); 38extern void lcd_scroll_speed(int speed); 39extern void lcd_scroll_delay(int ms); 40 41#ifdef HAVE_REMOTE_LCD 42extern void lcd_remote_scroll_speed(int speed); 43extern void lcd_remote_scroll_delay(int ms); 44#endif 45 46#ifdef BOOTLOADER 47static inline void lcd_scroll_stop(void) 48{ 49} 50 51static inline void lcd_scroll_stop_viewport(const struct viewport *vp) 52{ 53 (void)vp; 54} 55 56static inline void lcd_scroll_stop_viewport_rect(const struct viewport *vp, int x, int y, int width, int height) 57{ 58 (void)vp; 59 (void)x; 60 (void)y; 61 (void)width; 62 (void)height; 63} 64 65static inline bool lcd_scroll_now(struct scrollinfo *scroll) 66{ 67 (void)scroll; 68 return false; 69} 70 71#ifdef HAVE_REMOTE_LCD 72static inline void lcd_remote_scroll_stop(void) 73{ 74} 75 76static inline void lcd_remote_scroll_stop_viewport(const struct viewport *vp) 77{ 78 (void)vp; 79} 80 81static inline void lcd_remote_scroll_stop_viewport_rect(const struct viewport *vp, int x, int y, int width, int height) 82{ 83 (void)vp; 84 (void)x; 85 (void)y; 86 (void)width; 87 (void)height; 88} 89 90static inline bool lcd_remote_scroll_now(struct scrollinfo *scroll) 91{ 92 (void)scroll; 93 return false; 94} 95#endif /* HAVE_REMOTE_LCD */ 96#else 97extern void lcd_scroll_stop(void); 98extern void lcd_scroll_stop_viewport(const struct viewport *vp); 99extern void lcd_scroll_stop_viewport_rect(const struct viewport *vp, int x, int y, int width, int height); 100extern bool lcd_scroll_now(struct scrollinfo *scroll); 101 102#ifdef HAVE_REMOTE_LCD 103extern void lcd_remote_scroll_stop(void); 104extern void lcd_remote_scroll_stop_viewport(const struct viewport *vp); 105extern void lcd_remote_scroll_stop_viewport_rect(const struct viewport *vp, int x, int y, int width, int height); 106extern bool lcd_remote_scroll_now(struct scrollinfo *scroll); 107#endif /* HAVE_REMOTE_LCD */ 108#endif /* BOOTLOADER */ 109 110 111/* internal usage, but in multiple drivers 112 * larger than the normal linebuffer since it holds the line a second 113 * time (+3 spaces) for non-bidir scrolling */ 114#define SCROLL_SPACING 3 115#define SCROLL_LINE_SIZE (MAX_PATH + SCROLL_SPACING + 3*LCD_WIDTH/2 + 2) 116 117struct scrollinfo 118{ 119 struct viewport* vp; 120 char linebuffer[(SCROLL_LINE_SIZE / 2) - SCROLL_SPACING]; 121 const char *line; 122 /* rectangle for the line */ 123 int x, y; /* relative to the viewort */ 124 int width, height; 125 /* pixel to skip from the beginning of the string, increments as the text scrolls */ 126 int offset; 127 /* getstringsize width of linebuffer */ 128 unsigned short line_stringsize; 129 /* scroll presently forward or backward? */ 130 bool backward; 131 bool bidir; 132 long start_tick; 133 134 /* support for custom scrolling functions, 135 * must be called with ::line == NULL to indicate that the line 136 * stops scrolling or when the userdata pointer is going to be changed 137 * (the custom scroller can release the userdata then) */ 138 void (*scroll_func)(struct scrollinfo *s); 139 void *userdata; 140}; 141 142struct scroll_screen_info 143{ 144 struct scrollinfo * const scroll; 145 const int num_scroll; /* number of scrollable lines (also number of scroll structs) */ 146 int lines; /* Number of currently scrolling lines */ 147 long ticks; /* # of ticks between updates*/ 148 long delay; /* ticks delay before start */ 149 int bidir_limit; /* percent */ 150 int step; /* pixels per scroll step */ 151#if defined(HAVE_REMOTE_LCD) 152 long last_scroll; 153#endif 154}; 155 156/** main lcd **/ 157#define LCD_SCROLLABLE_LINES ((LCD_HEIGHT+4)/5 < 32 ? (LCD_HEIGHT+4)/5 : 32) 158 159extern struct scroll_screen_info lcd_scroll_info; 160 161/** remote lcd **/ 162#ifdef HAVE_REMOTE_LCD 163#define LCD_REMOTE_SCROLLABLE_LINES \ 164 (((LCD_REMOTE_HEIGHT+4)/5 < 32) ? (LCD_REMOTE_HEIGHT+4)/5 : 32) 165extern struct scroll_screen_info lcd_remote_scroll_info; 166#endif 167 168#endif /* __SCROLL_ENGINE_H__ */