Update drone mute function + mosfet

This commit is contained in:
Daniele Lacamera 2020-04-24 23:50:43 +02:00
parent 3b2641fdcd
commit b43948ded3
3 changed files with 28 additions and 4 deletions

29
drone.c
View file

@ -7,6 +7,8 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "unicore-mx/stm32/gpio.h"
#include "unicore-mx/stm32/rcc.h"
#include "ui.h"
#include "timer.h"
#include "led.h"
@ -42,7 +44,9 @@ static struct drone_slot drone_pattern[MAX_PATTERN_LEN] = {
void drone_mute(void)
{
pot_set(0, 0);
pot_set(1, 99);
pot_set(1, 0);
gpio_clear(GPIOE, GPIO2);
gpio_clear(GPIOE, GPIO3);
}
void drone_beat(int pattern_pos)
@ -54,10 +58,18 @@ void drone_beat(int pattern_pos)
int lfo_rate = 7;
int lfo_step = 2;
int tgt_env;
if ((key->pitch == 0) && (key->env == 0)) {
pot_set(0, 99);
pot_set(1, 0);
gpio_clear(GPIOE, GPIO2);
gpio_clear(GPIOE, GPIO3);
return;
}
pot_set(0, 0);
pot_set(1, 99);
if ((key->pitch == 0) && (key->env == 0))
return;
gpio_set(GPIOE, GPIO2);
gpio_set(GPIOE, GPIO3);
if ((pattern_pos % lfo_step) == 0) {
if (test_lfo_step == 0) {
@ -85,3 +97,14 @@ void drone_beat(int pattern_pos)
pot_set(0, key->pitch);
pot_set(1, tgt_env);
}
#define TRIG_PIN (GPIO2 | GPIO3)
void drone_init(void)
{
rcc_periph_clock_enable(RCC_GPIOE);
gpio_mode_setup(GPIOE, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, TRIG_PIN);
gpio_set_output_options(GPIOE, GPIO_OTYPE_OD, GPIO_OSPEED_100MHZ, TRIG_PIN);
gpio_clear(GPIOE, TRIG_PIN);
}

1
main.c
View file

@ -71,6 +71,7 @@ static void bootlevel_1(void)
printf("UI initialized.\r\n");
timer_init();
drums_init();
drone_init();
drums_start();
printf("System up and running.\r\n\n\n");

2
pot.c
View file

@ -59,7 +59,7 @@ static void p_offset(int p, int offset)
/* /CS off first (no store) */
gpio_set(GPIOC,cs);
//WFI();
for (int j = 0; j < 4000; j++)
for (int j = 0; j < 1000; j++)
;;
}