26 lines
757 B
C
26 lines
757 B
C
#ifndef MELODY_H
|
|
#define MELODY_H
|
|
|
|
#include "stm32f1xx_hal.h"
|
|
#include "songs.h"
|
|
//#include "sounds.h"
|
|
|
|
typedef struct {
|
|
TIM_HandleTypeDef* htim;
|
|
uint32_t channel;
|
|
uint32_t timer_clock_hz; // частота тактирования таймера в Гц
|
|
Melody_t *melody;
|
|
uint16_t current_index;
|
|
uint32_t note_start_time;
|
|
uint8_t is_playing;
|
|
uint16_t bpm;
|
|
} MelodyHandle;
|
|
|
|
void Melody_Init(MelodyHandle* mh, TIM_HandleTypeDef* htim, uint32_t channel, uint32_t timer_clock_hz);
|
|
void Melody_SetBPM(MelodyHandle* mh, uint16_t bpm);
|
|
void Melody_Play(MelodyHandle* mh, Melody_t* melody, uint16_t bpm);
|
|
void Melody_Stop(MelodyHandle* mh);
|
|
void Melody_Update(MelodyHandle* mh);
|
|
uint8_t Melody_IsPlaying(MelodyHandle* mh);
|
|
|
|
#endif |