From fd3790519a1acc46355f35e32ad88a426d46aa90 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sat, 9 Aug 2014 17:05:17 +0200 Subject: [PATCH 1/5] new compile option NANO=YES triggers usage of newlib-nano when linking ARM code. --- radio/src/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/radio/src/Makefile b/radio/src/Makefile index 205928d93..d375a7b02 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -1116,6 +1116,12 @@ MATH_LIB = -lm LDFLAGS = -Wl,-Map=$(TARGET).map,--cref LDFLAGS += $(MATH_LIB) + +ifeq ($(NANO), YES) +#use newlib-nano for linking +NEWLIB_NANO_FLAGS = --specs=nano.specs -u _printf_float +endif + # Define Messages # English MSG_BEGIN = -------- begin -------- @@ -1389,7 +1395,7 @@ OBJS = $(TMP:.s=.o) @echo @echo $(MSG_COMPILING) $@ $(CC) $(ARMCPPFLAGS) $< -o allsrc.o - $(CC) $(OBJS) allsrc.o -mcpu=cortex-m3 -mthumb -nostartfiles -lm -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch,--gc-sections -o $@ + $(CC) $(OBJS) allsrc.o -mcpu=cortex-m3 -mthumb -nostartfiles -lm -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch,--gc-sections $(NEWLIB_NANO_FLAGS) -o $@ endif # Target: clean project. From 07728782c851e89772b52abd14c42643c3231cb9 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sat, 9 Aug 2014 17:37:04 +0200 Subject: [PATCH 2/5] Fixes #1538: Lua playFile(): current language sound path added to the file name in case of a relative path --- radio/src/audio_arm.cpp | 3 +++ radio/src/audio_arm.h | 2 ++ radio/src/lua.cpp | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/radio/src/audio_arm.cpp b/radio/src/audio_arm.cpp index 1b69b1783..24b519f14 100644 --- a/radio/src/audio_arm.cpp +++ b/radio/src/audio_arm.cpp @@ -850,6 +850,9 @@ void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id) { #if defined(SIMU) printf("playFile(\"%s\", flags=%x, id=%d)\n", filename, flags, id); + if (strlen(filename) > AUDIO_FILENAME_MAXLEN) { + TRACE("file name too long! maximum length is %d characters", AUDIO_FILENAME_MAXLEN); + } fflush(stdout); #else diff --git a/radio/src/audio_arm.h b/radio/src/audio_arm.h index 756352c3c..187f46e58 100644 --- a/radio/src/audio_arm.h +++ b/radio/src/audio_arm.h @@ -348,6 +348,8 @@ void pushPrompt(uint16_t prompt, uint8_t id=0); #define START_SILENCE_PERIOD() #endif +char * getAudioPath(char * path); + void referenceSystemAudioFiles(); void referenceModelAudioFiles(); diff --git a/radio/src/lua.cpp b/radio/src/lua.cpp index 25d3b8512..2d3a86011 100644 --- a/radio/src/lua.cpp +++ b/radio/src/lua.cpp @@ -261,6 +261,15 @@ static int luaGetValue(lua_State *L) static int luaPlayFile(lua_State *L) { const char * filename = luaL_checkstring(L, 1); + if (filename[0] != '/') { + // relative sound file path - use current languague dir for absolute path + char file[AUDIO_FILENAME_MAXLEN+1]; + char * str = getAudioPath(file); + strncpy(str, filename, AUDIO_FILENAME_MAXLEN - (str-file)); + file[AUDIO_FILENAME_MAXLEN] = 0; + PLAY_FILE(file, 0, 0); + return 0; + } PLAY_FILE(filename, 0, 0); return 0; } From e13f2913dff71412b958e44014b76f3d7fbd6038 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sat, 9 Aug 2014 18:04:48 +0200 Subject: [PATCH 3/5] Fixes #1540: added Lua playDuration() --- radio/src/lua.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/radio/src/lua.cpp b/radio/src/lua.cpp index 2d3a86011..f4fabfe20 100644 --- a/radio/src/lua.cpp +++ b/radio/src/lua.cpp @@ -283,6 +283,14 @@ static int luaPlayNumber(lua_State *L) return 0; } +static int luaPlayDuration(lua_State *L) +{ + int duration = luaL_checkinteger(L, 1); + bool playTime = (luaL_checkinteger(L, 2) != 0); + playDuration(duration, playTime ? PLAY_TIME : 0, 0); + return 0; +} + static int luaKillEvents(lua_State *L) { int event = luaL_checkinteger(L, 1); @@ -1363,6 +1371,7 @@ void luaInit() lua_register(L, "playFile", luaPlayFile); lua_register(L, "playNumber", luaPlayNumber); + lua_register(L, "playDuration", luaPlayDuration); lua_register(L, "popupInput", luaPopupInput); lua_register(L, "defaultStick", luaDefaultStick); lua_register(L, "defaultChannel", luaDefaultChannel); From c813cacb1b595d9b206deaaca51150aaaa4d7fcb Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sat, 9 Aug 2014 20:19:01 +0200 Subject: [PATCH 4/5] (reverted from commit fd3790519a1acc46355f35e32ad88a426d46aa90) newlib-nano on my comp has a malloc/free bug, memory gets used but not freed --- radio/src/Makefile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/radio/src/Makefile b/radio/src/Makefile index d375a7b02..205928d93 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -1116,12 +1116,6 @@ MATH_LIB = -lm LDFLAGS = -Wl,-Map=$(TARGET).map,--cref LDFLAGS += $(MATH_LIB) - -ifeq ($(NANO), YES) -#use newlib-nano for linking -NEWLIB_NANO_FLAGS = --specs=nano.specs -u _printf_float -endif - # Define Messages # English MSG_BEGIN = -------- begin -------- @@ -1395,7 +1389,7 @@ OBJS = $(TMP:.s=.o) @echo @echo $(MSG_COMPILING) $@ $(CC) $(ARMCPPFLAGS) $< -o allsrc.o - $(CC) $(OBJS) allsrc.o -mcpu=cortex-m3 -mthumb -nostartfiles -lm -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch,--gc-sections $(NEWLIB_NANO_FLAGS) -o $@ + $(CC) $(OBJS) allsrc.o -mcpu=cortex-m3 -mthumb -nostartfiles -lm -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch,--gc-sections -o $@ endif # Target: clean project. From 3152ac1121890f4c53f9d6106192fccc786fa5d6 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sat, 9 Aug 2014 20:24:21 +0200 Subject: [PATCH 5/5] Fixes #1532: added Lua playTone() --- radio/src/lua.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/radio/src/lua.cpp b/radio/src/lua.cpp index f4fabfe20..3fb256ff3 100644 --- a/radio/src/lua.cpp +++ b/radio/src/lua.cpp @@ -291,6 +291,17 @@ static int luaPlayDuration(lua_State *L) return 0; } +static int luaPlayTone(lua_State *L) +{ + int frequency = luaL_checkinteger(L, 1); + int length = luaL_checkinteger(L, 2); + int pause = luaL_checkinteger(L, 3); + int flags = luaL_optinteger(L, 4, 0); + int freqIncr = luaL_optinteger(L, 5, 0); + audioQueue.playTone(frequency, length, pause, flags, freqIncr); + return 0; +} + static int luaKillEvents(lua_State *L) { int event = luaL_checkinteger(L, 1); @@ -1372,6 +1383,7 @@ void luaInit() lua_register(L, "playFile", luaPlayFile); lua_register(L, "playNumber", luaPlayNumber); lua_register(L, "playDuration", luaPlayDuration); + lua_register(L, "playTone", luaPlayTone); lua_register(L, "popupInput", luaPopupInput); lua_register(L, "defaultStick", luaDefaultStick); lua_register(L, "defaultChannel", luaDefaultChannel); @@ -1424,6 +1436,8 @@ void luaInit() lua_registerint(L, "DOTTED", DOTTED); lua_registerint(L, "LCD_W", LCD_W); lua_registerint(L, "LCD_H", LCD_H); + lua_registerint(L, "PLAY_NOW", PLAY_NOW); + lua_registerint(L, "PLAY_BACKGROUND", PLAY_BACKGROUND); } void luaFree(ScriptInternalData & sid)