Hey all
After 2 weeks typing and 4000+ lines, I think I need to start my Teensy code all over.
I KNOW you want me to post it, but believe me... it's got so complicated, it's unfathomable. I don't want the backlash of how bad my coding is.
The Teensy4.1 is driving 5x DMX Universes with the Teensy DMX Library. That all works fine. In fact, my original code works fine at the moment, but it's going to crawl once all the data starts getting sent.
The outline. 5x DMX Universes. Each Universe has 10x possible 'channels'.
Each channel has an address, a target DMX value, and a method of getting to that target DMX value (on/off/ramped/timed etc).
All addresses for each Universe, target values, timings etc are stored in arrays of 10 values.
The main loop watches 5x input pins. If one goes high, then that Universe needs to transmit DMX data for that associated DMX Universe.
Every 100ms, if an input is ON, the main loop goes out and sees if any of the DMX needs updating (which is highly likely).
If the input then goes OFF, the main loop instantly jumps out and sees what needs turning off.
I run through a for-loop (using switch/case) for the 10x channels associated with that Universe.
This for loop checks to see what kind of output each of the 10 channels has been allocated, and then if that Universe should be updated.
If it needs updating, then it does so.
Some of these are simple 'If the input is ON, then output ###', if the input is off, then send zero. These have status flags to ensure the DMX value is only ever sent once.
The problem has start because the more advance options are getting very involved. The most complicated is the RAMP UP to a value, HOLD for a time, and RAMP back down when the input goes off.
This means tracking values after the input has been turned off, but the value isn't being turned off instantly... I need to continue updating this value at a timed speed in the loop until it reaches zero again.
Difficult to expalin and I don't expect anyone to help here.... think I need to just get it off my chest! Got number blindness.
The main problem will be speed. Updating DMX values at 100ms is slow. The light I am controlling has visible steps in its brightness as it comes on. Yet less than 100ms doesn't seem to give enough time (the timings for the ramp functions become inaccurate).
If all 5 Universes were active, and all 10 channels of each Universe are used... that is 50x DMX signals per 100ms.... probably WAY too much for the Teensy 4.1
I write all my code in one (organised) lump. Never used classes etc as I don't really understand them.
But, do they help with achieving faster code? Or is it basically a 'tidyness' thing.
I think my code is as efficent as I can make it.
This is a hobby project, so it was never going to be super efficent, but I have put some time into this.
Not exactly sure what I am asking here....
After 2 weeks typing and 4000+ lines, I think I need to start my Teensy code all over.
I KNOW you want me to post it, but believe me... it's got so complicated, it's unfathomable. I don't want the backlash of how bad my coding is.
The Teensy4.1 is driving 5x DMX Universes with the Teensy DMX Library. That all works fine. In fact, my original code works fine at the moment, but it's going to crawl once all the data starts getting sent.
The outline. 5x DMX Universes. Each Universe has 10x possible 'channels'.
Each channel has an address, a target DMX value, and a method of getting to that target DMX value (on/off/ramped/timed etc).
All addresses for each Universe, target values, timings etc are stored in arrays of 10 values.
The main loop watches 5x input pins. If one goes high, then that Universe needs to transmit DMX data for that associated DMX Universe.
Every 100ms, if an input is ON, the main loop goes out and sees if any of the DMX needs updating (which is highly likely).
If the input then goes OFF, the main loop instantly jumps out and sees what needs turning off.
I run through a for-loop (using switch/case) for the 10x channels associated with that Universe.
This for loop checks to see what kind of output each of the 10 channels has been allocated, and then if that Universe should be updated.
If it needs updating, then it does so.
Some of these are simple 'If the input is ON, then output ###', if the input is off, then send zero. These have status flags to ensure the DMX value is only ever sent once.
The problem has start because the more advance options are getting very involved. The most complicated is the RAMP UP to a value, HOLD for a time, and RAMP back down when the input goes off.
This means tracking values after the input has been turned off, but the value isn't being turned off instantly... I need to continue updating this value at a timed speed in the loop until it reaches zero again.
Difficult to expalin and I don't expect anyone to help here.... think I need to just get it off my chest! Got number blindness.
The main problem will be speed. Updating DMX values at 100ms is slow. The light I am controlling has visible steps in its brightness as it comes on. Yet less than 100ms doesn't seem to give enough time (the timings for the ramp functions become inaccurate).
If all 5 Universes were active, and all 10 channels of each Universe are used... that is 50x DMX signals per 100ms.... probably WAY too much for the Teensy 4.1
I write all my code in one (organised) lump. Never used classes etc as I don't really understand them.
But, do they help with achieving faster code? Or is it basically a 'tidyness' thing.
I think my code is as efficent as I can make it.
This is a hobby project, so it was never going to be super efficent, but I have put some time into this.
Not exactly sure what I am asking here....