- chirp_stop() implemented

- chirps stop playing when ESC or F5
This commit is contained in:
2022-12-28 16:09:11 +01:00
parent 40c2b009a9
commit 97902594ad
5 changed files with 21 additions and 1 deletions

View File

@@ -151,3 +151,8 @@ int32_t interpret_next_token(uint8_t* buffer) {
return 0; return 0;
}; };
} }
void chirp_stop() {
audio_state=AUDIO_NONE;
audio_lock=false;
}

View File

@@ -6,3 +6,5 @@ void chirp_init();
void chirp_play(const char* new_song, const bool lock); void chirp_play(const char* new_song, const bool lock);
int32_t interpret_next_token(uint8_t* buffer); int32_t interpret_next_token(uint8_t* buffer);
void chirp_stop();

View File

@@ -657,6 +657,11 @@ extern "C" {
return 0; return 0;
} }
static int cpp_stopchirp(lua_State *L) {
stopchirp();
return 0;
}
static int cpp_exit(lua_State *L) { static int cpp_exit(lua_State *L) {
exit(); exit();
return 0; return 0;
@@ -759,6 +764,7 @@ void push_lua_funcs() {
lua_pushcfunction(L,cpp_freadb); lua_setglobal(L, "freadb"); lua_pushcfunction(L,cpp_freadb); lua_setglobal(L, "freadb");
lua_pushcfunction(L,cpp_playchirp); lua_setglobal(L, "playchirp"); lua_pushcfunction(L,cpp_playchirp); lua_setglobal(L, "playchirp");
lua_pushcfunction(L,cpp_stopchirp); lua_setglobal(L, "stopchirp");
lua_pushcfunction(L,cpp_exit); lua_setglobal(L, "quit"); lua_pushcfunction(L,cpp_exit); lua_setglobal(L, "quit");

View File

@@ -217,6 +217,7 @@ int main(int argc,char*argv[]){
if (mini_eve.type == SDL_QUIT) { should_exit=true; should_quit=true; break; } if (mini_eve.type == SDL_QUIT) { should_exit=true; should_quit=true; break; }
if (mini_eve.type == SDL_KEYDOWN) { if (mini_eve.type == SDL_KEYDOWN) {
if (mini_eve.key.keysym.scancode == SDL_SCANCODE_ESCAPE) { if (mini_eve.key.keysym.scancode == SDL_SCANCODE_ESCAPE) {
chirp_stop();
if (lua_is_playing()) { if (lua_is_playing()) {
lua_quit(); lua_quit();
quitaudio(); quitaudio();
@@ -228,6 +229,7 @@ int main(int argc,char*argv[]){
//lua_call_init(); //lua_call_init();
} }
} else if (mini_eve.key.keysym.scancode == SDL_SCANCODE_F5) { } else if (mini_eve.key.keysym.scancode == SDL_SCANCODE_F5) {
chirp_stop();
should_exit=true; should_exit=true;
//lua_quit(); //lua_quit();
//reinit(); //reinit();
@@ -987,6 +989,10 @@ void playchirp(const char *song, const bool lock) {
chirp_play(song, lock); chirp_play(song, lock);
} }
void stopchirp() {
chirp_stop();
}
void exit() { void exit() {
should_exit = true; should_exit = true;
} }

1
mini.h
View File

@@ -258,5 +258,6 @@ const char *freadw();
bool freadb(); bool freadb();
void playchirp(const char *song, const bool lock); void playchirp(const char *song, const bool lock);
void stopchirp();
void exit(); void exit();