master_clock/include/globals.h

79 lines
2.5 KiB
C++

#ifndef GLOBALS_H
#define GLOBALS_H
#include "pico/stdlib.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 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;
// 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;
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"};
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