Skip to content

Re-implement the light class to use GPIO #327

@cal-pratt

Description

@cal-pratt

Instead of a Maestro for lights we're going to use a GPIO.

Steps:

  • Remove the existing Light class and and tests from the project.
  • Create a Light interface in the devices package. The flash method should do the same thing as the existing light class; just change between on/off at the same frequency.
public interface Light {
    void write(final boolean active);
    void flash();
}
  • Implement the interface using a pi4j gpio object. Place this in the io.rpi package. Some name like RaspberryGpioLight
  • Add the light channel to the config.
  • Add the light to the Rov ctor and manage.

SpeedValue no longer really works; the value is a boolean not a float range. For now you can just map the speedvalue to a boolean, until you recreate the lights value fully.

eventPublisher.valuesOfType(LightASpeedValue.class)
    .startWith(new LightASpeedValue())
    .map(SpeedValue::getSpeed)
    .map(v -> v > 0.5)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions