0
1
mirror of https://github.com/radio95-rnt/rds95.git synced 2026-02-26 20:33:53 +01:00

massive lua api refactor

This commit is contained in:
2026-01-20 19:50:04 +01:00
parent 97f9b3069c
commit 53c9169330
15 changed files with 976 additions and 776 deletions

View File

@@ -3,48 +3,62 @@
-- Global Variables
---@type string
core_version = ""
---@type integer
eon_count = 0
---@type integer
max_programs = 0
---@type integer
user_data_len = 0
--#region Functions implemented or used in C
---Executes a CRC-16 CCIIT
dp = {}
---@type integer
dp.max_programs = 0
---Executes a CRC-16 CCIIT on given data
---@param data string
---@return integer
function crc16(data) end
function dp.crc16(data) end
---Starts the initialization sequence, also calls the on_init function
---@return nil
function set_rds_program_defaults() end
function dp.set_rds_program_defaults() end
---Saves, loads and resets the state of the data, you might as well restart the whole program
---@return nil
function reset_rds() end
function dp.reset_rds() end
---Forces encoder and modulator data to be saved to disc
---@return nil
function force_save() end
function dp.force_save() end
---@param program_idx integer 0 to (max_programs - 1)
function dp.set_rds_program(program_idx) end
---@return integer
function dp.get_rds_program() end
---This function is called by the C core after we reset data, or have no data in general
---It should be defined by the user in the script.
---@return nil
function on_init() end
on_inits = {}
---This function is called by the C core after we initialize the encoder (always, every start)
---It should be defined by the user in the script.
---@return nil
function on_start() end
on_starts = {}
---This function is called every time when the state resets, register your odas here
---It should be defined by the user in the script.
---@return nil
function on_state() end
on_states = {}
---This function is called every second
---It should be defined by the user in the script.
---@return nil
function tick() end
ticks = {}
-- Every function with with the s suffixed table means that other versions of that function can be in that list-table, and each one will be called
---This function is called in order to handle UDP data
---It should be defined by the user in the script.
---@param data string
@@ -70,72 +84,77 @@ function group(group) end
---@return integer d
function rds2_group(stream) end
rds = {}
---@type integer
rds.eon_count = 0
---@param pi integer
function set_rds_pi(pi) end
function rds.set_pi(pi) end
---@return integer
function get_rds_pi() end
function rds.get_pi() end
---@param pty integer
function set_rds_pty(pty) end
function rds.set_pty(pty) end
---@return integer
function get_rds_pty() end
function rds.get_pty() end
---@param ecc integer
function set_rds_ecc(ecc) end
function rds.set_ecc(ecc) end
---@return integer
function get_rds_ecc() end
function rds.get_ecc() end
---@param slc_data integer
function set_rds_slc_data(slc_data) end
function rds.set_slc_data(slc_data) end
---@return integer
function get_rds_slc_data() end
function rds.get_slc_data() end
---@param ct boolean
function set_rds_ct(ct) end
function rds.set_ct(ct) end
---@return boolean
function get_rds_ct() end
function rds.get_ct() end
---@param dpty boolean
function set_rds_dpty(dpty) end
function rds.set_dpty(dpty) end
---@return boolean
function get_rds_dpty() end
function rds.get_dpty() end
---@param tp boolean
function set_rds_tp(tp) end
function rds.set_tp(tp) end
---@return boolean
function get_rds_tp() end
function rds.get_tp() end
---@param ta boolean
function set_rds_ta(ta) end
function rds.set_ta(ta) end
---@return boolean
function get_rds_ta() end
function rds.get_ta() end
-- Feature Flags
---@param enabled boolean
function set_rds_rt1_enabled(enabled) end
function rds.set_rt1_enabled(enabled) end
---@return boolean
function get_rds_rt1_enabled() end
function rds.get_rt1_enabled() end
---@param enabled boolean
function set_rds_rt2_enabled(enabled) end
function rds.set_rt2_enabled(enabled) end
---@return boolean
function get_rds_rt2_enabled() end
function rds.get_rt2_enabled() end
---@param enabled boolean
function set_rds_ptyn_enabled(enabled) end
function rds.set_ptyn_enabled(enabled) end
---@return boolean
function get_rds_ptyn_enabled() end
function rds.get_ptyn_enabled() end
---@param rt_type integer
function set_rds_rt_type(rt_type) end
function rds.set_rt_type(rt_type) end
---@return integer
function get_rds_rt_type() end
function rds.get_rt_type() end
-- Modulation & Generation
---@param mode integer
function set_rds2_mode(mode) end
function rds.set_rds2_mode(mode) end
---@return integer
function get_rds2_mode() end
function rds.get_rds2_mode() end
---@param streams integer
function set_rds_streams(streams) end
@@ -152,72 +171,67 @@ function get_rds_level() end
-- Program & Linking
---@param linkage boolean
function set_rds_link(linkage) end
function rds.set_link(linkage) end
---@return boolean
function get_rds_link() end
---@param program_idx integer 0 to (max_programs - 1)
function set_rds_program(program_idx) end
---@return integer
function get_rds_program() end
function rds.get_link() end
-- Timeouts and Periods
---@param period integer in seconds
function set_rds_rt_switching_period(period) end
function rds.set_rt_switching_period(period) end
---@return integer
function get_rds_rt_switching_period() end
function rds.get_rt_switching_period() end
---For a RT1, this sets the timeout period before setting RT1 into "Default RT" (not literally)
---@param timeout integer in seconds
function set_rds_rt_text_timeout(timeout) end
function rds.set_rt_text_timeout(timeout) end
---@return integer
function get_rds_rt_text_timeout() end
function rds.get_rt_text_timeout() end
-- String Setters (Charset converted)
---@param ptyn string Program Type Name (max 8 chars)
function set_rds_ptyn(ptyn) end
function rds.set_ptyn(ptyn) end
---@param ps string Program Service (8 chars)
function set_rds_ps(ps) end
function rds.set_ps(ps) end
---@param tps string Traffic PS
function set_rds_tps(tps) end
function rds.set_tps(tps) end
---@param rt1 string Radio Text 1 (max 64 chars)
function set_rds_rt1(rt1) end
function rds.set_rt1(rt1) end
---@param rt2 string Radio Text 2 (max 64 chars)
function set_rds_rt2(rt2) end
function rds.set_rt2(rt2) end
---@param rt string Default radio text - max 64 characters
function set_rds_default_rt(rt) end
function rds.set_default_rt(rt) end
---@param lps string
function set_rds_lps(lps) end
function rds.set_lps(lps) end
---@return string
function get_rds_lps() end
function rds.get_lps() end
---@param grpseq string
function set_rds_grpseq(grpseq) end
function rds.set_grpseq(grpseq) end
---@return string
function get_rds_grpseq() end
function rds.get_grpseq() end
---@param grpseq2 string
function set_rds_grpseq2(grpseq2) end
function rds.set_grpseq2(grpseq2) end
---@return string
function get_rds_grpseq2() end
function rds.get_grpseq2() end
---Puts in a RDS1 group in the buffer, note that block A is filled in always
---@param b integer
---@param c integer
---@param d integer
function put_rds_custom_group(b, c, d) end
function rds.put_custom_group(b, c, d) end
---Puts in a RDS2 group in the buffer
---@param a integer
---@param b integer
---@param c integer
---@param d integer
function put_rds2_custom_group(a, b, c, d) end
function rds.put_rds2_custom_group(a, b, c, d) end
---Sets the AFs included in group 0
---@param afs table
function set_rds_af_group0(afs) end
function rds.set_af(afs) end
---Sets data about the EON
---@param eon integer Index of the EON we are setting
@@ -229,7 +243,7 @@ function set_rds_af_group0(afs) end
---@param ps string
---@param afs table
---@param data integer
function set_rds_eon(eon, enabled, pi, tp, ta, pty, ps, afs, data) end
function rds.set_eon(eon, enabled, pi, tp, ta, pty, ps, afs, data) end
---Gets the same data set_rds_eon sets, yes this returns 8 arguments
---@param eon integer
@@ -241,37 +255,45 @@ function set_rds_eon(eon, enabled, pi, tp, ta, pty, ps, afs, data) end
---@return string ps
---@return table _ this is empty, getting afs is not supported yet
---@return integer data
function get_rds_eon(eon) end
function rds.get_eon(eon) end
---Sets the X/Y of the UDG
---@param xy boolean
---@param groups table Table of tables, this should be up to 8 tables containing 3 integers
function set_rds_udg(xy, groups) end
function rds.set_udg(xy, groups) end
---Sets the X/Y of the UDG for RDS2
---@param xy boolean
---@param groups table Table of tables, this should be up to 8 tables containing 4 integers
function set_rds_udg2(xy, groups) end
function rds.set_udg2(xy, groups) end
userdata = {}
---@type integer
userdata.len = 0
---Data is allocated in each program's data for lua data (per program, diffrent program, diffrent data), note that this overwrites existing data over the whole userdata string
---@param data string
function set_userdata(data) end
function userdata.set(data) end
---Writes to the userdata at the offset, size does not have to match the length of the string, if the string is less than size then the rest of the string will be padded with zeroes until it is size
---@param offset integer
---@param size integer
---@param data string
function set_userdata_offset(offset, size, data) end
function userdata.set_offset(offset, size, data) end
---Returns all of the data saved as user data
---@return string
function get_userdata() end
function userdata.get() end
---Gets data from userdata but at the specified offset
---@param offset integer
---@param size integer
---@return string
function get_userdata_offset(offset, size) end
function userdata.get_offset(offset, size) end
--#endregion
ext = {}
rds.ext = {}
-- RT Plus Tags
---Sets RT+ tags: type1, start1, len1, type2, start2, len2
---@param ertp boolean
@@ -281,29 +303,29 @@ function get_userdata_offset(offset, size) end
---@param t2 integer
---@param s2 integer
---@param l2 integer
function set_rds_rtplus_tags(ertp, t1, s1, l1, t2, s2, l2) end
function rds.ext.set_rtplus_tags(ertp, t1, s1, l1, t2, s2, l2) end
---Gets RT+ tags: type1, start1, len1, type2, start2, len2
---@param ertp boolean
---@return integer type1, integer start1, integer len1, integer type2, integer start2, integer len2
function get_rds_rtplus_tags(ertp) end
function rds.ext.get_rtplus_tags(ertp) end
---Toggles RTP or ERTP's toggle switch
---@param ertp boolean
function toggle_rds_rtp(ertp) end
function rds.ext.toggle_rtp(ertp) end
---Sets the metadata of RTP or ERTP
---@param ertp boolean
---@param running boolean
function set_rds_rtp_meta(ertp, running) end
function rds.ext.set_rtp_meta(ertp, running) end
---Gets the metadata of RTP and ERTP
---@param ertp boolean
---@return boolean running
function get_rds_rtp_meta(ertp) end
function rds.ext.get_rtp_meta(ertp) end
---Sets the AFs included in the ODA
---@param afs table
function set_rds_af_oda(afs) end
function rds.ext.set_af_oda(afs) end
---Registers an ODA to be used in the O of the group sequence. ODAs are stored as state data, thus running reset_rds will clear it
---Groups 14, 15, 2, 0 cannot be registered either version, groups 10, 4, 1 can be only registered as B, any other is free to take
@@ -313,16 +335,16 @@ function set_rds_af_oda(afs) end
---@param aid integer
---@param data integer
---@return integer oda_id
function register_oda(group, group_version, aid, data) end
function ext.register_oda(group, group_version, aid, data) end
---Unregisters an ODA, this stops the handler or AID being called/sent
---@param oda_id integer
function unregister_oda(oda_id) end
function ext.unregister_oda(oda_id) end
---Sets the data for a existing ODA group
---@param oda_id integer
---@param data integer
function set_oda_id_data(oda_id, data) end
function ext.set_oda_id_data(oda_id, data) end
---The callback function for an ODA handler
---@alias ODAHandler fun(): (boolean, integer, integer, integer)
@@ -334,7 +356,7 @@ function set_oda_id_data(oda_id, data) end
---You are asked to set groups B last 5 bits, leave rest 0
---@param oda_id integer The ID returned by register_oda
---@param fun ODAHandler
function set_oda_handler(oda_id, fun) end
function ext.set_oda_handler(oda_id, fun) end
---The callback function for an ODA handler
---@alias RDS2_ODAHandler fun(integer): (boolean, integer, integer, integer, integer)
@@ -342,23 +364,23 @@ function set_oda_handler(oda_id, fun) end
---You are asked to not fill in the channel id in block A, however you are asked to fill in the function number (if you do not know what is that, just OR block A with (1 << 14))
---@param oda_id integer
---@param func RDS2_ODAHandler
function set_oda_handler_rds2(oda_id, func) end
function ext.set_oda_handler_rds2(oda_id, func) end
---@param oda_id integer
---@param data integer
function set_oda_id_data_rds2(oda_id, data) end
function ext.set_oda_id_data_rds2(oda_id, data) end
---@param aid integer
---@param data integer
---@param file_related boolean
---@return integer oda_id
function register_oda_rds2(aid, data, file_related) end
function ext.register_oda_rds2(aid, data, file_related) end
---Unregisters an RDS 2 ODA, this stops the handler or AID being called/sent
---@param oda_id integer
function unregister_oda_rds2(oda_id) end
function ext.unregister_oda_rds2(oda_id) end
---@param ert string
function set_rds_ert(ert) end
function rds.ext.set_ert(ert) end
---@return string
function get_rds_ert() end
function rds.ext.get_ert() end