diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/ThermistorController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/ThermistorController.java new file mode 100644 index 00000000..3ba06f96 --- /dev/null +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/ThermistorController.java @@ -0,0 +1,23 @@ +package com.opensourcewithslu.components.controllers; + +import com.opensourcewithslu.inputdevices.ThermistorHelper; +import com.pi4j.io.gpio.digital.DigitalInput; +import com.pi4j.io.gpio.digital.DigitalOutput; +import io.micronaut.http.annotation.Controller; +import io.micronaut.http.annotation.Get; +import jakarta.inject.Named; + +@Controller("/thermistor") +public class ThermistorController { + + private final ThermistorHelper thermistorHelper; + //maybe use multipin + public ThermistorController(@Named("thermistor-input") DigitalInput sensorInput, @Named("thermistor-output") DigitalOutput sensorOutput){ + this.thermistorHelper = new ThermistorHelper(sensorInput, sensorOutput); + } + + @Get("/value") + public int getThermistorValue(){ + return thermistorHelper.getThermistorValue(); + } +} diff --git a/components/src/main/resources/application.yml b/components/src/main/resources/application.yml index dcb1951a..2da3d58d 100644 --- a/components/src/main/resources/application.yml +++ b/components/src/main/resources/application.yml @@ -80,6 +80,10 @@ pi4j: pull: PULL_DOWN debounce: 3000 provider: pigpio-digital-input + thermistor-input: + name: Thermistor Input + address: 18 + provider: pigpio-digital-input ### DIGITAL OUTPUTS digital-output: # tag::digitalOutput[] @@ -102,6 +106,12 @@ pi4j: shutdown: LOW initial: HIGH provider: pigpio-digital-output + thermistor-output: + name: Thermistor Output + address: 27 + shutdown: LOW + initial: HIGH + provider: pigpio-digital-output # tag::multiInput[] multi-digital-input: # <.> rotary-encoder: # <.> diff --git a/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/thermistor.adoc b/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/thermistor.adoc new file mode 100644 index 00000000..7c449b46 --- /dev/null +++ b/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/thermistor.adoc @@ -0,0 +1,37 @@ + +==== Rotary Encoder +[.text-right] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/thermistor.adoc[Improve this doc] + +===== Overview +... + +===== Components +... + +===== Assembly Instructions +... + +===== Circuit Diagram +... + +===== Functionality +... + +===== Testing +... + +===== Troubleshooting +... + +===== YAML Pin Order +... + +===== Constructors +... + +===== Methods +... + +===== An Example Controller +... \ No newline at end of file diff --git a/micronautpi4j-utils/src/main/java/com/opensourcewithslu/inputdevices/ThermistorHelper.java b/micronautpi4j-utils/src/main/java/com/opensourcewithslu/inputdevices/ThermistorHelper.java new file mode 100644 index 00000000..825fa7e3 --- /dev/null +++ b/micronautpi4j-utils/src/main/java/com/opensourcewithslu/inputdevices/ThermistorHelper.java @@ -0,0 +1,20 @@ +package com.opensourcewithslu.inputdevices; + +import com.pi4j.io.gpio.digital.DigitalInput; +import com.pi4j.io.gpio.digital.DigitalOutput; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ThermistorHelper { + private static final Logger log = LoggerFactory.getLogger(ThermistorHelper.class); + private String helperName; + private int globalValue; + + public ThermistorHelper(DigitalInput sensorInput, DigitalOutput sensorOutput){ + //maybe use multipin + } + + public int getThermistorValue() { + return 1; + } +}