use of com.neuronrobotics.sdk.dyio.DyIO in project java-bowler by NeuronRobotics.
the class PWMTest method main.
/**
* @param args
*/
public static void main(String[] args) {
DyIO dyio = new DyIO();
if (!ConnectionDialog.getBowlerDevice(dyio)) {
System.exit(1);
}
PWMOutputChannel pwm = new PWMOutputChannel(dyio.getChannel(4));
// Loop 10 times setting the pwm output
float time = 5;
for (int i = 0; i < 10; i++) {
System.out.println("Moving.");
// Set the duty cycle to either 100% or 50%
int pos = ((i % 2 == 0) ? 100 : 50);
pwm.setValue(pos);
// pause between cycles so that the changes are visible
try {
Thread.sleep((long) (time * 1000));
} catch (InterruptedException e) {
}
}
dyio.disconnect();
System.exit(0);
}
use of com.neuronrobotics.sdk.dyio.DyIO in project java-bowler by NeuronRobotics.
the class SPITest method main.
public static void main(String[] args) throws InterruptedException {
DyIO dyio = new DyIO();
if (!ConnectionDialog.getBowlerDevice(dyio)) {
System.exit(0);
}
// Instantiate the SPI
SPIChannel spi = new SPIChannel(dyio);
ByteList dataStream = new ByteList(new byte[] { 33, 55, 66, 77, 88, 99 });
int slaveSelectChannelNumber = 3;
// Send data to the SPI channel using the given DYIO channel as the slave select.
byte[] back = spi.write(slaveSelectChannelNumber, dataStream.getBytes());
// Cleanup and exit
dyio.disconnect();
System.exit(0);
}
use of com.neuronrobotics.sdk.dyio.DyIO in project java-bowler by NeuronRobotics.
the class BluetoothConector method main.
/**
* @param args
*/
public static void main(String[] args) {
DyIO dyio;
BlueCoveManager manager = new BlueCoveManager();
String[] devices = manager.getAvailableSerialDevices(true);
System.out.println("Devices: ");
for (String d : devices) {
System.out.println(d);
}
if (devices.length > 0) {
System.out.println("Connecting to : " + devices[0]);
dyio = new DyIO(new BluetoothSerialConnection(manager, devices[0]));
dyio.connect();
if (dyio.ping())
System.out.println("All OK!");
}
System.exit(0);
}
use of com.neuronrobotics.sdk.dyio.DyIO in project java-bowler by NeuronRobotics.
the class AnalogInputTest method main.
/**
* @param args
*/
public static void main(String[] args) {
DyIO.disableFWCheck();
Log.enableDebugPrint();
DyIO dyio = new DyIO();
if (!ConnectionDialog.getBowlerDevice(dyio)) {
System.exit(1);
}
AnalogInputChannel ana = new AnalogInputChannel(dyio, 15);
ana.setAsync(false);
// Loop forever printing out the voltage on the pin
ServoChannel servo = new ServoChannel(dyio, 1);
servo.SetPosition(128);
while (true) {
// System.out.println(ana.getValue());
int currentVoltageValue = ana.getValue();
int scaledVoltageValue = currentVoltageValue / 4;
servo.SetPosition(scaledVoltageValue);
}
}
use of com.neuronrobotics.sdk.dyio.DyIO in project java-bowler by NeuronRobotics.
the class CoordinatedMotion method main.
public static void main(String[] args) throws InterruptedException {
DyIO dyio = new DyIO();
if (!ConnectionDialog.getBowlerDevice(dyio)) {
System.exit(1);
}
dyio.connect();
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++) {
pos = (pos == 50) ? 200 : 50;
for (ServoChannel s : chans) {
// Store the cached value
s.getChannel().setCachedValue(pos);
}
// Flush all values to the DyIO
dyio.flushCache(time);
Thread.sleep((long) (time * 1500));
}
System.exit(0);
}
Aggregations