A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 93 lines 3.0 kB view raw
1/***************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// __ \_/ ___\| |/ /| __ \ / __ \ \/ / 5 * Jukebox | | ( (__) ) \___| ( | \_\ ( (__) ) ( 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * $Id$ 9 * 10 * Copyright (C) 2008 Andrew Mahone 11 * 12 * This program is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; either version 2 15 * of the License, or (at your option) any later version. 16 * 17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18 * KIND, either express or implied. 19 * 20 ****************************************************************************/ 21 22#include "plugin.h" 23#include "lib/grey.h" 24#include "lib/pluginlib_bmp.h" 25#include "lib/pluginlib_actions.h" 26/* this set the context to use with PLA */ 27static const struct button_mapping *plugin_contexts[] = { pla_main_ctx }; 28#define GBS_QUIT PLA_EXIT 29#define GBS_QUIT2 PLA_CANCEL 30 31#if LCD_DEPTH == 1 32#define BMP_LOAD read_bmp_file 33#else 34#define BMP_LOAD rb->read_bmp_file 35#endif 36 37 38GREY_INFO_STRUCT 39static unsigned char grey_bm_buf[LCD_WIDTH * LCD_HEIGHT + 40 BM_SCALED_SIZE(LCD_WIDTH,0,FORMAT_NATIVE,0)]; 41 42/* this is the plugin entry point */ 43enum plugin_status plugin_start(const void* parameter) 44{ 45 void * plugin_buf; 46 size_t plugin_buf_len; 47 static char filename[MAX_PATH]; 48 struct bitmap grey_bm = { 49 .width = LCD_WIDTH, 50 .height = LCD_HEIGHT, 51 .data = grey_bm_buf 52 }; 53 int ret, x, y; 54 int button = 0; 55 56 if(!parameter) return PLUGIN_ERROR; 57 58 rb->strcpy(filename, parameter); 59 60 ret = BMP_LOAD(filename, &grey_bm, sizeof(grey_bm_buf), 61 FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT, 62 &format_grey); 63 64 if(ret < 1) 65 { 66 rb->splash(HZ*2, "failed to load bitmap"); 67 return PLUGIN_ERROR; 68 } 69 70 plugin_buf = rb->plugin_get_buffer(&plugin_buf_len); 71 if(!grey_init(plugin_buf, plugin_buf_len, 0, LCD_WIDTH, LCD_HEIGHT, 72 NULL)) 73 { 74 rb->splash(HZ*2,"grey init failed"); 75 return PLUGIN_ERROR; 76 } 77 grey_ub_clear_display(); 78 x = (LCD_WIDTH - grey_bm.width) / 2; 79 y = (LCD_HEIGHT - grey_bm.height) / 2; 80 grey_ub_gray_bitmap(grey_bm_buf, x, y, grey_bm.width, grey_bm.height); 81 grey_show(true); 82 83 /* wait until user closes plugin */ 84 while ((button != GBS_QUIT) && (button != GBS_QUIT2)) 85 { 86 button = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts, 87 ARRAYLEN(plugin_contexts)); 88 } 89 90 grey_release(); 91 92 return PLUGIN_OK; 93}