xevi/NuEVI/src/hardware.h
Brian Hrebec b401b34bb4 Changes to accomodate new sensors
PB control -> 2d stick
Extra -> cap lip sensor
Bite -> force sensitive resistor
Lever -> pot
2d Stick added
2024-10-19 20:39:01 -05:00

122 lines
2.4 KiB
C

#ifndef __HARDWARE_H
#define __HARDWARE_H
#include <Adafruit_MPR121.h>
#include <Adafruit_MPRLS.h>
#include <Adafruit_ICM20X.h>
#include <WS2812Serial.h>
#include <Adafruit_ICM20948.h>
#include <stdint.h>
#include "settings.h"
// Hardware sensor definitions
// TODO: remove these
extern WS2812Serial ledStrip;
extern Adafruit_Sensor *accelSensor;
extern Adafruit_ICM20948 icmSensor;
struct icm_result_t {
float tilt;
float roll;
};
enum Control : uint8_t {
CONTROL_PB = 0,
CONTROL_PB_Y = 1,
CONTROL_EXTRA = 2,
CONTROL_LEVER = 3,
CONTROL_STICK_X = 4,
CONTROL_STICK_Y = 5,
CONTROL_BITE = 6,
};
void initHardware();
void updateFilters(preset_t &preset);
bool checkButtonState(uint8_t mask); // return true if the given buttons are pressed
uint8_t buttonState(); // return true if the given buttons are pressed
int readKnob(uint8_t n);
int readTouchKey(uint8_t n);
int readTouchRoller(uint8_t n);
int readRawControl(Control id);
int16_t readControl(Control id, int thr);
uint16_t keysTouched();
int readPressure();
int readAltPressure();
int readSpikePressure();
icm_result_t readICM();
// xEVI hardware setup
// I2C
#define MainI2CBus Wire
#define AuxI2CBus Wire1
#define KeysI2CAddr 0x5A
#define RollerI2CAddr 0x5B
#define UtilI2CAddr 0x5C
// Digital pins for encoder buttons
#define b1Pin 4
#define b2Pin 3
#define b3Pin 2
#define b4Pin 0
// Digital pins for encoder quadrature
#define e1aPin 8
#define e2aPin 7
#define e3aPin 6
#define e4aPin 5
#define e1bPin 12
#define e2bPin 11
#define e3bPin 10
#define e4bPin 9
// CV pins
#define cvGatePin 9
#define cvPitchPin 10
#define cvBreathPin 11
#define cvBitePin 12
//Output pins for LEDs
#define statusLedPin 13
#define ledStripPin 1
#define numLeds 8
// Key pins
// RH keys
#define K1Pin 1
#define K2Pin 7
#define K3Pin 3
#define K4Pin 10
#define K5Pin 2
#define K6Pin 6
#define K7Pin 4
#define K8Pin 11
// LH keys
#define K9Pin 0
#define K10Pin 5
#define K11Pin 8
#define K12Pin 9
// Octave roller pins
#define R1Pin 6
#define R2Pin 7
#define R3Pin 8
#define R4Pin 9
#define R5Pin 10
#define R6Pin 11
// Control pins
#define extraPin 0
#define bitePin A6
#define pbXPin A8
#define pbYPin A9
#define pbBPin 21
#define stickXPin A10
#define stickYPin A11
#define leverPin A1
#define stickBPin 14
#endif