Skip to content

Commit

Permalink
Clouds: latest firmware
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Gillet committed Jun 30, 2015
1 parent 6401b7e commit 2d0a5dc
Show file tree
Hide file tree
Showing 16 changed files with 309 additions and 217 deletions.
9 changes: 6 additions & 3 deletions clouds/bootloader/bootloader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "clouds/drivers/leds.h"
#include "clouds/drivers/switches.h"
#include "clouds/drivers/system.h"
#include "clouds/drivers/version.h"
#include "clouds/meter.h"

#include "stm_audio_bootloader/qpsk/packet_decoder.h"
Expand Down Expand Up @@ -161,7 +162,6 @@ void SysTick_Handler() {
}

size_t discard_samples = 8000;

void FillBuffer(Codec::Frame* input, Codec::Frame* output, size_t n) {
meter.Process(input, n);
while (n--) {
Expand Down Expand Up @@ -216,12 +216,15 @@ void ProgramPage(const uint8_t* data, size_t size) {

void Init() {
System sys;
Version version;

sys.Init(false);
leds.Init();
meter.Init(48000);
switches.Init();
if (!codec.Init(48000, CODEC_PROTOCOL_PHILIPS, CODEC_FORMAT_16_BIT)) { }
if (!codec.Start(&FillBuffer)) { }
version.Init();
if (!codec.Init(!version.revised(), 48000)) { }
if (!codec.Start(32, &FillBuffer)) { }
sys.StartTimers();
}

Expand Down
2 changes: 1 addition & 1 deletion clouds/bootloader/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ FAMILY = f4xx
# USB = enabled

# Preferred upload command
UPLOAD_COMMAND = upload_jtag
UPLOAD_COMMAND = upload_jtag_erase_first

# Packages to build
TARGET = clouds_bootloader
Expand Down
23 changes: 15 additions & 8 deletions clouds/clouds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "clouds/drivers/debug_pin.h"
#include "clouds/drivers/debug_port.h"
#include "clouds/drivers/system.h"
#include "clouds/drivers/version.h"
#include "clouds/dsp/granular_processor.h"
#include "clouds/meter.h"
#include "clouds/resources.h"
Expand Down Expand Up @@ -70,10 +71,12 @@ extern "C" {

void SysTick_Handler() {
ui.Poll();
if (debug_port.readable()) {
uint8_t command = debug_port.Read();
uint8_t response = ui.HandleFactoryTestingRequest(command);
debug_port.Write(response);
if (settings.freshly_baked()) {
if (debug_port.readable()) {
uint8_t command = debug_port.Read();
uint8_t response = ui.HandleFactoryTestingRequest(command);
debug_port.Write(response);
}
}
}

Expand All @@ -87,8 +90,10 @@ void FillBuffer(Codec::Frame* input, Codec::Frame* output, size_t n) {

void Init() {
System sys;
Version version;

sys.Init(true);
version.Init();

// Init granular processor.
processor.Init(
Expand All @@ -100,14 +105,16 @@ void Init() {
meter.Init(32000);
ui.Init(&settings, &cv_scaler, &processor, &meter);

if (!codec.Init(32000, CODEC_PROTOCOL_PHILIPS, CODEC_FORMAT_16_BIT)) {
bool master = !version.revised();
if (!codec.Init(master, 32000)) {
ui.Panic();
}
if (!codec.Start(&FillBuffer)) {
if (!codec.Start(32, &FillBuffer)) {
ui.Panic();
}
// DebugPin::Init();
debug_port.Init();
if (settings.freshly_baked()) {
debug_port.Init();
}
sys.StartTimers();
}

Expand Down
10 changes: 8 additions & 2 deletions clouds/cv_scaler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ void CvScaler::Init(CalibrationData* calibration_data) {
blend_parameter_ = BLEND_PARAMETER_DRY_WET;
blend_knob_quantized_ = 0.0f;
blend_knob_touched_ = false;

previous_trigger_ = false;
previous_gate_ = false;
}

void CvScaler::UpdateBlendParameters(float knob_value, float cv) {
Expand Down Expand Up @@ -190,8 +193,11 @@ void CvScaler::Read(Parameters* parameters) {
parameters->freeze = false;
}

parameters->trigger = gate_input_.trigger_rising_edge();
parameters->gate = gate_input_.gate();
parameters->trigger = previous_trigger_;
parameters->gate = previous_gate_;

previous_trigger_ = gate_input_.trigger_rising_edge();
previous_gate_ = gate_input_.gate();

adc_.Convert();
}
Expand Down
3 changes: 3 additions & 0 deletions clouds/cv_scaler.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ class CvScaler {

float cv_c1_;

bool previous_trigger_;
bool previous_gate_;

DISALLOW_COPY_AND_ASSIGN(CvScaler);
};

Expand Down
Loading

0 comments on commit 2d0a5dc

Please sign in to comment.