mirror of
https://github.com/jhbruhn/eurorack.git
synced 2025-03-15 02:55:49 +00:00
Update stereo_mix to new hardware revision
This commit is contained in:
parent
32477861d8
commit
a71be667fb
18 changed files with 7555 additions and 2785 deletions
|
@ -38,15 +38,7 @@ class Adc {
|
||||||
|
|
||||||
inline int16_t cv_value(AdcChannel channel)
|
inline int16_t cv_value(AdcChannel channel)
|
||||||
{
|
{
|
||||||
#ifdef NEW_HARDWARE
|
return -(this->values_[ADC_GROUP_CV + channel] - 32768);
|
||||||
return this->values_[ADC_GROUP_CV + channel] - 32768;
|
|
||||||
#else
|
|
||||||
if (channel >= ADC_CHANNEL_PAN_1) {
|
|
||||||
return this->values_[ADC_GROUP_CV + channel] - 32768;
|
|
||||||
} else {
|
|
||||||
return this->values_[ADC_GROUP_CV + channel] >> 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint16_t value(int32_t channel) const
|
inline uint16_t value(int32_t channel) const
|
||||||
|
|
|
@ -10,8 +10,8 @@ namespace stereo_mix {
|
||||||
GPIO_TypeDef* kMDacPorts[] = { GPIOB, GPIOB, GPIOB, GPIOB };
|
GPIO_TypeDef* kMDacPorts[] = { GPIOB, GPIOB, GPIOB, GPIOB };
|
||||||
const uint16_t kMDacPins[] = { GPIO_PIN_8, GPIO_PIN_9, GPIO_PIN_10, GPIO_PIN_11 };
|
const uint16_t kMDacPins[] = { GPIO_PIN_8, GPIO_PIN_9, GPIO_PIN_10, GPIO_PIN_11 };
|
||||||
|
|
||||||
GPIO_TypeDef* kOffsetDacPorts[] = { GPIOA, GPIOA, GPIOA, GPIOA };
|
GPIO_TypeDef* kOffsetDacPorts[] = { GPIOA, GPIOB, GPIOB, GPIOC };
|
||||||
const uint16_t kOffsetDacPins[] = { GPIO_PIN_8, GPIO_PIN_9, GPIO_PIN_10, GPIO_PIN_11 };
|
const uint16_t kOffsetDacPins[] = { GPIO_PIN_15, GPIO_PIN_7, GPIO_PIN_15, GPIO_PIN_13 };
|
||||||
|
|
||||||
class Dacs { // MCP4xx2 dac implementation
|
class Dacs { // MCP4xx2 dac implementation
|
||||||
public:
|
public:
|
||||||
|
@ -19,6 +19,7 @@ class Dacs { // MCP4xx2 dac implementation
|
||||||
{
|
{
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
__HAL_RCC_SPI1_CLK_ENABLE();
|
__HAL_RCC_SPI1_CLK_ENABLE();
|
||||||
|
|
||||||
HAL_NVIC_SetPriority(SPI1_IRQn, 0, 0);
|
HAL_NVIC_SetPriority(SPI1_IRQn, 0, 0);
|
||||||
|
|
|
@ -1,74 +1,140 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../resources.h"
|
#include "../resources.h"
|
||||||
|
#include "peripherals.h"
|
||||||
|
#include "stm32f030x8.h"
|
||||||
|
#include "stm32f0xx_hal_gpio_ex.h"
|
||||||
|
#include "stm32f0xx_hal_rcc.h"
|
||||||
|
#include "stm32f0xx_hal_tim.h"
|
||||||
|
#include "stm32f0xx_hal_tim_ex.h"
|
||||||
#include "stmlib/utils/dsp.h"
|
#include "stmlib/utils/dsp.h"
|
||||||
#include "stm32f0xx_hal_gpio.h"
|
#include "stm32f0xx_hal_gpio.h"
|
||||||
#include <stm32f0xx_hal.h>
|
#include <stm32f0xx_hal.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
using namespace stereo_mix;
|
using namespace stereo_mix;
|
||||||
using namespace stmlib;
|
using namespace stmlib;
|
||||||
|
|
||||||
|
enum LedColor {
|
||||||
|
LED_COLOR_GREEN,
|
||||||
|
LED_COLOR_RED,
|
||||||
|
LED_COLOR_ORANGE
|
||||||
|
};
|
||||||
|
|
||||||
const uint8_t kNumChannels = 4;
|
const uint8_t kNumChannels = 4;
|
||||||
|
|
||||||
static const uint16_t kGpioPins[] = { GPIO_PIN_7, GPIO_PIN_15, GPIO_PIN_13, GPIO_PIN_14 };
|
static GPIO_TypeDef* kGpioPorts[] = { GPIOA, GPIOA, GPIOA, GPIOA };
|
||||||
static GPIO_TypeDef* kGpioPorts[] = { GPIOB, GPIOB, GPIOC, GPIOC };
|
static const uint16_t kGpioPins[] = { GPIO_PIN_8, GPIO_PIN_9, GPIO_PIN_10, GPIO_PIN_11 };
|
||||||
|
|
||||||
|
static GPIO_TypeDef* kGpioColorPorts[] = {GPIOC, GPIOC, GPIOF, GPIOF};
|
||||||
|
static const uint16_t kGpioColorPins[] = {GPIO_PIN_14, GPIO_PIN_15, GPIO_PIN_6, GPIO_PIN_7};
|
||||||
|
|
||||||
class Leds {
|
class Leds {
|
||||||
public:
|
public:
|
||||||
Leds()
|
Leds()
|
||||||
{
|
{
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||||
|
|
||||||
GPIO_InitTypeDef gpioInit;
|
GPIO_InitTypeDef gpioInit;
|
||||||
for (size_t i = 0; i < kNumChannels; i++) {
|
for (size_t i = 0; i < kNumChannels; i++) {
|
||||||
gpioInit.Mode = GPIO_MODE_OUTPUT_PP;
|
gpioInit.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
gpioInit.Pin = kGpioColorPins[i];
|
||||||
|
gpioInit.Pull = GPIO_NOPULL;
|
||||||
|
gpioInit.Speed = GPIO_SPEED_FREQ_MEDIUM;
|
||||||
|
HAL_GPIO_Init(kGpioColorPorts[i], &gpioInit);
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(kGpioColorPorts[i], kGpioColorPins[i], GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__HAL_RCC_TIM1_CLK_ENABLE();
|
||||||
|
|
||||||
|
htim1.Init.Prescaler = 1;
|
||||||
|
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
htim1.Init.Period = 4095; // 12 bit
|
||||||
|
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
|
HAL_TIM_PWM_Init(&htim1);
|
||||||
|
|
||||||
|
TIM_MasterConfigTypeDef sMasterConfig;
|
||||||
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||||
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||||
|
HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig);
|
||||||
|
|
||||||
|
TIM_OC_InitTypeDef sConfigOC;
|
||||||
|
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||||
|
sConfigOC.Pulse = 100;
|
||||||
|
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||||
|
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||||
|
HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1);
|
||||||
|
HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_2);
|
||||||
|
HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_3);
|
||||||
|
HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_4);
|
||||||
|
|
||||||
|
for(size_t i = 0; i < kNumChannels; i++) {
|
||||||
|
gpioInit.Mode = GPIO_MODE_AF_PP;
|
||||||
gpioInit.Pin = kGpioPins[i];
|
gpioInit.Pin = kGpioPins[i];
|
||||||
gpioInit.Pull = GPIO_NOPULL;
|
gpioInit.Pull = GPIO_NOPULL;
|
||||||
gpioInit.Speed = GPIO_SPEED_FREQ_MEDIUM;
|
gpioInit.Speed = GPIO_SPEED_FREQ_MEDIUM;
|
||||||
|
gpioInit.Alternate = GPIO_AF2_TIM1;
|
||||||
HAL_GPIO_Init(kGpioPorts[i], &gpioInit);
|
HAL_GPIO_Init(kGpioPorts[i], &gpioInit);
|
||||||
|
}
|
||||||
|
|
||||||
intensities[i] = 0;
|
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
|
||||||
blinking[i] = false;
|
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2);
|
||||||
}
|
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3);
|
||||||
|
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Write()
|
void Write()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_PIN
|
for(size_t i = 0; i < kNumChannels; i++) {
|
||||||
for (size_t i = 0; i < kNumChannels - 1; i++) {
|
LedColor targetColor = colors[i];
|
||||||
#else
|
uint16_t intensity = intensities[i];
|
||||||
for (size_t i = 0; i < kNumChannels; i++) {
|
if(colors[i] == LED_COLOR_ORANGE) {
|
||||||
|
if(toggle[i]) targetColor = LED_COLOR_RED;
|
||||||
|
else targetColor = LED_COLOR_GREEN;
|
||||||
|
toggle[i] = !toggle[i];
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
if(targetColor == LED_COLOR_RED) {
|
||||||
bool in_blink_phase = blink_counter > (0x2000 / 2) || !blinking[i];
|
HAL_GPIO_WritePin(kGpioColorPorts[i], kGpioColorPins[i], GPIO_PIN_SET);
|
||||||
if (intensities[i] && lut_led_gamma[intensities[i] >> 8] >= pwm_counter && in_blink_phase) {
|
intensity = 65534 - lut_led_red_gamma[intensity >> 4];
|
||||||
kGpioPorts[i]->BSRR |= kGpioPins[i];
|
} else if(targetColor == LED_COLOR_GREEN) {
|
||||||
|
HAL_GPIO_WritePin(kGpioColorPorts[i], kGpioColorPins[i], GPIO_PIN_RESET);
|
||||||
|
intensity = lut_led_green_gamma[intensity >> 4];
|
||||||
|
}
|
||||||
|
|
||||||
|
__HAL_TIM_SET_COMPARE(&htim1, i, intensity >> 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_intensity_signed(uint8_t channel, int16_t intensity) {
|
||||||
|
if(channel >= kNumChannels) return;
|
||||||
|
|
||||||
|
if(intensity < 0) {
|
||||||
|
colors[channel] = LED_COLOR_RED;
|
||||||
|
intensities[channel] = (-intensity) << 1;
|
||||||
} else {
|
} else {
|
||||||
kGpioPorts[i]->BRR |= kGpioPins[i];
|
colors[channel] = LED_COLOR_GREEN;
|
||||||
}
|
intensities[channel] = (intensity) << 1;
|
||||||
}
|
|
||||||
pwm_counter++;
|
|
||||||
blink_counter++;
|
|
||||||
if(blink_counter > 0x2000) blink_counter = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void set_intensity(uint8_t channel, uint16_t intensity)
|
void set_intensity_unsigned(uint8_t channel, uint16_t intensity, LedColor color)
|
||||||
{
|
{
|
||||||
if (channel >= kNumChannels)
|
if (channel >= kNumChannels)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
intensities[channel] = intensity;
|
intensities[channel] = intensity;
|
||||||
}
|
colors[channel] = color;
|
||||||
void set_blinking(uint8_t channel, bool blink)
|
|
||||||
{
|
|
||||||
if (channel >= kNumChannels)
|
|
||||||
return;
|
|
||||||
blinking[channel] = blink;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t pwm_counter;
|
|
||||||
uint16_t blink_counter;
|
|
||||||
uint16_t intensities[kNumChannels];
|
uint16_t intensities[kNumChannels];
|
||||||
bool blinking[kNumChannels];
|
bool toggle[kNumChannels];
|
||||||
|
LedColor colors[kNumChannels];
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
ADC_HandleTypeDef hadc1 = { .Instance = ADC1 };
|
ADC_HandleTypeDef hadc1 = { .Instance = ADC1 };
|
||||||
DMA_HandleTypeDef hdma1_channel1 = { .Instance = DMA1_Channel1 };
|
DMA_HandleTypeDef hdma1_channel1 = { .Instance = DMA1_Channel1 };
|
||||||
SPI_HandleTypeDef hspi1 = { .Instance = SPI1 };
|
SPI_HandleTypeDef hspi1 = { .Instance = SPI1 };
|
||||||
|
TIM_HandleTypeDef htim1 = { .Instance = TIM1 };
|
||||||
TIM_HandleTypeDef htim3 = { .Instance = TIM3 };
|
TIM_HandleTypeDef htim3 = { .Instance = TIM3 };
|
||||||
TIM_HandleTypeDef htim6 = { .Instance = TIM6 };
|
TIM_HandleTypeDef htim6 = { .Instance = TIM6 };
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
extern ADC_HandleTypeDef hadc1;
|
extern ADC_HandleTypeDef hadc1;
|
||||||
extern DMA_HandleTypeDef hdma1_channel1;
|
extern DMA_HandleTypeDef hdma1_channel1;
|
||||||
extern SPI_HandleTypeDef hspi1;
|
extern SPI_HandleTypeDef hspi1;
|
||||||
|
extern TIM_HandleTypeDef htim1;
|
||||||
extern TIM_HandleTypeDef htim3;
|
extern TIM_HandleTypeDef htim3;
|
||||||
extern TIM_HandleTypeDef htim6;
|
extern TIM_HandleTypeDef htim6;
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,21 +1,22 @@
|
||||||
Comment,Designator,Footprint,LCSC Part #
|
Comment,Designator,Footprint,LCSC Part #
|
||||||
|
1.0nF,C19 C20 C21 C22 C67 C68 C69 C70,C0402,
|
||||||
1k,R95 R96,R0402,
|
1k,R95 R96,R0402,
|
||||||
4.7nF,C19 C20 C21 C22,C0402,
|
|
||||||
8MHz,X1,NX5032,
|
8MHz,X1,NX5032,
|
||||||
10k,R85,R0402,
|
10k,R85,R0402,
|
||||||
10uF,C37 C38 C39 C41,CASE-A_3216,
|
10uF,C37 C38 C39 C41,CASE-A_3216,
|
||||||
10uF,C49 C50 C51 C52 C53 C54 C55 C56,C0402,
|
10uF,C49 C50 C51 C52 C53 C54 C55 C56,C0805,
|
||||||
10uF,C65 C66,CASE-A_3216,
|
10uF,C65 C66,CASE-A_3216,
|
||||||
15k,R9 R10 R11 R12 R41 R42 R43 R44,R0402,
|
15k,R9 R10 R11 R12 R41 R42 R43 R44,R0402,
|
||||||
|
20k,R73 R74 R75 R76 R97 R98 R99 R100,R0402,
|
||||||
22pF,C26 C27,C0402,
|
22pF,C26 C27,C0402,
|
||||||
22uF,C47 C48,C0805,
|
22uF,C47 C48,C0805,
|
||||||
33k,R73 R74 R75 R76,R0402,
|
47k,R13 R14 R15 R16 R17 R18 R19 R20 R45 R46 R47 R48 R49 R50 R51 R52 R86 R87,R0402,
|
||||||
47k,R13 R14 R15 R16 R17 R18 R19 R20 R45 R46 R47 R48 R49 R50 R51 R52,R0402,
|
|
||||||
91k,R1 R3 R5 R7 R33 R35 R37 R39,R0402,
|
91k,R1 R3 R5 R7 R33 R35 R37 R39,R0402,
|
||||||
100R,R91 R92 R93 R94,R0402,
|
100R,R91 R92 R93 R94,R0402,
|
||||||
100k,R2 R4 R6 R8 R21 R22 R24 R27 R29 R30 R31 R32 R34 R36 R38 R40 R53 R54 R55 R56 R61 R62 R63 R64 R66 R68 R70 R72 R81 R82 R83 R84 R88 R89,R0402,
|
100k,R2 R4 R6 R8 R21 R22 R24 R27 R29 R30 R31 R32 R34 R36 R38 R40 R53 R54 R55 R56 R61 R62 R63 R64 R66 R68 R70 R72 R88 R89,R0402,
|
||||||
100nF,C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18 C23 C24 C25 C28 C29 C30 C31 C34 C35 C40 C42 C43 C44 C45 C46 C57 C58 C59 C60 C61 C62 C63 C64,C0402,
|
100nF,C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18 C23 C24 C25 C28 C29 C30 C31 C34 C35 C40 C42 C43 C44 C45 C46 C57 C58 C59 C60 C61 C62 C63 C64,C0402,
|
||||||
200k,R65 R67 R69 R71 R77 R78 R79 R80,R0402,
|
120k,R65 R67 R69 R71 R81 R82 R83 R101,R0402,
|
||||||
|
200k,R77 R78 R79 R80,R0402,
|
||||||
220pF,C32 C33,C0402,
|
220pF,C32 C33,C0402,
|
||||||
300k,R23 R25 R26 R28 R57 R58 R59 R60,R0402,
|
300k,R23 R25 R26 R28 R57 R58 R59 R60,R0402,
|
||||||
470R,R90,R0402,
|
470R,R90,R0402,
|
||||||
|
|
|
|
@ -11,7 +11,7 @@ C9, 3.18,88.58,Bottom,90.0
|
||||||
C10, 3.18,66.99,Bottom,90.0
|
C10, 3.18,66.99,Bottom,90.0
|
||||||
C11, 3.18,45.40,Bottom,90.0
|
C11, 3.18,45.40,Bottom,90.0
|
||||||
C12, 3.18,23.50,Bottom,90.0
|
C12, 3.18,23.50,Bottom,90.0
|
||||||
C13,55.56,33.02,Bottom,0.0
|
C13,64.66,33.76,Bottom,0.0
|
||||||
C14,62.87,55.25,Bottom,180.0
|
C14,62.87,55.25,Bottom,180.0
|
||||||
C15,62.87,98.43,Bottom,180.0
|
C15,62.87,98.43,Bottom,180.0
|
||||||
C16,62.87,76.84,Bottom,180.0
|
C16,62.87,76.84,Bottom,180.0
|
||||||
|
@ -28,8 +28,8 @@ C26,41.91, 1.27,Bottom,180.0
|
||||||
C27,36.83, 1.27,Bottom,180.0
|
C27,36.83, 1.27,Bottom,180.0
|
||||||
C28,42.23, 6.67,Bottom,0.0
|
C28,42.23, 6.67,Bottom,0.0
|
||||||
C29,32.38,15.88,Bottom,180.0
|
C29,32.38,15.88,Bottom,180.0
|
||||||
C30,43.50, 8.89,Bottom,90.0
|
C30,43.60, 8.89,Bottom,90.0
|
||||||
C31,57.79,37.47,Bottom,180.0
|
C31,31.12,45.72,Bottom,0.0
|
||||||
C32,18.10,14.61,Bottom,0.0
|
C32,18.10,14.61,Bottom,0.0
|
||||||
C33, 7.30,13.34,Bottom,0.0
|
C33, 7.30,13.34,Bottom,0.0
|
||||||
C34,14.61, 9.53,Bottom,0.0
|
C34,14.61, 9.53,Bottom,0.0
|
||||||
|
@ -40,20 +40,20 @@ C39,58.42, 3.49,Bottom,180.0
|
||||||
C40,20.32, 5.40,Bottom,180.0
|
C40,20.32, 5.40,Bottom,180.0
|
||||||
C41,45.40, 6.03,Bottom,270.0
|
C41,45.40, 6.03,Bottom,270.0
|
||||||
C42,45.40, 1.27,Bottom,180.0
|
C42,45.40, 1.27,Bottom,180.0
|
||||||
C43,55.56,84.77,Bottom,270.0
|
C43,56.36,84.77,Bottom,270.0
|
||||||
C44,55.56,63.18,Bottom,270.0
|
C44,56.83,63.18,Bottom,270.0
|
||||||
C45,55.56,41.59,Bottom,270.0
|
C45,55.56,41.59,Bottom,270.0
|
||||||
C46,56.20,17.78,Bottom,270.0
|
C46,55.09,20.80,Bottom,270.0
|
||||||
C47,29.21, 7.62,Bottom,270.0
|
C47,29.21, 7.62,Bottom,270.0
|
||||||
C48,58.42, 6.67,Bottom,0.0
|
C48,58.42, 6.67,Bottom,0.0
|
||||||
C49,54.29,84.77,Bottom,270.0
|
C49,56.20,80.80,Bottom,0.0
|
||||||
C50,54.29,63.18,Bottom,270.0
|
C50,56.83,59.05,Bottom,0.0
|
||||||
C51,54.29,41.59,Bottom,270.0
|
C51,56.83,37.78,Bottom,0.0
|
||||||
C52,54.93,17.78,Bottom,270.0
|
C52,53.34,20.64,Bottom,270.0
|
||||||
C53,57.79,98.43,Bottom,180.0
|
C53,56.83,98.58,Bottom,180.0
|
||||||
C54,62.87,78.11,Bottom,180.0
|
C54,62.87,78.74,Bottom,180.0
|
||||||
C55,62.87,56.52,Bottom,180.0
|
C55,62.87,57.15,Bottom,180.0
|
||||||
C56,55.56,31.75,Bottom,0.0
|
C56,61.12,34.29,Bottom,180.0
|
||||||
C57,59.69,85.09,Bottom,180.0
|
C57,59.69,85.09,Bottom,180.0
|
||||||
C58,59.69,63.50,Bottom,180.0
|
C58,59.69,63.50,Bottom,180.0
|
||||||
C59,59.69,41.91,Bottom,180.0
|
C59,59.69,41.91,Bottom,180.0
|
||||||
|
@ -64,10 +64,14 @@ C63,38.10,41.91,Bottom,180.0
|
||||||
C64,38.10,20.32,Bottom,180.0
|
C64,38.10,20.32,Bottom,180.0
|
||||||
C65, 5.71, 2.54,Bottom,0.0
|
C65, 5.71, 2.54,Bottom,0.0
|
||||||
C66,12.07, 2.54,Bottom,180.0
|
C66,12.07, 2.54,Bottom,180.0
|
||||||
|
C67,19.69,85.09,Bottom,90.0
|
||||||
|
C68,19.69,63.50,Bottom,90.0
|
||||||
|
C69,19.69,41.91,Bottom,90.0
|
||||||
|
C70,19.69,20.32,Bottom,90.0
|
||||||
D1,58.74,12.70,Bottom,0.0
|
D1,58.74,12.70,Bottom,0.0
|
||||||
D2,31.12, 2.86,Bottom,180.0
|
D2,31.12, 2.86,Bottom,180.0
|
||||||
D3,20.32, 2.54,Bottom,0.0
|
D3,20.32, 2.54,Bottom,0.0
|
||||||
IC1,63.18,33.02,Bottom,270.0
|
IC1,31.75,40.01,Bottom,270.0
|
||||||
IC2,50.80, 3.81,Bottom,0.0
|
IC2,50.80, 3.81,Bottom,0.0
|
||||||
R1, 6.99,95.25,Bottom,270.0
|
R1, 6.99,95.25,Bottom,270.0
|
||||||
R2, 5.71,95.25,Bottom,270.0
|
R2, 5.71,95.25,Bottom,270.0
|
||||||
|
@ -152,31 +156,37 @@ R80,20.96,20.32,Bottom,270.0
|
||||||
R81,22.23,85.09,Bottom,90.0
|
R81,22.23,85.09,Bottom,90.0
|
||||||
R82,22.23,63.50,Bottom,90.0
|
R82,22.23,63.50,Bottom,90.0
|
||||||
R83,22.23,41.91,Bottom,90.0
|
R83,22.23,41.91,Bottom,90.0
|
||||||
R84,22.23,20.32,Bottom,90.0
|
|
||||||
R85,53.98, 8.26,Bottom,270.0
|
R85,53.98, 8.26,Bottom,270.0
|
||||||
|
R86, 5.71, 1.27,Bottom,180.0
|
||||||
|
R87,12.07, 1.27,Bottom,0.0
|
||||||
R88,17.78,13.34,Bottom,0.0
|
R88,17.78,13.34,Bottom,0.0
|
||||||
R89, 7.62,12.07,Bottom,0.0
|
R89, 7.62,12.07,Bottom,0.0
|
||||||
R90,23.50, 2.86,Bottom,0.0
|
R90,23.50, 2.86,Bottom,0.0
|
||||||
R91,49.53,79.06,Bottom,0.0
|
R91,49.53,79.06,Bottom,0.0
|
||||||
R92,49.53,57.47,Bottom,0.0
|
R92,49.53,57.47,Bottom,0.0
|
||||||
R93,49.53,35.88,Bottom,0.0
|
R93,50.24,35.27,Bottom,0.0
|
||||||
R94,49.85,14.29,Bottom,0.0
|
R94,49.85,14.29,Bottom,0.0
|
||||||
R95, 1.91, 2.54,Bottom,180.0
|
R95, 1.91, 2.54,Bottom,180.0
|
||||||
R96,15.88, 2.54,Bottom,0.0
|
R96,15.88, 2.54,Bottom,0.0
|
||||||
|
R97,18.41,85.09,Bottom,90.0
|
||||||
|
R98,18.41,63.50,Bottom,90.0
|
||||||
|
R99,18.41,41.91,Bottom,90.0
|
||||||
|
R100,18.41,20.32,Bottom,90.0
|
||||||
|
R101,22.23,20.32,Bottom,90.0
|
||||||
U1,60.96,95.25,Bottom,270.0
|
U1,60.96,95.25,Bottom,270.0
|
||||||
U2,60.96,73.66,Bottom,270.0
|
U2,60.96,73.66,Bottom,270.0
|
||||||
U3, 6.35,90.17,Bottom,0.0
|
U3, 6.35,90.17,Bottom,0.0
|
||||||
U4, 6.35,68.58,Bottom,0.0
|
U4, 6.35,68.58,Bottom,0.0
|
||||||
U5,50.16,90.17,Bottom,180.0
|
U5,50.16,90.81,Bottom,180.0
|
||||||
U6,50.16,68.58,Bottom,180.0
|
U6,50.16,69.22,Bottom,180.0
|
||||||
U7,35.88,96.52,Bottom,270.0
|
U7,35.88,96.52,Bottom,270.0
|
||||||
U8,35.56,74.93,Bottom,270.0
|
U8,35.56,74.93,Bottom,270.0
|
||||||
U9,60.96,52.07,Bottom,270.0
|
U9,60.96,52.07,Bottom,270.0
|
||||||
U10,50.16,30.48,Bottom,270.0
|
U10,60.96,30.48,Bottom,270.0
|
||||||
U11, 6.35,46.99,Bottom,0.0
|
U11, 6.35,46.99,Bottom,0.0
|
||||||
U12, 6.35,25.40,Bottom,0.0
|
U12, 6.35,25.40,Bottom,0.0
|
||||||
U13,50.16,46.99,Bottom,180.0
|
U13,50.16,47.63,Bottom,180.0
|
||||||
U14,50.16,22.86,Bottom,180.0
|
U14,50.16,26.67,Bottom,180.0
|
||||||
U15,35.56,53.34,Bottom,270.0
|
U15,35.56,53.34,Bottom,270.0
|
||||||
U16,35.56,31.75,Bottom,270.0
|
U16,35.56,31.75,Bottom,270.0
|
||||||
U17,20.32,90.17,Bottom,0.0
|
U17,20.32,90.17,Bottom,0.0
|
||||||
|
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -25,7 +25,6 @@ void Processor::Process(int16_t cvs[], uint16_t* outs)
|
||||||
// calculate value for ui
|
// calculate value for ui
|
||||||
int32_t lin = vol_offset + (vol_cv << 3) * 3;
|
int32_t lin = vol_offset + (vol_cv << 3) * 3;
|
||||||
lin = ClipU16(lin);
|
lin = ClipU16(lin);
|
||||||
lin *= !mute;
|
|
||||||
this->linear_vol = lin;
|
this->linear_vol = lin;
|
||||||
|
|
||||||
uint16_t vol_pot_exp = Interpolate124(lut_linear_to_exp, vol_pot);
|
uint16_t vol_pot_exp = Interpolate124(lut_linear_to_exp, vol_pot);
|
||||||
|
@ -41,8 +40,6 @@ void Processor::Process(int16_t cvs[], uint16_t* outs)
|
||||||
|
|
||||||
vol = ClipU16(vol);
|
vol = ClipU16(vol);
|
||||||
|
|
||||||
this->previous_vol = vol;
|
|
||||||
|
|
||||||
int32_t pan_cv = (cv_input_pan * static_cast<int32_t>(pan_att)) >> 15; // full attenuate gives 2x amplification :)
|
int32_t pan_cv = (cv_input_pan * static_cast<int32_t>(pan_att)) >> 15; // full attenuate gives 2x amplification :)
|
||||||
pan_cv = Clip16(pan_cv);
|
pan_cv = Clip16(pan_cv);
|
||||||
int32_t pan = pan_pot + ((pan_cv) * 2);
|
int32_t pan = pan_pot + ((pan_cv) * 2);
|
||||||
|
|
|
@ -30,12 +30,15 @@ class Processor {
|
||||||
mute = m;
|
mute = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool is_muted() {
|
||||||
|
return mute;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t linear_volume() {
|
uint16_t linear_volume() {
|
||||||
return linear_vol;
|
return linear_vol;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t previous_vol;
|
|
||||||
uint16_t linear_vol;
|
uint16_t linear_vol;
|
||||||
|
|
||||||
int16_t cv_input_pan = 0;
|
int16_t cv_input_pan = 0;
|
||||||
|
@ -45,7 +48,7 @@ class Processor {
|
||||||
int16_t pan_offset = 0;
|
int16_t pan_offset = 0;
|
||||||
int16_t vol_att;
|
int16_t vol_att;
|
||||||
int16_t pan_att;
|
int16_t pan_att;
|
||||||
uint16_t log_exp_mix_cv = 32767;//32767; // -> linear
|
uint16_t log_exp_mix_cv = 32767; // -> linear
|
||||||
uint16_t log_exp_mix_pot = 0; // -> exp
|
uint16_t log_exp_mix_pot = 0; // -> exp
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -49,15 +49,18 @@ extern const uint8_t* lookup_table_u8_table[];
|
||||||
extern const uint16_t lut_linear_to_exp[];
|
extern const uint16_t lut_linear_to_exp[];
|
||||||
extern const uint16_t lut_left_sin_pan[];
|
extern const uint16_t lut_left_sin_pan[];
|
||||||
extern const uint16_t lut_right_cos_pan[];
|
extern const uint16_t lut_right_cos_pan[];
|
||||||
extern const uint16_t lut_led_gamma[];
|
extern const uint16_t lut_led_red_gamma[];
|
||||||
|
extern const uint16_t lut_led_green_gamma[];
|
||||||
#define LUT_LINEAR_TO_EXP 0
|
#define LUT_LINEAR_TO_EXP 0
|
||||||
#define LUT_LINEAR_TO_EXP_SIZE 4096
|
#define LUT_LINEAR_TO_EXP_SIZE 4096
|
||||||
#define LUT_LEFT_SIN_PAN 1
|
#define LUT_LEFT_SIN_PAN 1
|
||||||
#define LUT_LEFT_SIN_PAN_SIZE 4096
|
#define LUT_LEFT_SIN_PAN_SIZE 4096
|
||||||
#define LUT_RIGHT_COS_PAN 2
|
#define LUT_RIGHT_COS_PAN 2
|
||||||
#define LUT_RIGHT_COS_PAN_SIZE 4096
|
#define LUT_RIGHT_COS_PAN_SIZE 4096
|
||||||
#define LUT_LED_GAMMA 3
|
#define LUT_LED_RED_GAMMA 3
|
||||||
#define LUT_LED_GAMMA_SIZE 256
|
#define LUT_LED_RED_GAMMA_SIZE 4096
|
||||||
|
#define LUT_LED_GREEN_GAMMA 4
|
||||||
|
#define LUT_LED_GREEN_GAMMA_SIZE 4096
|
||||||
|
|
||||||
} // namespace stereo_mix
|
} // namespace stereo_mix
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,12 @@ lookup_tables_u16.append(('right_cos_pan', r_pan))
|
||||||
print(r_pan.size)
|
print(r_pan.size)
|
||||||
|
|
||||||
# led gamma correction
|
# led gamma correction
|
||||||
gamma = 2.4
|
gamma_green = 2.4
|
||||||
max_in = 255
|
gamma_red = 2.8
|
||||||
max_out = 255
|
max_in = 4095
|
||||||
|
max_out = 65535
|
||||||
input_vals = np.linspace(0, max_in, num=max_in + 1)
|
input_vals = np.linspace(0, max_in, num=max_in + 1)
|
||||||
gamma_correction = ((input_vals / max_in) ** gamma) * max_out + 0.5
|
gamma_correction_red = ((input_vals / max_in) ** gamma_red) * max_out + 0.5
|
||||||
lookup_tables_u16.append(('led_gamma', np.floor(gamma_correction)))
|
gamma_correction_green = ((input_vals / max_in) ** gamma_green) * max_out + 0.5
|
||||||
|
lookup_tables_u16.append(('led_red_gamma', np.floor(gamma_correction_red)))
|
||||||
|
lookup_tables_u16.append(('led_green_gamma', np.floor(gamma_correction_green)))
|
||||||
|
|
|
@ -127,15 +127,16 @@ void Init(void)
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOF_CLK_ENABLE();
|
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||||
|
__HAL_RCC_TIM1_CLK_ENABLE();
|
||||||
__HAL_RCC_TIM3_CLK_ENABLE();
|
__HAL_RCC_TIM3_CLK_ENABLE();
|
||||||
__HAL_RCC_TIM6_CLK_ENABLE();
|
__HAL_RCC_TIM6_CLK_ENABLE();
|
||||||
__HAL_RCC_SPI1_CLK_ENABLE();
|
__HAL_RCC_SPI1_CLK_ENABLE();
|
||||||
|
|
||||||
HAL_NVIC_SetPriority(TIM3_IRQn, 0, 0);
|
HAL_NVIC_SetPriority(TIM3_IRQn, 0, 0);
|
||||||
HAL_NVIC_EnableIRQ(TIM3_IRQn);
|
HAL_NVIC_EnableIRQ(TIM3_IRQn);
|
||||||
htim3.Init.Prescaler = 8;
|
htim3.Init.Prescaler = 27;
|
||||||
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
|
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
htim3.Init.Period = 128;
|
htim3.Init.Period = 65535 >> 2;
|
||||||
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
htim3.Init.RepetitionCounter = 0;
|
htim3.Init.RepetitionCounter = 0;
|
||||||
HAL_TIM_Base_Init(&htim3);
|
HAL_TIM_Base_Init(&htim3);
|
||||||
|
@ -177,7 +178,6 @@ int main(void)
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
ui.Init();
|
ui.Init();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
ui.DoEvents();
|
ui.DoEvents();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <stm32f0xx_hal.h>
|
#include <stm32f0xx_hal.h>
|
||||||
|
|
||||||
const int kLongPressDuration = 2000;
|
const int kLongPressDuration = 2000;
|
||||||
const int kShowChangedValueMilliseconds = 1000;
|
const int kShowChangedValueMilliseconds = 600;
|
||||||
|
|
||||||
void UI::Poll()
|
void UI::Poll()
|
||||||
{
|
{
|
||||||
|
@ -99,24 +99,17 @@ void UI::TaskDrawLeds()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < kNumChannels; i++) {
|
for (size_t i = 0; i < kNumChannels; i++) {
|
||||||
if (potControllers[i].editing_hidden_parameter()) {
|
if (potControllers[i].editing_hidden_parameter()) {
|
||||||
leds->set_intensity(i, abs(volume_att_pots[i] - 32767) << 1);
|
leds->set_intensity_signed(i, volume_att_pots[i]);
|
||||||
leds->set_blinking(i, volume_att_pots[i] - 32767 < 0);
|
|
||||||
} else if (potControllers[i + kNumChannels].editing_hidden_parameter()) {
|
} else if (potControllers[i + kNumChannels].editing_hidden_parameter()) {
|
||||||
leds->set_intensity(i, abs(pan_att_pots[i] - 32767) << 1);
|
leds->set_intensity_signed(i, pan_att_pots[i] - 32767);
|
||||||
leds->set_blinking(i, pan_att_pots[i] - 32767 < 0);
|
|
||||||
} else {
|
} else {
|
||||||
if (system_clock.milliseconds() - last_vol_pot_touch[i] < kShowChangedValueMilliseconds) {
|
// TODO: refactor
|
||||||
// show volume
|
if (system_clock.milliseconds() - last_pan_pot_touch[i] < kShowChangedValueMilliseconds) {
|
||||||
leds->set_intensity(i, volume_pots[i]);
|
|
||||||
leds->set_blinking(i, false);
|
|
||||||
} else if (system_clock.milliseconds() - last_pan_pot_touch[i] < kShowChangedValueMilliseconds) {
|
|
||||||
// show panning
|
// show panning
|
||||||
leds->set_intensity(i, abs(pan_pots[i] - 32767) << 1);
|
leds->set_intensity_signed(i, pan_pots[i] - 32767);
|
||||||
leds->set_blinking(i, pan_pots[i] - 32767 < 0);
|
|
||||||
} else {
|
} else {
|
||||||
// show volume if not muted
|
// show volume if not muted
|
||||||
leds->set_intensity(i, processors[i].linear_volume());
|
leds->set_intensity_unsigned(i, processors[i].linear_volume(), processors[i].is_muted() ? LED_COLOR_RED : LED_COLOR_GREEN);
|
||||||
leds->set_blinking(i, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue