Skip to content

Commit

Permalink
[OC] version
Browse files Browse the repository at this point in the history
136
  • Loading branch information
mxmxmx authored Oct 7, 2019
2 parents c01588d + 9b6eb89 commit 22bbb33
Show file tree
Hide file tree
Showing 21 changed files with 430 additions and 86 deletions.
33 changes: 21 additions & 12 deletions software/o_c_REV/APP_DQ.ino
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public:

for (int i = 0; i < NUM_SCALE_SLOTS; i++) {
last_scale_[i] = -1;
last_mask_[i] = 0;
last_mask_[i] = 0xFFFF;
}

aux_sample_ = 0;
Expand Down Expand Up @@ -434,20 +434,22 @@ public:
update_asr_ = true;
aux_sample_ = ON;
}


if (scale_reset_) {
// manual change?
scale_reset_ = false;
scale_sequence_cnt_ = 0x0;
scale_advance_state_ = 0x1;
active_scale_slot_ = get_scale_select();
prev_scale_slot_ = display_scale_slot_ = active_scale_slot_;
}

if (get_scale_seq_mode()) {
// to do, don't hardcode ..
uint8_t _advance_trig = (dac_channel == DAC_CHANNEL_A) ? digitalReadFast(TR2) : digitalReadFast(TR4);
if (_advance_trig < scale_advance_state_)
scale_advance_ = true;
scale_advance_state_ = _advance_trig;

if (scale_reset_) {
// manual change?
scale_reset_ = false;
active_scale_slot_ = get_scale_select();
prev_scale_slot_ = display_scale_slot_ = active_scale_slot_;
}
}
else if (prev_scale_slot_ != get_scale_select()) {
active_scale_slot_ = get_scale_select();
Expand Down Expand Up @@ -504,6 +506,7 @@ public:
// if scale changes, we have to update the root and transpose values, too; mask gets updated in update_scale
root = get_root(display_scale_slot_);
transpose = get_transpose(display_scale_slot_);
schedule_scale_update_ = true;
break;
case DQ_DEST_ROOT:
root += (OC::ADC::value(static_cast<ADC_CHANNEL>(channel_id)) + 127) >> 8;
Expand All @@ -519,7 +522,12 @@ public:
break;
default:
break;
} // end switch
} // end switch

if (schedule_scale_update_) {
force_update_ = true;
schedule_scale_update_ = false;
}
} // -> triggered update

// constrain values:
Expand Down Expand Up @@ -658,7 +666,7 @@ public:

// update scale?
if (schedule_scale_update_ && _continuous_update) {
update_scale(false, display_scale_slot_, schedule_mask_rotate_);
update_scale(true, display_scale_slot_, schedule_mask_rotate_);
schedule_scale_update_ = false;
}

Expand Down Expand Up @@ -1046,7 +1054,7 @@ private:
force_update_ = false;
const int scale = get_scale(scale_select);
uint16_t mask = get_mask(scale_select);

if (mask_rotate)
mask = OC::ScaleEditor<DQ_QuantizerChannel>::RotateMask(mask, OC::Scales::GetScale(scale).num_notes, mask_rotate);

Expand Down Expand Up @@ -1389,6 +1397,7 @@ void DQ_handleEncoderEvent(const UI::Event &event) {
dq_state.cursor.AdjustEnd(selected.num_enabled_settings() - 1);
break;
case DQ_CHANNEL_SETTING_SCALE_SEQ:
case DQ_CHANNEL_SETTING_SEQ_MODE:
selected.update_enabled_settings();
dq_state.cursor.AdjustEnd(selected.num_enabled_settings() - 1);
selected.reset_scale();
Expand Down
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
4 changes: 2 additions & 2 deletions software/o_c_REV/APP_QQ.ino
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,8 @@ public:
*settings++ = CHANNEL_SETTING_TURING_RANGE;
*settings++ = CHANNEL_SETTING_TURING_PROB;
if (OC::Scales::SCALE_NONE != get_scale(DUMMY))
*settings++ = CHANNEL_SETTING_TURING_RANGE_CV_SOURCE;
*settings++ = CHANNEL_SETTING_TURING_MODULUS_CV_SOURCE;
*settings++ = CHANNEL_SETTING_TURING_RANGE_CV_SOURCE;
*settings++ = CHANNEL_SETTING_TURING_PROB_CV_SOURCE;
break;
case CHANNEL_SOURCE_LOGISTIC_MAP:
Expand Down Expand Up @@ -1565,4 +1566,3 @@ void QQ_debug() {
}
}
#endif // QQ_DEBUG

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
22 changes: 21 additions & 1 deletion software/o_c_REV/OC_DAC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,21 @@ void DAC::Init(CalibrationData *calibration_data) {

// set up DAC pins
OC::pinMode(DAC_CS, OUTPUT);
OC::pinMode(DAC_RST,OUTPUT);

#ifndef VOR
OC::pinMode(DAC_RST,OUTPUT);
#ifdef DAC8564 // A0 = 0, A1 = 0
digitalWrite(DAC_RST, LOW);
#else // default to DAC8565 - pull RST high
digitalWrite(DAC_RST, HIGH);
#endif
#endif

#ifdef VOR
// set Vbias, using onboard DAC:
init_Vbias();
delay(10);
#endif

history_tail_ = 0;
memset(history_, 0, sizeof(uint16_t) * kHistoryDepth * DAC_CHANNEL_LAST);
Expand Down Expand Up @@ -185,6 +193,7 @@ void DAC::restore_scaling(uint32_t scaling) {
set_scaling(_scaling, i);
}
}
/*static*/
uint32_t DAC::store_scaling() {

uint32_t _scaling = 0;
Expand All @@ -193,6 +202,17 @@ uint32_t DAC::store_scaling() {
_scaling |= (DAC_scaling[i] << (i * 8));
return _scaling;
}
/*static*/
void DAC::init_Vbias() {
/* using MK20 DAC0 for Vbias*/
VREF_TRM = 0x60; VREF_SC = 0xE1; // enable 1v2 reference
SIM_SCGC2 |= SIM_SCGC2_DAC0; // DAC clock
DAC0_C0 = DAC_C0_DACEN; // enable module + use internal 1v2 reference
}
/*static*/
void DAC::set_Vbias(uint32_t data) {
*(volatile int16_t *)&(DAC0_DAT0L) = data;
}
/*static*/
DAC::CalibrationData *DAC::calibration_data_ = nullptr;
/*static*/
Expand Down
7 changes: 7 additions & 0 deletions software/o_c_REV/OC_DAC.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class DAC {

#ifdef BUCHLA_4U
static constexpr int kOctaveZero = 0;
#elif defined(VOR)
static constexpr int kOctaveZero = 0;
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 = 2760; // onboard DAC @ Vref 1.2V (internal), 1.75x gain
#else
static constexpr int kOctaveZero = 3;
#endif
Expand All @@ -62,6 +67,8 @@ class DAC {
static void restore_scaling(uint32_t scaling);
static uint8_t get_voltage_scaling(uint8_t channel_id);
static uint32_t store_scaling();
static void set_Vbias(uint32_t data);
static void init_Vbias();

static void set_all(uint32_t value) {
for (int i = DAC_CHANNEL_A; i < DAC_CHANNEL_LAST; ++i)
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
10 changes: 8 additions & 2 deletions software/o_c_REV/OC_calibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#define OC_CALIBRATION_H_

#include "OC_ADC.h"
#include "OC_config.h"
#include "OC_DAC.h"
#include "OC_config.h"
#include "OC_options.h"
#include "util/util_pagestorage.h"
#include "util/EEPROMStorage.h"

Expand Down Expand Up @@ -44,7 +45,12 @@ struct CalibrationData {
uint32_t flags;
uint8_t screensaver_timeout; // 0: default, else seconds
uint8_t reserved0[3];
uint32_t reserved1;
#ifdef VOR
/* less complicated this way than adding it to DAC::CalibrationData... */
uint32_t v_bias; // upper 2 bytes: asymmetric; lower 2 bytes: bipolar.
#else
uint32_t reserved1;
#endif

EncoderConfig encoder_config() const {
return static_cast<EncoderConfig>(flags & CALIBRATION_FLAG_ENCODER_MASK);
Expand Down
Loading

0 comments on commit 22bbb33

Please sign in to comment.