From 9451e82004bb59a95d9589058759169c1c486c91 Mon Sep 17 00:00:00 2001 From: Oliver Schinagl Date: Wed, 10 Nov 2004 12:45:18 +0000 Subject: First Real Version --- Graphic_Equalizer/include/configuration.hch | 32 ++++- Graphic_Equalizer/include/display.hch | 5 +- Graphic_Equalizer/include/display_shared.hch | 29 ++++ Graphic_Equalizer/include/eventhandler.hch | 34 +++++ Graphic_Equalizer/include/eventhandler_shared.hch | 38 +++++ Graphic_Equalizer/include/mouse.hch | 41 ++++++ Graphic_Equalizer/include/mouse_shared.hch | 56 ++++++++ Graphic_Equalizer/include/mousedriver.hch | 40 ------ Graphic_Equalizer/include/mousedriver_shared.hch | 56 -------- Graphic_Equalizer/include/smartmedia.hch | 46 ++++++ Graphic_Equalizer/src/audio/audiodriver.hcc | 106 -------------- Graphic_Equalizer/src/audio/sample.hcc | 106 -------------- Graphic_Equalizer/src/audiodriver.hcc | 107 ++++++++++++++ Graphic_Equalizer/src/display.hcc | 140 ++++++++++++++++++ Graphic_Equalizer/src/display/display.hcc | 109 -------------- Graphic_Equalizer/src/display/main.hcc | 87 ------------ Graphic_Equalizer/src/display/mousedriver.hcc | 117 --------------- Graphic_Equalizer/src/eventhandler.hcc | 71 +++++++++ Graphic_Equalizer/src/main.hcc | 164 +++++++++++++++++++++ Graphic_Equalizer/src/mouse.hcc | 120 ++++++++++++++++ Graphic_Equalizer/src/sample.hcc | 106 ++++++++++++++ Graphic_Equalizer/src/smartmedia.hcc | 166 ++++++++++++++++++++++ 22 files changed, 1149 insertions(+), 627 deletions(-) create mode 100644 Graphic_Equalizer/include/eventhandler.hch create mode 100644 Graphic_Equalizer/include/eventhandler_shared.hch create mode 100644 Graphic_Equalizer/include/mouse.hch create mode 100644 Graphic_Equalizer/include/mouse_shared.hch delete mode 100644 Graphic_Equalizer/include/mousedriver.hch delete mode 100644 Graphic_Equalizer/include/mousedriver_shared.hch create mode 100644 Graphic_Equalizer/include/smartmedia.hch delete mode 100644 Graphic_Equalizer/src/audio/audiodriver.hcc delete mode 100644 Graphic_Equalizer/src/audio/sample.hcc create mode 100644 Graphic_Equalizer/src/audiodriver.hcc create mode 100644 Graphic_Equalizer/src/display.hcc delete mode 100644 Graphic_Equalizer/src/display/display.hcc delete mode 100644 Graphic_Equalizer/src/display/main.hcc delete mode 100644 Graphic_Equalizer/src/display/mousedriver.hcc create mode 100644 Graphic_Equalizer/src/eventhandler.hcc create mode 100644 Graphic_Equalizer/src/main.hcc create mode 100644 Graphic_Equalizer/src/mouse.hcc create mode 100644 Graphic_Equalizer/src/sample.hcc create mode 100644 Graphic_Equalizer/src/smartmedia.hcc diff --git a/Graphic_Equalizer/include/configuration.hch b/Graphic_Equalizer/include/configuration.hch index f256886..6e9480a 100644 --- a/Graphic_Equalizer/include/configuration.hch +++ b/Graphic_Equalizer/include/configuration.hch @@ -20,6 +20,24 @@ #define _CONFIGURATION_HCH 1 /* + * To print debug information on the RS232 port set this define. + */ +#define HAVE_DEBUG 0 + + + +/* + * If we don't want to use the SmartMedia (and therefor fill the memory + * with simple static data) set this to 0. Otherwise 1 will load the smartmedia + * routines. To only load the mask and not the entire data set USE_MASK_ONLY to + * 1. 0 will load all bitmaps. + */ +#define HAVE_SMART_MEDIA 0 +#define USE_MASK_ONLY 1 + + + +/* * Data can be arranged in two ways. Either as one large blok of continuous * data, or each segment is stored seperatly at its own address. If set to 1 * we'll asume one large continuous blok. @@ -42,13 +60,11 @@ /* * Here we setup the start and end address for the various components. - * NOTE: The Help image starts at the same address because we intend to use the - * second rambank for this image. */ #define ADDR_SKIN_START 0x000000 #define ADDR_SKIN_END (ADDR_SKIN_START +SIZE_SKIN) -#define ADDR_HELP_START 0x000000 +#define ADDR_HELP_START 0x04b001 #define ADDR_HELP_END (ADDR_HELP_START +SIZE_HELP) #if LARGE_DATA_BLOCK @@ -66,8 +82,8 @@ #else #define SM_ADDR_SKIN_START 0x084000 #define SM_ADDR_SKIN_MASK_START 0x168000 - #define SM_ADDR_HELP_START 0x000000 - #define SM_ADDR_HELP_START 0x000000 + #define SM_ADDR_HELP_START 0x1b4000 + #define SM_ADDR_HELP_START 0x298000 #define SM_ADDR_SKIN_END (SM_ADDR_SKIN_START +(SIZE_SKIN *3)) #define SM_ADDR_SKIN_MASK_END (SM_ADDR_SKIN_END +(SIZE_MASK_SKIN *3)) @@ -76,6 +92,12 @@ #endif + +/* + * Set the color for various items that will be drawn on screen. + */ +#define PIXEL_VOLUME_YAXIS (0x00ff00) + #else #error "ERROR file configuration.hch multiple times included" #endif /* --- _CONFIGURATION_HCH --- */ diff --git a/Graphic_Equalizer/include/display.hch b/Graphic_Equalizer/include/display.hch index d10c8ed..d191149 100644 --- a/Graphic_Equalizer/include/display.hch +++ b/Graphic_Equalizer/include/display.hch @@ -31,8 +31,11 @@ /* * Main display loop. This function never returns! It handles display output. + * It needs to respond to certain events set by the events pointer. Also it + * informs events what the current mask is. To optain the current mask we need + * the X and Y coordinates from our mousedata pointer. */ -extern macro proc display_main(RAM_BANK0, RAM_BANK1); +void display_main(events_t *events, mousedata_t *mousedata); #else #error "ERROR file display.hch multiple times included" diff --git a/Graphic_Equalizer/include/display_shared.hch b/Graphic_Equalizer/include/display_shared.hch index 3268473..66e8111 100644 --- a/Graphic_Equalizer/include/display_shared.hch +++ b/Graphic_Equalizer/include/display_shared.hch @@ -20,6 +20,35 @@ #define _DISPLAY_SHARED_HCH 1 + +/* + * Volume Control lookuptable. + * TODO: This table is now hardcoded. To ensure full skinability this table + * should be dynamically loaded. + */ +rom unsigned 6 volumecontrol_table[46] = {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0}; + +/* + * Equalizer lookuptabe. + * TODO: This table is now hardcoded. To ensure full skinability this table + * should be dynamically loaded. + */ +rom unsigned 4 equalizer_table[66] = {15, 15, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0}; + + + +/* + * Define all area's of the display. + */ +#define AREA_WAVEFORM 0x01 +#define AREA_VOLUME_YAXIS 0x02 +#define AREA_SPECTRUM_ANALYZER 0x03 + +#define BUTTON_HELP 0x12 + +#define AREA_EQUALIZER_MIN 0x80 +#define AREA_EQUALIZER_MAX 0xff + #else #error "ERROR file display_shared.hch multiple times included" #endif /* --- _DISPLAY_SHARED_HCH --- */ diff --git a/Graphic_Equalizer/include/eventhandler.hch b/Graphic_Equalizer/include/eventhandler.hch new file mode 100644 index 0000000..413e563 --- /dev/null +++ b/Graphic_Equalizer/include/eventhandler.hch @@ -0,0 +1,34 @@ +/*! \file eventhandler.hch + * + * \section generic SmartMedia API + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author O.M. Schinagl + * \date 20041110 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041110: O.M. Schinagl\n Initial version + * + ********************************************************************/ + +#ifndef _EVENTHANDLER_HCH +#define _EVENTHANDLER_HCH 1 + + + + +/* + * This is the main eventhandler loop. It never returns! It coordinates + * userinput and the actions requred to be taken. + */ +void eventhandler_main(events_t *events); + +#else +#error "ERROR file eventhandler.hch multiple times included" +#endif /* --- _EVENTHANDLER_HCH --- */ + diff --git a/Graphic_Equalizer/include/eventhandler_shared.hch b/Graphic_Equalizer/include/eventhandler_shared.hch new file mode 100644 index 0000000..1ce7578 --- /dev/null +++ b/Graphic_Equalizer/include/eventhandler_shared.hch @@ -0,0 +1,38 @@ +/*! \file eventhandler_shared.hch + * + * \section generic Shared definitions etc. for eveents. + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author O.M. Schinagl + * \date 20041110 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041110: O.M. Schinagl\n Initial version + * + *****************************************************************************/ + +#ifndef _EVENTHANDLER_SHARED_HCH +#define _EVENTHANDLER_SHARED_HCH 1 + + + +/*** Data Types **********************/ + +/* + * Type definition of the shared memory to be used in various processes + */ +typedef struct { + unsigned 1 help; + unsigned 10 volume_position; + unsigned 8 mask; +} events_t; + +#else +#error "ERROR file eventhandler_shared.hch multiple times included" +#endif /* --- _EVENTHANDLER_SHARED_HCH --- */ + diff --git a/Graphic_Equalizer/include/mouse.hch b/Graphic_Equalizer/include/mouse.hch new file mode 100644 index 0000000..f6ae164 --- /dev/null +++ b/Graphic_Equalizer/include/mouse.hch @@ -0,0 +1,41 @@ +/*! \file mousedriver.hch + * + * \section generic Mousedriver API + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author O.M. Schinagl + * \date 20041011 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041011: O.M. Schinagl\n Initial version + * + ********************************************************************/ + +#ifndef _MOUSEDRIVER_HCH +#define _MOUSEDRIVER_HCH 1 + + + +/* + * Create a define to keep API generic + */ +#define MouseRun(ClockRate) RC200TouchScreenRun(ClockRate) + + + +/* + * Main mousedriver loop. This procedure never returns! It handles mouse input, + * updates the shared memory and notifies listeners. It requires a pointer to + * a mousedata_t struct to store mouse information. + */ +void mouse_main(mousedata_t *mousedata); + +#else +#error "ERROR file mousedriver.hch multiple times included" +#endif /* --- _MOUSEDRIVER_HCH --- */ + diff --git a/Graphic_Equalizer/include/mouse_shared.hch b/Graphic_Equalizer/include/mouse_shared.hch new file mode 100644 index 0000000..43887c4 --- /dev/null +++ b/Graphic_Equalizer/include/mouse_shared.hch @@ -0,0 +1,56 @@ +/*! \file mousedriver_shared.hch + * + * \section generic Shared definitions etc. + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author O.M. Schinagl + * \date 20041011 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041011: O.M. Schinagl\n Initial version + * + *****************************************************************************/ + +#ifndef _MOUSEDRIVER_SHARED_HCH +#define _MOUSEDRIVER_SHARED_HCH 1 + +/*** Data Types **********************/ + +/* + * Type definition of the shared memory to be used in various processes + */ +typedef struct { + unsigned 10 x; + unsigned 9 y; + unsigned 3 state; +} mousedata_t; + + + +/* + * States used to identify wether mouse data is updated + */ +#define MOUSE_NOT_UPDATED 0 +#define MOUSE_UPDATED 1 + + + +/* + * Set of Mouse States defines + */ +#define MOUSE_STATE_UP 0 +#define MOUSE_STATE_ON_PRESS 1 +#define MOUSE_STATE_DOWN 2 +#define MOUSE_STATE_ON_RELEASE 3 + + + +#else +#error "ERROR file mousedriver_shared.hch multiple times included" +#endif /* --- _MOUSEDRIVER_SHARED_HCH --- */ + diff --git a/Graphic_Equalizer/include/mousedriver.hch b/Graphic_Equalizer/include/mousedriver.hch deleted file mode 100644 index 9c674cd..0000000 --- a/Graphic_Equalizer/include/mousedriver.hch +++ /dev/null @@ -1,40 +0,0 @@ -/*! \file mousedriver.hch - * - * \section generic Mousedriver API - * - * \section project Project information. - * Project Graphic Equalizer\n - * \author O.M. Schinagl - * \date 20041011 - * \version 0.1 - * - * \section copyright Copyright - * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved - * - * \section history Change history - * 20041011: O.M. Schinagl\n Initial version - * - ********************************************************************/ - -#ifndef _MOUSEDRIVER_HCH -#define _MOUSEDRIVER_HCH 1 - - - -/* - * Create a define to keep API generic - */ -#define MouseRun(ClockRate) RC200TouchScreenRun(ClockRate) - - - -/* - * Main mousedriver loop. This procedure never returns! It handles mouse input, - * updates the shared memory and notifies listeners. - */ -void mouse_main(void); - -#else -#error "ERROR file mousedriver.hch multiple times included" -#endif /* --- _MOUSEDRIVER_HCH --- */ - diff --git a/Graphic_Equalizer/include/mousedriver_shared.hch b/Graphic_Equalizer/include/mousedriver_shared.hch deleted file mode 100644 index 01470fa..0000000 --- a/Graphic_Equalizer/include/mousedriver_shared.hch +++ /dev/null @@ -1,56 +0,0 @@ -/*! \file mousedriver_shared.hch - * - * \section generic Shared definitions etc. - * - * \section project Project information. - * Project Graphic Equalizer\n - * \author O.M. Schinagl - * \date 20041011 - * \version 0.1 - * - * \section copyright Copyright - * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved - * - * \section history Change history - * 20041011: O.M. Schinagl\n Initial version - * - *****************************************************************************/ - -#ifndef _MOUSEDRIVER_SHARED_HCH -#define _MOUSEDRIVER_SHARED_HCH 1 - -/*** Data Types **********************/ - -/* - * Type definition of the shared memory to be used in various processes - */ -typedef struct { - unsigned 10 x; - unsigned 9 y; - unsigned 3 state; -} mousedata_s; - - - -/* - * States used to identify wether mouse data is updated - */ -#define MOUSE_NOT_UPDATED 0 -#define MOUSE_UPDATED 1 - - - -/* - * Set of Mouse States defines - */ -#define MOUSE_STATE_UP 0 -#define MOUSE_STATE_ON_PRESS 1 -#define MOUSE_STATE_DOWN 2 -#define MOUSE_STATE_ON_RELEASE 3 - - - -#else -#error "ERROR file mousedriver_shared.hch multiple times included" -#endif /* --- _MOUSEDRIVER_SHARED_HCH --- */ - diff --git a/Graphic_Equalizer/include/smartmedia.hch b/Graphic_Equalizer/include/smartmedia.hch new file mode 100644 index 0000000..e44e435 --- /dev/null +++ b/Graphic_Equalizer/include/smartmedia.hch @@ -0,0 +1,46 @@ +/*! \file smartmedia.hch + * + * \section generic SmartMedia API + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author O.M. Schinagl + * \date 20041110 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041110: O.M. Schinagl\n Initial version + * + ********************************************************************/ + +#ifndef _SMARTMEDIA_HCH +#define _SMARTMEDIA_HCH 1 + + + +/* + * Create a define to keep API generic + */ +#define CPLDRun(ClockRate) RC200CPLDRun(ClockRate) +#define SmartMediaRun(ClockRate) RC200SmartMediaRun(ClockRate) + + + +/* + * Initializes the smartmedia device. + */ +void smartmedia_init(void); + + +/* + * This function loads the memory with data from the smartmedia card. + */ +void smartmedia_loaddata(void); + +#else +#error "ERROR file smartmedia.hch multiple times included" +#endif /* --- _SMARTMEDIA_HCH --- */ + diff --git a/Graphic_Equalizer/src/audio/audiodriver.hcc b/Graphic_Equalizer/src/audio/audiodriver.hcc deleted file mode 100644 index aadcc6e..0000000 --- a/Graphic_Equalizer/src/audio/audiodriver.hcc +++ /dev/null @@ -1,106 +0,0 @@ -/*! \file header_templace.hcc - * - * \section generic Message build up information and more - * - * \section project Project information. - * Project Graphic Equalizer\n - * \author - * \date 20041011 - * \version 0.1 - * - * \section copyright Copyright - * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved - * - * \section history Change history - * 20041011: \n Initial version - * - ********************************************************************/ - -/******** System Includes *************/ -#include - -#include "pal_master.hch" - -/******** Application Includes ********/ -#include "audiodriver.hch" -#include "audiodriver_shared.hch" - - - -/*! \fn void audio_init(unsigned 4 gain_level, - * unsigned 1 input_source, - * unsigned 3 sample_rate) - * - * \brief Set some inital values to the audio hardware. - * - * \param unsigned 4 gain_level Set the input amplifier to this - * amplification level. - * \param unsigned 1 input_source Choose between microphone input - * or linein input - * \param unsigned 3 sample_rate Set the sample rate between 8000 - * and 48000 - * - * \return void - * \retval void - * - */ -void audio_init(unsigned 4 gain_level, - unsigned 1 input_source, - unsigned 3 sample_rate) { - /* - * We simply call the appropiate handlers and pass values along. We - * Don't set the mute on input gain. We have volume control to do this. - * Input and Output sampling rates are equal. We dont' need different - * rates. - */ - RC200AudioInSetGain(FALSE, gain_level, gain_level); - RC200AudioInSetInput(input_source); - PalAudioInSetSampleRate(AudioIn, sample_rate); - PalAudioOutSetSampleRate(AudioOut, sample_rate); -} /* --- audio_init() --- */ - - - -/*! \fn void audio_main(void); - * \brief Main audiodriver. This function never returns! It calls the - * audiohandlers and stores samples into a global array. Once 64 - * Samples are collected it raises a signal AUDIO_READY to let - * other processes know it's ready. We use quadruple buffering for - * audio input and double buffering for audio output. - * - * \param void - * - * \return Never Returns. - * \retval void - */ -void audio_main(void) { - /* - * Setup audio pointers. - */ - macro expr AudioIn = PalAudioInCT(0); - macro expr AudioOut = PalAudioOutCT(0); - /* - * Determin the data width for the current platform. - */ - macro expr IW = PalAudioInGetMaxDataWidthCT(); - macro expr OW = PalAudioOutGetMaxDataWidthCT(); - - signed IW sample_left_in, sample_right_in; - signed 16 sample_left_out, sample_right_out; - - for (;;) { - PalAudioRead(AudioIn, &sample_left_in, &sample_right_in); - - par { - sample_add(sample_left_in); - sample_get(&sample_left_out); - sample_right_out = sample_right_in; - } - if (rotate_samples()) { - /* - * 64 Samples have been processed, calculate. - */ - } - PalAudioWrite(AudioOut, (signed OW)(sample_left @ 0), (signed OW)(sample_right @ 0)); - } -} /* --- audio_main() --- */ diff --git a/Graphic_Equalizer/src/audio/sample.hcc b/Graphic_Equalizer/src/audio/sample.hcc deleted file mode 100644 index 000baf9..0000000 --- a/Graphic_Equalizer/src/audio/sample.hcc +++ /dev/null @@ -1,106 +0,0 @@ -/*! \file sample.hcc - * - * \section generic Handle audio sampling and buffer rotation. - * - * \section project Project information. - * Project Graphic Equalizer\n - * \author O.M. Schinagl - * \date 20041021 - * \version 0.1 - * - * \section copyright Copyright - * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved - * - * \section history Change history - * 20041021: O.M. Schinagl\n Initial version - * - ********************************************************************/ - -/******** System Includes *************/ - -/******** Application Includes ********/ -#include "sample.hch" - - - -/* - * Pointer that points towards the current 64 bits samples. - */ -signed 16 *audio_in_ptr; - -/* - * 64 step counter to keep track of our samples. This is a private variable. - */ -unsigned 8 sample_count; - - - -/*! \fn void sample_add(signed 16 in_sample); - * \brief This procedure adds the supplied sample to the input buffer. - * - * \param signed 16 in_sample 16 bits signed sample to be added. - * - * \return void - * \retval void - */ -void sample_add(signed 16 in_sample) { - /* - * We only sample 64 bits in our buffer, hence we circulate around the - * last 6 bits. - */ - audio_in_ptr[sample_count <-6] = in_sample; - sample_count++; -} /* --- sample_add() --- */ - - - -/*! \fn void sample_get(signed 16 *out_sample); - * \brief This procedure gets the sample from the current output buffer. - * - * \param * in_sample pointer to storage for sample. - * - * \return void - * \retval void - */ -void sample_get(signed 16 *out_sample) { - /* - * We circulate around a 64 bits buffer, therefor we only use the last - * 6 bits. - */ - *out_sample = audio_out_ptr[sample_count <-6]; -} /* --- sample_get() --- */ - - - -/*! \fn unsigned 1 sample_rotate_buffers(void); - * \brief This procedure rotates our buffers around if 64 samples are - * read into our current buffer. - * - * \param in_sample 16 bits signed sample to be added. - * - * \return 1 when 64 samples have passed, 0 otherwise. - * \retval unsigned 1; - */ -unsigned 1 sample_rotate_buffers(void) { - unsigned 1 retval; /* store for returnvalue */ - - retval = 0; - /* - * We only want to read 64 samples, but calculations work nicer if we - * use 256 samples. Therefor we circulate our audio pointer around. - */ - if (!(sample_count <- 6)) { - /* - * 64 Samples have passed. We are back at '0'. Use the full - * sample count as index which is 0 64 128 or 192 and back to - * 0. Our Output is only 128 big so we only look at the - * 7 LSB. Also, notify the main application that 64 samples - * have been processed. - */ - par { - audio_in_ptr = &pcm_audio_in[sample_count]; - audio_out_ptr = &pcm_audio_out[(sample_count <- 7)]; - retval = 1; - } - } -} /* --- sample_rotate_buffers() --- */ diff --git a/Graphic_Equalizer/src/audiodriver.hcc b/Graphic_Equalizer/src/audiodriver.hcc new file mode 100644 index 0000000..c7d1adf --- /dev/null +++ b/Graphic_Equalizer/src/audiodriver.hcc @@ -0,0 +1,107 @@ +/*! \file header_templace.hcc + * + * \section generic Message build up information and more + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author + * \date 20041011 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041011: \n Initial version + * + ********************************************************************/ + +/******** System Includes *************/ +#include + +#include "pal_master.hch" + +/******** Application Includes ********/ +#include "audio.hch" +#include "audio_shared.hch" + + + +/*! \fn void audio_init(unsigned 4 gain_level, + * unsigned 1 input_source, + * unsigned 3 sample_rate) + * + * \brief Set some inital values to the audio hardware. + * + * \param unsigned 4 gain_level Set the input amplifier to this + * amplification level. + * \param unsigned 1 input_source Choose between microphone input + * or linein input + * \param unsigned 3 sample_rate Set the sample rate between 8000 + * and 48000 + * + * \return void + * \retval void + * + */ +void audio_init(unsigned 4 gain_level, + unsigned 1 input_source, + unsigned 3 sample_rate) { + /* + * We simply call the appropiate handlers and pass values along. We + * Don't set the mute on input gain. We have volume control to do this. + * Input and Output sampling rates are equal. We dont' need different + * rates. + */ + RC200AudioInSetGain(FALSE, gain_level, gain_level); + RC200AudioInSetInput(input_source); + PalAudioInSetSampleRate(AudioIn, sample_rate); + PalAudioOutSetSampleRate(AudioOut, sample_rate); +} /* --- audio_init() --- */ + + + +/*! \fn void audio_main(void); + * \brief Main audiodriver. This function never returns! It calls the + * audiohandlers and stores samples into a global array. Once 64 + * Samples are collected it raises a signal AUDIO_READY to let + * other processes know it's ready. We use quadruple buffering for + * audio input and double buffering for audio output. + * + * \param void + * + * \return Never Returns. + * \retval void + */ +void audio_main(void) { + /* + * Setup audio pointers. + */ + macro expr AudioIn = PalAudioInCT(0); + macro expr AudioOut = PalAudioOutCT(0); + + /* + * Determin the data width for the current platform. + */ + macro expr IW = PalAudioInGetMaxDataWidthCT(); + macro expr OW = PalAudioOutGetMaxDataWidthCT(); + + signed IW sample_left_in, sample_right_in; + signed OW sample_left_out, sample_right_out; + + for (;;) { + PalAudioRead(AudioIn, &sample_left_in, &sample_right_in); + +/* par { + sample_add(sample_left_in); + sample_get(&sample_left_out); + sample_right_out = sample_right_in; + } + if (rotate_samples()) { + / * + * 64 Samples have been processed, calculate. + * / + } +*/ PalAudioWrite(AudioOut, (signed OW)(sample_left_in @ 0), (signed OW)(sample_right_in @ 0)); + } +} /* --- audio_main() --- */ diff --git a/Graphic_Equalizer/src/display.hcc b/Graphic_Equalizer/src/display.hcc new file mode 100644 index 0000000..8be1f2e --- /dev/null +++ b/Graphic_Equalizer/src/display.hcc @@ -0,0 +1,140 @@ +/*! \file display.hcc + * + * \section generic Message build up information and more + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author O.M. Schinagl + * \date 20041011 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041011: O.M. Schinagl\n Initial version + * + ********************************************************************/ + +/******** System Includes *************/ +#include + +#include "pal_master.hch" + +/******** Application Includes ********/ +#include "configuration.hch" +#include "display.hch" +#include "eventhandler_shared.hch" + + + +/*! \fn void display_main(events_t *events, mousedata_t *mousedata); + * \brief This routine handles all drawing of pixels. It never returns! + * + * \param events_t *events pointer to struct with all events. + * \param mousedata_t *mousedata pointer to struct with coordinates to + * current X en Y. + * + * \return Never Returns. + * \retval void + */ +void display_main(events_t *events, mousedata_t *mousedata) { + /* + * Setup macro's RAM/Video handles and to coordinate pixel writing. + */ + macro expr RAM_BANK0 = PalPL2RAMCT(0); + macro expr VideoOut = PalVideoOutOptimalCT(ClockRate); + macro expr VisibleX = PalVideoOutGetVisibleX (VideoOut, ClockRate); + macro expr TotalX = PalVideoOutGetTotalX (VideoOut, ClockRate); + macro expr TotalY = PalVideoOutGetTotalY (VideoOut); + macro expr X = PalVideoOutGetX (VideoOut); + macro expr Y = PalVideoOutGetY (VideoOut); + + unsigned AW address; + unsigned DW pixeldata; + +/* + * To draw something usefull when only drawing our mask, we simply draw the + * mask itself. Thus creating a blueish image to help identify all interesting + * area's on the screen. Otherwise we only use the last 24 bits, the RGB values + * to draw on the screen. + */ +#if USE_MASK_ONLY +#define PIXEL (0 @ pixeldata[31:24]) +#else +#define PIXEL (pixeldata <- 24) +#endif + /* + * Prime Rendering Pipeline to start where the skin starts. + */ + PalPL2RAMSetReadAddress(RAM_BANK0, ADDRESS_SKIN_START); + + /* + * Run the following tasks indefinatly and in parallel + */ + par (;;) { + /* + * Before starting this loop we allready set the the address. + * Therefor we can start reading the previously set address and + * prepare the next address for the next cycle. + */ + PalPL2RAMRead(RAM_BANK0, &pixeldata); + PalPL2RAMSetReadAddress(RAM_BANK0, address); + + switch (pixeldata[31:24]) { + case (AREA_VOLUME_YAXIS == pixeldata[31:24]): + if (ScanY <= events->volume_position) { + PalVideoOutWrite(VideoOut, PIXEL_VOLUME_YAXIS); + } else { + PalVideoOutWrite(VideoOut, PIXEL); + } + break; + default: + PalVideoOutWrite(VideoOut, PIXEL); + break; + } + + /* + */ + if ((ScanX == mousedata->x) && (ScanY == mousedata->y)) { + events->mask = pixeldata[31:24]; + } + + /* + * The current position of the screen can lay in an area called + * the blanking area. We don't have data for this area as it is + * not drawn. We therefor have to determin wether we are beyond + * the visible area of the screen, but before the end of the + * total width of the screen. + * Our pipeline consists of 4 total stages. Therefor we have to + * substract 4 pixels. + */ + if ((X > (VisibleX - 4)) && (X <= (TotalX - 4))) { + /* + * We are in the blanking area of the screen. If we are + * on the last line, and thus last pixel we reset our + * address counter. + */ + if (Y == (TotalY -1)) { + /* + * The reset address is determined by the help + * bit. FIXME: This needs come from a struct. + */ + address = (events->help) ? ADDRESS_HELP_START : ADDRESS_SKIN_START; + } else { + /* + * We should not ever get inhere. To keep + * everything consequent however, we add a + * a delay. + */ + delay; + } + } else { + /* + * Increase the memory counter for each pixel drawn + * thus keeping the memory location in sync with + * the current pixel position. + */ + address++; + } +} /* --- display_main() --- */ diff --git a/Graphic_Equalizer/src/display/display.hcc b/Graphic_Equalizer/src/display/display.hcc deleted file mode 100644 index 2dfc669..0000000 --- a/Graphic_Equalizer/src/display/display.hcc +++ /dev/null @@ -1,109 +0,0 @@ -/*! \file display.hcc - * - * \section generic Message build up information and more - * - * \section project Project information. - * Project Graphic Equalizer\n - * \author O.M. Schinagl - * \date 20041011 - * \version 0.1 - * - * \section copyright Copyright - * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved - * - * \section history Change history - * 20041011: O.M. Schinagl\n Initial version - * - ********************************************************************/ - -/******** System Includes *************/ -#include - -#include "pal_master.hch" - -/******** Application Includes ********/ -#include "display.hch" - - - -/*! \fn void display_main(RAM_BANK0, RAM_BANK1); - * \brief This routine handles all drawing of pixels. It never returns! - * - * \param PL2RAM RAM_BANK0 Handle to the first rambank. - * \param PL2RAM RAM_BANK1 Handle to the second rambank. - * - * \return Never Returns. - * \retval void - */ -macro void display_main(RAM_BANK0, RAM_BANK1) { - /* - * Setup macro's to coordinate pixel writing. - */ - macro expr VideoOut = PalVideoOutOptimalCT(ClockRate); - macro expr VisibleX = PalVideoOutGetVisibleX (VideoOut, ClockRate); - macro expr TotalX = PalVideoOutGetTotalX (VideoOut, ClockRate); - macro expr TotalY = PalVideoOutGetTotalY (VideoOut); - macro expr X = PalVideoOutGetX (VideoOut); - macro expr Y = PalVideoOutGetY (VideoOut); - - unsigned 32 pixeldata; - unsigned AW nextaddr; - unsigned DW pixeldata; - unsigned 1 SwitchData, help; - - /* - * Prime Rendering Pipeline to start at bank 0 address 0. - */ - PalPL2RAMSetReadAddress(RAM_BANK0, 0); - - /* - * Run the following tasks indefinatly and in parallel - */ - par (;;) { - /* - * We write only the last 24 bits of pixeldata as it also - * contains information about the mask. - */ - PalVideoOutWrite(VideoOut, pixeldata <- 24); - - /* FIXME this needs to be replaced by a global state array */ - PalSwitchRead(PalSwitchCT(0), &help); - /* - * When 'help' is activated, we display data from rambank 1 - * otherwise we draw from rambank 0. - */ - if (help) { - PalPL2RAMRead(RAM_BANK1, &Data); - PalPL2RAMSetReadAddress(RAM_BANK1, nextaddr); - } else { - PalPL2RAMRead(PL2RAM_BANK0, &Data); - PalPL2RAMSetReadAddress(RAM_BANK0, nextaddr); - } - - /* - * The current position of the screen can lay in an area called - * the blanking area. We don't have data for this area as it is - * not drawn. We therefor have to determin wether we are beyond - * the visible area of the screen, but before the end of the - * total width of the screen. - * Our pipeline consists of 5 total stages. Therefor we have to - * substract 5 pixels. - */ - if ((X > (VisibleX - 5)) && (X <= (TotalX - 5))) { - /* - * We are in the blanking area of the screen. If we are - * on the last line, and thus last pixel we reset our - * address counter. - */ - if (Y == (TotalY -1)) { - nextaddr = 0; - } - } else { - /* - * Increase the memory counter for each pixel drawn - * thus keeping the memory location in sync with - * the current pixel position. - */ - nextaddr++; - } -} /* --- display_main() --- */ diff --git a/Graphic_Equalizer/src/display/main.hcc b/Graphic_Equalizer/src/display/main.hcc deleted file mode 100644 index 1c52856..0000000 --- a/Graphic_Equalizer/src/display/main.hcc +++ /dev/null @@ -1,87 +0,0 @@ -/*! \file main.hcc - * - * \section generic Message build up information and more - * - * \section project Project information. - * Project Graphic Equalizer\n - * \author O.M. Schinagl - * \date 20041011 - * \version 0.1 - * - * \section copyright Copyright - * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved - * - * \section history Change history - * 20041011: O.M. Schinagl\n Initial version - * - *****************************************************************************/ - - -/* - * Set the Clock rate for this domain. 25.175 Mhz is required for the Video output. - */ -#define PAL_TARGET_CLOCK_RATE 25175000 - -/******** System Includes *************/ -#include "pal_master.hch" -#include "pal_mouse.hch" - -/******** Application Includes ********/ -#include "display.hch" -#include "mousedriver.hch" - - - -/* - * Request Clockrate. Approximated ClockRate is compiler assigned. - */ -static macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE; - - -/*! \fn void main(void); - * \brief Main User Input/Ouput loop. - * - * \param void - * - * \return void - * \retval void - */ -void main(void) { - /* Set VideoOut Pointer */ - macro expr VideoOut = PalVideoOutOptimalCT(ClockRate); - - /* - * Check library versions and Request VideoOutput. - * We need at least Major Version 1. Minor version 0 suffices. - */ - PalVersionRequire(1, 0); - PalVideoOutRequire(1); - - /* - * Run The Following main tasks in parallel. - */ - par { - /* - * Primary task is to 'Run' several hardware simultaniously. - * VideoOutput needs to be in sync with the touchscreen and - * need to run in sync. - */ - PalVideoOutRun(VideoOut, ClockRate); - MouseRun(ClockRate); - - /* Parallel to our Primary tasks we run the application. */ - seq { - /* But first we need to initialize the display */ - display_init(ClockRate); - par { - /* - * From here we run the mouse driver and - * display parallel. - */ - mouse_main(); - display_main(); - } - } - } - -} /* --- main() --- */ diff --git a/Graphic_Equalizer/src/display/mousedriver.hcc b/Graphic_Equalizer/src/display/mousedriver.hcc deleted file mode 100644 index 6f69129..0000000 --- a/Graphic_Equalizer/src/display/mousedriver.hcc +++ /dev/null @@ -1,117 +0,0 @@ -/*! \file mousedriver.hcc - * - * \section generic This module takes care of mouse input. The mouse - * input function itself is however performed by the - * touchscreen of the RC200. - * - * \section project Project information. - * Project Graphic Equalizer\n - * \author O.M. Schinagl - * \date 20041011 - * \version 0.1 - * - * \section copyright Copyright - * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved - * - * \section history Change history - * 20041011: O.M. Schinagl\n Initial version - * - ********************************************************************/ - -/******** System Includes *************/ -#include - -#include "pal_master.hch" -#include "pal_mouse.hch" - -/******** Application Includes ********/ -#include "mousedriver.hch" -#include "mousedriver_shared.hch" - -/* - * Mouse data is stored in shared memory. When new mouse data is available - * Mouse notification is triggerd. - */ -mousedata_s mousedata; -chan unsigned 1 mousedata_notification; - -/*! \fn void mouse_main(void); - * \brief Main mousedriver. This function never returns! It calls the - * main mousehandler and returns the States and coordinates - * into the shared mpram. - * - * \param void None. - * - * \return Never Returns. - * \retval void - */ -void mouse_main(void) -{ - unsigned 14 touch_sampler; - unsigned 10 x, oldx; - unsigned 9 y, oldy; - unsigned 3 mousestate, oldmousestate; - unsigned 1 touch, touched, oldtouched; - - /* - * We only check for mouse states once every 2^14 time. This to - * overcome the sampling of the 'Touch' state of the RC200 libs. When - * using newer libs this might be overkill, e.g. smaller values may due - * or sampling all together will be redundant. - */ - for(touch_sampler = 1;;touch_sampler++) { - if (!touch_sampler) { - /* - * We are here ready to set mouse states. We compare - * current and previous states and thereby determine - * the state to send to others - */ - if (touched) { - if(oldtouched) { - mousestate = MOUSE_STATE_DOWN; - } else { - mousestate = MOUSE_STATE_ON_PRESS; - } - oldtouched = TRUE; - } else { - if(oldtouched) { - mousestate = MOUSE_STATE_ON_RELEASE; - } else { - mousestate = MOUSE_STATE_UP; - } - oldtouched = FALSE; - } - /* - * We have now processed our Touch. Reset it for the - * next run. - */ - touched = FALSE; - - /* - * Compare Previous States and Coordinates to determine - * wether they have changed. If so, Copy them into - * shared memory, notify the listening processes and - * Set the new as previous values for the next run. - */ - if ((oldmousestate != mousestate) || (oldx != x) || (oldy != y)) { - mousedata.x = x; - mousedata.y = y; - mousedata.state = mousestate; - mousedata_notification ! MOUSE_UPDATED; - oldx = x; - oldy = y; - oldmousestate = mousestate; - } - } - - /* - * Read the current X and Y of the 'cursor' and register wether - * the display was touched. If touched store this in a local - * store. This we do to catch the sampling of the RC200 lib. - */ - RC200TouchScreenReadScaled(&x, &y, &touch); - if (touch) { - touched = TRUE; - } - } -} /* --- mouse_main_loop() --- */ diff --git a/Graphic_Equalizer/src/eventhandler.hcc b/Graphic_Equalizer/src/eventhandler.hcc new file mode 100644 index 0000000..9c67aef --- /dev/null +++ b/Graphic_Equalizer/src/eventhandler.hcc @@ -0,0 +1,71 @@ +/*! \file eventhandler.hcc + * + * \section generic This modules coordinates all events. Thus for example + * when the mousehandler registers a 'click' we coordinate + * the actions that follow that click. + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author O.M. Schinagl + * \date 20041110 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041110: O.M. Schinagl\n Initial version + * + ********************************************************************/ + +/******** System Includes *************/ +#include + +#include "pal_master.hch" + +/******** Application Includes ********/ +#include "eventhandler.hch" +#include "eventhandler_shared.hch" +#include "mouse_shared.hch" +#include "display_shared.hch" + + + +/*! \fn void eventhandler_main(events_t *events, mousedata_t *mousedata); + * \brief + * + * \param events_t *events pointer to struct with all events. + * \param mousedata_t *mousedata pointer to struct with mouse data. + * + * \return Never Returns. + * \retval void + */ +void eventhandler_main(events_t *events, mousedata_t *mousedata) { + extern chan unsigned 1 mousedata_notification; + + unsigned 5 volume_left; + unsigned 1 newmousedata; + + for (;;) { + /* + * First we determine what mousestate we currently have. Then + * we check where we are to decide what to do. + */ + switch (mousedata->state) { + case MOUSE_STATE_DOWN: + if (BUTTON_HELP == events->mask) { + events->help = !events->help; + } + break; + case MOUSE_STATE_ON_PRESS: + if (AREA_VOLUME_YAXIS) { + events->volume_position = mousedata->y; + volume_left = volume_table[(mousedata->y) -65]; + RC200SetVolume(!volume_left, volume_left, volume_left); + } + if ((AREA_EQUALIZER_MIN <= events->mask) && (events->mask <= AREA_EQUALIZER_MAX)) { + } + break; + } + } +} /* --- eventhandler_main() --- */ diff --git a/Graphic_Equalizer/src/main.hcc b/Graphic_Equalizer/src/main.hcc new file mode 100644 index 0000000..6e4f7ae --- /dev/null +++ b/Graphic_Equalizer/src/main.hcc @@ -0,0 +1,164 @@ +/*! \file main.hcc + * + * \section generic Message build up information and more + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author O.M. Schinagl + * \date 20041011 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041011: O.M. Schinagl\n Initial version + * + *****************************************************************************/ + + +/* + * Set the Clock rate for this domain. 25.175 Mhz is required for the Video output. + */ +#define PAL_TARGET_CLOCK_RATE 25175000 + +/******** System Includes *************/ +#include "pal_master.hch" +#include "pal_mouse.hch" + +/******** Application Includes ********/ +#include "configuration.hch" +#include "display.hch" +#include "mouse.hch" +#include "mouse_shared.hch" +#include "audio.hch" +#include "eventhandler.hch" +#include "eventhandler_shared.hch" + +#if HAVE_DEBUG + #include "debug.hch" +#endif + + +/* + * Request Clockrate. Approximated ClockRate is compiler assigned. As the + * ClockRate is identical throughout the entire domain, this is a global + * expression so that all process use the correct one. + */ +macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE; + + +/*! \fn void main(void); + * \brief Main User Input/Ouput loop. + * + * \param void + * + * \return void + * \retval void + */ +void main(void) { + /* + * Set VideoOut, Audio I/O and Ram Handles + */ + macro expr VideoOut = PalVideoOutOptimalCT(ClockRate); + macro expr AudioIn = PalAudioInCT(0); + macro expr AudioOut = PalAudioOutCT(0) + macro expr RAM_BANK0 = PalPL2RAMCT(0); + + unsigned mousedata_t mousedata; + unsigned events_t events; + + /* + * Check library versions and Request various hardware functionality. + * We need at least Major Version 1. For Audio purposes we need atleast + * minor version 2. + */ + PalVersionRequire(1, 2); + PalVideoOutRequire(1); + PalAudioInRequire(1); + PalAudioOutRequire(1); + PalPL2RAMRequire(1); + + /* + * We verify some datawidths here at compile time. This to ensure + * successfull operation. + */ + assert (PalVideoOutGetColorWidthCT(VideoOut) == 24, 0, + "We need a 24-bit color Display."); + assert (PalPL2RAMGetDataWidthCT(PL2RAM_BANK0) >= 32, 0, + "We can't work with anything less then 32 bits wide ram."); + + /* + * Run The Following main tasks in parallel. + */ + par { + /* + * Primary task is to 'Run' several hardware simultaniously. + */ + PalVideoOutRun(VideoOut, ClockRate); + MouseRun(ClockRate); + PalAudioInRun(AudioIn, ClockRate); + PalAudioOutRun(AudioOut, ClockRate); +#if HAVE_SMART_MEDIA + /* + * The smartmedia device needs the CPLD to run. + */ + CPLDRun(ClockRate); + SmartMediaRun(ClockRate); +#endif + + /* + * Parallel to our Primary tasks we run the application. + */ + seq { + /* + * But first we need to initialize Video and Audio. + * We also load the data from the SmartMedia card + * into the ram. + */ + display_init(ClockRate); + PalAudioInEnable(AudioIn); + PalAudioOutEnable(AudioOut); + audio_init(6, LINE_IN, SR_44100); +#if HAVE_SMART_MEDIA + /* + * Once we properly setup the SmartMedia we load our + * data folowed by our main program loop. + */ + if (!smartmedia_init()) { +#endif +#if HAVE_DEBUG + print_string("Loading Skin ..."); +#endif + smartmedia_loaddata(); +#if HAVE_DEBUG + print_string("Done Loading Skin ..."); + print_eol(); + print_string("Running Main Application."); +#endif + + /* + * Main application starts here! + */ + par { + /* + * From here we run the mouse driver, audio + * and display in parallel. None of these + * should ever return. + */ + mouse_main(&mousedata); + display_main(&events, &mousedata); + eventhandler_main(&events, &mousedata); + audio_main(); + } +#if HAVE_SMART_MEDIA + } else { +#if HAVE_DEBUG + print_string("Error Initializing SmartMedia"); +#endif + } +#endif + } + } + +} /* --- main() --- */ diff --git a/Graphic_Equalizer/src/mouse.hcc b/Graphic_Equalizer/src/mouse.hcc new file mode 100644 index 0000000..7e7ca26 --- /dev/null +++ b/Graphic_Equalizer/src/mouse.hcc @@ -0,0 +1,120 @@ +/*! \file mousedriver.hcc + * + * \section generic This module takes care of mouse input. The mouse + * input function itself is however performed by the + * touchscreen of the RC200. + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author O.M. Schinagl + * \date 20041011 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041011: O.M. Schinagl\n Initial version + * + ********************************************************************/ + +/******** System Includes *************/ +#include + +#include "pal_master.hch" +#include "pal_mouse.hch" + +/******** Application Includes ********/ +#include "mousedriver.hch" +#include "mousedriver_shared.hch" + + + +/* + * Channel to notify others when new mousedata is available. If so + * Then mousedata struct is updated with shared data. + */ +chan unsigned 1 mousedata_notification; + + + +/*! \fn void mouse_main(mousedata_t *mousedata); + * \brief Main mousedriver. This function never returns! It calls the + * main mousehandler and returns the States and coordinates + * into the shared mpram. + * + * \param void None. + * + * \return Never Returns. + * \retval void + */ +void mouse_main(mousedata_t *mousedata) +{ + unsigned 14 touch_sampler; + unsigned 10 x, oldx; + unsigned 9 y, oldy; + unsigned 3 mousestate, oldmousestate; + unsigned 1 touch, touched, oldtouched; + + /* + * We only check for mouse states once every 2^14 time. This to + * overcome the sampling of the 'Touch' state of the RC200 libs. When + * using newer libs this might be overkill, e.g. smaller values may due + * or sampling all together will be redundant. + */ + for(touch_sampler = 1;;touch_sampler++) { + if (!touch_sampler) { + /* + * We are here ready to set mouse states. We compare + * current and previous states and thereby determine + * the state to send to others + */ + if (touched) { + if(oldtouched) { + mousestate = MOUSE_STATE_DOWN; + } else { + mousestate = MOUSE_STATE_ON_PRESS; + } + oldtouched = TRUE; + } else { + if(oldtouched) { + mousestate = MOUSE_STATE_ON_RELEASE; + } else { + mousestate = MOUSE_STATE_UP; + } + oldtouched = FALSE; + } + /* + * We have now processed our Touch. Reset it for the + * next run. + */ + touched = FALSE; + + /* + * Compare Previous States and Coordinates to determine + * wether they have changed. If so, Copy them into + * shared memory, notify the listening processes and + * Set the new as previous values for the next run. + */ + if ((oldmousestate != mousestate) || (oldx != x) || (oldy != y)) { + mousedata->x = x; + mousedata->y = y; + mousedata->state = mousestate; + mousedata_notification ! MOUSE_UPDATED; + oldx = x; + oldy = y; + oldmousestate = mousestate; + } + } + + /* + * Read the current X and Y of the 'cursor' and register wether + * the display was touched. If touched store this in a local + * store. This we do to catch the sampling of the RC200 lib. + */ + RC200TouchScreenReadScaled(&x, &y, &touch); + if (touch) { + touched = TRUE; + } + } +} /* --- mouse_main_loop() --- */ diff --git a/Graphic_Equalizer/src/sample.hcc b/Graphic_Equalizer/src/sample.hcc new file mode 100644 index 0000000..000baf9 --- /dev/null +++ b/Graphic_Equalizer/src/sample.hcc @@ -0,0 +1,106 @@ +/*! \file sample.hcc + * + * \section generic Handle audio sampling and buffer rotation. + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author O.M. Schinagl + * \date 20041021 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041021: O.M. Schinagl\n Initial version + * + ********************************************************************/ + +/******** System Includes *************/ + +/******** Application Includes ********/ +#include "sample.hch" + + + +/* + * Pointer that points towards the current 64 bits samples. + */ +signed 16 *audio_in_ptr; + +/* + * 64 step counter to keep track of our samples. This is a private variable. + */ +unsigned 8 sample_count; + + + +/*! \fn void sample_add(signed 16 in_sample); + * \brief This procedure adds the supplied sample to the input buffer. + * + * \param signed 16 in_sample 16 bits signed sample to be added. + * + * \return void + * \retval void + */ +void sample_add(signed 16 in_sample) { + /* + * We only sample 64 bits in our buffer, hence we circulate around the + * last 6 bits. + */ + audio_in_ptr[sample_count <-6] = in_sample; + sample_count++; +} /* --- sample_add() --- */ + + + +/*! \fn void sample_get(signed 16 *out_sample); + * \brief This procedure gets the sample from the current output buffer. + * + * \param * in_sample pointer to storage for sample. + * + * \return void + * \retval void + */ +void sample_get(signed 16 *out_sample) { + /* + * We circulate around a 64 bits buffer, therefor we only use the last + * 6 bits. + */ + *out_sample = audio_out_ptr[sample_count <-6]; +} /* --- sample_get() --- */ + + + +/*! \fn unsigned 1 sample_rotate_buffers(void); + * \brief This procedure rotates our buffers around if 64 samples are + * read into our current buffer. + * + * \param in_sample 16 bits signed sample to be added. + * + * \return 1 when 64 samples have passed, 0 otherwise. + * \retval unsigned 1; + */ +unsigned 1 sample_rotate_buffers(void) { + unsigned 1 retval; /* store for returnvalue */ + + retval = 0; + /* + * We only want to read 64 samples, but calculations work nicer if we + * use 256 samples. Therefor we circulate our audio pointer around. + */ + if (!(sample_count <- 6)) { + /* + * 64 Samples have passed. We are back at '0'. Use the full + * sample count as index which is 0 64 128 or 192 and back to + * 0. Our Output is only 128 big so we only look at the + * 7 LSB. Also, notify the main application that 64 samples + * have been processed. + */ + par { + audio_in_ptr = &pcm_audio_in[sample_count]; + audio_out_ptr = &pcm_audio_out[(sample_count <- 7)]; + retval = 1; + } + } +} /* --- sample_rotate_buffers() --- */ diff --git a/Graphic_Equalizer/src/smartmedia.hcc b/Graphic_Equalizer/src/smartmedia.hcc new file mode 100644 index 0000000..7fc647b --- /dev/null +++ b/Graphic_Equalizer/src/smartmedia.hcc @@ -0,0 +1,166 @@ +/*! \file smartmedia.hcc + * + * \section generic Here we interface with the SmartMedia card. + * + * \section project Project information. + * Project Graphic Equalizer\n + * \author O.M. Schinagl + * \date 20041110 + * \version 0.1 + * + * \section copyright Copyright + * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved + * + * \section history Change history + * 20041110: O.M. Schinagl\n Initial version + * + ********************************************************************/ + +/******** System Includes *************/ +#include + +#include "pal_master.hch" + +/******** Application Includes ********/ +#include "configuration.hch" +#include "smartmedia.hch" + + + +/*! \fn void smartmedia_init(void); + * \brief We here initialize the Smart Media card and verify wether the + * card is inserted and such. + * + * \param void None. + * + * \return We return 0 on success, 1 on error. + * \retval unsigned 1 + */ +unsigned 1 smartmedia_init(void) { + unsigned 1 retval; + + /* + * Firstly we enable both the CPLD and the SmartMedia. + */ + RC200CPLDEnable(); + RC200SmartMediaInit(&retval); + + /* + * In the case of initialization failing, we try to reset the + * SmartMedia. + */ + if (retval) { + RC200SmartMediaReset(&retval); + } + + return retval; +} /* --- smartmedia_init() --- */ + + + +/*! \fn void smartmedia_loaddata(void); + * \brief We load our memory with skin and help data from the smartmedia. + * + * \param void None. + * + * \return void + * \retval void + */ +void smartmedia_loaddata(void) { + /* + * Setup RAM Handle, and determin maximum Data and Address widths + */ + macro expr RAM_BANK0 = PalPL2RAMCT(0); + macro expr DW = PalPL2RAMGetMaxDataWidthCT(); + macro expr AW = PalPL2RAMGetMaxAddressWidthCT(); + + unsigned 27 smartmedia_address, smartmedia_address_mask; + unsigned AW address; + unsigned 8 mask, r, g, b; + unsigned 1 result; + +#if HAVE_DEBUG + /* + * Print some nice stats about data loading. + */ + print_eol(); + print_hex_value(0 @ 0); +#endif + /* + * Before we enter our loop to fill our memory with valid data, we have + * to set the startup positions for the SmartMedia. + */ + smartmedia_address = SMARTMEDIA_ADDRES_SKIN_START; + smartmedia_address_mask = SMARTMEDIA_ADDRESS_SKINMASK_START; + for (address = ADDRESS_SKIN_START; address != (ADDRESS_HELP_END);) { + /* + * Once we are done with the loading of our skin, we need to + * change the smartmedia start addresses. + */ + if (address == ADDRRESS_HELP_START) { + smartmedia_address = SMARTMEDIA_ADDRESS_HELP_START; + smartmedia_address_mask = SMARTMEDIA_ADDRESS_HELPMASK_START; + } + + /* + * Before reading our data from the smartmedia we set our + * address pointer to the address from our loop. + */ + PalPL2RAMSetWriteAddress(RAM_BANK0, address); + + /* + * SmartMedia data is read one byte per call. Because we want + * to store the mask + the rgb values in one variable for later + * useage we need to read those 4 bytes from the smartmedia + * before storing it as one. + */ +#if HAVE_SMARTMEDIA + /* + * FIXME: Due to a bug in the DK2 smartmedia libraries we need + * stop reading after each byte with OperationEnd call. This is + * VERY slow and must be changed. + */ + #if !USE_MASK_ONLY + RC200SmartMediaSetAddress(READ, smartmedia_address); + RC200SmartMediaRead(&r, TRUE); + RC200SmartMediaOperationEnd(&result); + RC200SmartMediaSetAddress(READ, (smartmedia_address +1)); + RC200SmartMediaRead(&g, TRUE); + RC200SmartMediaOperationEnd(&result); + RC200SmartMediaSetAddress(READ, (smartmedia_address +2)); + RC200SmartMediaRead(&b, TRUE); + RC200SmartMediaOperationEnd(&result); + #endif + RC200SmartMediaSetAddress(READ, smartmedia_address_mask); + RC200SmartMediaRead(&mask, TRUE); + RC200SmartMediaOperationEnd(&result); +#else + mask = 0x01; + r = 0xff; + g = 0x00; + b = 0x00; +#endif + /* + * Now that we have gathered all pixel data, store it in ram. + */ + PalPL2RAMWrite(RAM_BANK0, (unsigned DW)(0 @ mask @ r @ g @ b)) + +#if HAVE_DEBUG + /* + * Print some nice stats about data loading. + */ + if (!address[8:0]) { + print_cr(); + print_hex_value(0 @ address); + print_string(" / 02E4000"); + } +#endif + + /* + * Finally increase al our indexes approperiatly. + */ + smartmedia_address += 3; + smartmedia_address_mask++; + address++; + } +} /* --- smartmedia_loaddata() --- */ -- cgit v0.12