mirror of
https://github.com/skogaby/OpeNITHM.git
synced 2026-09-22 22:58:16 +03:00
Fixed Serial Plot, added more debug defines
This commit is contained in:
@@ -152,7 +152,7 @@ void AirSensor::analogCalibrate() {
|
||||
bool AirSensor::getSensorState(int sensor) {
|
||||
uint16_t value = getValue(sensor);
|
||||
|
||||
/*
|
||||
#ifdef SERIAL_AIR_READINGS
|
||||
Serial.print(sensor);
|
||||
Serial.print("\t");
|
||||
Serial.print(value);
|
||||
@@ -161,7 +161,8 @@ bool AirSensor::getSensorState(int sensor) {
|
||||
Serial.print("\t");
|
||||
Serial.print(thresholds[sensor]);
|
||||
Serial.println();
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef IR_SENSOR_ANALOG
|
||||
return value == LOW ? true : false;
|
||||
|
||||
@@ -121,6 +121,10 @@ uint16_t AutoTouchboard::getRawValue(int key) {
|
||||
return key_values[key];
|
||||
}
|
||||
|
||||
uint16_t AutoTouchboard::getReleaseThresholdSingle(int key) {
|
||||
return (uint16_t)releaseThresholdsSingle[key];
|
||||
}
|
||||
|
||||
void AutoTouchboard::calcThresholds(int key, int pressure) {
|
||||
triggerThresholdsSingle[key] = pressure + deltaThreshold;
|
||||
releaseThresholdsSingle[key] = pressure + (deltaThreshold * releaseThreshold);
|
||||
|
||||
@@ -52,6 +52,7 @@ class AutoTouchboard {
|
||||
void scan();
|
||||
KeyState update(int key);
|
||||
uint16_t getRawValue(int key);
|
||||
uint16_t getReleaseThresholdSingle(int key);
|
||||
void calibrateKeys();
|
||||
bool isCalibrated() { return calibrated; }
|
||||
};
|
||||
|
||||
@@ -41,14 +41,17 @@
|
||||
// *** FOR CALIBRATING AND DEBUGGING
|
||||
|
||||
// Uncomment this line to output the touch values to the Serial port (for use with Arduino's Serial Plotter)
|
||||
//#define SERIAL_PLOT
|
||||
// #define SERIAL_KEY_PLOT
|
||||
|
||||
// Uncomment this line if you want RAW touch values (vs. normalized)
|
||||
//#define SERIAL_RAW_VALUE
|
||||
// #define SERIAL_RAW_VALUES
|
||||
|
||||
// Define PLOT_PIN as -1 to print all key's values, otherwise define as 0-15 for an individual key
|
||||
#define PLOT_PIN -1
|
||||
|
||||
// Uncomment this line to output the air sensor values to the Serial port
|
||||
// #define SERIAL_AIR_READINGS
|
||||
|
||||
// Uncomment this if you wish to ignore a falsely calibrated air sensor
|
||||
// #define IGNORE_AIR_CALIBRATION
|
||||
|
||||
|
||||
@@ -188,11 +188,17 @@ void loop() {
|
||||
useSerialLeds = false;
|
||||
|
||||
// Process air sensor hand position
|
||||
#if !defined(SERIAL_PLOT) && defined(USB)
|
||||
#if defined(USB)
|
||||
#ifdef IR_SENSOR_KEY
|
||||
output->sendSensor(sensor->getSensorReadings());
|
||||
uint8_t airReadings = sensor->getSensorReadings();
|
||||
#ifndef SERIAL_AIR_READINGS
|
||||
output->sendSensor(airReadings);
|
||||
#endif
|
||||
#else
|
||||
output->sendSensorEvent(sensor->getHandPosition());
|
||||
float handPosition = sensor->getHandPosition();
|
||||
#ifndef SERIAL_AIR_READINGS
|
||||
output->sendSensorEvent(handPosition);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -210,7 +216,7 @@ void loop() {
|
||||
#if NUM_SENSORS == 16
|
||||
KeyState keyState = touchboard->update(i);
|
||||
|
||||
#if !defined(SERIAL_PLOT) && defined(USB)
|
||||
#if !defined(SERIAL_KEY_PLOT) && defined(USB)
|
||||
if (key_states[i] != keyState)
|
||||
output->sendKeyEvent(i, keyState);
|
||||
#endif
|
||||
@@ -222,7 +228,7 @@ void loop() {
|
||||
KeyState stateBot = touchboard->update(i * 2 + 1);
|
||||
KeyState keyState = stateTop + stateBot;
|
||||
|
||||
#if !defined(SERIAL_PLOT) && defined(USB)
|
||||
#if !defined(SERIAL_KEY_PLOT) && defined(USB)
|
||||
if (key_states[i * 2] != stateTop)
|
||||
output->sendKeyEvent(i * 2, stateTop);
|
||||
|
||||
@@ -278,7 +284,7 @@ void loop() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SERIAL_PLOT
|
||||
#ifdef SERIAL_KEY_PLOT
|
||||
if (PLOT_PIN == -1) {
|
||||
for (int i = 0; i < NUM_SENSORS; i++) {
|
||||
#ifdef SERIAL_RAW_VALUES
|
||||
@@ -286,7 +292,7 @@ void loop() {
|
||||
Serial.print(touchboard->getRawValue(i));
|
||||
#else
|
||||
// Print normalized values
|
||||
Serial.print(touchboard->getRawValue(i) - touchboard->getNeutralValue(i));
|
||||
Serial.print(touchboard->getRawValue(i) - touchboard->getReleaseThresholdSingle(i));
|
||||
#endif
|
||||
Serial.print("\t");
|
||||
}
|
||||
@@ -302,17 +308,12 @@ void loop() {
|
||||
bool sliderCalibrated = touchboard->isCalibrated();
|
||||
|
||||
// Send update
|
||||
#if !defined(SERIAL_PLOT) && defined(USB)
|
||||
#if !defined(SERIAL_KEY_PLOT) && !defined(SERIAL_AIR_READINGS) && defined(USB)
|
||||
if (airCalibrated && sliderCalibrated) {
|
||||
output->sendUpdate();
|
||||
}
|
||||
#endif
|
||||
|
||||
//#if defined(SERIAL_PLOT)
|
||||
// Serial.print("\t");
|
||||
// Serial.println(sensor->getSensorReadings());
|
||||
//#endif
|
||||
|
||||
if (updateLeds && airCalibrated && sliderCalibrated) {
|
||||
FastLED.show();
|
||||
updateLeds = false;
|
||||
|
||||
Reference in New Issue
Block a user