Skip to content

Instantly share code, notes, and snippets.

@madhephaestus
Last active November 27, 2017 19:55
Show Gist options
  • Save madhephaestus/5dd2606f922aac48a95d to your computer and use it in GitHub Desktop.
Save madhephaestus/5dd2606f922aac48a95d to your computer and use it in GitHub Desktop.
int [] vals = dyio.getAllChannelValues();
//Set up the array of channels
ArrayList<ServoChannel> chans = new ArrayList<ServoChannel>();
Log.enableDebugPrint();
float time = 5;
for(int i=0;i<12;i++){
chans.add(new ServoChannel(dyio.getChannel(i)));
}
//Set the DyIO into cached mode
dyio.setCachedMode(true);
int pos = 50;
for(int i=0;i<5;i++){
if(pos==50){
pos=200;
for(ServoChannel s:chans){
//Store the cached value
s.getChannel().setCachedValue(pos);
}
//Flush all values to the DyIO
dyio.flushCache(time);
}else{
pos=50;
for(ServoChannel s:chans){
// set the servo positions individually
s.SetPosition(pos, time);
if(s.getChannel().getCachedMode())
s.getChannel().flush();
}
}
Thread.sleep((long) (time*1500));
System.out.println("Sending "+pos);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment