-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17ebd81
commit dd92876
Showing
20 changed files
with
245 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/com/easternedgerobotics/rov/io/DigitalLight.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.easternedgerobotics.rov.io; | ||
|
||
import com.easternedgerobotics.rov.io.devices.Light; | ||
import com.easternedgerobotics.rov.value.LightValue; | ||
|
||
import rx.Observable; | ||
|
||
public class DigitalLight { | ||
/** | ||
* The raspi gpio pin being used. | ||
*/ | ||
private final Light light; | ||
|
||
/** | ||
* The latest value from the speed observable. | ||
*/ | ||
private LightValue value; | ||
|
||
public DigitalLight(final Observable<LightValue> values, final Light light) { | ||
this.light = light; | ||
values.subscribe(v -> value = v); | ||
} | ||
|
||
public final void write() { | ||
light.write(value.getActive()); | ||
} | ||
|
||
public final void writeZero() { | ||
light.write(false); | ||
} | ||
|
||
public final void flash() { | ||
light.flash(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
src/main/java/com/easternedgerobotics/rov/io/devices/Light.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.easternedgerobotics.rov.io.devices; | ||
|
||
public interface Light { | ||
void write(boolean active); | ||
|
||
void flash(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/easternedgerobotics/rov/io/rpi/RPiGPIOLight.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.easternedgerobotics.rov.io.rpi; | ||
|
||
import com.easternedgerobotics.rov.io.devices.Light; | ||
|
||
import com.pi4j.io.gpio.GpioController; | ||
import com.pi4j.io.gpio.GpioFactory; | ||
import com.pi4j.io.gpio.GpioPinDigitalOutput; | ||
import com.pi4j.io.gpio.RaspiPin; | ||
|
||
public final class RPiGPIOLight implements Light { | ||
/** | ||
* The raspi gpio pin being used. | ||
*/ | ||
private final GpioPinDigitalOutput pin; | ||
|
||
/** | ||
* Flashing period for the lights. | ||
*/ | ||
private static final int PERIOD = 600; | ||
|
||
public RPiGPIOLight(final int pinNumber) { | ||
final GpioController gpioController = GpioFactory.getInstance(); | ||
pin = gpioController.provisionDigitalOutputPin(RaspiPin.getPinByName("GPIO " + pinNumber)); | ||
} | ||
|
||
@Override | ||
public void write(final boolean value) { | ||
pin.setState(value); | ||
} | ||
|
||
@Override | ||
public void flash() { | ||
pin.blink(PERIOD); | ||
} | ||
|
||
} |
5 changes: 0 additions & 5 deletions
5
src/main/kotlin/com/easternedgerobotics/rov/value/LightASpeedValue.kt
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/com/easternedgerobotics/rov/value/LightAValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.easternedgerobotics.rov.value | ||
|
||
data class LightAValue(override val active: Boolean = false) : LightValue { | ||
constructor() : this(false) | ||
} |
5 changes: 0 additions & 5 deletions
5
src/main/kotlin/com/easternedgerobotics/rov/value/LightBSpeedValue.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.