mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-07-29 16:29:17 +02:00
af is in lua now
This commit is contained in:
@@ -263,6 +263,51 @@ int lua_get_rds_grpseq(lua_State *localL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lua_set_rds_af_group0(lua_State *localL) {
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
|
||||
int n = lua_rawlen(L, 1);
|
||||
if (n == 0) {
|
||||
memset(&(mod->enc->data[mod->enc->program].af), 0, sizeof(RDSAFs));
|
||||
return 0;
|
||||
}
|
||||
if(n > 25) return luaL_error(L, "table length over 25");
|
||||
|
||||
RDSAFs new_af;
|
||||
memset(&new_af, 0, sizeof(RDSAFs));
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
lua_rawgeti(L, 1, i);
|
||||
if (lua_isnumber(L, -1)) add_rds_af(&new_af, lua_tonumber(L, -1));
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
memcpy(&(mod->enc->data[mod->enc->program].af), &new_af, sizeof(new_af));
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_set_rds_af_oda(lua_State *localL) {
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
|
||||
int n = lua_rawlen(L, 1);
|
||||
if (n == 0) {
|
||||
memset(&(mod->enc->data[mod->enc->program].af_oda), 0, sizeof(RDSAFsODA));
|
||||
return 0;
|
||||
}
|
||||
if(n > 25) return luaL_error(L, "table length over 25");
|
||||
|
||||
RDSAFsODA new_af;
|
||||
memset(&new_af, 0, sizeof(RDSAFsODA));
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
lua_rawgeti(L, 1, i);
|
||||
if (lua_isnumber(L, -1)) add_rds_af_oda(&new_af, lua_tonumber(L, -1));
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
memcpy(&(mod->enc->data[mod->enc->program].af_oda), &new_af, sizeof(new_af));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void init_lua(RDSModulator* rds_mod) {
|
||||
mod = rds_mod;
|
||||
L = luaL_newstate();
|
||||
@@ -367,6 +412,9 @@ void init_lua(RDSModulator* rds_mod) {
|
||||
|
||||
lua_register(L, "put_rds_custom_group", lua_put_rds_custom_group);
|
||||
lua_register(L, "put_rds2_custom_group", lua_put_rds2_custom_group);
|
||||
|
||||
lua_register(L, "set_rds_af_group0", lua_set_rds_af_group0);
|
||||
lua_register(L, "set_rds_af_oda", lua_set_rds_af_oda);
|
||||
}
|
||||
|
||||
void run_lua(char *str, char *cmd_output) {
|
||||
|
||||
Reference in New Issue
Block a user