diff --git a/Cargo.lock b/Cargo.lock index b160be4..7c4c4c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3102,7 +3102,7 @@ dependencies = [ [[package]] name = "tether-artnet-controller" -version = "0.7.4" +version = "0.8.0" dependencies = [ "anyhow", "artnet_protocol", diff --git a/Cargo.toml b/Cargo.toml index 87335b8..792c3b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tether-artnet-controller" -version = "0.7.4" +version = "0.8.0" edition = "2021" repository = "https://github.com/RandomStudio/tether-artnet-controller" homepage = "https://github.com/RandomStudio/tether-artnet-controller" diff --git a/README.md b/README.md index dca2435..e2a9e04 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,9 @@ If you have Tether Egui installed (`cargo install tether-egui`) then the easiest - [x] Allow the app to launch just fine without Tether - [x] If no ArtNet provided in Project (and no settings provided from CLI), then do NOT connect, but allow editing / manual connect - [x] Allow Tether settings to be saved with project as well +- [ ] Add amber Macros for some fixtures (and include these in scenes) - [ ] Keep project files sorted, e.g. by fixtures - [x] Allow the app to launch without any project file at all -- [ ] Add 16-bit control, at least for macros (single slider adjusts the two channels as split between first and second 8-bit digits) +- [x] Add 16-bit control, at least for macros (single slider adjusts the two channels as split between first and second 8-bit digits) - [ ] ArtNet on separate thread, with more precise timing; this might require some messaging back and forth and/or mutex - [ ] It should be possible to add Macros from "Advanced Mode" into the available macros for the fixtures (and therefore the scenes). This would be part of a fixture-editing UI? diff --git a/build.rs b/build.rs index 82e36fc..e6a80b7 100644 --- a/build.rs +++ b/build.rs @@ -17,18 +17,20 @@ fn main() { for (index, fixture_path) in entries.iter().enumerate() { println!("Fixture file: {:?}", fixture_path); - match fs::read_to_string(fixture_path) { - Ok(d) => { - entire_string.push_str(&d); - if index < (entries.len() - 1) { - entire_string.push(','); + if fixture_path.is_file() { + match fs::read_to_string(fixture_path) { + Ok(d) => { + entire_string.push_str(&d); + if index < (entries.len() - 1) { + entire_string.push(','); + } + } + Err(e) => { + panic!( + "Something went wrong reading the contents of the fixture file: {}", + e + ); } - } - Err(e) => { - panic!( - "Something went wrong reading the contents of the fixture file: {}", - e - ); } } } diff --git a/example.project.json b/example.project.json index 51151bb..6632dd1 100644 --- a/example.project.json +++ b/example.project.json @@ -34,12 +34,7 @@ "ControlValue": 195 }, "colour": { - "ColourValue": [ - 255, - 0, - 245, - 255 - ] + "ColourValue": [255, 0, 245, 255] }, "pan": { "ControlValue": 50 @@ -56,12 +51,7 @@ "ControlValue": 255 }, "colour": { - "ColourValue": [ - 49, - 81, - 255, - 255 - ] + "ColourValue": [49, 81, 255, 255] }, "pan": { "ControlValue": 155 @@ -78,12 +68,7 @@ "ControlValue": 255 }, "colour": { - "ColourValue": [ - 0, - 104, - 255, - 255 - ] + "ColourValue": [0, 104, 255, 255] }, "pan": { "ControlValue": 105 @@ -100,12 +85,7 @@ "ControlValue": 255 }, "colour": { - "ColourValue": [ - 243, - 0, - 255, - 255 - ] + "ColourValue": [243, 0, 255, 255] }, "pan": { "ControlValue": 60 @@ -127,12 +107,7 @@ "ControlValue": 255 }, "colour": { - "ColourValue": [ - 37, - 0, - 243, - 255 - ] + "ColourValue": [37, 0, 243, 255] }, "pan": { "ControlValue": 67 @@ -149,12 +124,7 @@ "ControlValue": 255 }, "colour": { - "ColourValue": [ - 237, - 255, - 0, - 255 - ] + "ColourValue": [237, 255, 0, 255] }, "pan": { "ControlValue": 15 @@ -171,12 +141,7 @@ "ControlValue": 15 }, "colour": { - "ColourValue": [ - 244, - 222, - 159, - 255 - ] + "ColourValue": [244, 222, 159, 255] }, "pan": { "ControlValue": 60 @@ -193,12 +158,7 @@ "ControlValue": 15 }, "colour": { - "ColourValue": [ - 255, - 237, - 220, - 255 - ] + "ColourValue": [255, 237, 220, 255] }, "pan": { "ControlValue": 30 @@ -220,12 +180,7 @@ "ControlValue": 255 }, "colour": { - "ColourValue": [ - 0, - 0, - 0, - 0 - ] + "ColourValue": [0, 0, 0, 0] }, "pan": { "ControlValue": 193 @@ -242,12 +197,7 @@ "ControlValue": 255 }, "colour": { - "ColourValue": [ - 0, - 0, - 0, - 0 - ] + "ColourValue": [0, 0, 0, 0] }, "pan": { "ControlValue": 205 @@ -264,12 +214,7 @@ "ControlValue": 255 }, "colour": { - "ColourValue": [ - 0, - 0, - 0, - 0 - ] + "ColourValue": [0, 0, 0, 0] }, "pan": { "ControlValue": 82 @@ -286,12 +231,7 @@ "ControlValue": 255 }, "colour": { - "ColourValue": [ - 0, - 0, - 0, - 0 - ] + "ColourValue": [0, 0, 0, 0] }, "pan": { "ControlValue": 165 @@ -311,9 +251,6 @@ "noteStart": 49 }, "artnetConfig": { - "Unicast": [ - "127.0.0.1", - "127.0.0.1" - ] + "Unicast": ["127.0.0.1", "127.0.0.1"] } -} \ No newline at end of file +} diff --git a/fixtures/ADJ_Vizi_Hex_Wash7.json b/fixtures/ADJ_Vizi_Hex_Wash7.json index 228756f..169f930 100644 --- a/fixtures/ADJ_Vizi_Hex_Wash7.json +++ b/fixtures/ADJ_Vizi_Hex_Wash7.json @@ -7,322 +7,322 @@ "mappings": [ { "channel": 1, - "label": "PAN MOVEMENT 8bit", + "label": "Pan Movement 8 Bit", "notes": "(540° or 630°)" }, { "channel": 2, - "label": "PAN MOVEMENT FINE 16bit" + "label": "Pan Movement Fine 16 Bit" }, { "channel": 3, - "label": "TILT MOVEMENT 8bit", + "label": "Tilt Movement 8 Bit", "home": 128 }, { "channel": 4, - "label": "TILT MOVEMENT FINE 16bit" + "label": "Tilt Movement Fine 16 Bit" }, { "channel": 5, - "label": "RED CENTER LED", + "label": "Red Center LED", "notes": "0% - 100%" }, { "channel": 6, - "label": "GREEN CENTER LED", + "label": "Green Center LED", "notes": "0% - 100%" }, { "channel": 7, - "label": "BLUE CENTER LED", + "label": "Blue Center LED", "notes": "0% - 100%" }, { "channel": 8, - "label": "WHITE CENTER LED", + "label": "White Center LED", "notes": "0% - 100%" }, { "channel": 9, - "label": "AMBER CENTER LED", + "label": "Amber Center LED", "notes": "0% - 100%" }, { "channel": 10, - "label": "UV CENTER LED", + "label": "Uv Center LED", "notes": "0% - 100%" }, { "channel": 11, - "label": "RED OUTER LEDs", + "label": "Red Outer LEDs", "notes": "0% - 100%" }, { "channel": 12, - "label": "GREEN OUTER LEDs", + "label": "Green Outer LEDs", "notes": "0% - 100%" }, { "channel": 13, - "label": "BLUE OUTER LEDs", + "label": "Blue Outer LEDs", "notes": "0% - 100%" }, { "channel": 14, - "label": "WHITE OUTER LEDs", + "label": "White Outer LEDs", "notes": "0% - 100%" }, { "channel": 15, - "label": "AMBER OUTER LEDs", + "label": "Amber Outer LEDs", "notes": "0% - 100%" }, { "channel": 16, - "label": "UV OUTER LEDs", + "label": "Uv Outer LEDs", "notes": "0% - 100%" }, { "channel": 17, - "label": "COLOR MACROS" + "label": "Color Macros" }, { "channel": 18, - "label": "SHUTTER/STROBE", + "label": "Shutter/strobe", "home": 255, "ranges": [ { "range": [0, 31], - "label": "LED OFF" + "label": "LED Off" }, { "range": [32, 63], - "label": "LED ON" + "label": "LED On" }, { "range": [64, 95], - "label": "STROBING SPEED", + "label": "Strobing Speed", "notes": "SLOW - FAST" }, { "range": [96, 127], - "label": "LED ON" + "label": "LED On" }, { "range": [128, 159], - "label": "STROBE PULSE SPEED", + "label": "Strobe Pulse Speed", "notes": "SLOW - FAST" }, { "range": [160, 191], - "label": "LED ON" + "label": "LED On" }, { "range": [192, 223], - "label": "RANDOM STROBE SPEED", + "label": "Random Strobe Speed", "notes": "SLOW - FAST" }, { "range": [224, 255], - "label": "LED ON" + "label": "LED On" } ] }, { "channel": 19, - "label": "MASTER DIMMER", + "label": "Master Dimmer", "home": 0 }, { "channel": 20, - "label": "DIMMER FINE" + "label": "Dimmer Fine" }, { "channel": 21, - "label": "ZOOM", + "label": "Zoom", "notes": "7° - 58°" }, { "channel": 22, - "label": "AUTO PROGRAMS", + "label": "Auto Programs", "ranges": [ { "range": [0, 0], - "label": "OFF" + "label": "Off" }, { "range": [1, 20], - "label": "PROGRAM 1" + "label": "Program 1" }, { "range": [1, 20], - "label": "PROGRAM 2" + "label": "Program 2" }, { "range": [21, 40], - "label": "PROGRAM 3" + "label": "Program 3" }, { "range": [61, 80], - "label": "PROGRAM 4" + "label": "Program 4" }, { "range": [81, 100], - "label": "PROGRAM 5" + "label": "Program 5" }, { "range": [101, 120], - "label": "PROGRAM 6" + "label": "Program 6" }, { "range": [121, 140], - "label": "PROGRAM 7" + "label": "Program 7" }, { "range": [141, 160], - "label": "PROGRAM 8" + "label": "Program 8" }, { "range": [161, 180], - "label": "PROGRAM 9" + "label": "Program 9" }, { "range": [181, 200], - "label": "PROGRAM 10" + "label": "Program 10" }, { "range": [201, 220], - "label": "PROGRAM 11" + "label": "Program 11" }, { "range": [221, 240], - "label": "PROGRAM 12" + "label": "Program 12" }, { "range": [241, 250], - "label": "PROGRAM 13" + "label": "Program 13" }, { "range": [251, 255], - "label": "PROGRAM 14" + "label": "Program 14" } ] }, { "channel": 23, - "label": "PROGRAM SPEED", + "label": "Program Speed", "notes": "SLOW - FAST" }, { "channel": 24, - "label": "AUTO PROGRAM FADE", + "label": "Auto Program Fade", "ranges": [ { "range": [0, 0], - "label": "NORMAL" + "label": "Normal" }, { "range": [1, 255], - "label": "SLOW - FAST" + "label": "Slow Fast" } ] }, { "channel": 25, - "label": "DIMMER MODE", + "label": "Dimmer Mode", "ranges": [ { "range": [0, 20], - "label": "STANDARD" + "label": "Standard" }, { "range": [21, 40], - "label": "STAGE" + "label": "Stage" }, { "range": [41, 60], - "label": "TV" + "label": "Tv" }, { "range": [61, 80], - "label": "ARCHITECTRUAL" + "label": "Architectrual" }, { "range": [81, 100], - "label": "THEATRE" + "label": "Theatre" }, { "range": [100, 255], - "label": "DEFAULT DIMMER SETTING" + "label": "Default Dimmer Setting" } ] }, { "channel": 26, - "label": "PAN/TILT SPEED", + "label": "Pan/tilt Speed", "ranges": [ { "range": [0, 225], - "label": "FAST - SLOW" + "label": "Fast Slow" }, { "range": [226, 235], - "label": "BLACKOUT BY MOVEMENT" + "label": "Blackout By Movement" }, { "range": [236, 255], - "label": "NO FUNCTION" + "label": "No Function" } ] }, { "channel": 27, - "label": "AUTO PROGRAMS", + "label": "Auto Programs", "ranges": [ { "range": [0, 79], - "label": "NORMAL" + "label": "Normal" }, { "range": [80, 84], - "label": "ALL MOTOR RESET" + "label": "All Motor Reset" }, { "range": [85, 99], - "label": "NO FUNCTION" + "label": "No Function" }, { "range": [101, 119], - "label": "INTERNAL PROGRAM 1" + "label": "Internal Program 1" }, { "range": [120, 139], - "label": "INTERNAL PROGRAM 2" + "label": "Internal Program 2" }, { "range": [130, 159], - "label": "INTERNAL PROGRAM 3" + "label": "Internal Program 3" }, { "range": [160, 179], - "label": "INTERNAL PROGRAM 4" + "label": "Internal Program 4" }, { "range": [180, 199], - "label": "INTERNAL PROGRAM 5" + "label": "Internal Program 5" }, { "range": [200, 219], - "label": "INTERNAL PROGRAM 6" + "label": "Internal Program 6" }, { "range": [220, 239], - "label": "INTERNAL PROGRAM 7" + "label": "Internal Program 7" }, { "range": [240, 255], - "label": "NO FUNCTION" + "label": "No Function" } ] } @@ -330,7 +330,7 @@ "macros": [ { "colour": { - "label": "colour", + "label": "Colour", "channels": { "additive": { "red": [5, 11], @@ -343,26 +343,26 @@ }, { "control": { - "label": "brightness", - "channels": [19] + "label": "Brightness", + "channels": [{ "HiRes": [19, 20] }] } }, { "control": { - "label": "pan", - "channels": [1] + "label": "Pan", + "channels": [{ "HiRes": [1, 2] }] } }, { "control": { - "label": "tilt", - "channels": [3] + "label": "Tilt", + "channels": [{ "HiRes": [3, 4] }] } }, { "control": { - "label": "zoom", - "channels": [21] + "label": "Zoom", + "channels": [{ "LoRes": 21 }] } } ] diff --git a/fixtures/Cameo_Opus_S5.json b/fixtures/Cameo_Opus_S5.json index 1e85283..336cfb0 100644 --- a/fixtures/Cameo_Opus_S5.json +++ b/fixtures/Cameo_Opus_S5.json @@ -99,14 +99,14 @@ { "channel": 18, "label": "Focus", - "notes": "0% to 100% " + "notes": "0% to 100%" } ], "macros": [ { "control": { "label": "brightness", - "channels": [5] + "channels": [{ "HiRes": [5, 6] }] } }, { @@ -125,25 +125,25 @@ { "control": { "label": "pan", - "channels": [1] + "channels": [{ "HiRes": [1, 2] }] } }, { "control": { "label": "tilt", - "channels": [3] + "channels": [{ "HiRes": [3, 4] }] } }, { "control": { "label": "zoom", - "channels": [17] + "channels": [{ "LoRes": 17 }] } }, { "control": { "label": "focus", - "channels": [18] + "channels": [{ "LoRes": 18 }] } } ] diff --git a/fixtures/GLP_Impression_X5.json b/fixtures/GLP_Impression_X5.json index da3039e..b73e08d 100644 --- a/fixtures/GLP_Impression_X5.json +++ b/fixtures/GLP_Impression_X5.json @@ -589,7 +589,7 @@ { "control": { "label": "brightness", - "channels": [5] + "channels": [{ "HiRes": [5, 6] }] } }, { @@ -608,25 +608,25 @@ { "control": { "label": "pan", - "channels": [1] + "channels": [{ "HiRes": [1, 2] }] } }, { "control": { "label": "tilt", - "channels": [3] + "channels": [{ "HiRes": [3, 4] }] } }, { "control": { "label": "zoom", - "channels": [8] + "channels": [{ "LoRes": 8 }] } }, { "control": { "label": "shutter", - "channels": [7] + "channels": [{ "LoRes": 7 }] } } ] diff --git a/fixtures/SHEHDS_LED_Flat_PAR_12x3W_RGBW.json b/fixtures/SHEHDS_LED_Flat_PAR_12x3W_RGBW.json index f7618ce..0f25362 100644 --- a/fixtures/SHEHDS_LED_Flat_PAR_12x3W_RGBW.json +++ b/fixtures/SHEHDS_LED_Flat_PAR_12x3W_RGBW.json @@ -65,7 +65,7 @@ { "control": { "label": "brightness", - "channels": [1] + "channels": [{ "LoRes": 1 }] } }, { diff --git a/fixtures/Varytec_HERO_340FX.json b/fixtures/Varytec_HERO_340FX.json index 0ff36b6..34d3344 100644 --- a/fixtures/Varytec_HERO_340FX.json +++ b/fixtures/Varytec_HERO_340FX.json @@ -169,7 +169,7 @@ { "control": { "label": "brightness", - "channels": [6] + "channels": [{ "LoRes": 6 }] } }, { @@ -189,19 +189,19 @@ { "control": { "label": "pan", - "channels": [1] + "channels": [{ "HiRes": [1, 2] }] } }, { "control": { "label": "tilt", - "channels": [3] + "channels": [{ "HiRes": [3, 4] }] } }, { "control": { "label": "zoom", - "channels": [14] + "channels": [{ "LoRes": 14 }] } } ] diff --git a/src/all_fixtures.json b/src/all_fixtures.json index 32e8318..673fb4c 100644 --- a/src/all_fixtures.json +++ b/src/all_fixtures.json @@ -100,14 +100,14 @@ { "channel": 18, "label": "Focus", - "notes": "0% to 100% " + "notes": "0% to 100%" } ], "macros": [ { "control": { "label": "brightness", - "channels": [5] + "channels": [{ "HiRes": [5, 6] }] } }, { @@ -126,25 +126,25 @@ { "control": { "label": "pan", - "channels": [1] + "channels": [{ "HiRes": [1, 2] }] } }, { "control": { "label": "tilt", - "channels": [3] + "channels": [{ "HiRes": [3, 4] }] } }, { "control": { "label": "zoom", - "channels": [17] + "channels": [{ "LoRes": 17 }] } }, { "control": { "label": "focus", - "channels": [18] + "channels": [{ "LoRes": 18 }] } } ] @@ -742,7 +742,7 @@ { "control": { "label": "brightness", - "channels": [5] + "channels": [{ "HiRes": [5, 6] }] } }, { @@ -761,25 +761,25 @@ { "control": { "label": "pan", - "channels": [1] + "channels": [{ "HiRes": [1, 2] }] } }, { "control": { "label": "tilt", - "channels": [3] + "channels": [{ "HiRes": [3, 4] }] } }, { "control": { "label": "zoom", - "channels": [8] + "channels": [{ "LoRes": 8 }] } }, { "control": { "label": "shutter", - "channels": [7] + "channels": [{ "LoRes": 7 }] } } ] @@ -795,322 +795,322 @@ "mappings": [ { "channel": 1, - "label": "PAN MOVEMENT 8bit", + "label": "Pan Movement 8 Bit", "notes": "(540° or 630°)" }, { "channel": 2, - "label": "PAN MOVEMENT FINE 16bit" + "label": "Pan Movement Fine 16 Bit" }, { "channel": 3, - "label": "TILT MOVEMENT 8bit", + "label": "Tilt Movement 8 Bit", "home": 128 }, { "channel": 4, - "label": "TILT MOVEMENT FINE 16bit" + "label": "Tilt Movement Fine 16 Bit" }, { "channel": 5, - "label": "RED CENTER LED", + "label": "Red Center LED", "notes": "0% - 100%" }, { "channel": 6, - "label": "GREEN CENTER LED", + "label": "Green Center LED", "notes": "0% - 100%" }, { "channel": 7, - "label": "BLUE CENTER LED", + "label": "Blue Center LED", "notes": "0% - 100%" }, { "channel": 8, - "label": "WHITE CENTER LED", + "label": "White Center LED", "notes": "0% - 100%" }, { "channel": 9, - "label": "AMBER CENTER LED", + "label": "Amber Center LED", "notes": "0% - 100%" }, { "channel": 10, - "label": "UV CENTER LED", + "label": "Uv Center LED", "notes": "0% - 100%" }, { "channel": 11, - "label": "RED OUTER LEDs", + "label": "Red Outer LEDs", "notes": "0% - 100%" }, { "channel": 12, - "label": "GREEN OUTER LEDs", + "label": "Green Outer LEDs", "notes": "0% - 100%" }, { "channel": 13, - "label": "BLUE OUTER LEDs", + "label": "Blue Outer LEDs", "notes": "0% - 100%" }, { "channel": 14, - "label": "WHITE OUTER LEDs", + "label": "White Outer LEDs", "notes": "0% - 100%" }, { "channel": 15, - "label": "AMBER OUTER LEDs", + "label": "Amber Outer LEDs", "notes": "0% - 100%" }, { "channel": 16, - "label": "UV OUTER LEDs", + "label": "Uv Outer LEDs", "notes": "0% - 100%" }, { "channel": 17, - "label": "COLOR MACROS" + "label": "Color Macros" }, { "channel": 18, - "label": "SHUTTER/STROBE", + "label": "Shutter/strobe", "home": 255, "ranges": [ { "range": [0, 31], - "label": "LED OFF" + "label": "LED Off" }, { "range": [32, 63], - "label": "LED ON" + "label": "LED On" }, { "range": [64, 95], - "label": "STROBING SPEED", + "label": "Strobing Speed", "notes": "SLOW - FAST" }, { "range": [96, 127], - "label": "LED ON" + "label": "LED On" }, { "range": [128, 159], - "label": "STROBE PULSE SPEED", + "label": "Strobe Pulse Speed", "notes": "SLOW - FAST" }, { "range": [160, 191], - "label": "LED ON" + "label": "LED On" }, { "range": [192, 223], - "label": "RANDOM STROBE SPEED", + "label": "Random Strobe Speed", "notes": "SLOW - FAST" }, { "range": [224, 255], - "label": "LED ON" + "label": "LED On" } ] }, { "channel": 19, - "label": "MASTER DIMMER", + "label": "Master Dimmer", "home": 0 }, { "channel": 20, - "label": "DIMMER FINE" + "label": "Dimmer Fine" }, { "channel": 21, - "label": "ZOOM", + "label": "Zoom", "notes": "7° - 58°" }, { "channel": 22, - "label": "AUTO PROGRAMS", + "label": "Auto Programs", "ranges": [ { "range": [0, 0], - "label": "OFF" + "label": "Off" }, { "range": [1, 20], - "label": "PROGRAM 1" + "label": "Program 1" }, { "range": [1, 20], - "label": "PROGRAM 2" + "label": "Program 2" }, { "range": [21, 40], - "label": "PROGRAM 3" + "label": "Program 3" }, { "range": [61, 80], - "label": "PROGRAM 4" + "label": "Program 4" }, { "range": [81, 100], - "label": "PROGRAM 5" + "label": "Program 5" }, { "range": [101, 120], - "label": "PROGRAM 6" + "label": "Program 6" }, { "range": [121, 140], - "label": "PROGRAM 7" + "label": "Program 7" }, { "range": [141, 160], - "label": "PROGRAM 8" + "label": "Program 8" }, { "range": [161, 180], - "label": "PROGRAM 9" + "label": "Program 9" }, { "range": [181, 200], - "label": "PROGRAM 10" + "label": "Program 10" }, { "range": [201, 220], - "label": "PROGRAM 11" + "label": "Program 11" }, { "range": [221, 240], - "label": "PROGRAM 12" + "label": "Program 12" }, { "range": [241, 250], - "label": "PROGRAM 13" + "label": "Program 13" }, { "range": [251, 255], - "label": "PROGRAM 14" + "label": "Program 14" } ] }, { "channel": 23, - "label": "PROGRAM SPEED", + "label": "Program Speed", "notes": "SLOW - FAST" }, { "channel": 24, - "label": "AUTO PROGRAM FADE", + "label": "Auto Program Fade", "ranges": [ { "range": [0, 0], - "label": "NORMAL" + "label": "Normal" }, { "range": [1, 255], - "label": "SLOW - FAST" + "label": "Slow Fast" } ] }, { "channel": 25, - "label": "DIMMER MODE", + "label": "Dimmer Mode", "ranges": [ { "range": [0, 20], - "label": "STANDARD" + "label": "Standard" }, { "range": [21, 40], - "label": "STAGE" + "label": "Stage" }, { "range": [41, 60], - "label": "TV" + "label": "Tv" }, { "range": [61, 80], - "label": "ARCHITECTRUAL" + "label": "Architectrual" }, { "range": [81, 100], - "label": "THEATRE" + "label": "Theatre" }, { "range": [100, 255], - "label": "DEFAULT DIMMER SETTING" + "label": "Default Dimmer Setting" } ] }, { "channel": 26, - "label": "PAN/TILT SPEED", + "label": "Pan/tilt Speed", "ranges": [ { "range": [0, 225], - "label": "FAST - SLOW" + "label": "Fast Slow" }, { "range": [226, 235], - "label": "BLACKOUT BY MOVEMENT" + "label": "Blackout By Movement" }, { "range": [236, 255], - "label": "NO FUNCTION" + "label": "No Function" } ] }, { "channel": 27, - "label": "AUTO PROGRAMS", + "label": "Auto Programs", "ranges": [ { "range": [0, 79], - "label": "NORMAL" + "label": "Normal" }, { "range": [80, 84], - "label": "ALL MOTOR RESET" + "label": "All Motor Reset" }, { "range": [85, 99], - "label": "NO FUNCTION" + "label": "No Function" }, { "range": [101, 119], - "label": "INTERNAL PROGRAM 1" + "label": "Internal Program 1" }, { "range": [120, 139], - "label": "INTERNAL PROGRAM 2" + "label": "Internal Program 2" }, { "range": [130, 159], - "label": "INTERNAL PROGRAM 3" + "label": "Internal Program 3" }, { "range": [160, 179], - "label": "INTERNAL PROGRAM 4" + "label": "Internal Program 4" }, { "range": [180, 199], - "label": "INTERNAL PROGRAM 5" + "label": "Internal Program 5" }, { "range": [200, 219], - "label": "INTERNAL PROGRAM 6" + "label": "Internal Program 6" }, { "range": [220, 239], - "label": "INTERNAL PROGRAM 7" + "label": "Internal Program 7" }, { "range": [240, 255], - "label": "NO FUNCTION" + "label": "No Function" } ] } @@ -1118,7 +1118,7 @@ "macros": [ { "colour": { - "label": "colour", + "label": "Colour", "channels": { "additive": { "red": [5, 11], @@ -1131,26 +1131,26 @@ }, { "control": { - "label": "brightness", - "channels": [19] + "label": "Brightness", + "channels": [{ "HiRes": [19, 20] }] } }, { "control": { - "label": "pan", - "channels": [1] + "label": "Pan", + "channels": [{ "HiRes": [1, 2] }] } }, { "control": { - "label": "tilt", - "channels": [3] + "label": "Tilt", + "channels": [{ "HiRes": [3, 4] }] } }, { "control": { - "label": "zoom", - "channels": [21] + "label": "Zoom", + "channels": [{ "LoRes": 21 }] } } ] @@ -1224,7 +1224,7 @@ { "control": { "label": "brightness", - "channels": [1] + "channels": [{ "LoRes": 1 }] } }, { @@ -1415,7 +1415,7 @@ { "control": { "label": "brightness", - "channels": [6] + "channels": [{ "LoRes": 6 }] } }, { @@ -1435,19 +1435,19 @@ { "control": { "label": "pan", - "channels": [1] + "channels": [{ "HiRes": [1, 2] }] } }, { "control": { "label": "tilt", - "channels": [3] + "channels": [{ "HiRes": [3, 4] }] } }, { "control": { "label": "zoom", - "channels": [14] + "channels": [{ "LoRes": 14 }] } } ] diff --git a/src/artnet.rs b/src/artnet.rs index 6bc851e..8eec548 100644 --- a/src/artnet.rs +++ b/src/artnet.rs @@ -9,7 +9,10 @@ use log::{debug, trace}; use rand::Rng; use crate::{ - project::fixture::{CMYChannels, ChannelList, FixtureInstance, FixtureMacro, RGBWChannels}, + project::fixture::{ + CMYChannels, ChannelList, ChannelWithResolution, FixtureInstance, FixtureMacro, + RGBWChannels, + }, settings::CHANNELS_PER_UNIVERSE, }; @@ -95,8 +98,32 @@ impl ArtNetInterface { match m { FixtureMacro::Control(control_macro) => { for c in &control_macro.channels { - self.channels[(*c - 1 + f.offset_channels) as usize] = - control_macro.current_value; + match c { + ChannelWithResolution::LoRes(single_channel) => { + let target_channel = + (*single_channel - 1 + f.offset_channels) as usize; + let scaled_value = ((control_macro.current_value as f32 + / u16::MAX as f32) + * 255.0) + as u8; + debug!( + "Apply LoRes value to single fixture macro (channel {}) => {}, value {} => {}", + single_channel, + target_channel, + control_macro.current_value, + scaled_value + ); + self.channels[target_channel] = scaled_value; + } + ChannelWithResolution::HiRes((c1, c2)) => { + // Assume coarse+fine 16-bit values are "big endian" (be): + let [b1, b2] = control_macro.current_value.to_be_bytes(); + // coarse channel: + self.channels[(*c1 - 1 + f.offset_channels) as usize] = b1; + // fine channel: + self.channels[(*c2 - 1 + f.offset_channels) as usize] = b2; + } + } } } FixtureMacro::Colour(colour_macro) => { diff --git a/src/model.rs b/src/model.rs index 22875bb..da369bc 100644 --- a/src/model.rs +++ b/src/model.rs @@ -218,8 +218,9 @@ impl Model { FixtureMacro::Control(control_macro) => { if let Some(animation) = &mut control_macro.animation { let (value, is_done) = animation.get_value_and_done(); - let dmx_value = (value * 255.0) as u8; - control_macro.current_value = dmx_value; + let int_value = (value * u16::MAX as f32) as u16; + + control_macro.current_value = int_value; // NB: Check if done AFTER applying value if is_done { @@ -291,9 +292,15 @@ impl Model { { Some(m) => match m { FixtureMacro::Control(control_macro) => { - let value = value * 2; - debug!("Adjust {} to {}", &control_macro.label, value); - control_macro.current_value = value; + // MIDI uses 7-bit, i.e. 0-127 + let percentage = value as f32 / 127.0; + let converted_value: u16 = + (percentage * u16::MAX as f32) as u16; + debug!( + "Adjust {} to {}", + &control_macro.label, converted_value + ); + control_macro.current_value = converted_value; } FixtureMacro::Colour(colour_macro) => { let value = value * 2; @@ -319,7 +326,8 @@ impl Model { match m { FixtureMacro::Control(control_macro) => { if index == control_macro.global_index { - control_macro.current_value = (255.0 * position) as u8; + control_macro.current_value = + (u16::MAX as f32 * position) as u16; } } FixtureMacro::Colour(_colour_macro) => { @@ -357,8 +365,8 @@ impl Model { if let Some(ms) = msg.ms { let duration = Duration::from_millis(ms); let start_value = - control_macro.current_value as f32 / 255.0; - let end_value = target_value as f32 / 255.0; + control_macro.current_value as f32 / u16::MAX as f32; + let end_value = target_value as f32 / u16::MAX as f32; control_macro.animation = Some(Animation::new( duration, @@ -378,7 +386,8 @@ impl Model { "No animation; immediately go to Control Macro value" ); control_macro.animation = None; // cancel first - control_macro.current_value = target_value; + control_macro.current_value = + (target_value * (u16::MAX as f32)) as u16; } } RemoteMacroValue::ColourValue(_) => { diff --git a/src/project/fixture.rs b/src/project/fixture.rs index 6d86559..aa5456b 100644 --- a/src/project/fixture.rs +++ b/src/project/fixture.rs @@ -84,12 +84,18 @@ pub struct Mapping { pub ranges: Option>, } +#[derive(Serialize, Deserialize, Clone)] +pub enum ChannelWithResolution { + LoRes(u16), + HiRes((u16, u16)), +} + #[derive(Serialize, Deserialize)] -pub struct ChannelMacro { +pub struct ValueMacro { pub label: String, - pub channels: Vec, + pub channels: Vec, #[serde(skip)] - pub current_value: u8, + pub current_value: u16, #[serde(skip)] pub animation: Option, #[serde(skip)] @@ -97,7 +103,7 @@ pub struct ChannelMacro { } // Cloning an Animation is tricky, and we don't need it anyway -impl Clone for ChannelMacro { +impl Clone for ValueMacro { fn clone(&self) -> Self { Self { label: self.label.clone(), @@ -160,7 +166,7 @@ impl Clone for ColourMacro { #[derive(Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub enum FixtureMacro { - Control(ChannelMacro), + Control(ValueMacro), Colour(ColourMacro), } diff --git a/src/project/scene.rs b/src/project/scene.rs index c707a8e..bc2e1ca 100644 --- a/src/project/scene.rs +++ b/src/project/scene.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Clone, Debug)] pub enum SceneValue { - ControlValue(u8), + ControlValue(u16), ColourValue(Color32), } diff --git a/src/tether_interface.rs b/src/tether_interface.rs index ab9f5c2..65a457b 100644 --- a/src/tether_interface.rs +++ b/src/tether_interface.rs @@ -36,7 +36,7 @@ pub struct TetherKnobPayload { #[derive(Serialize, Deserialize, Debug)] pub enum RemoteMacroValue { - ControlValue(u8), + ControlValue(f32), ColourValue(Color32), } diff --git a/src/ui/macro_controls.rs b/src/ui/macro_controls.rs index 1126e4a..196f5b4 100644 --- a/src/ui/macro_controls.rs +++ b/src/ui/macro_controls.rs @@ -57,24 +57,14 @@ pub fn render_macro_controls(model: &mut Model, ui: &mut Ui) { for m in current_mode.macros.iter_mut() { match m { FixtureMacro::Control(control_macro) => { - let remapped_channels: Vec = control_macro - .channels - .iter() - .map(|c| c + fixture.offset_channels) - .collect(); - let channel_list = format!( - "{:?} => {:?}", - &control_macro.channels, remapped_channels - ); - ui.label(&control_macro.label).on_hover_text(channel_list); + ui.label(&control_macro.label); if ui .add_enabled( control_macro.animation.is_none(), Slider::new( &mut control_macro.current_value, - 0..=255, - ) - .step_by(1.0), + 0..=u16::MAX, + ), ) .changed() {