uilleann/pipe.h

60 lines
1.5 KiB
C
Raw Normal View History

2020-11-11 20:20:21 -07:00
#pragma once
#include <stdint.h>
#include <SparkFun_Qwiic_Button.h>
#include <Adafruit_MPR121.h>
#include <paj7620.h>
2020-11-24 16:56:58 -07:00
#include "tuning.h"
2020-11-11 20:20:21 -07:00
class Pipe {
2020-11-22 17:21:47 -07:00
public:
// kneeClosedness indicates how "closed" the knee sensor is. 0 = wide open.
uint8_t kneeClosedness;
2020-11-11 20:20:21 -07:00
2020-11-22 17:21:47 -07:00
// keys are which keys are being pressed.
uint8_t keys;
2020-11-24 16:56:58 -07:00
uint8_t keysLast;
2020-11-11 20:20:21 -07:00
2020-11-22 17:21:47 -07:00
// note holds the note being played, according to the fingering chart.
2020-11-24 16:56:58 -07:00
Note note;
// glissandoNote is the note that would be played if partially open keys were fully open.
Note glissandoNote;
// glissandoOpenness is how "open" the holes are in the direction of the glissandoNote.
float glissandoOpenness;
2020-11-11 20:20:21 -07:00
2020-11-22 17:21:47 -07:00
// silent is true if all keys and the knee are closed.
bool silent;
2020-11-11 20:20:21 -07:00
2020-11-22 17:21:47 -07:00
// bag is true if the bag is being squished.
bool bag;
2020-11-11 20:20:21 -07:00
2020-11-22 17:21:47 -07:00
// altFingering is true if the "alternate fingering" is being played.
// This should sound different than the standard fingering.
bool altFingering;
2020-11-11 20:20:21 -07:00
2020-11-22 17:21:47 -07:00
Pipe();
2020-11-11 20:20:21 -07:00
2020-11-22 17:21:47 -07:00
// Init initializes everything.
//
// Returns true if it all worked. You can run it again if it didn't.
bool Init();
2020-11-11 20:20:21 -07:00
2020-11-22 17:21:47 -07:00
// Update reads sensors and updates pipe state.
//
// It should be run once per loop.
void Update();
2020-11-11 20:20:21 -07:00
2020-11-24 16:56:58 -07:00
// Pressed returns whether the given key is pressed.
bool Pressed(uint8_t key);
// JustPressed returns whether the given key was just pressed.
bool JustPressed(uint8_t key);
2020-11-22 17:21:47 -07:00
private:
Adafruit_MPR121 capSensor;
QwiicButton bagSensor;
bool bag_enabled;
2020-11-11 20:20:21 -07:00
};