Add support for an analog joystick component to the Pi4Micronaut library.
Component Behavior
The joystick component should allow users to read directional input, with the x-axis and y-axis each being read. The class should also be able to read when the joystick is being pressed down. It should expose methods to query its state.
You can find example circuit diagrams and code at the Sunfounder Raphael Kit documentation. You can use this to help you write the helper class and wire up your components for hardware testing and writing the documentation.
Prerequisite:
The ADC component refactoring issue (#380) is a prerequisite for this work, as integrating the potentiometer requires reliable analog-to-digital conversion.
Since this requires an ADC converter, the joystick helper class should take in an ADC converter into its constructor. It will then call the ADC's readValue method; it will read from the ADC's channel 0 to get the x-axis value, and from channel 1 to get the y-axis value.
Whether the joystick is pushed down will be a simple DigitalInput read, akin to our push button component.
Acceptance Criteria
Helper Class
A helper class is needed to implement the low-level interactions with the component, and the methods that developers will call when using our library.
Controller Class
A controller class is needed to provide an example of how developers can use our helper class. This will be used in our documentation.
Tests
Software unit tests are needed to verify that the helper class functions correctly.
Documentation
Add support for an analog joystick component to the Pi4Micronaut library.
Component Behavior
The joystick component should allow users to read directional input, with the x-axis and y-axis each being read. The class should also be able to read when the joystick is being pressed down. It should expose methods to query its state.
You can find example circuit diagrams and code at the Sunfounder Raphael Kit documentation. You can use this to help you write the helper class and wire up your components for hardware testing and writing the documentation.
Prerequisite:
The ADC component refactoring issue (#380) is a prerequisite for this work, as integrating the potentiometer requires reliable analog-to-digital conversion.
Since this requires an ADC converter, the joystick helper class should take in an ADC converter into its constructor. It will then call the ADC's
readValuemethod; it will read from the ADC's channel 0 to get the x-axis value, and from channel 1 to get the y-axis value.Whether the joystick is pushed down will be a simple
DigitalInputread, akin to our push button component.Acceptance Criteria
Helper Class
A helper class is needed to implement the low-level interactions with the component, and the methods that developers will call when using our library.
pi4micronaut-utils/src/main/java/com/opensourcewithslu.Controller Class
A controller class is needed to provide an example of how developers can use our helper class. This will be used in our documentation.
components/src/main/java/com/opensourcewithslu/components/controllers.components/src/main/resources/application.yml, following the template set by the rest of the file. It will have an ADC configuration under thespisection, and a configuration under thedigital-inputsection for reading whether the joystick is pushed down.Tests
Software unit tests are needed to verify that the helper class functions correctly.
pi4micronaut-utils/src/test/java/com/opensourcewithslu.Documentation
pi4micronaut-utils/src/docs/asciidoc/components.application.ymlfor the breadboard circuit. This should match the relevant parts of theapplication.ymlfile in thecomponentsproject.componentsproject.