mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-07-29 08:19:17 +02:00
quite a lot of stuff, can't list them all here (approaching 1.9)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
hooks.registered_groups = {}
|
||||
|
||||
function hooks.group(group)
|
||||
if hooks.registered_groups[group] then
|
||||
local ok, generated, b, c, d = pcall(hooks.registered_groups[group], group)
|
||||
if ok then return generated, b, c, d
|
||||
else
|
||||
print(generated)
|
||||
return false, 0, 0, 0
|
||||
end
|
||||
end
|
||||
return false, 0, 0, 0
|
||||
end
|
||||
|
||||
---@param designator string
|
||||
---@param handler function
|
||||
function rds.ext.register_group(designator, handler)
|
||||
for i = 1, #designator do
|
||||
local char = designator:sub(i, i)
|
||||
hooks.registered_groups[char] = handler
|
||||
end
|
||||
end
|
||||
@@ -51,7 +51,7 @@ function ext.set_oda_handler_rds2(oda_id, func)
|
||||
_RDS2_ODAs[oda_id].handler = func
|
||||
end
|
||||
|
||||
function rds2_group(stream)
|
||||
function hooks.rds2_group(stream)
|
||||
if #_RDS2_ODAs == 0 then return false, 0, 0, 0, 0 end
|
||||
|
||||
if _RDS2_ODA_pointer > #_RDS2_ODAs then _RDS2_ODA_pointer = 1 end
|
||||
|
||||
@@ -112,16 +112,14 @@ local function get_data()
|
||||
return false, 0, 0, 0
|
||||
end
|
||||
|
||||
function group(group_type)
|
||||
if group_type == "O" or group_type == "K" then
|
||||
if #_RDS_ODAs == 0 then return false, 0, 0, 0 end
|
||||
if _RDS_ODA_pointer > #_RDS_ODAs or _RDS_ODA_pointer < 1 then _RDS_ODA_pointer = 1 end
|
||||
local function group_handler(group_type)
|
||||
if #_RDS_ODAs == 0 then return false, 0, 0, 0 end
|
||||
if _RDS_ODA_pointer > #_RDS_ODAs or _RDS_ODA_pointer < 1 then _RDS_ODA_pointer = 1 end
|
||||
|
||||
if group_type == "O" then return get_aid()
|
||||
elseif group_type == "K" then return get_data() end
|
||||
end
|
||||
return false, 0, 0, 0
|
||||
if group_type == "O" then return get_aid()
|
||||
elseif group_type == "K" then return get_data() end
|
||||
end
|
||||
rds.ext.register_group("OK", group_handler)
|
||||
|
||||
table.insert(hooks.on_state, function ()
|
||||
_RDS_ODAs = {}
|
||||
+12
-4
@@ -19,7 +19,7 @@ hooks.rt_transmission[#hooks.rt_transmission + 1] = function ()
|
||||
local entry = uecp.rt_buffer[uecp.rt_buffer_index]
|
||||
uecp.rt_tx_remaining = entry.number_tx
|
||||
|
||||
rds.set_rt(entry.text)
|
||||
rds.set_rt_raw(entry.text)
|
||||
if entry.toggle_ab then rds.toggle_rt_ab() end
|
||||
end
|
||||
|
||||
@@ -167,7 +167,7 @@ mec_handlers[0x0A] = function(data)
|
||||
uecp.rt_tx_remaining = number_tx
|
||||
-- Seed the encoder immediately with the first entry
|
||||
dsn_helper(dsn, function ()
|
||||
rds.set_rt(rt_text)
|
||||
rds.set_rt_raw(rt_text)
|
||||
if toggle_ab then rds.toggle_rt_ab() end
|
||||
rds.set_rt_enabled(true)
|
||||
end)
|
||||
@@ -222,7 +222,15 @@ mec_handlers[0x2E] = function (data)
|
||||
end
|
||||
mec_handlers[0x24] = function (data)
|
||||
-- Free-format data in type A or B group
|
||||
-- TODO: figure out the docs
|
||||
local group = string.byte(data, 2)
|
||||
local bufferdata = string.byte(data, 3)
|
||||
local buffer = (bufferdata >> 5) & 3 -- No clue
|
||||
local blockb = bufferdata & 31
|
||||
local blockc_msb = string.byte(data, 4)
|
||||
local blockc_lsb = string.byte(data, 5)
|
||||
local blockd_msb = string.byte(data, 6)
|
||||
local blockd_lsb = string.byte(data, 7)
|
||||
rds.put_custom_group((group << 11) | blockb, (blockc_msb << 8) | blockc_lsb, (blockd_msb << 8) | blockd_lsb)
|
||||
return 7
|
||||
end
|
||||
-- Fuck you mean, i have to implement some fucking "spinning wHELLs"? may the lord have mercy
|
||||
@@ -274,7 +282,7 @@ mec_handlers[0x2D] = function (data)
|
||||
local designation = string.sub(data, 3, 4)
|
||||
if string.byte(designation, 1) == 0x39 and string.byte(designation, 2) == 0x35 and mel > 2 then
|
||||
local data = string.sub(data, 5, 4+mel)
|
||||
pcall(data_handle, data)
|
||||
pcall(hooks.data_handle, data)
|
||||
end
|
||||
return 2+mel
|
||||
end
|
||||
|
||||
+3
-34
@@ -1,5 +1,5 @@
|
||||
---@param data string
|
||||
function data_handle(data)
|
||||
function hooks.data_handle(data)
|
||||
-- UECP
|
||||
if uecp.parse_uecp and string.byte(data, 1) == 0xfe then return uecp.parse_uecp(data) end
|
||||
|
||||
@@ -42,7 +42,7 @@ function data_handle(data)
|
||||
end
|
||||
if cmd == nil then
|
||||
data = data:lower()
|
||||
if data == "ver" then return string.format("rds95 core v. %s - (C) 2025 radio95 - lua parser\r\n", core_version)
|
||||
if data == "ver" then return string.format("rds95 core v. %s - (C) 2025 radio95 - lua parser\r\n", dp.core_version)
|
||||
elseif data == "init" then
|
||||
dp.set_program_defaults()
|
||||
return "+\r\n"
|
||||
@@ -165,37 +165,6 @@ function data_handle(data)
|
||||
else return "?\r\n" end
|
||||
end
|
||||
|
||||
local udg_num = cmd:match("^udg([12])$")
|
||||
local udg2_num = cmd:match("^2udg([12])$")
|
||||
if udg_num then
|
||||
local xy = (udg_num == "1")
|
||||
local groups = {}
|
||||
|
||||
for segment in value:gmatch("([^,]+)") do
|
||||
local b, c, d = segment:match("^(%x%x%x%x)(%x%x%x%x)(%x%x%x%x)$")
|
||||
if not (b and c and d) then return "-\r\n" end
|
||||
table.insert(groups, {tonumber(b, 16), tonumber(c, 16), tonumber(d, 16)})
|
||||
end
|
||||
|
||||
if #groups > 8 or #groups == 0 then return "-\r\n" end
|
||||
rds.set_udg(xy, groups)
|
||||
return "+\r\n"
|
||||
end
|
||||
if udg2_num then
|
||||
local xy = (udg2_num == "1")
|
||||
local groups = {}
|
||||
|
||||
for segment in value:gmatch("([^,]+)") do
|
||||
local a, b, c, d = segment:match("^(%x%x%x%x)(%x%x%x%x)(%x%x%x%x)(%x%x%x%x)$")
|
||||
if not (a and b and c and d) then return "-" end
|
||||
table.insert(groups, {tonumber(a, 16), tonumber(b, 16), tonumber(c, 16), tonumber(d, 16)})
|
||||
end
|
||||
|
||||
if #groups > 8 or #groups == 0 then return "-" end
|
||||
rds.set_udg2(xy, groups)
|
||||
return "+\r\n"
|
||||
end
|
||||
|
||||
if cmd == "pi" then
|
||||
local pi = tonumber(value, 16)
|
||||
if not pi then return "-\r\n" end
|
||||
@@ -264,7 +233,7 @@ function data_handle(data)
|
||||
elseif cmd == "rt1" or cmd == "text" then
|
||||
uecp.rt_buffer = {}
|
||||
uecp.rt_buffer_index = 1
|
||||
uecp.rt_buffer[1] = { text = value, number_tx = 0, toggle_ab = true }
|
||||
uecp.rt_buffer[1] = { text = dp.encode_charset(value), number_tx = 0, toggle_ab = true }
|
||||
uecp.rt_tx_remaining = 0
|
||||
rds.set_rt_enabled(true)
|
||||
rds.set_rt(value)
|
||||
|
||||
Reference in New Issue
Block a user