Skip to content

Commit

Permalink
Merge pull request #36 from mxmxmx/v.1_2_3b
Browse files Browse the repository at this point in the history
V.1 2 3b
  • Loading branch information
mxmxmx authored Mar 7, 2018
2 parents 181cf80 + 6c068bd commit 36032d1
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 49 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# System temporary files
.DS_Store
*~
50 changes: 37 additions & 13 deletions soft/t_u_REV/APP_CLK.ino
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ public:
write_pattern_->notes[step] = pitch;

if (get_cv_playmode() == _ARP) // to do
cv_pattern_changed(get_cv_mask(),true);
cv_pattern_changed(get_cv_mask(), true);
}

int16_t dac_correction() const {
Expand Down Expand Up @@ -792,6 +792,12 @@ public:
display_mask_ = mask;
}

void init_pattern(uint16_t mask) {
force_update_ = true;
display_mask_ = mask;
arpeggiator_.UpdateArpeggiator(0x0, get_cv_mask(), get_cv_sequence_length());
}

uint8_t get_gpio_state() const {
return gpio_state_;
}
Expand All @@ -809,11 +815,12 @@ public:
// rotate already
mask_rotate_ = (TU::ADC::value(static_cast<ADC_CHANNEL>(mask_rotate_ - 1)) + 127) >> 8;

if (force || (prev_mask_rotate_ != mask_rotate_)) {
if (force || (prev_mask_rotate_ != mask_rotate_) || (prev_cv_playmode_ != get_cv_playmode()) ) {
cv_display_mask_ = TU::PatternEditor<Clock_channel>::RotateMask(get_cv_mask(), get_cv_sequence_length(), mask_rotate_);
arpeggiator_.UpdateArpeggiator(0x0, cv_display_mask_, get_cv_sequence_length());
}
prev_mask_rotate_ = mask_rotate_;
prev_cv_playmode_ = get_cv_playmode();
}
}

Expand Down Expand Up @@ -943,6 +950,7 @@ public:
pending_reset_ = 0;
logic_ = false;
prev_mask_rotate_ = 0xFF;
prev_cv_playmode_ = get_cv_playmode();
menu_page_ = PARAMETERS;
dac_overflow_ = 0xFFF;

Expand Down Expand Up @@ -1932,11 +1940,11 @@ public:

if (menu_page_ == CV_SOURCES) {

if (mode != DAC)
*settings++ = CHANNEL_SETTING_PULSEWIDTH_CV_SOURCE;

*settings++ = CHANNEL_SETTING_MULT_CV_SOURCE;
*settings++ = CHANNEL_SETTING_SWING_CV_SOURCE;

if (mode != DAC)
*settings++ = CHANNEL_SETTING_PULSEWIDTH_CV_SOURCE;

switch (mode) {

Expand Down Expand Up @@ -2018,11 +2026,11 @@ public:

else if (menu_page_ == PARAMETERS) {

if (mode != DAC)
*settings++ = CHANNEL_SETTING_PULSEWIDTH;

*settings++ = CHANNEL_SETTING_MULT;
*settings++ = CHANNEL_SETTING_SWING;

if (mode != DAC)
*settings++ = CHANNEL_SETTING_PULSEWIDTH;

switch (mode) {

Expand Down Expand Up @@ -2178,6 +2186,7 @@ private:
uint8_t menu_page_;
uint16_t bpm_last_;
int16_t prev_mask_rotate_;
int8_t prev_cv_playmode_;
int16_t dac_overflow_;

util::TuringShiftRegister turing_machine_;
Expand Down Expand Up @@ -2244,7 +2253,11 @@ SETTINGS_DECLARE(Clock_channel, CHANNEL_SETTING_LAST) {
#ifdef MOD_OFFSET
{ 0, -1, 5, "DAC: offset", NULL, settings::STORAGE_TYPE_I8 },
#else
{ 0, -3, 3, "DAC: offset", NULL, settings::STORAGE_TYPE_I8 },
#ifdef MODEL_2TT
{ 0, 0, 6, "DAC: offset", NULL, settings::STORAGE_TYPE_I8 },
#else
{ 0, -3, 3, "DAC: offset", NULL, settings::STORAGE_TYPE_I8 },
#endif
#endif
{ 0, 0, _DAC_MODES_LAST - 1, "DAC: mode", TU::Strings::dac_modes, settings::STORAGE_TYPE_U4 },
{ 0, 0, 1, "track -->", TU::Strings::binary_tracking, settings::STORAGE_TYPE_U4 },
Expand All @@ -2253,7 +2266,7 @@ SETTINGS_DECLARE(Clock_channel, CHANNEL_SETTING_LAST) {
{ LFSR_MIN << 1, LFSR_MIN, LFSR_MAX, "LFSR length", NULL, settings::STORAGE_TYPE_U8 },
{ 128, 0, 255, "LFSR p(x)", NULL, settings::STORAGE_TYPE_U8 },
{ 1, 1, 255, "LGST(R)", NULL, settings::STORAGE_TYPE_U8 },
{ 0, 0, 4, "arp.range", NULL, settings::STORAGE_TYPE_U4 },
{ 1, 0, 4, "arp.range", NULL, settings::STORAGE_TYPE_U4 },
{ 0, 0, 3, "arp.direction", arp_directions, settings::STORAGE_TYPE_U4 },
{ 65535, 0, 65535, "--> edit", NULL, settings::STORAGE_TYPE_U16 }, // seq 1
{ 65535, 0, 65535, "--> edit", NULL, settings::STORAGE_TYPE_U16 }, // seq 2
Expand Down Expand Up @@ -2336,6 +2349,7 @@ Clock_channel clock_channel[NUM_CHANNELS];
void CLOCKS_init() {

TU::Patterns::Init();
TU::Patterns::Fill();

ext_frequency[CHANNEL_TRIGGER_TR1] = 0xFFFFFFFF;
ext_frequency[CHANNEL_TRIGGER_TR2] = 0xFFFFFFFF;
Expand Down Expand Up @@ -2371,7 +2385,7 @@ size_t CLOCKS_restore(const void *storage) {
clock_channel[i].update_enabled_settings(i);
// update display sequence + mask:
clock_channel[i].set_display_sequence(clock_channel[i].get_sequence());
clock_channel[i].pattern_changed(clock_channel[i].get_mask(clock_channel[i].get_sequence()), true);
clock_channel[i].init_pattern(clock_channel[i].get_mask(clock_channel[i].get_sequence()));
clock_channel[i].reset_channel_frequency();
}
clocks_state.cursor.AdjustEnd(clock_channel[0].num_enabled_settings() - 1);
Expand Down Expand Up @@ -2666,10 +2680,15 @@ void CLOCKS_handleEncoderEvent(const UI::Event &event) {
case CHANNEL_SETTING_MODE:
case CHANNEL_SETTING_MODE4:
case CHANNEL_SETTING_DAC_MODE:
case CHANNEL_SETTING_CV_SEQUENCE_PLAYMODE:
selected.update_enabled_settings(clocks_state.selected_channel);
clocks_state.cursor.AdjustEnd(selected.num_enabled_settings() - 1);
break;
case CHANNEL_SETTING_CV_SEQUENCE_PLAYMODE:
// update ARP if need be
selected.update_enabled_settings(clocks_state.selected_channel);
clocks_state.cursor.AdjustEnd(selected.num_enabled_settings() - 1);
selected.cv_pattern_changed(selected.get_cv_mask(), false);
break;
// special cases:
case CHANNEL_SETTING_EUCLID_N:
case CHANNEL_SETTING_EUCLID_K:
Expand Down Expand Up @@ -2732,8 +2751,13 @@ void CLOCKS_upButton() {
switch (_menu_page) {

case TEMPO:
selected.set_page(PARAMETERS);
{
clocks_state.cursor = clocks_state.cursor_state;
// disallow case where things would end up in editor:
if (selected.enabled_setting_at(clocks_state.cursor_pos()) == CHANNEL_SETTING_SEQ_MASK_CV_SOURCE)
clocks_state.cursor.set_editing(false);
selected.set_page(PARAMETERS);
}
break;
default:
clocks_state.cursor_state = clocks_state.cursor;
Expand Down
45 changes: 35 additions & 10 deletions soft/t_u_REV/TU_calibration.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@
using TU::OUTPUTS;

#ifdef MOD_OFFSET
static constexpr uint16_t _DAC_OFFSET = 30; // DAC offset, initial approx., ish --> 0v
static constexpr uint16_t _DAC_OFFSET = 30; // DAC offset, initial approx., ish --> 0v
#else
static constexpr uint16_t _DAC_OFFSET = 2200; // DAC offset, initial approx., ish --> 0v
#ifdef MODEL_2TT
static constexpr uint16_t _DAC_OFFSET = 30; // DAC offset, initial approx., ish --> 0v
#else
static constexpr uint16_t _DAC_OFFSET = 2200; // DAC offset, initial approx., ish --> 0v
#endif
#endif

#ifdef MODEL_2TT
static constexpr uint16_t _ADC_OFFSET = (uint16_t)((float)pow(2,TU::ADC::kAdcResolution)*1.0f); // ADC offset
#else
static constexpr uint16_t _ADC_OFFSET = (uint16_t)((float)pow(2,TU::ADC::kAdcResolution)*0.5f); // ADC offset
#endif

namespace TU {
CalibrationStorage calibration_storage;
Expand All @@ -30,7 +38,11 @@ static constexpr unsigned kCalibrationAdcSmoothing = 4;
const TU::CalibrationData kCalibrationDefaults = {
// DAC
{ {
{514, 1375, 2236, 3097, 3960} // 1 octave ~ 430
#ifdef MODEL_2TT
{0, 901, 1809, 2723, 3632} // 1.2V/oct for 2TT
#else
{514, 1375, 2236, 3097, 3960} // 1.0V/oct ==> 1 octave ~ 430
#endif
},
},
// ADC
Expand Down Expand Up @@ -124,7 +136,12 @@ const char *default_help_r = "[R] => Adjust";
const char *select_help = "[R] => Select";

const CalibrationStep calibration_steps[CALIBRATION_STEP_LAST] = {

#ifdef MODEL_2TT
{ HELLO, "2TT calibration", "use defaults? ", select_help, start_footer, CALIBRATE_NONE, 0, TU::Strings::no_yes, 0, 1 },
#else
{ HELLO, "T_U calibration", "use defaults? ", select_help, start_footer, CALIBRATE_NONE, 0, TU::Strings::no_yes, 0, 1 },
#endif
{ CENTER_DISPLAY, "center display", "pixel offset ", default_help_r, default_footer, CALIBRATE_DISPLAY, 0, nullptr, 0, 2 },
#ifdef MOD_OFFSET
{ DAC_4VM, "DAC -2.0 volts", "--> -2.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 0, nullptr, 0, OUTPUTS::MAX_VALUE },
Expand All @@ -133,11 +150,19 @@ const CalibrationStep calibration_steps[CALIBRATION_STEP_LAST] = {
{ DAC_2V, "DAC +4.0 volts", "--> +4.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 3, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_4V, "DAC +6.0 volts", "--> +6.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 4, nullptr, 0, OUTPUTS::MAX_VALUE },
#else
{ DAC_4VM, "DAC -4.0 volts", "--> -4.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 0, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_2VM, "DAC -2.0 volts", "--> -2.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 1, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_ZERO,"DAC 0.0 volts", "--> 0.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 2, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_2V, "DAC +2.0 volts", "--> +2.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 3, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_4V, "DAC +4.0 volts", "--> +4.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 4, nullptr, 0, OUTPUTS::MAX_VALUE },
#ifdef MODEL_2TT
{ DAC_4VM, "DAC 0.0 volts", "--> 0.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 0, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_2VM, "DAC +2.4 volts", "--> +2.4V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 1, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_ZERO,"DAC +4.8 volts", "--> +4.8V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 2, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_2V, "DAC +7.2 volts", "--> +7.2V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 3, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_4V, "DAC +9.6 volts", "--> +9.6V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 4, nullptr, 0, OUTPUTS::MAX_VALUE },
#else
{ DAC_4VM, "DAC -4.0 volts", "--> -4.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 0, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_2VM, "DAC -2.0 volts", "--> -2.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 1, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_ZERO,"DAC 0.0 volts", "--> 0.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 2, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_2V, "DAC +2.0 volts", "--> +2.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 3, nullptr, 0, OUTPUTS::MAX_VALUE },
{ DAC_4V, "DAC +4.0 volts", "--> +4.0V ", default_help_r, default_footer, CALIBRATE_DAC_OUTPUT, 4, nullptr, 0, OUTPUTS::MAX_VALUE },
#endif
#endif
{ CV_OFFSET_0, "ADC CV1", "--> 0V", default_help_r, default_footer, CALIBRATE_ADC_OFFSET, ADC_CHANNEL_1, nullptr, 0, 4095 },
{ CV_OFFSET_1, "ADC CV2", "--> 0V", default_help_r, default_footer, CALIBRATE_ADC_OFFSET, ADC_CHANNEL_2, nullptr, 0, 4095 },
Expand Down Expand Up @@ -339,15 +364,15 @@ void calibration_update(CalibrationState &state) {

switch (step->calibration_type) {
case CALIBRATE_NONE:
OUTPUTS::set_all(0);
OUTPUTS::zero_all();
break;
case CALIBRATE_DAC_OUTPUT:
TU::calibration_data.dac.calibration_points[0x0][step->index] = state.encoder_value;
OUTPUTS::set(CLOCK_CHANNEL_4, state.encoder_value);
break;
case CALIBRATE_ADC_OFFSET:
TU::calibration_data.adc.offset[step->index] = state.encoder_value;
OUTPUTS::set_all(0);
OUTPUTS::zero_all();
break;
case CALIBRATE_DISPLAY:
TU::calibration_data.display_offset = state.encoder_value;
Expand Down
2 changes: 2 additions & 0 deletions soft/t_u_REV/TU_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
//#define MOD_OFFSET
/* ------------ uncomment if using a pre-rev 1 PCB ---------------------------- */
//#define _TEMPS_UTILE_REV_0
/* ------------ Northern Light 4U Model 2TT ----------------------------------- */
//#define MODEL_2TT

#endif
1 change: 1 addition & 0 deletions soft/t_u_REV/TU_outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ uint16_t OUTPUTS::calibrated_v_oct_;
}; // namespace TU

const uint16_t _MAX_VALUE = 4095;
const int8_t _DAC_CHANNEL = CLOCK_CHANNEL_4;

void set_Output1(uint8_t data) {
digitalWriteFast(CLK1, data);
Expand Down
14 changes: 9 additions & 5 deletions soft/t_u_REV/TU_outputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ class OUTPUTS {
#ifdef MOD_OFFSET
static constexpr int kOctaveZero = 1;
#else
#ifdef MODEL_2TT
static constexpr int kOctaveZero = 0;
#else
static constexpr int kOctaveZero = 2;
#endif
#endif

struct CalibrationData {
Expand All @@ -51,9 +55,9 @@ class OUTPUTS {
static void Init(CalibrationData *calibration_data);
static void SPI_Init();

static void set_all(uint32_t value) {
for (int i = CLOCK_CHANNEL_1; i < CLOCK_CHANNEL_LAST; ++i)
values_[i] = USAT16(value);
static void zero_all() {
for (int i = CLOCK_CHANNEL_1; i < CLOCK_CHANNEL_LAST; i++)
values_[i] = get_zero_offset(i);
}

template <CLOCK_CHANNEL channel>
Expand Down Expand Up @@ -82,10 +86,10 @@ class OUTPUTS {
return states_[index];
}

static uint32_t get_zero_offset(CLOCK_CHANNEL channel) {
static uint32_t get_zero_offset(int channel) {

if (channel == _DAC_CHANNEL)
return calibration_data_->calibration_points[0x0][0x2];
return calibration_data_->calibration_points[0x0][kOctaveZero];
else
return 0x0;
}
Expand Down
Loading

0 comments on commit 36032d1

Please sign in to comment.