I've written a small code to allow basic control of a buzzer and to play "melody" (using a compact format)
I'm putting the link here, if it can be useful to someone else.
https://github.com/sdalu/kakapo
buzzer player
Re: buzzer player
i get from ruby
kakapo.rb:184: syntax error, unexpected '.'
... return if delta_error&.< edlt # Ensure ac...
... ^
kakapo.rb:185: syntax error, unexpected '.'
return if pct_error&.< epct # Ensure ...
^
kakapo.rb:184: syntax error, unexpected '.'
... return if delta_error&.< edlt # Ensure ac...
... ^
kakapo.rb:185: syntax error, unexpected '.'
return if pct_error&.< epct # Ensure ...
^
kakapo.rb:184: syntax error, unexpected '.'
... return if delta_error&.< edlt # Ensure ac...
... ^
kakapo.rb:185: syntax error, unexpected '.'
return if pct_error&.< epct # Ensure ...
^
kakapo.rb:184: syntax error, unexpected '.'
... return if delta_error&.< edlt # Ensure ac...
... ^
kakapo.rb:185: syntax error, unexpected '.'
return if pct_error&.< epct # Ensure ...
^
i really hate ruby
kakapo.rb:184: syntax error, unexpected '.'
... return if delta_error&.< edlt # Ensure ac...
... ^
kakapo.rb:185: syntax error, unexpected '.'
return if pct_error&.< epct # Ensure ...
^
kakapo.rb:184: syntax error, unexpected '.'
... return if delta_error&.< edlt # Ensure ac...
... ^
kakapo.rb:185: syntax error, unexpected '.'
return if pct_error&.< epct # Ensure ...
^
kakapo.rb:184: syntax error, unexpected '.'
... return if delta_error&.< edlt # Ensure ac...
... ^
kakapo.rb:185: syntax error, unexpected '.'
return if pct_error&.< epct # Ensure ...
^
kakapo.rb:184: syntax error, unexpected '.'
... return if delta_error&.< edlt # Ensure ac...
... ^
kakapo.rb:185: syntax error, unexpected '.'
return if pct_error&.< epct # Ensure ...
^
i really hate ruby
Re: buzzer player
Hi.
You need to use ruby 2.3, due to the &. syntax and some of the Enumerable methods
Volume is currently not handled by the driver as it is not possible to control it by using only the pwm driver.
It would requires additional circuitry to control it using the voltage. If you can provide me with the schematic, I could add the code.
If I'm wrong let me now, as electronic is not my strength.
Sincerly
You need to use ruby 2.3, due to the &. syntax and some of the Enumerable methods
Volume is currently not handled by the driver as it is not possible to control it by using only the pwm driver.
It would requires additional circuitry to control it using the voltage. If you can provide me with the schematic, I could add the code.
If I'm wrong let me now, as electronic is not my strength.
Sincerly
Re: buzzer player
Dear sdalu,
I have some difficulties to make your kakapo library to work with my STM32F401 Nucleo based board. It successfully executes buzzer_init() but gets stuck at buzzer_melody, _ring, or _beep. If you kindly provide your main.c together with appropriate configuration files, e.g., halconf, mcuconf, and board.h), I will be appreciated.
Regards,
Renan
I have some difficulties to make your kakapo library to work with my STM32F401 Nucleo based board. It successfully executes buzzer_init() but gets stuck at buzzer_melody, _ring, or _beep. If you kindly provide your main.c together with appropriate configuration files, e.g., halconf, mcuconf, and board.h), I will be appreciated.
Regards,
Renan
Re: buzzer player
Hi,
That's what I'm using
(sorry for the delay, these times, I'm not actively reading the forum)
I'm using standard halconf/mcuconf for the STM32F042K6 with PWM enabled
That's what I'm using
(sorry for the delay, these times, I'm not actively reading the forum)
I'm using standard halconf/mcuconf for the STM32F042K6 with PWM enabled
Code: Select all
// PWM
static const PWMConfig pwm_cfg = {
.frequency = 1000000, /* 1MHz PWM clock frequency. */
.period = 250, /* Initial PWM period 250µs. */
.channels = {
{ .mode = PWM_OUTPUT_ACTIVE_HIGH },
}
};
// Buzzer
static const BuzzerConfig buzzer_cfg = {
.pwm = &PWMD1,
.channel = 0,
};
char melody_zelda[] = {
0xfa, 0xfa, 0xfd, 0x8d, 0x51, 0x02, 0x4a, 0x04,
0x4d, 0x02, 0x51, 0x02, 0x4a, 0x04, 0x4d, 0x02,
0x51, 0x01, 0x54, 0x01, 0x53, 0x02, 0x4f, 0x02,
0x4d, 0x01, 0x4f, 0x01, 0x51, 0x02, 0x4a, 0x02,
0x48, 0x01, 0x4c, 0x01, 0x4a, 0x83, 0x00, 0xff };
struct buzzer BZZR1;
main() {
palSetPadMode(GPIOA, 8, PAL_MODE_ALTERNATE(2));
pwmStart(&PWMD1, &pwm_cfg);
pwmDisableChannel(&PWMD1, 0);
buzzer_init (&BZZR1, &buzzer_cfg);
buzzer_melody(&BZZR1, melody_zelda);
}
Re: buzzer player
Hi,
With the help of the given configuration file, I managed to get it work. The problem was with my PWM configuration structure, but now it chirps perfectly
Thanks a lot.
Renan
With the help of the given configuration file, I managed to get it work. The problem was with my PWM configuration structure, but now it chirps perfectly
Thanks a lot.
Renan
Who is online
Users browsing this forum: No registered users and 44 guests