Skip to content

Commit

Permalink
Some generic changes that were done without forethought (bug fixes?)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Cerruti authored and e3-cerruti committed Jan 13, 2018
1 parent 919962a commit ee7907e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/jointheleague/jcodrone/Flight.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public static void stop(CoDrone coDrone) throws MessageNotSentException {
sendFlightEvent(coDrone, FlightEvent.STOP);
}

public static void flyDirect(CoDrone coDrone, DirectControl control) throws MessageNotSentException {
public static void flyDirect(CoDrone coDrone, DirectControl control) {
Control message = new Control(
control.getRoll(),
control.getPitch(),
control.getYaw(),
control.getThrottle()
);
coDrone.sendMessageWait(message);
coDrone.sendMessage(message);
}

private static void sendInFlightEvent(CoDrone coDrone, FlightEvent event) throws MessageNotSentException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public LightModeBuilder setColor(Color color) {
log.warn("Value of colors is being overridden by setColor for light mode.");
}
this.color = color;
this.colorsSet = true;
this.colorSet = true;
return this;
}

Expand Down
50 changes: 50 additions & 0 deletions src/main/java/org/jointheleague/jcodrone/examples/DomDrone.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.jointheleague.jcodrone.examples;

import org.jointheleague.jcodrone.CoDrone;
import org.jointheleague.jcodrone.CoDroneNotFoundException;
import org.jointheleague.jcodrone.LightModeBuilder;
import org.jointheleague.jcodrone.MessageNotSentException;
import org.jointheleague.jcodrone.protocol.light.LightMode;
import org.jointheleague.jcodrone.protocol.light.LightModeDrone;

public class DomDrone {

public static final int TIME_UNIT = 250;

public static void main(String args[]) {
try (CoDrone drone = new CoDrone()) {
drone.connect();
// Thread.sleep(2000);
// LightMode mode= new LightModeBuilder().setColor("BLUE").setMode(LightModeDrone.EYE_HOLD).build();
// drone.lightMode(mode);
// Thread.sleep(2000);
// mode= new LightModeBuilder().setColor("orange").setMode(LightModeDrone.ARM_NONE).build();
// drone.lightMode(mode);
// Thread.sleep(2000);
drone.land();
Thread.sleep(2000);

String pattern = "...---...";
for (byte a : pattern.getBytes()) {
int interval = a == '.' ? TIME_UNIT : 3 * TIME_UNIT;
System.out.format("%c %d", a, interval);
LightMode mode2 = new LightModeBuilder()
.setColor("magenta")
.setMode(LightModeDrone.EYE_HOLD)
.build();
drone.lightMode(mode2);
Thread.sleep(interval);
mode2 = new LightModeBuilder()
.setColor("magenta")
.setMode(LightModeDrone.EYE_NONE)
.build();
drone.lightMode(mode2);
Thread.sleep(TIME_UNIT);
}
Thread.sleep(2000);
drone.land();
} catch (CoDroneNotFoundException | InterruptedException | MessageNotSentException e) {
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.jointheleague.jcodrone;
package org.jointheleague.jcodrone.examples;

import org.jointheleague.jcodrone.CoDrone;
import org.jointheleague.jcodrone.DirectControl;
import org.jointheleague.jcodrone.LightModeBuilder;
import org.jointheleague.jcodrone.protocol.light.LightMode;
import org.jointheleague.jcodrone.protocol.light.LightModeDrone;

Expand All @@ -10,8 +13,17 @@ public static void main(String argx[]) {
Thread.sleep(2000);
drone.flyDirect(new DirectControl((byte) 0, (byte) 0, (byte) 0, (byte) 0));
Thread.sleep(200);
// for(int i = 0; i < 1080; i++) {
// Color c = Color.getHSBColor(i / 360.0f, 1.0f, 1.0f);
// LightMode mode2 = new LightModeBuilder().setColor(c.getRed(), c.getGreen(), c.getBlue()).setMode(LightModeDrone.EYE_HOLD).build();
// drone.lightMode(mode2);
// Thread.sleep(60);
// }
drone.takeoff();
Thread.sleep(2000);
drone.flyDirect(new DirectControl((byte) 0, (byte) 0, (byte) 0, 30));
Thread.sleep(2000);

for (int i = 0; i < 3; i++) {
LightMode mode = new LightModeBuilder().setColor("BLUE").setInterval(5).setMode(LightModeDrone.EYE_HOLD).build();
drone.lightMode(mode);
Expand All @@ -21,7 +33,7 @@ public static void main(String argx[]) {
mode = new LightModeBuilder().setColor("RED").setInterval(5).setMode(LightModeDrone.EYE_HOLD).build();
drone.lightMode(mode);
Thread.sleep(100);
drone.flyDirect(new DirectControl((byte) 0, (byte) 0, (byte) -55, -20));
drone.flyDirect(new DirectControl((byte) 0, (byte) 0, (byte) -55, -15));
Thread.sleep(2000);
}
drone.flyDirect(new DirectControl((byte) 0, (byte) 0, (byte) 0, (byte) 0));
Expand Down

0 comments on commit ee7907e

Please sign in to comment.