Changes to accomodate new sensors
PB control -> 2d stick Extra -> cap lip sensor Bite -> force sensitive resistor Lever -> pot 2d Stick added
This commit is contained in:
parent
e8aeb26399
commit
b401b34bb4
8 changed files with 150 additions and 143 deletions
|
|
@ -20,7 +20,6 @@ float sliderMALever = 0.0;
|
|||
|
||||
Adafruit_MPR121 touchSensorKeys = Adafruit_MPR121();
|
||||
Adafruit_MPR121 touchSensorRoller = Adafruit_MPR121();
|
||||
Adafruit_MPR121 touchSensorUtil = Adafruit_MPR121();
|
||||
Adafruit_MPRLS pressureSensorMain = Adafruit_MPRLS();
|
||||
Adafruit_MPRLS pressureSensorAlt = Adafruit_MPRLS();
|
||||
|
||||
|
|
@ -56,9 +55,6 @@ void initHardware() {
|
|||
tiltFilter.setFilter(LOWPASS, ICM_FILTER_FREQ, 0.0); // create a one pole (RC) lowpass filter
|
||||
rollFilter.setFilter(LOWPASS, ICM_FILTER_FREQ, 0.0); // create a one pole (RC) lowpass filter
|
||||
icmSensor.begin_I2C(ICM20948_I2CADDR_DEFAULT, &MainI2CBus);
|
||||
sliderFilterExtra.setFilter(INTEGRATOR, 0.75, 0.0);
|
||||
sliderFilterLever.setFilter(INTEGRATOR, 0.75, 0.0);
|
||||
sliderFilterPB.setFilter(INTEGRATOR, 0.75, 0.0);
|
||||
|
||||
ledStrip.begin();
|
||||
|
||||
|
|
@ -72,13 +68,6 @@ void initHardware() {
|
|||
errorWait();
|
||||
}
|
||||
|
||||
if (!touchSensorUtil.begin(UtilI2CAddr, &MainI2CBus)) {
|
||||
displayError("Util touch error");
|
||||
errorWait();
|
||||
}
|
||||
//touchSensorUtil.writeRegister(MPR121_CONFIG1, 0x3f); // default, 16uA charge current
|
||||
//touchSensorUtil.writeRegister(MPR121_CONFIG2, 0xE0); // 0.5uS encoding, 1ms period
|
||||
|
||||
if (!pressureSensorMain.begin(MPRLS_DEFAULT_ADDR, &AuxI2CBus)) {
|
||||
displayError("Main pressure sensor error");
|
||||
errorWait();
|
||||
|
|
@ -171,18 +160,10 @@ int readTouchRoller(uint8_t n) {
|
|||
return CAP_SENS_ABSOLUTE_MAX - touchSensorRoller.filteredData(n);
|
||||
}
|
||||
|
||||
int readTouchUtil(uint8_t n) {
|
||||
return CAP_SENS_ABSOLUTE_MAX - touchSensorUtil.filteredData(n);
|
||||
}
|
||||
|
||||
uint16_t keysTouched() {
|
||||
return touchSensorKeys.touched();
|
||||
}
|
||||
|
||||
uint16_t utilTouched() {
|
||||
return touchSensorUtil.touched();
|
||||
}
|
||||
|
||||
int readSpikePressure() {
|
||||
return spikeFilter.output();
|
||||
}
|
||||
|
|
@ -198,47 +179,12 @@ int readAltPressure() {
|
|||
return breathAltFilter.input(pressureSensorAlt.readPressure()) * PRESSURE_SENS_MULTIPLIER;
|
||||
}
|
||||
|
||||
int16_t readSlider(Slider id, int thr) {
|
||||
float filtered = 0.0;
|
||||
float a = 0, b = 0;
|
||||
FilterOnePole *filter;
|
||||
|
||||
int16_t readAnalog(Control id, int thr) {
|
||||
switch (id) {
|
||||
case SLIDER_PITCH_BEND:
|
||||
a = touchSensorUtil.filteredData(pbSliderPin1);
|
||||
b = touchSensorUtil.filteredData(pbSliderPin2);
|
||||
filter = &sliderFilterPB;
|
||||
break;
|
||||
case SLIDER_EXTRA:
|
||||
a = touchSensorRoller.filteredData(extraSliderPin1);
|
||||
b = touchSensorRoller.filteredData(extraSliderPin2);
|
||||
filter = &sliderFilterExtra;
|
||||
/*
|
||||
Serial.print(">a:");
|
||||
Serial.println(a);
|
||||
Serial.print(">b:");
|
||||
Serial.println(b);
|
||||
Serial.print(">thr:");
|
||||
Serial.println(thr);
|
||||
*/
|
||||
break;
|
||||
case SLIDER_LEVER:
|
||||
a = touchSensorUtil.filteredData(leverSliderPin1);
|
||||
b = touchSensorUtil.filteredData(leverSliderPin2);
|
||||
filter = &sliderFilterLever;
|
||||
break;
|
||||
default:
|
||||
return 0.0;
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((a + b) <= (thr + thr - SLIDER_TOUCH_OFFSET)) {
|
||||
filtered = filter->input(a - b);
|
||||
} else {
|
||||
return INT16_MIN;
|
||||
}
|
||||
|
||||
return filtered * 100;
|
||||
}
|
||||
|
||||
icm_result_t readICM() {
|
||||
|
|
@ -254,25 +200,34 @@ icm_result_t readICM() {
|
|||
};
|
||||
}
|
||||
|
||||
int readRawSlider(Slider id) {
|
||||
float a, b;
|
||||
int readRawControl(Control id) {
|
||||
int a;
|
||||
switch (id) {
|
||||
case SLIDER_PITCH_BEND:
|
||||
a = touchSensorUtil.filteredData(pbSliderPin1);
|
||||
b = touchSensorUtil.filteredData(pbSliderPin2);
|
||||
case CONTROL_PB:
|
||||
a = analogRead(pbXPin);
|
||||
break;
|
||||
case SLIDER_EXTRA:
|
||||
a = touchSensorRoller.filteredData(extraSliderPin1);
|
||||
b = touchSensorRoller.filteredData(extraSliderPin2);
|
||||
case CONTROL_PB_Y:
|
||||
a = analogRead(pbYPin);
|
||||
break;
|
||||
case SLIDER_LEVER:
|
||||
a = touchSensorUtil.filteredData(leverSliderPin1);
|
||||
b = touchSensorUtil.filteredData(leverSliderPin2);
|
||||
case CONTROL_EXTRA:
|
||||
a = readTouchRoller(extraPin);
|
||||
break;
|
||||
case CONTROL_BITE:
|
||||
a = analogRead(bitePin);
|
||||
break;
|
||||
case CONTROL_LEVER:
|
||||
a = analogRead(leverPin);
|
||||
break;
|
||||
case CONTROL_STICK_X:
|
||||
a = analogRead(stickXPin);
|
||||
break;
|
||||
case CONTROL_STICK_Y:
|
||||
a = analogRead(stickYPin);
|
||||
break;
|
||||
default:
|
||||
return 0.0;
|
||||
break;
|
||||
}
|
||||
|
||||
return (a + b) / 2;
|
||||
return a;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue