Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plumaudio #90

Merged
merged 27 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions software/o_c_REV/APP_ENVGEN.ino
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,11 @@ public:
CONSTRAIN(s[CV_MAPPING_EUCLIDEAN_FILL], 0, 32);
CONSTRAIN(s[CV_MAPPING_EUCLIDEAN_OFFSET], 0, 32);
CONSTRAIN(s[CV_MAPPING_DELAY_MSEC], 0, 65535);
#ifdef VOR
CONSTRAIN(s[CV_MAPPING_AMPLITUDE], 0, 62850);
#else
CONSTRAIN(s[CV_MAPPING_AMPLITUDE], 0, 65535);
#endif
CONSTRAIN(s[CV_MAPPING_MAX_LOOPS], 0, 65535);

EnvelopeType type = get_type();
Expand Down
2 changes: 2 additions & 0 deletions software/o_c_REV/APP_REFS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ const char* const error[] = {
SETTINGS_DECLARE(ReferenceChannel, REF_SETTING_LAST) {
#ifdef BUCHLA_4U
{ 0, 0, 9, "Octave", nullptr, settings::STORAGE_TYPE_I8 },
#elif defined(VOR)
{0, 0, 10, "Octave", nullptr, settings::STORAGE_TYPE_I8 },
#else
{ 0, -3, 6, "Octave", nullptr, settings::STORAGE_TYPE_I8 },
#endif
Expand Down
11 changes: 3 additions & 8 deletions software/o_c_REV/OC_DAC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void DAC::Init(CalibrationData *calibration_data) {
// set up DAC pins
OC::pinMode(DAC_CS, OUTPUT);

#ifndef OC_PLUS
#ifndef VOR
OC::pinMode(DAC_RST,OUTPUT);
#ifdef DAC8564 // A0 = 0, A1 = 0
digitalWrite(DAC_RST, LOW);
Expand All @@ -64,16 +64,11 @@ void DAC::Init(CalibrationData *calibration_data) {
#endif
#endif

#if defined(OC_PLUS) || defined(OC_1U)
#ifdef VOR
// set Vbias, using onboard DAC:
init_Vbias();
#ifdef OC_PLUS
set_Vbias(VBiasUnipolar);
#else
set_Vbias(VBiasAsymmetric);
#endif
delay(10);
#endif
#endif

history_tail_ = 0;
memset(history_, 0, sizeof(uint16_t) * kHistoryDepth * DAC_CHANNEL_LAST);
Expand Down
8 changes: 2 additions & 6 deletions software/o_c_REV/OC_DAC.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@ class DAC {

#ifdef BUCHLA_4U
static constexpr int kOctaveZero = 0;
#elif defined(OC_PLUS) || defined(OC_1U)
#ifdef OC_1U
static constexpr int kOctaveZero = 3; // todo: can't be a constant (eventually)
#else
#elif defined(VOR)
static constexpr int kOctaveZero = 0;
#endif
static constexpr int VBiasUnipolar = 3900; // onboard DAC @ Vref 1.2V (internal), 1.75x gain
static constexpr int VBiasBipolar = 2000; // onboard DAC @ Vref 1.2V (internal), 1.75x gain
static constexpr int VBiasAsymmetric = 2450; // onboard DAC @ Vref 1.2V (internal), 1.75x gain
static constexpr int VBiasAsymmetric = 2760; // onboard DAC @ Vref 1.2V (internal), 1.75x gain
#else
static constexpr int kOctaveZero = 3;
#endif
Expand Down
9 changes: 9 additions & 0 deletions software/o_c_REV/OC_apps.ino
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ void restore_app_data() {
}
restored_bytes += chunk->length;
data += chunk->length;

#ifdef VOR
VBiasManager *vbias_m = vbias_m->get();
vbias_m->SetStateForApp(apps::index_of(global_settings.current_app_id));
#endif
}

SERIAL_PRINTLN("App data restored: %u, expected %u", restored_bytes, app_settings.used);
Expand Down Expand Up @@ -407,6 +412,10 @@ void Ui::AppSettings() {
// Restore state
apps::current_app->HandleAppEvent(APP_EVENT_RESUME);
CORE::app_isr_enabled = true;
#ifdef VOR
VBiasManager *vbias_m = vbias_m->get();
vbias_m->SetStateForApp(apps::index_of(global_settings.current_app_id));
#endif
}

bool Ui::ConfirmReset() {
Expand Down
4 changes: 4 additions & 0 deletions software/o_c_REV/OC_autotuner.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const char* const AT_steps[] = {
const char* const AT_steps[] = {
"0.0V", "1.0V", "2.0V", "3.0V", "4.0V", "5.0V", "6.0V", "7.0V", "8.0V", "9.0V", " "
};
#elif defined(VOR)
const char* const AT_steps[] = {
"0.0V", "1.0V", "2.0V", "3.0V", "4.0V", "5.0V", "6.0V", "7.0V", "8.0V", "9.0V", "10.0V", " "
};
#else
const char* const AT_steps[] = {
"-3V", "-2V", "-1V", " 0V", "+1V", "+2V", "+3V", "+4V", "+5V", "+6V", " "
Expand Down
2 changes: 1 addition & 1 deletion software/o_c_REV/OC_calibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct CalibrationData {
uint32_t flags;
uint8_t screensaver_timeout; // 0: default, else seconds
uint8_t reserved0[3];
#ifdef OC_PLUS
#ifdef VOR
/* less complicated this way than adding it to DAC::CalibrationData... */
uint32_t v_bias;
#else
Expand Down
34 changes: 17 additions & 17 deletions software/o_c_REV/OC_calibration.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

using OC::DAC;

#if defined(BUCHLA_cOC) || defined(OC_PLUS)
#if defined(BUCHLA_cOC) || defined(VOR)
static constexpr uint16_t DAC_OFFSET = 0; // DAC offset, initial approx., ish (Easel card)
#else
static constexpr uint16_t DAC_OFFSET = 4890; // DAC offset, initial approx., ish --> -3.5V to 6V
Expand Down Expand Up @@ -38,11 +38,11 @@ const OC::CalibrationData kCalibrationDefaults = {
{197, 6634, 13083, 19517, 25966, 32417, 38850, 45301, 51733, 58180, 64400},
{197, 6634, 13083, 19517, 25966, 32417, 38850, 45301, 51733, 58180, 64400},
{197, 6634, 13083, 19517, 25966, 32417, 38850, 45301, 51733, 58180, 64400}
#elif defined(OC_PLUS)
{880, 7190, 13510, 19830, 27790, 32460, 38770, 45090, 51410, 57720, 64040},
{880, 7190, 13510, 19830, 27790, 32460, 38770, 45090, 51410, 57720, 64040},
{880, 7190, 13510, 19830, 27790, 32460, 38770, 45090, 51410, 57720, 64040},
{880, 7190, 13510, 19830, 27790, 32460, 38770, 45090, 51410, 57720, 64040}
#elif defined(VOR)
{880, 7190, 13510, 19830, 26300, 32460, 38770, 45090, 51410, 57720, 64040},
{880, 7190, 13510, 19830, 26300, 32460, 38770, 45090, 51410, 57720, 64040},
{880, 7190, 13510, 19830, 26300, 32460, 38770, 45090, 51410, 57720, 64040},
{880, 7190, 13510, 19830, 26300, 32460, 38770, 45090, 51410, 57720, 64040}
#else
{0, 6553, 13107, 19661, 26214, 32768, 39321, 45875, 52428, 58981, 65535},
{0, 6553, 13107, 19661, 26214, 32768, 39321, 45875, 52428, 58981, 65535},
Expand All @@ -61,7 +61,7 @@ const OC::CalibrationData kCalibrationDefaults = {
OC_CALIBRATION_DEFAULT_FLAGS,
SCREENSAVER_TIMEOUT_S,
{ 0, 0, 0 }, // reserved0
#ifdef OC_PLUS
#ifdef VOR
DAC::VBiasBipolar // default v_bias
#else
0 // reserved1
Expand Down Expand Up @@ -118,7 +118,7 @@ enum CALIBRATION_STEP {
HELLO,
CENTER_DISPLAY,

#ifdef OC_PLUS
#ifdef VOR
DAC_A_VOLT_3m, DAC_A_VOLT_2m, DAC_A_VOLT_1m, DAC_A_VOLT_0, DAC_A_VOLT_1, DAC_A_VOLT_2, DAC_A_VOLT_3, DAC_A_VOLT_4, DAC_A_VOLT_5, DAC_A_VOLT_6, DAC_A_VOLT_7,
DAC_B_VOLT_3m, DAC_B_VOLT_2m, DAC_B_VOLT_1m, DAC_B_VOLT_0, DAC_B_VOLT_1, DAC_B_VOLT_2, DAC_B_VOLT_3, DAC_B_VOLT_4, DAC_B_VOLT_5, DAC_B_VOLT_6, DAC_B_VOLT_7,
DAC_C_VOLT_3m, DAC_C_VOLT_2m, DAC_C_VOLT_1m, DAC_C_VOLT_0, DAC_C_VOLT_1, DAC_C_VOLT_2, DAC_C_VOLT_3, DAC_C_VOLT_4, DAC_C_VOLT_5, DAC_C_VOLT_6, DAC_C_VOLT_7,
Expand All @@ -142,7 +142,7 @@ enum CALIBRATION_STEP {
enum CALIBRATION_TYPE {
CALIBRATE_NONE,
CALIBRATE_OCTAVE,
#ifdef OC_PLUS
#ifdef VOR
CALIBRATE_VBIAS,
#endif
CALIBRATE_ADC_OFFSET,
Expand Down Expand Up @@ -244,7 +244,7 @@ const CalibrationStep calibration_steps[CALIBRATION_STEP_LAST] = {
{ DAC_D_VOLT_4, "DAC D 8.4 volts", "-> 8.400V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 7, nullptr, 0, DAC::MAX_VALUE },
{ DAC_D_VOLT_5, "DAC D 9.6 volts", "-> 9.600V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 8, nullptr, 0, DAC::MAX_VALUE },
{ DAC_D_VOLT_6, "DAC D 10.8 volts", "-> 10.800V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 9, nullptr, 0, DAC::MAX_VALUE },
#elif defined(IO_10V) && !defined(OC_PLUS)
#elif defined(IO_10V) && !defined(VOR)
{ DAC_A_VOLT_3m, "DAC A 0.0 volts", "-> 0.000V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 0, nullptr, 0, DAC::MAX_VALUE },
{ DAC_A_VOLT_2m, "DAC A 1.0 volts", "-> 1.000V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 1, nullptr, 0, DAC::MAX_VALUE },
{ DAC_A_VOLT_1m, "DAC A 2.0 volts", "-> 2.000V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 2, nullptr, 0, DAC::MAX_VALUE },
Expand Down Expand Up @@ -288,7 +288,7 @@ const CalibrationStep calibration_steps[CALIBRATION_STEP_LAST] = {
{ DAC_D_VOLT_4, "DAC D 7.0 volts", "-> 7.000V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 7, nullptr, 0, DAC::MAX_VALUE },
{ DAC_D_VOLT_5, "DAC D 8.0 volts", "-> 8.000V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 8, nullptr, 0, DAC::MAX_VALUE },
{ DAC_D_VOLT_6, "DAC D 9.0 volts", "-> 9.000V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 9, nullptr, 0, DAC::MAX_VALUE },
#elif defined(OC_PLUS)
#elif defined(VOR)
{ DAC_A_VOLT_3m, "DAC A 0.0 volts", "-> 0.000V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 0, nullptr, 0, DAC::MAX_VALUE },
{ DAC_A_VOLT_2m, "DAC A 1.0 volts", "-> 1.000V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 1, nullptr, 0, DAC::MAX_VALUE },
{ DAC_A_VOLT_1m, "DAC A 2.0 volts", "-> 2.000V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 2, nullptr, 0, DAC::MAX_VALUE },
Expand Down Expand Up @@ -382,7 +382,7 @@ const CalibrationStep calibration_steps[CALIBRATION_STEP_LAST] = {
{ DAC_D_VOLT_6, "DAC D 6 volts", "-> 6.000V ", default_help_r, default_footer, CALIBRATE_OCTAVE, 6, nullptr, 0, DAC::MAX_VALUE },
#endif

#ifdef OC_PLUS
#ifdef VOR
{ V_BIAS, "0.000V: bipolar", "--> 0.000V", default_help_r, default_footer, CALIBRATE_VBIAS, 0, nullptr, 0, 4095 },
#endif

Expand Down Expand Up @@ -516,7 +516,7 @@ void OC::Ui::Calibrate() {
OC::calibration_data.dac.calibrated_octaves[step_to_channel(next_step->step)][next_step->index + DAC::kOctaveZero];
break;

#ifdef OC_PLUS
#ifdef VOR
case CALIBRATE_VBIAS:
calibration_state.encoder_value = OC::calibration_data.v_bias;
break;
Expand Down Expand Up @@ -583,7 +583,7 @@ void calibration_draw(const CalibrationState &state) {
switch (step->calibration_type) {
case CALIBRATE_OCTAVE:
case CALIBRATE_SCREENSAVER:
#ifdef OC_PLUS
#ifdef VOR
case CALIBRATE_VBIAS:
#endif
graphics.print(step->message);
Expand Down Expand Up @@ -678,12 +678,12 @@ void calibration_update(CalibrationState &state) {
OC::calibration_data.dac.calibrated_octaves[step_to_channel(step->step)][step->index + DAC::kOctaveZero] =
state.encoder_value;
DAC::set_all_octave(step->index);
#ifdef OC_PLUS
#ifdef VOR
/* set 0V @ unipolar range */
DAC::set_Vbias(DAC::VBiasUnipolar);
#endif
break;
#ifdef OC_PLUS
#ifdef VOR
case CALIBRATE_VBIAS:
/* set 0V @ bipolar range */
DAC::set_all_octave(5);
Expand All @@ -694,7 +694,7 @@ void calibration_update(CalibrationState &state) {
case CALIBRATE_ADC_OFFSET:
OC::calibration_data.adc.offset[step->index] = state.encoder_value;
DAC::set_all_octave(0);
#ifdef OC_PLUS
#ifdef VOR
/* set 0V @ unipolar range */
DAC::set_Vbias(DAC::VBiasUnipolar);
#endif
Expand Down
2 changes: 1 addition & 1 deletion software/o_c_REV/OC_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

#define DAC_CS 10

#ifdef OC_PLUS
#ifdef VOR
#define but_mid 9
#else
#define DAC_RST 9
Expand Down
31 changes: 16 additions & 15 deletions software/o_c_REV/OC_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@
#ifndef OC_OPTIONS_H_
#define OC_OPTIONS_H_

/* ------------ uncomment for Buchla/non-octaval/quartertone support: ------------------------------- */
/* ------------ uncomment for use with Plum Audio VOR anabled versions (OCP, 1uO_c v2, 4Robots) --------------------------------------------------------- */
#define VOR
/* ------------ uncomment for use with Plum Audio 1uO_c 4Robots (To use Up button long press to change VOR instead activate screensaver) ---------------- */
//#define VOR_NO_RANGE_BUTTON

/* ------------ uncomment for Buchla/non-octaval/quartertone support: ----------------------------------------------------------------------------------- */
//#define BUCHLA_SUPPORT
/* ------------ uncomment for use with Northernlight cOC program card: ------------------------------ */
/* ------------ uncomment for use with Northernlight cOC program card: ---------------------------------------------------------------------------------- */
//#define BUCHLA_cOC
/* ------------ uncomment for use with Northernlight 4U / cOC : ------------------------------------- */
/* ------------ uncomment for use with Northernlight 4U / cOC : ----------------------------------------------------------------------------------------- */
//#define BUCHLA_4U
/* ------------ uncomment for use with Plum Audio OC+ ----------------------------------------------- */
//#define OC_PLUS
/* ------------ uncomment for use with Plum Audio 1U ------------------------------------------------ */
#define OC_1U
/* ------------ uncomment for boring app names ------------------------------------------------------ */
//#define BORING_APP_NAMES
/* ------------ print debug messages to USB serial -------------------------------------------------- */
/* ------------ uncomment for boring app names ---------------------------------------------------------------------------------------------------------- */
#define BORING_APP_NAMES
/* ------------ print debug messages to USB serial ------------------------------------------------------------------------------------------------------ */
//#define PRINT_DEBUG
/* ------------ flip screen / IO mapping ------------------------------------------------------------ */
/* ------------ flip screen / IO mapping ---------------------------------------------------------------------------------------------------------------- */
//#define FLIP_180
/* ------------ invert screen pixels ---------------------------------------------------------------- */
/* ------------ invert screen pixels -------------------------------------------------------------------------------------------------------------------- */
//#define INVERT_DISPLAY
/* ------------ use DAC8564 ------------------------------------------------------------------------- */
/* ------------ use DAC8564 ----------------------------------------------------------------------------------------------------------------------------- */
//#define DAC8564
/* ------------ 0 / 10V range ----------------------------------------------------------------------- */
/* ------------ 0 / 10V range --------------------------------------------------------------------------------------------------------------------------- */
//#define IO_10V


Expand All @@ -37,7 +38,7 @@
#define BUCHLA_4U
#endif

#if defined(OC_PLUS)
#if defined(VOR)
#define IO_10V
#endif

Expand Down
2 changes: 2 additions & 0 deletions software/o_c_REV/OC_strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace OC {

const char * const note_names_unpadded[12] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };

const char * const VOR_offsets[3] = { "-5V", "-3V", "0V"};

const char * const trigger_input_names[4] = { "TR1", "TR2", "TR3", "TR4" };

const char * const trigger_input_names_none[5] = { " - ", "TR1", "TR2", "TR3", "TR4" };
Expand Down
1 change: 1 addition & 0 deletions software/o_c_REV/OC_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace OC {
extern const char * const channel_id[];
extern const char * const note_names[];
extern const char * const note_names_unpadded[];
extern const char * const VOR_offsets[];
extern const char * const trigger_input_names[];
extern const char * const trigger_input_names_none[];
extern const char * const cv_input_names[];
Expand Down
44 changes: 23 additions & 21 deletions software/o_c_REV/OC_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "OC_version.h"
#include "OC_options.h"
#include "src/drivers/display.h"
#include "VBiasManager.h"
VBiasManager *VBiasManager::instance = 0;

extern uint_fast8_t MENU_REDRAW;

Expand All @@ -24,9 +26,8 @@ void Ui::Init() {
ticks_ = 0;
set_screensaver_timeout(SCREENSAVER_TIMEOUT_S);

#ifdef OC_PLUS
#ifdef VOR
static const int button_pins[] = { but_top, but_bot, butL, butR, but_mid };
v_bias_ = false;
#else
static const int button_pins[] = { but_top, but_bot, butL, butR };
#endif
Expand Down Expand Up @@ -117,30 +118,31 @@ UiMode Ui::DispatchEvents(App *app) {

switch (event.type) {
case UI::EVENT_BUTTON_PRESS:
#ifdef OC_PLUS
{
if (OC::CONTROL_BUTTON_M == event.control) {
/* handled here for the time being, could also be on an per-app basis; or whatever the revised framework will look like/allow .. */
if (v_bias_) {
DAC::set_Vbias(DAC::VBiasUnipolar);
v_bias_ = false;
}
else {
DAC::set_Vbias(OC::calibration_data.v_bias);
v_bias_ = true;
}
}
else
app->HandleButtonEvent(event);
}
#ifdef VOR
#ifdef VOR_NO_RANGE_BUTTON
if (OC::CONTROL_BUTTON_UP == event.control) {
VBiasManager *vbias_m = vbias_m->get();
if (vbias_m->IsEditing()) vbias_m->AdvanceBias();
else app->HandleButtonEvent(event);
} else app->HandleButtonEvent(event);
#else
if (OC::CONTROL_BUTTON_M == event.control) {
VBiasManager *vbias_m = vbias_m->get();
vbias_m->AdvanceBias();
} else app->HandleButtonEvent(event);
#endif
#else
app->HandleButtonEvent(event);
#endif
break;
case UI::EVENT_BUTTON_LONG_PRESS:
if (OC::CONTROL_BUTTON_UP == event.control) {
if (!preempt_screensaver_)
screensaver_ = true;
#ifdef VOR_NO_RANGE_BUTTON
VBiasManager *vbias_m = vbias_m->get();
vbias_m->AdvanceBias();
#else
if (!preempt_screensaver_) screensaver_ = true;
#endif
}
else if (OC::CONTROL_BUTTON_R == event.control)
return UI_MODE_APP_SETTINGS;
Expand Down Expand Up @@ -193,7 +195,7 @@ UiMode Ui::Splashscreen(bool &reset_settings) {
menu::DefaultTitleBar::Draw();
#ifdef BUCHLA_cOC
graphics.print("NLM card O_C");
#elif defined(OC_PLUS)
#elif defined(VOR)
graphics.print("Plum Audio O_C+");
#else
graphics.print("Ornaments & Crimes");
Expand Down
Loading