Skip to content

Commit

Permalink
a little closer to worky motors
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Nov 14, 2023
1 parent 820d0c4 commit 8d33fc5
Show file tree
Hide file tree
Showing 12 changed files with 210 additions and 130 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/myrobotlab/service/AudioFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ public AudioData play(String filename, boolean blocking, Integer repeat, String
data.track = track;
data.repeat = repeat;

return play(data);
return playAudioData(data);
}

public AudioData play(AudioData data) {
public AudioData playAudioData(AudioData data) {
// use File interface such that filename is preserved
// but regardless of location (e.g. url, local, resource)
// or type (mp3 wav) a stream is opened and the
Expand Down Expand Up @@ -382,7 +382,7 @@ public AudioData repeat(String filename, Integer count) {
// TODO Auto-generated method stub
AudioData data = new AudioData(filename);
data.repeat = count;
return play(data);
return playAudioData(data);
}

@Deprecated /* use setTrack() */
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/myrobotlab/service/I2cMux.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,13 @@ public void attach(Attachable service) throws Exception {
}
}

@Deprecated /* use attach(String) */
public void attach(String controllerName, String deviceBus, String deviceAddress) {
attach((I2CController) Runtime.getService(controllerName), deviceBus, deviceAddress);
}

@Override
@Deprecated /*use attach(String) */
public void attach(I2CController controller, String deviceBus, String deviceAddress) {

if (isAttached && this.controller != controller) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/myrobotlab/service/Motor.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,16 @@ public static void main(String[] args) {

}

@Override
public void attachMotorController(String controller) throws Exception {
// TODO Auto-generated method stub

}

@Override
public void detachMotorController(String controller) {
// TODO Auto-generated method stub

}

}
43 changes: 22 additions & 21 deletions src/main/java/org/myrobotlab/service/MotorDualPwm.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package org.myrobotlab.service;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

import org.myrobotlab.framework.Platform;
import org.myrobotlab.logging.Level;
import org.myrobotlab.logging.LoggingFactory;
import org.myrobotlab.service.abstracts.AbstractMotor;
import org.myrobotlab.service.config.MotorDualPwmConfig;
import org.myrobotlab.service.config.ServiceConfig;

public class MotorDualPwm extends AbstractMotor<MotorDualPwmConfig> {
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -92,32 +91,34 @@ public MotorDualPwmConfig apply(MotorDualPwmConfig c) {
return c;
}

public static void main(String[] args) throws InterruptedException {

LoggingFactory.init(Level.INFO);
String arduinoPort = "COM5";

VirtualArduino virtual = (VirtualArduino) Runtime.start("virtual", "VirtualArduino");
public static void main(String[] args) {
try {
virtual.connect(arduinoPort);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Runtime.start("gui", "SwingGui");
Runtime.start("python", "Python");
LoggingFactory.init(Level.INFO);
String arduinoPort = "COM5";

Platform.setVirtual(true);
Runtime.startConfig("dev");
Runtime.start("webgui", "WebGui");
MotorDualPwm motor = (MotorDualPwm) Runtime.start("motor", "MotorDualPwm");
Arduino arduino = (Arduino) Runtime.start("arduino", "Arduino");
arduino.connect(arduinoPort);
motor.setPwmPins(10, 11);

MotorDualPwm motor = (MotorDualPwm) Runtime.start("motor", "MotorDualPwm");
Arduino arduino = (Arduino) Runtime.start("arduino", "Arduino");
arduino.connect(arduinoPort);
motor.setPwmPins(10, 11);
try {
motor.attach(arduino);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

@Override
public void attachMotorController(String controller) throws Exception {
// TODO Auto-generated method stub

}

@Override
public void detachMotorController(String controller) {
// TODO Auto-generated method stub

}
}
12 changes: 12 additions & 0 deletions src/main/java/org/myrobotlab/service/MotorHat4Pi.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,16 @@ public static void main(String[] args) {
hat.attach(raspi, "1", "0x60");
}

@Override
public void attachMotorController(String controller) throws Exception {
// TODO Auto-generated method stub

}

@Override
public void detachMotorController(String controller) {
// TODO Auto-generated method stub

}

}
12 changes: 12 additions & 0 deletions src/main/java/org/myrobotlab/service/MotorPort.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ public static void main(String[] args) {
log.error("main threw", e);
}
}

@Override
public void attachMotorController(String controller) throws Exception {
// TODO Auto-generated method stub

}

@Override
public void detachMotorController(String controller) {
// TODO Auto-generated method stub

}



Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/myrobotlab/service/WebGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ public static void main(String[] args) {

// Platform.setVirtual(true);

Runtime.startConfig("default");
Runtime.startConfig("dev");

boolean done = true;
if (done) {
Expand Down
Loading

0 comments on commit 8d33fc5

Please sign in to comment.