100 lines
3 KiB
C++
100 lines
3 KiB
C++
#ifndef GLOBALS_H
|
|
#define GLOBALS_H
|
|
|
|
#include "pico/stdlib.h"
|
|
#include "Mod.h"
|
|
#include <cstdint>
|
|
#include <array>
|
|
#include <string>
|
|
|
|
|
|
// PINS
|
|
static constexpr uint8_t OUT_1_PIN = 0;
|
|
static constexpr uint8_t OUT_2_PIN = 2;
|
|
static constexpr uint8_t OUT_3_PIN = 4;
|
|
static constexpr uint8_t OUT_4_PIN = 6;
|
|
static constexpr uint8_t OUT_5_PIN = 8;
|
|
static constexpr uint8_t OUT_6_PIN = 10;
|
|
static constexpr uint8_t OUT_7_PIN = 12;
|
|
static constexpr uint8_t OUT_8_PIN = 14;
|
|
|
|
static constexpr uint8_t IN_RUN_PIN = 17;
|
|
|
|
static constexpr uint8_t SCREEN_SCL_PIN = 18;
|
|
static constexpr uint8_t SCREEN_SDA_PIN = 19;
|
|
|
|
// Modify moves per detent if your encoder is acting weird
|
|
// for me, with 20 detents per full rotation, 4 works
|
|
static constexpr uint8_t TICKS_PER_DETENT = 4;
|
|
static constexpr uint8_t ENCODER_CLK_PIN = 20;
|
|
static constexpr uint8_t ENCODER_DT_PIN = 21;
|
|
static constexpr uint8_t ENCODER_SW_PIN = 22;
|
|
|
|
void gpio_callback(uint gpio, uint32_t events);
|
|
|
|
// TIME BASED
|
|
extern volatile bool PLAY;
|
|
extern volatile uint8_t BPM;
|
|
static constexpr uint32_t MINUTE_US = 60000000;
|
|
static constexpr uint8_t PPQN = 96;
|
|
extern volatile uint32_t MASTER_TICK;
|
|
|
|
extern volatile bool RUN;
|
|
|
|
extern volatile uint8_t EXTPPQNIdx;
|
|
#define PPQN_OPTS_LEN 5
|
|
extern const uint16_t PPQNOPTS[PPQN_OPTS_LEN];
|
|
|
|
enum WaveShape { SQUARE, TRIANGLE, SAW, RAMP, EXP, HALFSINE, REXP, LOG, SINE, BOUNCE, SIGMO, WOBBLE, STEPDW, STEPUP, SH, SHAPE_COUNT};
|
|
|
|
inline const char* waveShapeToString(WaveShape shape) {
|
|
switch (shape) {
|
|
case SQUARE: return "SQR";
|
|
case SINE: return "SINE";
|
|
case TRIANGLE: return "TRI";
|
|
case SAW: return "SAW";
|
|
case EXP: return "EXP";
|
|
case REXP: return "REXP";
|
|
case RAMP: return "RAMP";
|
|
case LOG: return "LOG";
|
|
case BOUNCE: return "BNC";
|
|
case WOBBLE: return "WOB";
|
|
case SIGMO: return "SIG";
|
|
case STEPDW: return "STPD";
|
|
case STEPUP: return "STPU";
|
|
case SH: return "S&H";
|
|
case HALFSINE: return "HUMP";
|
|
default: return "?";
|
|
}
|
|
}
|
|
|
|
// Modifiers in UI order
|
|
static std::array<uint8_t, 17> MODIFIERS = {32, 16, 12, 8, 6, 4, 3, 2, 0, 1, 2, 3, 4, 6, 8, 16, 32};
|
|
// Modifier type; 0 = multiplicaton, 1 = division; matched with MODIFIERS
|
|
static std::array<uint8_t, 17> MOD_TYPES = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1};
|
|
// Modifier string
|
|
static std::array<std::string, 17> MODIFIER_STRINGS = {"x32", "x16", "x12", "x8", "x6", "x4", "x3", "x2", "x0", "/1", "/2", "/3", "/4", "/6", "/8", "/16", "/32"};
|
|
|
|
|
|
extern ModMatrix matrix;
|
|
|
|
inline const char* modDestToString(ModDest modType) {
|
|
switch (modType) {
|
|
case DEST_LEVEL: return "LVL";
|
|
case DEST_PROBABILITY: return "PROB";
|
|
case DEST_WIDTH: return "WIDTH";
|
|
default: return "?";
|
|
}
|
|
}
|
|
|
|
inline uint32_t millis() {
|
|
return to_ms_since_boot(get_absolute_time());
|
|
}
|
|
|
|
|
|
inline uint32_t micros() {
|
|
return to_us_since_boot(get_absolute_time());
|
|
}
|
|
|
|
|
|
#endif // GLOBALS_H
|