andrewm@17: /* andrewm@17: TouchKeys: multi-touch musical keyboard control software andrewm@17: Copyright (c) 2013 Andrew McPherson andrewm@17: andrewm@17: This program is free software: you can redistribute it and/or modify andrewm@17: it under the terms of the GNU General Public License as published by andrewm@17: the Free Software Foundation, either version 3 of the License, or andrewm@17: (at your option) any later version. andrewm@17: andrewm@17: This program is distributed in the hope that it will be useful, andrewm@17: but WITHOUT ANY WARRANTY; without even the implied warranty of andrewm@17: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the andrewm@17: GNU General Public License for more details. andrewm@17: andrewm@17: You should have received a copy of the GNU General Public License andrewm@17: along with this program. If not, see . andrewm@17: andrewm@17: ===================================================================== andrewm@17: andrewm@17: KeyboardTesterDisplay.h: A keyboard display for raw data that can be used andrewm@17: for testing the functionality of individual TouchKeys sensors andrewm@17: */ andrewm@17: andrewm@17: #ifndef KEYBOARDTESTERDISPLAY_H_INCLUDED andrewm@17: #define KEYBOARDTESTERDISPLAY_H_INCLUDED andrewm@17: #ifdef ENABLE_TOUCHKEYS_SENSOR_TEST andrewm@17: andrewm@17: #include "KeyboardDisplay.h" andrewm@17: #include "../TouchKeys/Osc.h" andrewm@17: andrewm@17: class MainApplicationController; andrewm@17: class PianoKeyboard; andrewm@17: andrewm@17: class KeyboardTesterDisplay : public KeyboardDisplay, public OscHandler { andrewm@17: private: andrewm@17: static const int kNumSensorsPerKey; andrewm@17: static const int kDefaultSensorThreshold; andrewm@17: andrewm@17: public: andrewm@17: KeyboardTesterDisplay(MainApplicationController& controller, PianoKeyboard& keyboard); andrewm@17: ~KeyboardTesterDisplay() {} andrewm@17: andrewm@17: // Render the display andrewm@17: void render(); andrewm@17: andrewm@18: // Called when a given key is clicked by mouse andrewm@18: void keyClicked(int key); andrewm@18: andrewm@17: // Set the threshold for a value considered active andrewm@17: void setSensorThreshold(int threshold); andrewm@17: andrewm@17: // Set whether the given sensor is active or not andrewm@17: void setSensorState(int key, int sensor, bool active); andrewm@17: andrewm@17: // Reset the detection state for a given key to all sensors off andrewm@17: void resetSensorState(int key); andrewm@17: andrewm@17: // Check whether all the sensors are good on a given key andrewm@17: bool allSensorsGood(int key); andrewm@17: andrewm@17: // OSC callback andrewm@17: bool oscHandlerMethod(const char *path, const char *types, int numValues, lo_arg **values, void *data); andrewm@17: andrewm@17: private: andrewm@18: void drawSensorState(int key, float x, float y, float width, float height, bool white, float whiteOffset); andrewm@17: andrewm@17: MainApplicationController& controller_; andrewm@17: PianoKeyboard& keyboard_; andrewm@17: andrewm@17: // Keep track of which sensors have registered a positive reading; andrewm@17: // one bit per sensor (up to 26) andrewm@17: unsigned int keySensorActive_[128]; andrewm@17: unsigned int keySensorGood_[128]; andrewm@17: int currentlyActiveKey_; andrewm@17: int sensorThreshold_; andrewm@17: }; andrewm@17: andrewm@17: #endif // ENABLE_TOUCHKEYS_SENSOR_TEST andrewm@17: #endif // KEYBOARDTESTERDISPLAY_H_INCLUDED