Is there any sample code out there for controlling two LSS servos independently with a Mega2560?
All the library functions work fine assuming a servo ID of 0, ie:
LSS myLSS = LSS(0);
but not if I attempt to change a servo’s ID to 1. For example, in the setup() loop I’ll type the following:
I reset the servo (or cycle power) to save the change. Then I run some new code creating the object myLSS = LSS(1) this time. I think this should mean that any functions I call, such as myLSS.setColorLED(), should target servos with the ID of 1 now. However, the servos ignore the command.
You are indeed right, the code found here does not write the new ID to the servo.
The idea was that people would either:
Use the LSS Config to set the IDs of their servos individually before creating an assembly. This is required for the LSS Arm, for example.
If they really need to change the ID programmatically, they’ll do exactly what you did above.
The reason for not having a function like this in the library is twofold:
Even with the wear-levelling for the FLASH in the current code (virtual EEPROM system) that is in the LSS, if someone accidentally decides to do CID in a infinite loop (where the CID# changes and with no delay/stop of any kind), for example, it will quickly wreck the FLASH used to store configurations. It felt like a good idea at the time not to include such a function for this reason.
There is no real reason to programmatically do ID changes with the library. It is a setup things that you should, in theory, do only once. Firmware upgrades conserve ID, too, so that does not erase them either.
Anyway, I’m glad you found out how to do what you wanted.