diff --git a/Other tries/Udp.lua b/Legacy/Udp.lua similarity index 100% rename from Other tries/Udp.lua rename to Legacy/Udp.lua diff --git a/Other tries/client.py b/Legacy/client.py similarity index 100% rename from Other tries/client.py rename to Legacy/client.py diff --git a/Other tries/index.html b/Legacy/index.html similarity index 100% rename from Other tries/index.html rename to Legacy/index.html diff --git a/OBSTools/text2.lua b/OBSTools/text2.lua deleted file mode 100644 index 3983147..0000000 --- a/OBSTools/text2.lua +++ /dev/null @@ -1,68 +0,0 @@ -function script_description() - return "This script lets you select a text source to force it to reread files every frame instead of once per second." -end - -obs = obslua -source_name = nil - -local open = io.open - -local function read_file(path) - local file = open(path, "rb") -- r read mode and b binary mode - if not file then return nil end - local content = file:read "*a" -- *a or *all reads the whole file - file:close() - return content -end - - - - - -function script_update(settings) - source_name = obs.obs_data_get_string(settings, "source") - filepath = obs.obs_data_get_string(settings, "filepath") - - local fileContent = read_file("/Users/LB/Desktop/z_Projects/chorus-client/racestate.txt"); - set_text(fileContent) -end - -function script_properties() - local props = obs.obs_properties_create() - local p = obs.obs_properties_add_list(props, "source", "Text Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) - local p2 = obs.obs_properties_add_path(props, "filepath", "File", obs.OBS_PATH_FILE, nil, nil) - - local sources = obs.obs_enum_sources() - if sources ~= nil then - for _, source in ipairs(sources) do - source_id = obs.obs_source_get_id(source) - if source_id == "text_gdiplus" or source_id == "text_ft2_source" or source_id == "text_pango_source" then - local name = obs.obs_source_get_name(source) - obs.obs_property_list_add_string(p, name, name) - end - end - end - - obs.source_list_release(sources) - - return props -end - -function set_text(text) - - local source = obs.obs_get_source_by_name(source_name) - - if source ~= nil then - local settings = obs.obs_data_create() - obs.obs_data_set_string(settings, "text", text) - obs.obs_source_update(source, settings) - obs.obs_data_release(settings) - obs.obs_source_release(source) - end - end - -function script_tick(seconds) - if source_name == nil then return end - local fileContent = read_file(filepath); - set_text(fileContent) -end diff --git a/OBSTools/text3.lua b/OBSTools/text3.lua deleted file mode 100644 index 3983147..0000000 --- a/OBSTools/text3.lua +++ /dev/null @@ -1,68 +0,0 @@ -function script_description() - return "This script lets you select a text source to force it to reread files every frame instead of once per second." -end - -obs = obslua -source_name = nil - -local open = io.open - -local function read_file(path) - local file = open(path, "rb") -- r read mode and b binary mode - if not file then return nil end - local content = file:read "*a" -- *a or *all reads the whole file - file:close() - return content -end - - - - - -function script_update(settings) - source_name = obs.obs_data_get_string(settings, "source") - filepath = obs.obs_data_get_string(settings, "filepath") - - local fileContent = read_file("/Users/LB/Desktop/z_Projects/chorus-client/racestate.txt"); - set_text(fileContent) -end - -function script_properties() - local props = obs.obs_properties_create() - local p = obs.obs_properties_add_list(props, "source", "Text Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) - local p2 = obs.obs_properties_add_path(props, "filepath", "File", obs.OBS_PATH_FILE, nil, nil) - - local sources = obs.obs_enum_sources() - if sources ~= nil then - for _, source in ipairs(sources) do - source_id = obs.obs_source_get_id(source) - if source_id == "text_gdiplus" or source_id == "text_ft2_source" or source_id == "text_pango_source" then - local name = obs.obs_source_get_name(source) - obs.obs_property_list_add_string(p, name, name) - end - end - end - - obs.source_list_release(sources) - - return props -end - -function set_text(text) - - local source = obs.obs_get_source_by_name(source_name) - - if source ~= nil then - local settings = obs.obs_data_create() - obs.obs_data_set_string(settings, "text", text) - obs.obs_source_update(source, settings) - obs.obs_data_release(settings) - obs.obs_source_release(source) - end - end - -function script_tick(seconds) - if source_name == nil then return end - local fileContent = read_file(filepath); - set_text(fileContent) -end diff --git a/OBSTools/text4.lua b/OBSTools/text4.lua deleted file mode 100644 index 3983147..0000000 --- a/OBSTools/text4.lua +++ /dev/null @@ -1,68 +0,0 @@ -function script_description() - return "This script lets you select a text source to force it to reread files every frame instead of once per second." -end - -obs = obslua -source_name = nil - -local open = io.open - -local function read_file(path) - local file = open(path, "rb") -- r read mode and b binary mode - if not file then return nil end - local content = file:read "*a" -- *a or *all reads the whole file - file:close() - return content -end - - - - - -function script_update(settings) - source_name = obs.obs_data_get_string(settings, "source") - filepath = obs.obs_data_get_string(settings, "filepath") - - local fileContent = read_file("/Users/LB/Desktop/z_Projects/chorus-client/racestate.txt"); - set_text(fileContent) -end - -function script_properties() - local props = obs.obs_properties_create() - local p = obs.obs_properties_add_list(props, "source", "Text Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) - local p2 = obs.obs_properties_add_path(props, "filepath", "File", obs.OBS_PATH_FILE, nil, nil) - - local sources = obs.obs_enum_sources() - if sources ~= nil then - for _, source in ipairs(sources) do - source_id = obs.obs_source_get_id(source) - if source_id == "text_gdiplus" or source_id == "text_ft2_source" or source_id == "text_pango_source" then - local name = obs.obs_source_get_name(source) - obs.obs_property_list_add_string(p, name, name) - end - end - end - - obs.source_list_release(sources) - - return props -end - -function set_text(text) - - local source = obs.obs_get_source_by_name(source_name) - - if source ~= nil then - local settings = obs.obs_data_create() - obs.obs_data_set_string(settings, "text", text) - obs.obs_source_update(source, settings) - obs.obs_data_release(settings) - obs.obs_source_release(source) - end - end - -function script_tick(seconds) - if source_name == nil then return end - local fileContent = read_file(filepath); - set_text(fileContent) -end diff --git a/Readme.md b/Readme.md index 55e5e43..5cdac21 100644 --- a/Readme.md +++ b/Readme.md @@ -1,10 +1,37 @@ -# ChorusOBSsync +# Chorus32 OBS Sync + +This project tries to connect to a Chorus32 DroneRacing Laptimer and then sends the laptimes to OBS Studio via its websockets api. It is written in Rust + +This project is still under development, but feel free to play with it, no guarantees made. + + +# Basic Concepts + +## Basic Laptimes +For normal use one would create some scenes in OBS with Freetype Texts. These text sources should have names like "RX1LapTime" or similar and be put into the config.toml +Then add the IP address of your OBS into the config, connect the Chorus32 to your Network (Using the client mode) and add its IP to the config as well. + +Then start using `cargo run` + +You should be able to see your laptimes in OBS + +## Masking unused Channels (very experimental) + +For recieving the drones in OBS I use some Eachine Receivers. But when a drone is powered off that receiver will display noise and noise degrades the quality of the stream (cause it is though for the codec to encode a random pattern efficiently, so it takes more datarate) +Therefore I add a filter onto the camera source in OBS. The Filter should be Type Blend (Addition), 100% Opacity and Color White. Then select the bars.png from the OBSTools Folder +and name the filter eg mask. (Make sure to add the name to the Config.toml file). You can then set a threshold rssi to enable the bars overlay once the receiver powers off. + +## Filemode +When the filemode option is on the laptime info is written into text files than can be fetched from OBS, so the websocket api is not needed. This used to be the simpelst way to add data into obs. + + +## Todo -- [ ] Finish serde config parsing (more optionals, no filemode flag in clap) - [x] No OBS Mode - [x] Less errors! - [x] OBS Error message decodinng - [x] Initial states for race and beginning +- [ ] Finish serde config parsing (more optionals, no filemode flag in clap) - [ ] make lap decoding inndepedent of amount - [ ] Make parsing rssi better! - [ ] Could add some disconection handeling of the chorus device in rssi request (if it fails 5 times churus has disconnnected and conenction should be reinitialized ?!)