From 14199e75ce0b65d51148c3a8e0558d377eb8463e Mon Sep 17 00:00:00 2001 From: Oliver Schinagl Date: Wed, 24 Nov 2004 15:27:34 +0000 Subject: changed the eventhandler from a function to a macro proc. equalizer bars are now filled into a double buffered pointer locked piece of memory. Added the graphic visualization. after a preset is loaded, we use a function to update the equalizer display memory. Added preset buttons functionallity. moved equalizer lookup tables to here. --- Graphic_Equalizer/src/eventhandler.hcc | 141 +++++++++++++++++++++++---------- 1 file changed, 100 insertions(+), 41 deletions(-) diff --git a/Graphic_Equalizer/src/eventhandler.hcc b/Graphic_Equalizer/src/eventhandler.hcc index 2502518..40565c5 100644 --- a/Graphic_Equalizer/src/eventhandler.hcc +++ b/Graphic_Equalizer/src/eventhandler.hcc @@ -27,16 +27,24 @@ #include "configuration.hch" #include "audio.hch" #include "mouse_shared.hch" -#include "display_shared.hch" #include "eventhandler_shared.hch" #include "eventhandler.hch" +#include "events.hch" +#include "display_shared.hch" +#include "display.hch" #if HAVE_DEBUG #include "debug.hch" #endif + + +/* + */ extern chan unsigned 1 maskupdate_notification; + + /*! \fn void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mousedata); * \brief * @@ -46,17 +54,26 @@ extern chan unsigned 1 maskupdate_notification; * \return Never Returns. * \retval void */ -void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mousedata) { +macro proc eventhandler_main(audiodata, events, mousedata) { mpram { ram unsigned 4 write[768]; rom unsigned 4 read[768]; } equalizer_levels with { block = "BlockRAM"}; + unsigned ram 10 equalizer_display_0[128], equalizer_display_1[128]; + unsigned 10 preset_offset; - unsigned 7 equalizer_bands; unsigned 5 volume_left; unsigned 1 newmaskupdate; + events.equalizer_displayptr_set = &equalizer_display_0[0]; + events.equalizer_displayptr_get = &equalizer_display_1[0]; + + /* + * Initialize our equalizer display pointers here, as they don't point + * anywhere otherwise. + */ + for (;;) { maskupdate_notification ? newmaskupdate; @@ -64,14 +81,47 @@ void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mo * First we determine what mousestate we currently have. Then * we check where we are to decide what to do. */ - switch (mousedata->state) { + switch (mousedata.state) { case MOUSE_STATE_ON_PRESS: /* + * If we are displaying the graphic visual, + * any press returns to the application. + */ + if (MODE_GRAPH == events.mode) { + events.mode = MODE_SKIN; + events.mask = 0; + } else { + delay; + } + + /* + */ + if (BUTTON_MODE == events.mask) { + if (MODE_GRAPH == events.mode) { + events.mode = MODE_SKIN; + } else { + events.mode = MODE_GRAPH; + } + } else { + delay; + } + + /* * If the current mask equals the help button - * we flip the help bit. + * we set display mode to help. */ - if (BUTTON_HELP == events->mask) { - events->help = !events->help; + if (BUTTON_HELP == events.mask) { + /* + * Change the mode to help if it's + * currently not set, otherwise go back + * to skin mode. + */ + if (MODE_HELP == events.mode) { + events.mode = MODE_SKIN; + } else { + events.mode = MODE_HELP; + print_string("going to help");print_eol(); + } } else { delay; } @@ -81,21 +131,21 @@ void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mo * the mask one of those, we'll change the * pointer to point to the current preset. */ - if ((BUTTON_PRESET_1 <= events->mask) && (events->mask <= BUTTON_PRESET_6)) { + if ((BUTTON_PRESET_1 <= events.mask) && (events.mask <= BUTTON_PRESET_6)) { /* * The active preset is determined by * the mask minus an offset. Hence * ranging our active preset from 0 to * 6. */ - events->active_preset = 0 @ (events->mask -BUTTON_PRESET_1); + events.active_preset = 0 @ (events.mask -BUTTON_PRESET_1); /* * Each equalizer is 128 bands wide, * thus we need to add 128 * the preset * for each different preset. This * offset is calculated here. */ - preset_offset = events->active_preset << 7; + preset_offset = events.active_preset << 7; /* * We set the pointer to the active * part of the array by using the @@ -104,32 +154,46 @@ void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mo * we point to 0, 128, 256, 384, 512 * or 640. */ - audiodata->equalizer_levels_ptr = &equalizer_levels.write[preset_offset]; - + audiodata.equalizer_levels_ptr = &equalizer_levels.read[preset_offset]; /* - * Reverse fill + * Finally update the equalizer bars + * that are drawn by the display. */ - equalizer_bands = 0; - do { - events->equalizer_position[equalizer_bands] = equalizer_table_inv[audiodata->equalizer_levels_ptr[equalizer_bands]]; - equalizer_bands++; - } while (equalizer_bands); + reload_equalizer(events, equalizer_levels.write, preset_offset); } else { delay; } - if ((BUTTON_1 <= events->mask) && (events->mask <= BUTTON_5)) { - events->equalizer_mode = (events->mask -BUTTON_1) <- 3; + if ((BUTTON_CONVEX_FULL <= events.mask) && (events.mask <= BUTTON_CONCAVE_FULL)) { + events.equalizer_mode = (events.mask -BUTTON_CONVEX_FULL) <- 3; } else { delay; } /* + * If the demo button was pressed load the + * demo preset values into the presets. + */ + if (BUTTON_DEMO == events.mask) { + load_preset(ADDRESS_PRESET_DEMO_START, equalizer_levels.write); + reload_equalizer(events, equalizer_levels.write, preset_offset); + } + + /* + * If the reset button was pressed load the + * reset values into the presets. + */ + if (BUTTON_RESET == events.mask) { + load_preset(ADDRESS_PRESET_RESET_START, equalizer_levels.write); + reload_equalizer(events, equalizer_levels.write, preset_offset); + } + + /* * If the current mask equals the log button, * we flip the display_log bit. */ - if (BUTTON_LOG == events->mask) { - audiodata->display_log = !audiodata->display_log; + if (BUTTON_LOG == events.mask) { + audiodata.display_log = !audiodata.display_log; } else { delay; } @@ -141,13 +205,13 @@ void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mo * If we are in the volume area we update the * volume level for both channels. */ - if (AREA_VOLUME_YAXIS == events->mask) { + if (AREA_VOLUME_YAXIS == events.mask) { /* * Copy the current Y cursor position * to the events struct. This we then * later use for drawing purposes. */ - events->volume_position = 0 @ mousedata->y; + events.volume_position = 0 @ mousedata.y; /* * Look the relative y-coordinate up in * the volumecontrol lookup table. We @@ -155,7 +219,7 @@ void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mo * RC200 call doesn't behave nicely * when passing anything else. */ - volume_left = volumecontrol_table[((mousedata->y) -65) <- 6]; + volume_left = volumecontrol_table[((mousedata.y) -65) <- 6]; /* * We feel that volume gets softer the * closer it gets to the 0, and louder @@ -168,15 +232,21 @@ void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mo delay; } - if ((AREA_EQUALIZER_MIN <= events->mask) && (events->mask <= AREA_EQUALIZER_MAX)) { + if ((AREA_EQUALIZER_MIN <= events.mask) && (events.mask <= AREA_EQUALIZER_MAX)) { /* * Copy the current Y position into a * store for the current equalizer bar. * The index is determined by the mask * minus the maskoffset. */ - events->equalizer_position[((events->mask -AREA_EQUALIZER_MIN) <- 7)] = mousedata->y; -print_string("Eventsmask: ");print_hex_value(0 @ ((events->mask -AREA_EQUALIZER_MIN) <- 7));print_eol(); + events.equalizer_displayptr_set[((events.mask -AREA_EQUALIZER_MIN) <- 7)] = mousedata.y; + events.locked_equalizer = 1; + par { + events.equalizer_displayptr_set = events.equalizer_displayptr_get; + events.equalizer_displayptr_get = events.equalizer_displayptr_set; + } + events.locked_equalizer = 0; + /* * We look our current possition up in * the lookup table. We determin our @@ -187,11 +257,8 @@ print_string("Eventsmask: ");print_hex_value(0 @ ((events->mask -AREA_EQUALIZER_ * from the current mask. We add the * size of our equalizer bands times * the active preset. - * - * TODO: lock equalizer store with a - * semaphore! */ - audiodata->equalizer_levels_ptr[(events->mask -AREA_EQUALIZER_MIN) <- 7] = equalizer_table[(mousedata->y -382) <- 7]; + equalizer_levels.write[preset_offset +(0 @ ((events.mask -AREA_EQUALIZER_MIN) <- 7))] = equalizer_table[(mousedata.y -382) <- 7]; } else { delay; } @@ -207,12 +274,4 @@ print_string("Eventsmask: ");print_hex_value(0 @ ((events->mask -AREA_EQUALIZER_ * TODO: This table is now hardcoded. To ensure full skinability this table * should be dynamically loaded. */ -rom unsigned 5 volumecontrol_table[46] = {31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0}; - -/* - * Equalizer lookuptabes. - * 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}; -rom unsigned 9 equalizer_table_inv[16] = {448, 444, 440, 436, 432, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 382}; +rom unsigned 5 volumecontrol_table[46] = {31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0}; \ No newline at end of file -- cgit v0.12