andrewm@17
|
1 /*
|
andrewm@17
|
2 TouchKeys: multi-touch musical keyboard control software
|
andrewm@17
|
3 Copyright (c) 2013 Andrew McPherson
|
andrewm@17
|
4
|
andrewm@17
|
5 This program is free software: you can redistribute it and/or modify
|
andrewm@17
|
6 it under the terms of the GNU General Public License as published by
|
andrewm@17
|
7 the Free Software Foundation, either version 3 of the License, or
|
andrewm@17
|
8 (at your option) any later version.
|
andrewm@17
|
9
|
andrewm@17
|
10 This program is distributed in the hope that it will be useful,
|
andrewm@17
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
andrewm@17
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
andrewm@17
|
13 GNU General Public License for more details.
|
andrewm@17
|
14
|
andrewm@17
|
15 You should have received a copy of the GNU General Public License
|
andrewm@17
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
andrewm@17
|
17
|
andrewm@17
|
18 =====================================================================
|
andrewm@17
|
19
|
andrewm@17
|
20 KeyboardTesterDisplay.h: A keyboard display for raw data that can be used
|
andrewm@17
|
21 for testing the functionality of individual TouchKeys sensors
|
andrewm@17
|
22 */
|
andrewm@17
|
23
|
andrewm@17
|
24 #ifndef KEYBOARDTESTERDISPLAY_H_INCLUDED
|
andrewm@17
|
25 #define KEYBOARDTESTERDISPLAY_H_INCLUDED
|
andrewm@17
|
26 #ifdef ENABLE_TOUCHKEYS_SENSOR_TEST
|
andrewm@17
|
27
|
andrewm@17
|
28 #include "KeyboardDisplay.h"
|
andrewm@17
|
29 #include "../TouchKeys/Osc.h"
|
andrewm@17
|
30
|
andrewm@17
|
31 class MainApplicationController;
|
andrewm@17
|
32 class PianoKeyboard;
|
andrewm@17
|
33
|
andrewm@17
|
34 class KeyboardTesterDisplay : public KeyboardDisplay, public OscHandler {
|
andrewm@17
|
35 private:
|
andrewm@17
|
36 static const int kNumSensorsPerKey;
|
andrewm@17
|
37 static const int kDefaultSensorThreshold;
|
andrewm@17
|
38
|
andrewm@17
|
39 public:
|
andrewm@17
|
40 KeyboardTesterDisplay(MainApplicationController& controller, PianoKeyboard& keyboard);
|
andrewm@17
|
41 ~KeyboardTesterDisplay() {}
|
andrewm@17
|
42
|
andrewm@17
|
43 // Render the display
|
andrewm@17
|
44 void render();
|
andrewm@17
|
45
|
andrewm@18
|
46 // Called when a given key is clicked by mouse
|
andrewm@18
|
47 void keyClicked(int key);
|
andrewm@18
|
48
|
andrewm@17
|
49 // Set the threshold for a value considered active
|
andrewm@17
|
50 void setSensorThreshold(int threshold);
|
andrewm@17
|
51
|
andrewm@17
|
52 // Set whether the given sensor is active or not
|
andrewm@17
|
53 void setSensorState(int key, int sensor, bool active);
|
andrewm@17
|
54
|
andrewm@17
|
55 // Reset the detection state for a given key to all sensors off
|
andrewm@17
|
56 void resetSensorState(int key);
|
andrewm@17
|
57
|
andrewm@17
|
58 // Check whether all the sensors are good on a given key
|
andrewm@17
|
59 bool allSensorsGood(int key);
|
andrewm@17
|
60
|
andrewm@17
|
61 // OSC callback
|
andrewm@17
|
62 bool oscHandlerMethod(const char *path, const char *types, int numValues, lo_arg **values, void *data);
|
andrewm@17
|
63
|
andrewm@17
|
64 private:
|
andrewm@18
|
65 void drawSensorState(int key, float x, float y, float width, float height, bool white, float whiteOffset);
|
andrewm@17
|
66
|
andrewm@17
|
67 MainApplicationController& controller_;
|
andrewm@17
|
68 PianoKeyboard& keyboard_;
|
andrewm@17
|
69
|
andrewm@17
|
70 // Keep track of which sensors have registered a positive reading;
|
andrewm@17
|
71 // one bit per sensor (up to 26)
|
andrewm@17
|
72 unsigned int keySensorActive_[128];
|
andrewm@17
|
73 unsigned int keySensorGood_[128];
|
andrewm@17
|
74 int currentlyActiveKey_;
|
andrewm@17
|
75 int sensorThreshold_;
|
andrewm@17
|
76 };
|
andrewm@17
|
77
|
andrewm@17
|
78 #endif // ENABLE_TOUCHKEYS_SENSOR_TEST
|
andrewm@17
|
79 #endif // KEYBOARDTESTERDISPLAY_H_INCLUDED
|