From 0f8aedbe9492a5226fddd4ad27dae21b8a39e1b4 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 2 Dec 2012 01:09:44 -0500 Subject: Add a true waveform display to the oscilloscope plugin. * Adds some additional niftyness like a floating popup display that is implemented in an OSD library for use by other plugins. * Speed changes are now gradual for both views and follow a curve derived from some fiddling around to get a nice feel. * Refined a few behavioral things overall. It needs a bit of help from a direct PCM channel callback so it may capture PCM for waveform display. Also need a few other core routines to help out for the OSD. Messes with some keymaps. Some targets need keymaps to access the different views. Some devices can't support the additional view because it requires a large buffer ( > 1 s) for samples. If the plugin buffer is small, they can still use the popup display since the plugin is also much smaller in that case. Slow speed waveform needs some refining so it draws gradually like a real oscilloscope but I'll stick with what it is, for the moment. Change-Id: Ieb5b7922a2238264e9b19a58cb437739194eb036 Reviewed-on: http://gerrit.rockbox.org/245 Reviewed-by: Michael Sevakis Tested-by: Michael Sevakis --- apps/plugins/lib/osd.h | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 apps/plugins/lib/osd.h (limited to 'apps/plugins/lib/osd.h') diff --git a/apps/plugins/lib/osd.h b/apps/plugins/lib/osd.h new file mode 100644 index 0000000000..89441ae273 --- /dev/null +++ b/apps/plugins/lib/osd.h @@ -0,0 +1,94 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Floating on-screen display +* +* Copyright (C) 2012 Michael Sevakis +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +* KIND, either express or implied. +* +****************************************************************************/ +#ifndef OSD_H +#define OSD_H + +/* At this time: assumes use of the default viewport for normal drawing */ + +/* Callback implemented by user. Paramters are OSD vp-relative coordinates */ +typedef void (* osd_draw_cb_fn_t)(int x, int y, int width, int height); + +/* Initialize the OSD, set its backbuffer, update callback and enable it if + * the call succeeded. */ +bool osd_init(void *backbuf, size_t backbuf_size, + osd_draw_cb_fn_t draw_cb); + +enum +{ + OSD_HIDE = 0x0, /* Hide from view */ + OSD_SHOW = 0x1, /* Bring into view, updating if needed */ + OSD_UPDATENOW = 0x2, /* Force update even if nothing changed */ +}; + +/* Show/Hide the OSD on screen returning previous status */ +bool osd_show(unsigned flags); + +/* Redraw the entire OSD returning true if screen update occurred */ +bool osd_update(void); + +/* Redraw part of the OSD (OSD viewport-relative coordinates) returning true + if any screen update occurred */ +bool osd_update_rect(int x, int y, int width, int height); + +/* Set a new screen location and size (screen coordinates) */ +bool osd_update_pos(int x, int y, int width, int height); + +/* Call periodically to have the OSD timeout and hide itself */ +void osd_monitor_timeout(void); + +/* Set the OSD timeout value. 'timeout' <= 0 == never timeout */ +void osd_set_timeout(long timeout); + +/* Use the OSD viewport context */ +struct viewport * osd_get_viewport(void); + +/* Get the maximum buffer dimensions calculated by osd_init() */ +void osd_get_max_dims(int *maxwidth, int *maxheight); + +/* Is the OSD enabled? */ +bool osd_enabled(void); + +/** Functions that must be used in lieu of regular LCD functions for this + ** to work. + ** + ** To be efficient, as much drawing as possible should be combined between + ** *prepare and *update. + ** + ** osd_lcd_update_prepare(); + ** + ** osd_lcd_update[_rect](); + ** + ** TODO: Make it work seamlessly with greylib and regular LCD functions. + **/ + +/* Prepare LCD frambuffer for regular drawing - call before any other LCD + function */ +void osd_lcd_update_prepare(void); + +/* Update the whole screen and restore OSD if it is visible */ +void osd_lcd_update(void); + +/* Update a part of the screen and restore OSD if it is visible */ +void osd_lcd_update_rect(int x, int y, int width, int height); + +#endif /* OSD_H */ -- cgit v1.2.3