Update stereo_mix to new hardware revision

This commit is contained in:
Jan-Henrik 2020-07-16 20:47:55 +02:00
parent 32477861d8
commit a71be667fb
18 changed files with 7555 additions and 2785 deletions

View file

@ -38,15 +38,7 @@ class Adc {
inline int16_t cv_value(AdcChannel channel)
{
#ifdef NEW_HARDWARE
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
return -(this->values_[ADC_GROUP_CV + channel] - 32768);
}
inline uint16_t value(int32_t channel) const

View file

@ -10,8 +10,8 @@ namespace stereo_mix {
GPIO_TypeDef* kMDacPorts[] = { GPIOB, GPIOB, GPIOB, GPIOB };
const uint16_t kMDacPins[] = { GPIO_PIN_8, GPIO_PIN_9, GPIO_PIN_10, GPIO_PIN_11 };
GPIO_TypeDef* kOffsetDacPorts[] = { GPIOA, GPIOA, GPIOA, GPIOA };
const uint16_t kOffsetDacPins[] = { GPIO_PIN_8, GPIO_PIN_9, GPIO_PIN_10, GPIO_PIN_11 };
GPIO_TypeDef* kOffsetDacPorts[] = { GPIOA, GPIOB, GPIOB, GPIOC };
const uint16_t kOffsetDacPins[] = { GPIO_PIN_15, GPIO_PIN_7, GPIO_PIN_15, GPIO_PIN_13 };
class Dacs { // MCP4xx2 dac implementation
public:
@ -19,6 +19,7 @@ class Dacs { // MCP4xx2 dac implementation
{
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_SPI1_CLK_ENABLE();
HAL_NVIC_SetPriority(SPI1_IRQn, 0, 0);

View file

@ -1,74 +1,140 @@
#pragma once
#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 "stm32f0xx_hal_gpio.h"
#include <stm32f0xx_hal.h>
#include <math.h>
using namespace stereo_mix;
using namespace stmlib;
enum LedColor {
LED_COLOR_GREEN,
LED_COLOR_RED,
LED_COLOR_ORANGE
};
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[] = { GPIOB, GPIOB, GPIOC, GPIOC };
static GPIO_TypeDef* kGpioPorts[] = { GPIOA, GPIOA, GPIOA, GPIOA };
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 {
public:
Leds()
{
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
GPIO_InitTypeDef gpioInit;
for (size_t i = 0; i < kNumChannels; i++) {
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.Pull = GPIO_NOPULL;
gpioInit.Speed = GPIO_SPEED_FREQ_MEDIUM;
gpioInit.Alternate = GPIO_AF2_TIM1;
HAL_GPIO_Init(kGpioPorts[i], &gpioInit);
}
intensities[i] = 0;
blinking[i] = false;
}
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
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()
{
#ifdef DEBUG_PIN
for (size_t i = 0; i < kNumChannels - 1; i++) {
#else
for(size_t i = 0; i < kNumChannels; i++) {
LedColor targetColor = colors[i];
uint16_t intensity = intensities[i];
if(colors[i] == LED_COLOR_ORANGE) {
if(toggle[i]) targetColor = LED_COLOR_RED;
else targetColor = LED_COLOR_GREEN;
toggle[i] = !toggle[i];
}
#endif
bool in_blink_phase = blink_counter > (0x2000 / 2) || !blinking[i];
if (intensities[i] && lut_led_gamma[intensities[i] >> 8] >= pwm_counter && in_blink_phase) {
kGpioPorts[i]->BSRR |= kGpioPins[i];
if(targetColor == LED_COLOR_RED) {
HAL_GPIO_WritePin(kGpioColorPorts[i], kGpioColorPins[i], GPIO_PIN_SET);
intensity = 65534 - lut_led_red_gamma[intensity >> 4];
} 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 {
kGpioPorts[i]->BRR |= kGpioPins[i];
}
}
pwm_counter++;
blink_counter++;
if(blink_counter > 0x2000) blink_counter = 0;
colors[channel] = LED_COLOR_GREEN;
intensities[channel] = (intensity) << 1;
}
}
void set_intensity(uint8_t channel, uint16_t intensity)
void set_intensity_unsigned(uint8_t channel, uint16_t intensity, LedColor color)
{
if (channel >= kNumChannels)
return;
intensities[channel] = intensity;
}
void set_blinking(uint8_t channel, bool blink)
{
if (channel >= kNumChannels)
return;
blinking[channel] = blink;
colors[channel] = color;
}
private:
uint8_t pwm_counter;
uint16_t blink_counter;
uint16_t intensities[kNumChannels];
bool blinking[kNumChannels];
bool toggle[kNumChannels];
LedColor colors[kNumChannels];
};

View file

@ -3,6 +3,7 @@
ADC_HandleTypeDef hadc1 = { .Instance = ADC1 };
DMA_HandleTypeDef hdma1_channel1 = { .Instance = DMA1_Channel1 };
SPI_HandleTypeDef hspi1 = { .Instance = SPI1 };
TIM_HandleTypeDef htim1 = { .Instance = TIM1 };
TIM_HandleTypeDef htim3 = { .Instance = TIM3 };
TIM_HandleTypeDef htim6 = { .Instance = TIM6 };

View file

@ -5,6 +5,7 @@
extern ADC_HandleTypeDef hadc1;
extern DMA_HandleTypeDef hdma1_channel1;
extern SPI_HandleTypeDef hspi1;
extern TIM_HandleTypeDef htim1;
extern TIM_HandleTypeDef htim3;
extern TIM_HandleTypeDef htim6;

View file

@ -1,21 +1,22 @@
Comment,Designator,Footprint,LCSC Part #
1.0nF,C19 C20 C21 C22 C67 C68 C69 C70,C0402,
1k,R95 R96,R0402,
4.7nF,C19 C20 C21 C22,C0402,
8MHz,X1,NX5032,
10k,R85,R0402,
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,
15k,R9 R10 R11 R12 R41 R42 R43 R44,R0402,
20k,R73 R74 R75 R76 R97 R98 R99 R100,R0402,
22pF,C26 C27,C0402,
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,R0402,
47k,R13 R14 R15 R16 R17 R18 R19 R20 R45 R46 R47 R48 R49 R50 R51 R52 R86 R87,R0402,
91k,R1 R3 R5 R7 R33 R35 R37 R39,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,
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,
300k,R23 R25 R26 R28 R57 R58 R59 R60,R0402,
470R,R90,R0402,

1 Comment Designator Footprint LCSC Part #
2 1.0nF C19 C20 C21 C22 C67 C68 C69 C70 C0402
3 1k R95 R96 R0402
4.7nF C19 C20 C21 C22 C0402
4 8MHz X1 NX5032
5 10k R85 R0402
6 10uF C37 C38 C39 C41 CASE-A_3216
7 10uF C49 C50 C51 C52 C53 C54 C55 C56 C0402 C0805
8 10uF C65 C66 CASE-A_3216
9 15k R9 R10 R11 R12 R41 R42 R43 R44 R0402
10 20k R73 R74 R75 R76 R97 R98 R99 R100 R0402
11 22pF C26 C27 C0402
12 22uF C47 C48 C0805
13 33k 47k R73 R74 R75 R76 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
14 91k R1 R3 R5 R7 R33 R35 R37 R39 R0402
15 100R R91 R92 R93 R94 R0402
16 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 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
17 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
18 200k 120k R65 R67 R69 R71 R77 R78 R79 R80 R65 R67 R69 R71 R81 R82 R83 R101 R0402
19 200k R77 R78 R79 R80 R0402
20 220pF C32 C33 C0402
21 300k R23 R25 R26 R28 R57 R58 R59 R60 R0402
22 470R R90 R0402

View file

@ -11,7 +11,7 @@ C9, 3.18,88.58,Bottom,90.0
C10, 3.18,66.99,Bottom,90.0
C11, 3.18,45.40,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
C15,62.87,98.43,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
C28,42.23, 6.67,Bottom,0.0
C29,32.38,15.88,Bottom,180.0
C30,43.50, 8.89,Bottom,90.0
C31,57.79,37.47,Bottom,180.0
C30,43.60, 8.89,Bottom,90.0
C31,31.12,45.72,Bottom,0.0
C32,18.10,14.61,Bottom,0.0
C33, 7.30,13.34,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
C41,45.40, 6.03,Bottom,270.0
C42,45.40, 1.27,Bottom,180.0
C43,55.56,84.77,Bottom,270.0
C44,55.56,63.18,Bottom,270.0
C43,56.36,84.77,Bottom,270.0
C44,56.83,63.18,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
C48,58.42, 6.67,Bottom,0.0
C49,54.29,84.77,Bottom,270.0
C50,54.29,63.18,Bottom,270.0
C51,54.29,41.59,Bottom,270.0
C52,54.93,17.78,Bottom,270.0
C53,57.79,98.43,Bottom,180.0
C54,62.87,78.11,Bottom,180.0
C55,62.87,56.52,Bottom,180.0
C56,55.56,31.75,Bottom,0.0
C49,56.20,80.80,Bottom,0.0
C50,56.83,59.05,Bottom,0.0
C51,56.83,37.78,Bottom,0.0
C52,53.34,20.64,Bottom,270.0
C53,56.83,98.58,Bottom,180.0
C54,62.87,78.74,Bottom,180.0
C55,62.87,57.15,Bottom,180.0
C56,61.12,34.29,Bottom,180.0
C57,59.69,85.09,Bottom,180.0
C58,59.69,63.50,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
C65, 5.71, 2.54,Bottom,0.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
D2,31.12, 2.86,Bottom,180.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
R1, 6.99,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
R82,22.23,63.50,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
R86, 5.71, 1.27,Bottom,180.0
R87,12.07, 1.27,Bottom,0.0
R88,17.78,13.34,Bottom,0.0
R89, 7.62,12.07,Bottom,0.0
R90,23.50, 2.86,Bottom,0.0
R91,49.53,79.06,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
R95, 1.91, 2.54,Bottom,180.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
U2,60.96,73.66,Bottom,270.0
U3, 6.35,90.17,Bottom,0.0
U4, 6.35,68.58,Bottom,0.0
U5,50.16,90.17,Bottom,180.0
U6,50.16,68.58,Bottom,180.0
U5,50.16,90.81,Bottom,180.0
U6,50.16,69.22,Bottom,180.0
U7,35.88,96.52,Bottom,270.0
U8,35.56,74.93,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
U12, 6.35,25.40,Bottom,0.0
U13,50.16,46.99,Bottom,180.0
U14,50.16,22.86,Bottom,180.0
U13,50.16,47.63,Bottom,180.0
U14,50.16,26.67,Bottom,180.0
U15,35.56,53.34,Bottom,270.0
U16,35.56,31.75,Bottom,270.0
U17,20.32,90.17,Bottom,0.0

1 Designator Mid X Mid Y Layer Rotation
11 C10 3.18 66.99 Bottom 90.0
12 C11 3.18 45.40 Bottom 90.0
13 C12 3.18 23.50 Bottom 90.0
14 C13 55.56 64.66 33.02 33.76 Bottom 0.0
15 C14 62.87 55.25 Bottom 180.0
16 C15 62.87 98.43 Bottom 180.0
17 C16 62.87 76.84 Bottom 180.0
28 C27 36.83 1.27 Bottom 180.0
29 C28 42.23 6.67 Bottom 0.0
30 C29 32.38 15.88 Bottom 180.0
31 C30 43.50 43.60 8.89 Bottom 90.0
32 C31 57.79 31.12 37.47 45.72 Bottom 180.0 0.0
33 C32 18.10 14.61 Bottom 0.0
34 C33 7.30 13.34 Bottom 0.0
35 C34 14.61 9.53 Bottom 0.0
40 C40 20.32 5.40 Bottom 180.0
41 C41 45.40 6.03 Bottom 270.0
42 C42 45.40 1.27 Bottom 180.0
43 C43 55.56 56.36 84.77 Bottom 270.0
44 C44 55.56 56.83 63.18 Bottom 270.0
45 C45 55.56 41.59 Bottom 270.0
46 C46 56.20 55.09 17.78 20.80 Bottom 270.0
47 C47 29.21 7.62 Bottom 270.0
48 C48 58.42 6.67 Bottom 0.0
49 C49 54.29 56.20 84.77 80.80 Bottom 270.0 0.0
50 C50 54.29 56.83 63.18 59.05 Bottom 270.0 0.0
51 C51 54.29 56.83 41.59 37.78 Bottom 270.0 0.0
52 C52 54.93 53.34 17.78 20.64 Bottom 270.0
53 C53 57.79 56.83 98.43 98.58 Bottom 180.0
54 C54 62.87 78.11 78.74 Bottom 180.0
55 C55 62.87 56.52 57.15 Bottom 180.0
56 C56 55.56 61.12 31.75 34.29 Bottom 0.0 180.0
57 C57 59.69 85.09 Bottom 180.0
58 C58 59.69 63.50 Bottom 180.0
59 C59 59.69 41.91 Bottom 180.0
64 C64 38.10 20.32 Bottom 180.0
65 C65 5.71 2.54 Bottom 0.0
66 C66 12.07 2.54 Bottom 180.0
67 C67 19.69 85.09 Bottom 90.0
68 C68 19.69 63.50 Bottom 90.0
69 C69 19.69 41.91 Bottom 90.0
70 C70 19.69 20.32 Bottom 90.0
71 D1 58.74 12.70 Bottom 0.0
72 D2 31.12 2.86 Bottom 180.0
73 D3 20.32 2.54 Bottom 0.0
74 IC1 63.18 31.75 33.02 40.01 Bottom 270.0
75 IC2 50.80 3.81 Bottom 0.0
76 R1 6.99 95.25 Bottom 270.0
77 R2 5.71 95.25 Bottom 270.0
156 R81 22.23 85.09 Bottom 90.0
157 R82 22.23 63.50 Bottom 90.0
158 R83 22.23 41.91 Bottom 90.0
R84 22.23 20.32 Bottom 90.0
159 R85 53.98 8.26 Bottom 270.0
160 R86 5.71 1.27 Bottom 180.0
161 R87 12.07 1.27 Bottom 0.0
162 R88 17.78 13.34 Bottom 0.0
163 R89 7.62 12.07 Bottom 0.0
164 R90 23.50 2.86 Bottom 0.0
165 R91 49.53 79.06 Bottom 0.0
166 R92 49.53 57.47 Bottom 0.0
167 R93 49.53 50.24 35.88 35.27 Bottom 0.0
168 R94 49.85 14.29 Bottom 0.0
169 R95 1.91 2.54 Bottom 180.0
170 R96 15.88 2.54 Bottom 0.0
171 R97 18.41 85.09 Bottom 90.0
172 R98 18.41 63.50 Bottom 90.0
173 R99 18.41 41.91 Bottom 90.0
174 R100 18.41 20.32 Bottom 90.0
175 R101 22.23 20.32 Bottom 90.0
176 U1 60.96 95.25 Bottom 270.0
177 U2 60.96 73.66 Bottom 270.0
178 U3 6.35 90.17 Bottom 0.0
179 U4 6.35 68.58 Bottom 0.0
180 U5 50.16 90.17 90.81 Bottom 180.0
181 U6 50.16 68.58 69.22 Bottom 180.0
182 U7 35.88 96.52 Bottom 270.0
183 U8 35.56 74.93 Bottom 270.0
184 U9 60.96 52.07 Bottom 270.0
185 U10 50.16 60.96 30.48 Bottom 270.0
186 U11 6.35 46.99 Bottom 0.0
187 U12 6.35 25.40 Bottom 0.0
188 U13 50.16 46.99 47.63 Bottom 180.0
189 U14 50.16 22.86 26.67 Bottom 180.0
190 U15 35.56 53.34 Bottom 270.0
191 U16 35.56 31.75 Bottom 270.0
192 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

View file

@ -25,7 +25,6 @@ void Processor::Process(int16_t cvs[], uint16_t* outs)
// calculate value for ui
int32_t lin = vol_offset + (vol_cv << 3) * 3;
lin = ClipU16(lin);
lin *= !mute;
this->linear_vol = lin;
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);
this->previous_vol = vol;
int32_t pan_cv = (cv_input_pan * static_cast<int32_t>(pan_att)) >> 15; // full attenuate gives 2x amplification :)
pan_cv = Clip16(pan_cv);
int32_t pan = pan_pot + ((pan_cv) * 2);

View file

@ -30,12 +30,15 @@ class Processor {
mute = m;
}
inline bool is_muted() {
return mute;
}
uint16_t linear_volume() {
return linear_vol;
}
private:
uint16_t previous_vol;
uint16_t linear_vol;
int16_t cv_input_pan = 0;
@ -45,7 +48,7 @@ class Processor {
int16_t pan_offset = 0;
int16_t vol_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

File diff suppressed because it is too large Load diff

View file

@ -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_left_sin_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_SIZE 4096
#define LUT_LEFT_SIN_PAN 1
#define LUT_LEFT_SIN_PAN_SIZE 4096
#define LUT_RIGHT_COS_PAN 2
#define LUT_RIGHT_COS_PAN_SIZE 4096
#define LUT_LED_GAMMA 3
#define LUT_LED_GAMMA_SIZE 256
#define LUT_LED_RED_GAMMA 3
#define LUT_LED_RED_GAMMA_SIZE 4096
#define LUT_LED_GREEN_GAMMA 4
#define LUT_LED_GREEN_GAMMA_SIZE 4096
} // namespace stereo_mix

View file

@ -52,9 +52,12 @@ lookup_tables_u16.append(('right_cos_pan', r_pan))
print(r_pan.size)
# led gamma correction
gamma = 2.4
max_in = 255
max_out = 255
gamma_green = 2.4
gamma_red = 2.8
max_in = 4095
max_out = 65535
input_vals = np.linspace(0, max_in, num=max_in + 1)
gamma_correction = ((input_vals / max_in) ** gamma) * max_out + 0.5
lookup_tables_u16.append(('led_gamma', np.floor(gamma_correction)))
gamma_correction_red = ((input_vals / max_in) ** gamma_red) * max_out + 0.5
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)))

View file

@ -127,15 +127,16 @@ void Init(void)
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_TIM1_CLK_ENABLE();
__HAL_RCC_TIM3_CLK_ENABLE();
__HAL_RCC_TIM6_CLK_ENABLE();
__HAL_RCC_SPI1_CLK_ENABLE();
HAL_NVIC_SetPriority(TIM3_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM3_IRQn);
htim3.Init.Prescaler = 8;
htim3.Init.Prescaler = 27;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 128;
htim3.Init.Period = 65535 >> 2;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.RepetitionCounter = 0;
HAL_TIM_Base_Init(&htim3);
@ -177,7 +178,6 @@ int main(void)
Init();
ui.Init();
while (true) {
ui.DoEvents();
}

View file

@ -3,7 +3,7 @@
#include <stm32f0xx_hal.h>
const int kLongPressDuration = 2000;
const int kShowChangedValueMilliseconds = 1000;
const int kShowChangedValueMilliseconds = 600;
void UI::Poll()
{
@ -99,24 +99,17 @@ void UI::TaskDrawLeds()
{
for (size_t i = 0; i < kNumChannels; i++) {
if (potControllers[i].editing_hidden_parameter()) {
leds->set_intensity(i, abs(volume_att_pots[i] - 32767) << 1);
leds->set_blinking(i, volume_att_pots[i] - 32767 < 0);
leds->set_intensity_signed(i, volume_att_pots[i]);
} else if (potControllers[i + kNumChannels].editing_hidden_parameter()) {
leds->set_intensity(i, abs(pan_att_pots[i] - 32767) << 1);
leds->set_blinking(i, pan_att_pots[i] - 32767 < 0);
leds->set_intensity_signed(i, pan_att_pots[i] - 32767);
} else {
if (system_clock.milliseconds() - last_vol_pot_touch[i] < kShowChangedValueMilliseconds) {
// show volume
leds->set_intensity(i, volume_pots[i]);
leds->set_blinking(i, false);
} else if (system_clock.milliseconds() - last_pan_pot_touch[i] < kShowChangedValueMilliseconds) {
// TODO: refactor
if (system_clock.milliseconds() - last_pan_pot_touch[i] < kShowChangedValueMilliseconds) {
// show panning
leds->set_intensity(i, abs(pan_pots[i] - 32767) << 1);
leds->set_blinking(i, pan_pots[i] - 32767 < 0);
leds->set_intensity_signed(i, pan_pots[i] - 32767);
} else {
// show volume if not muted
leds->set_intensity(i, processors[i].linear_volume());
leds->set_blinking(i, false);
leds->set_intensity_unsigned(i, processors[i].linear_volume(), processors[i].is_muted() ? LED_COLOR_RED : LED_COLOR_GREEN);
}
}
}