diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/LEDController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/LEDController.java index d6f834c8..5c037b5c 100644 --- a/components/src/main/java/com/opensourcewithslu/components/controllers/LEDController.java +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/LEDController.java @@ -6,6 +6,7 @@ import io.micronaut.http.annotation.Get; import jakarta.inject.Named; +//tag::ex[] @Controller("/led") public class LEDController { private final LEDHelper ledHelper; @@ -34,3 +35,4 @@ public void blink(int duration){ ledHelper.blink(duration); } } +//end::ex[] \ No newline at end of file diff --git a/components/src/main/java/com/opensourcewithslu/components/controllers/lcdController.java b/components/src/main/java/com/opensourcewithslu/components/controllers/lcdController.java index f1a5bb9a..4f27e147 100644 --- a/components/src/main/java/com/opensourcewithslu/components/controllers/lcdController.java +++ b/components/src/main/java/com/opensourcewithslu/components/controllers/lcdController.java @@ -11,6 +11,7 @@ /** * Controller for managing LCD1602 display operations via HTTP requests. */ +//tag::ex[] @Controller("/lcd") public class lcdController { private final LCD1602Helper lcdHelper; @@ -68,3 +69,4 @@ public String turnOff() { return "Display turned off\n"; } } +//end::ex[] \ No newline at end of file diff --git a/components/src/main/resources/application.yml b/components/src/main/resources/application.yml index 62e25669..86abad60 100644 --- a/components/src/main/resources/application.yml +++ b/components/src/main/resources/application.yml @@ -14,13 +14,13 @@ pi4j: # tag::pwm[] pwm: - active-buzzer: - name: active-buzzer - address: 17 - pwmType: SOFTWARE - provider: pigpio-pwm - initial: 0 - shutdown: 0 + active-buzzer: # <1> + name: active-buzzer # <2> + address: 17 # <3> + pwmType: SOFTWARE # <4> + provider: pigpio-pwm # <5> + initial: 0 # <6> + shutdown: 0 # <7> passive-buzzer: name: passive-buzzer address: 17 diff --git a/pi4micronaut-utils/src/docs/asciidoc/Introduction/buildAndRun.adoc b/pi4micronaut-utils/src/docs/asciidoc/Introduction/buildAndRun.adoc index 6ec99014..7f456381 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/Introduction/buildAndRun.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/Introduction/buildAndRun.adoc @@ -74,6 +74,25 @@ Finally, install pigpio sudo apt-get install pigpio ---- +==== Enabling Different Communication Protocols +. In the Pi4Micronaut library, we have used different communication protocols, such as I2C, SPI, etc. +. To enable any of these protocols when needed, enter the following command: ++ +[source, bash] +---- +sudo raspi-config +---- ++ +. Navigate to "*Interfacing Options*" ++ +image::commProtocol1.png[] ++ +. Choose your desired protocol. ++ +image::commProtocol2.png[] ++ +. Reboot when prompted. + ==== Build and Copy Over Jar File . Open your terminal of choice . Navigate to the project root directory @@ -104,7 +123,7 @@ scp Demo_Pi4Micronaut-0.1-all.jar test@raspberrypi-test:~ + image:Copying_Jar_File_To_Pi.png[] -==== Almost Done! +==== Run Jar file on Pi and Test the Application . To test if you've set up everything correctly on your raspberry pi, we have some sample commands for you to run. . Open a new terminal and ssh into your raspberry pi. . Enter the following command to run the jar file: @@ -133,21 +152,3 @@ curl http://localhost:8080/led/ledOn . If this command works and the LED has lit up, congratulations! You have successfully built and ran one of our components! -==== Enabling Different Communication Protocols -. In the Pi4Micronaut library, we have used different communication protocols, such as I2C, SPI, etc. -. To enable any of these protocols when needed, enter the following command: -+ -[source, bash] ----- -sudo raspi-config ----- -+ -. Navigate to "*Interfacing Options*" -+ -image::commProtocol1.png[] -+ -. Choose your desired protocol -+ -image::commProtocol2.png[] -+ -. Reboot when prompted to diff --git a/pi4micronaut-utils/src/docs/asciidoc/Introduction/exampleApplications.adoc b/pi4micronaut-utils/src/docs/asciidoc/Introduction/exampleApplications.adoc index 5e8dcefa..779e0cd4 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/Introduction/exampleApplications.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/Introduction/exampleApplications.adoc @@ -1,9 +1,12 @@ === Example Applications [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/Introduction/exampleApplications.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/Introduction/exampleApplications.adoc[Improve this doc] If you're curious about what Pi4Micronaut is capable of, check out some of the working applications created using our library. -==== Remote Mointoring Check-In System +==== Remote Monitoring Check-In System https://github.com/oss-slu/SLU_OSS_CheckIn + +==== Home Automation +https://github.com/oss-slu/Pi4Micronaut/tree/Home_Automation diff --git a/pi4micronaut-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc b/pi4micronaut-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc index e2f51f88..b5291fed 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc @@ -1,6 +1,6 @@ == Currently Supported Hardware [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc[Improve this doc] If you plan on creating an application using any of the hardware components listed below, then our library is perfect for you! @@ -13,7 +13,7 @@ We plan on offering support for many more hardware components in the future. If * LED * RGB LED * LCD Screen -* Photosensor +* Photo Sensor * Touch Switch Sensor * Active Buzzer * Passive Buzzer diff --git a/pi4micronaut-utils/src/docs/asciidoc/adding_creating_App.adoc b/pi4micronaut-utils/src/docs/asciidoc/adding_creating_App.adoc deleted file mode 100644 index 75f3e049..00000000 --- a/pi4micronaut-utils/src/docs/asciidoc/adding_creating_App.adoc +++ /dev/null @@ -1,7 +0,0 @@ - -== Adding to/Creating an Application -[.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/adding_creating_App.adoc[Improve this doc] - -TODO: outline how to create a basic applicaton like we did for the start of the check-in system + -TODO: outline how someone should add our jar to their exsisting application \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components.adoc b/pi4micronaut-utils/src/docs/asciidoc/components.adoc deleted file mode 100644 index d0eb206f..00000000 --- a/pi4micronaut-utils/src/docs/asciidoc/components.adoc +++ /dev/null @@ -1,4 +0,0 @@ -== Components -[.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components.adoc[Improve this doc] - diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalInput.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalInput.adoc index 9d405ca8..1f46b6f6 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalInput.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalInput.adoc @@ -1,17 +1,21 @@ ==== Digital Input [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware/digitalInput.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalInput.adoc[Improve this doc] + +"Digital Input" refers to a type of electronic signal or data that can be read by the Raspberry Pi's GPIO pins. These signals are binary, meaning they can only be in one of two states: HIGH (1) or LOW (0). + +To define in application.yaml add digital-input as a field under Pi4J, then add each component under digital-input. -To define in application.yaml add digital-input as a field under pi4j, then add each component under digital-input Each component will need * name: Name of the component * address: GPIO pin associated with component -* debounce: +* debounce: value that determines the threshold for noise from the component * pull: Either PULL_UP or PULL_DOWN depending on component * provider: pigpio-digital-input +.Example Digital Input declaration [source,yaml] ---- include::../../../../../../components/src/main/resources/application.yml[tags=digitalInput] diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalOutput.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalOutput.adoc index fb9bc074..baa15cb2 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalOutput.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalOutput.adoc @@ -1,8 +1,13 @@ ==== Digital Output [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware/digitalOutput.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/digitalOutput.adoc[Improve this doc] + +"Digital Output" refers to a signal sent from the Raspberry Pi's GPIO pins to another device or circuit. Unlike digital input, which the Raspberry Pi reads, digital output is a signal that the Raspberry Pi sends out. + +Digital outputs are also binary, meaning they can only have two states: HIGH (1) or LOW (0). These states correspond to different voltage levels, typically 3.3V for high and 0V (ground) for low on a Raspberry Pi. + +To define in application.yaml, add digital-output as a field under Pi4J, then add each component under digital-output. -To define in application.yaml add digital-output as a field under pi4j, then add each component under digital-input Each component will need * name: Name of the component @@ -11,6 +16,7 @@ Each component will need * shutdown: State to take when program successfully shuts down properly, either LOW or HIGH * provider: pigpio-digital-output +.Example Digital Output declaration [source,yaml] ---- include::../../../../../../components/src/main/resources/application.yml[tags=digitalOutput] diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/i2c.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/i2c.adoc index 04e89968..0cee2b51 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/i2c.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/i2c.adoc @@ -1,7 +1,26 @@ ==== I2C [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware/i2c.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/i2c.adoc[Improve this doc] +I2C stands for **Inter-Integrated Circuit**. It is a bus interface connection protocol incorporated into devices for serial communication. (https://geeksforgeeks.org/i2c-communication-protocol/[Source: geeksforgeeks.com]) +The I2C protocol uses two wires: SDA (serial data) and SCL (serial clock). This protocol allows for communication between +multiple devices using only two wires and unique addresses. + +The I2C LCD1602 consists of a normal LCD1602 and an I2C module that is attached to the back of the LCD. +The I2C module is a chip that can expand the I/O ports of the LCD1602 using the I2C protocol. +It converts the signals from the Raspberry Pi into commands for the LCD. + +(https://docs.sunfounder.com/projects/umsk/en/latest/01_components_basic/26-component_i2c_lcd1602.html[Source: docs.sunfounder.com]) + +To define in application.yaml add i2c as a field under pi4j, then add each component under i2c. + +Each component will need: + +* name: Name of the component +* bus: Bus address of device +* device: Address of device + +.Example I2C declaration [source,yaml] ---- include::../../../../../../components/src/main/resources/application.yml[tags=i2c] @@ -11,4 +30,3 @@ include::../../../../../../components/src/main/resources/application.yml[tags=i2 <3> Device bus (0 or 1) <4> Device address -TODO: add I2C information \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/multipinConfig.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/multipinConfig.adoc index d85367eb..ef7cd1b9 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/multipinConfig.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/multipinConfig.adoc @@ -1,32 +1,32 @@ -==== Multipin Configurations +==== MultiPin Configurations [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware/multipinConfig.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/multipinConfig.adoc[Improve this doc] -Multipin components are unique in that they require several of the same type of pin in order to function properly. -Each class of multipin component (Digital Input, PWM), is declared slightly differently in the application.yaml file +MultiPin components are unique in that they require several of the same type of pin in order to function properly. +Each class of multi-pin component (Digital Input, PWM), is declared slightly differently in the application.yaml file -.Example Multipin Digital Input declaration +.Example MultiPin Digital Input declaration [source, yaml] ---- include::../../../../../../components/src/main/resources/application.yml[tags=multiInput] ---- -<.> Top level field for multipin digital inputs (equivlent of digital-output declaration) +<.> Top level field for multi-pin digital inputs (equivalent of digital-output declaration) <.> Component Identifier (Used in @Named annotations) <.> Component Name <.> Addresses for each pin (Each component has a specific order outlined in the component description) <.> Debounce values for each pin (same order as above) <.> Pull values for each pin (same order as above) <.> Shutdown value (All pins have the same shut down) -<.> Startup value (All pins have the same start up) +<.> Startup value (All pins have the same start-up) <.> Provider (All pins have the same provider) -.Example Multipin PWM declaration +.Example MultiPin PWM declaration [source, yaml] ---- -include::../../../../../../components/src/main/resources/application.yml[tags=multipwm] +include::../../../../../../components/src/main/resources/application.yml[tags=multiPWM] ---- -<.> Top level field for multipin PWMs (equivlent of digital-output declaration) +<.> Top level field for multi-pin PWMs <.> Component Identifier (Used in @Named annotations) <.> Component Name <.> Addresses for each pin (Each component has a specific order outlined in the component description) diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/pwm.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/pwm.adoc index a2652930..910c00a3 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/pwm.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/pwm.adoc @@ -1,15 +1,24 @@ ==== PWM [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware/pwm.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/pwm.adoc[Improve this doc] -To define in application.yaml add digital-input as a field under pi4j, then add each component under digital-input -Each component will need +Pulse width modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. +This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off. +The duration of “on time” is called the pulse width. To get varying analog values, you change, or modulate, that pulse width (https://learn.sunfounder.com/lesson-2-controlling-led-by-pwm-3/[Source: sunfounder.com]). +In our library, our Active Buzzer component uses PWM. Once fully activated at 5 Volts, the buzzer will go off, creating a tone. + +To define in application.yaml add pwm as a field under pi4j, then add each component under pwm. + +Each component will need: * name: Name of the component * address: GPIO pin associated with component * pwmType: Either SOFTWARE or HARDWARE based upon which type of PWM you wish to use * provider: pigpio-pwm +* initial: Initial value on startup +* shutdown: Final value at shut down +.Example PWM declaration [source,yaml] ---- include::../../../../../../components/src/main/resources/application.yml[tags=pwm] diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/spi.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/spi.adoc index 41fb4d14..25cebf75 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/spi.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/spi.adoc @@ -1,9 +1,43 @@ ==== SPI - [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/commun_WithHardware/spi.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/commun_WithHardware/spi.adoc[Improve this doc] + +The Serial Peripheral Interface (SPI) is a communication protocol used to transfer data between the Raspberry Pi and peripheral devices. These peripheral devices may be either sensors or actuators. + +(https://raspberrypi-aa.github.io/session3/spi.html[Source: raspberrypi-aa.github.io]) + +Many different devices use the SPI protocol, such as SD card reader modules, RFID card reader modules, and 2.4 GHz wireless transmitter/receivers all use SPI to communicate with the Raspberry Pi. + +(https://www.circuitbasics.com/basics-of-the-spi-communication-protocol/[Source: circuitbasics.com]) + + +SPI uses 4 separate connections to communicate with the target device: + +- COPI (Controller Output/Peripheral Input) – Line for the Controller to send data to the Peripherals. + +- CIPO (Controller Input/Peripheral Output) – Line for the Peripherals to send data to the Controller. + +- SCLK (Clock) – Line for the clock signal. + +- PS/CS (Peripheral Select/Chip Select) – Line for the Controller to select which Peripheral to send data to. + + +==== +*Note:* Controller/Peripheral is formerly referred to as Master/Slave. In order to move away from the use of such terminology, we have opted to use the term Controller in place of Master, and Peripheral in place of Slave. +==== + + +To define in application.yaml add spi as a field under pi4j, then add each component under spi. + +Each component will need: + +* name: Name of the component +* address: Address for Controller/Peripheral +* baud: Baud rate/data rate +* reset-pin: Address of GPIO reset pin +.Example SPI declaration [source,yaml] ---- include::../../../../../../components/src/main/resources/application.yml[tags=spi] @@ -14,4 +48,3 @@ include::../../../../../../components/src/main/resources/application.yml[tags=sp <4> Baud rate <5> Address of GPIO Reset pin -TODO: add SPI information \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents.adoc index 4d54242b..016b6a9c 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents.adoc @@ -1,3 +1,5 @@ === Input Components [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents.adoc[Improve this doc] + +The Components that provide input signal or data to the application from Raspberry Pi GPIO pins. \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photosensor.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photosensor.adoc index 6772abe5..3ee51ea5 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photosensor.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photosensor.adoc @@ -1,5 +1,5 @@ ==== Photosensor [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/photosensor.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/photosensor.adoc[Improve this doc] TODO: add in photosensor support docs \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pirSensor.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pirSensor.adoc index 7aa79cb8..0973e162 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pirSensor.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pirSensor.adoc @@ -42,20 +42,33 @@ image::PIR_Sensor_Circuit.png[] ===== Functionality -Use `curl http://localhost:8080/pirSensor/enable` to enable the sensor. Once the sensor is enabled, anytime the sensor detects motion, the RGB LED will turn red. If no motion is detected, the RGB LED will be green. +A PIR - Passive Infrared sensor detects motion by sensing changes in the infrared light emitted by objects in its environment. It works passively, meaning it does not emit any infrared light itself, but rather detects the infrared radiation coming from warm objects, such as humans or animals. The sensor has two sensitive slots that detect infrared radiation. -Use `curl http://localhost:8080/pirSensor/disable` to disable the sensor. +As a warm object moves across its field of view, the amount of infrared radiation reaching each slot changes, creating a detectable change in the radiation pattern. This change triggers the sensor to send an electrical signal, which can then be used to activate alarms, lights, or other devices, making PIR sensors widely used in security systems and automated lighting controls due to their efficiency and effectiveness in detecting motion. +===== Testing +Use the below command to enable the sensor. +[source, bash] +---- +$ curl http://localhost:8080/pirSensor/enable +---- +Once the sensor is enabled, anytime the sensor detects motion, the RGB LED will turn red. If no motion is detected, the RGB LED will be green. + +Use the below command to disable the sensor. +[source, bash] +---- +$ curl http://localhost:8080/pirSensor/disable +---- ===== Troubleshooting - Sensor not detecting something: * Make sure the object is moving. The sensor only detects movement. Once an object stops moving, it is no longer detected. -===== YAML +===== YAML Configuration [source, yaml] - ---- +digital-input: pir-sensor: name: PIR Sensor address: 13 diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pushButton.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pushButton.adoc index 9b3fde2f..5c0ad5c4 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pushButton.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pushButton.adoc @@ -1,6 +1,6 @@ ==== Push Button [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/pushButton.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/pushButton.adoc[Improve this doc] ===== Overview This document provides details of the Push Button circuit, @@ -16,20 +16,26 @@ including its components, assembly instructions, and functionality. . Power source ===== Circuit Diagram -Model: - -* Note the 220Ω resistor is for the LED and the 10Ω for the button. image::https://docs.sunfounder.com/projects/raphael-kit/en/latest/_images/image152.png[] +.*Note:* The 220Ω resistor is for the LED and the 10Ω for the button. - -Circuit Diagram: +*Schematic Diagram:* image::https://docs.sunfounder.com/projects/raphael-kit/en/latest/_images/image303.png[] ===== Functionality -A push of the button turns the LED light on and another push turns it off. +On click of a button can either open or close the circuit based on its current state. + +===== Testing +Use below command to test the component. + +[source, bash] +---- +$ curl http://localhost:8080/pushButton/init +---- +* `/init` - Initializes the Push Button for use. ===== Troubleshooting . LED not lighting up: Check all connections, ensure the LED is placed correctly, @@ -37,14 +43,18 @@ and check the power source. . LED is too dim: The resistor value might be too high. Ensure you're using the correct resistors or adjust according to your power source and LED specifications -===== YAML Pin Order +===== YAML Configuration The order for declaring the pin for the LED is as follows: [source, yaml] ---- digital-output: led: + name: LED Output address: 17 + shutdown: LOW + initial: LOW + provider: pigpio-digital-output ---- So the LED would be connected to GPIO 17. @@ -53,24 +63,20 @@ The order for declaring the pin for the push button is as follows: [source, yaml] ---- digital-input: - button-input-3: - address: 18 + button-input-3: + name: Push Button Input + address: 18 + pull: PULL_DOWN + debounce: 30 + provider: pigpio-digital-input ---- So the push button would be connected to GPIO 18. -===== Constructors - -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/PushButtonHelper.java[tag=const] ----- +===== Constructor and Methods -===== Methods +To see the constructor and methods of our PushButtonHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/PushButtonHelper.html[here] +for more details. -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/PushButtonHelper.java[tags=method] ----- ===== An Example Controller @@ -79,4 +85,4 @@ include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithsl [source, java] ---- include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/PushButtonController.java[tag=ex] ----- \ No newline at end of file +---- diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rfidScanner.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rfidScanner.adoc index 41788a47..d0ef36ea 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rfidScanner.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rfidScanner.adoc @@ -10,12 +10,11 @@ endif::rootpath[] ==== RFID Scanner [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/rfidScanner.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rfidScanner.adoc[Improve this doc] ===== Overview This section provides information regarding the RFID scanner component and its circuit, including assembly instructions. - ===== Components * RFID-RC522 @@ -24,9 +23,6 @@ This section provides information regarding the RFID scanner component and its c * Breadboard * Power source (3.3V) - - - ===== Assembly Instructions * Put RFID scanner on breadboard as shown in the diagram below. @@ -35,31 +31,25 @@ This section provides information regarding the RFID scanner component and its c ===== Circuit Diagram -Model: image::rfid_circuit.png[] ===== Functionality -The two main functions of the RFID scanner are to read RFIDs and to write to them. What is written to the RFID will vary depending on the intended use for the scanner. - -===== Troubleshooting +RFID Scanner requires RFID tags to work with. We can read/write the data on to the tags using the scanner. -Make sure everything is connected to the correct pins. +* `/write/{value}` - Writes {value} to the RFID key fob +* `/read` - Scanner will be ready to read the key fob ===== Testing the Circuit: -To write to the RFID fob: `curl -X POST http://localhost:8080/rfid/write/{message}` - -Example: +To write to the RFID fob: [source] ---- $ curl -X POST http://localhost:8080/rfid/write/HelloThere ---- Scan the key fob to write the message to the fob. -To read from the RFID fob: `curl http://localhost:8080/rfid/read` - -Example: +To read from the RFID fob: [source] ---- $ curl http://localhost:8080/rfid/read @@ -70,25 +60,25 @@ Scan the key fob and the message on the fob will be printed. HelloThere ---- -===== YAML -The RFID scanner as it appears in the application.yml: - -include::../../../../../../components/src/main/resources/application.yml[tag=spi] - - -===== Constructors +===== Troubleshooting -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/RFidHelper.java[tag=const] ----- +Make sure everything is connected to the correct pins. -===== Methods +===== YAML Configuration +The RFID scanner configuration as it appears in the application.yml: -[source, java] +[source] ---- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/RFidHelper.java[tag=method] +spi: + rfid: + name: MFRC522 + address: 8 + baud: 500000 + reset-pin: 25 ---- +===== Constructors and Methods +To see the constructor and methods of our RFidHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/RFidHelper.html[here] +for more details. ===== An Example Controller @@ -97,4 +87,4 @@ include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithsl [source, java] ---- include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/RFidController.java[tag=ex] ----- \ No newline at end of file +---- diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rotaryEncoder.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rotaryEncoder.adoc index f1a7a446..3b441b1d 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rotaryEncoder.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rotaryEncoder.adoc @@ -10,7 +10,7 @@ endif::rootpath[] ==== Rotary Encoder [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/rotaryEncoder.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/rotaryEncoder.adoc[Improve this doc] ===== Overview This section provides details of the Rotary Encoder circuit, @@ -38,15 +38,12 @@ stated below and in the diagram. ===== Circuit Diagram -- Note the resistor location at GPIO 27 - image::rotary_encoder_circuit.png[] +*Note:* The resistor location at GPIO 27. + ===== Functionality -- The initial value returned is 0. -- Turning the shaft one unit clockwise will increase the value returned by 1, whereas, turning the - knob counterclockwise by one unit will decrease the value returned by 1. -- The value returned is an integer with a max value of 2147483647 and min of -2147483647. +The rotary encoder returns the value as you rotate the knob. ===== Testing the Circuit To return the value of the rotary encoder: @@ -56,12 +53,14 @@ To return the value of the rotary encoder: $ curl http://localhost:8080/rotaryEncoder/value ---- +* `/value` - returns the current value of the rotary encoder + ===== Troubleshooting - Value not being returned: Make sure all pins on the encoder match up to the correct GPIO pins according to the YAML pin order below. - Make sure that a 10k resistor is being used -===== YAML Pin Order +===== YAML Configuration The order for declaring pins for a Rotary Encoder component in the application.yaml file is as follows *SW-PIN-INFO, CLK-PIN-INFO, DT-PIN-INFO* @@ -71,31 +70,27 @@ So in the case of [source, yaml] ---- multi-digital-input: - rot-encoder: - addresses: 17, 18, 27 + rotary-encoder: + name: Rotary Encoder + addresses: 27,18,17 + debounces: 6000,500,500 + pulls: PULL_DOWN,PULL_UP,PULL_UP + shutdown: LOW + initial: HIGH + provider: pigpio-digital-input ---- the sw pin would be the one connected to GPIO 27, the clk pin would be connected to GPIO 18, and the dt pin would connect to GPIO 17. All lists of values for Rotary Encoder components will follow the same order. -===== Constructors - -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/RotaryEncoderHelper.java[tag=const] ----- - -===== Methods - -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/RotaryEncoderHelper.java[tags=method] ----- +===== Constructors and Methods +To see the constructor and methods of our RotaryEncoderHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/RotaryEncoderHelper.html[here] +for more details. ===== An Example Controller -====== This controller sets up two rotary encoders +====== This controller uses a rotary encoder [source, java] ---- include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/RotaryEncoderController.java[tag=ex] ----- +---- \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/slideSwitch.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/slideSwitch.adoc index f8455900..c936b648 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/slideSwitch.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/slideSwitch.adoc @@ -13,7 +13,7 @@ endif::rootpath[] ==== Slide Switch [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/slideSwitch.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/slideSwitch.adoc[Improve this doc] ===== Overview @@ -36,7 +36,6 @@ This section provides the details of the Slide Switch circuit, including its com 6. Connect the GPIO18 pin of the Pi to the middle pin of the slide switch so that the resistor and the connection to the capacitor are between. ===== Circuit Diagram -Model: image::slideSwitch_circuit.jpg[] @@ -45,17 +44,23 @@ Making a request to the switch will return whether the switch is on or off, flip ===== Testing the Circuit: -Use: `curl http://localhost:8080/slideSwitch/switch1` to test the switch. This will either return true,if the switch is on, and false if the switch is off. Flip the switch and run the command again to see the opposite result of the first call. +Use the below command to test the switch. +[source, bash] +---- +$ curl http://localhost:8080/slideSwitch/switch1 +---- +This will either return true,if the switch is on, and false if the switch is off. Flip the switch and run the command again to see the opposite result of the first call. ===== Troubleshooting Verify that all connections are correct and that the order of components in a row are correct. -===== YAML +===== YAML Configuration The slide switch as it appears in the application.yml: [source, yaml] ---- +digital-input: slide-switch-input: name: Slide Switch Input address: 18 @@ -71,21 +76,12 @@ The slide switch as it appears in the application.yml: provider: pigpio-digital-input ---- -Note that there are two slide switches, one that uses GPIO 18 and the other uses GPIO 22. - -===== Constructors - -[source, java] ----- -include::../../../../main/java/com/opensourcewithslu/inputDevices/SlideSwitchHelper.java[tag=const] ----- +*Note:* There are two slide switches, one that uses GPIO 18 and the other uses GPIO 22. -===== Methods +===== Constructors and Methods +To see the constructor and methods of our SlideSwitchHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/SlideSwitchHelper.html[here] +for more details. -[source, java] ----- -include::../../../../main/java/com/opensourcewithslu/inputDevices/SlideSwitchHelper.java[tags=method] ----- ===== An Example Controller diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/touchSwitch.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/touchSwitch.adoc index 84d9a72d..c24f19a1 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/touchSwitch.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/touchSwitch.adoc @@ -11,7 +11,7 @@ endif::rootpath[] ==== Touch Switch [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/touchSwitch.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/touchSwitch.adoc[Improve this doc] ===== Overview @@ -43,33 +43,31 @@ so that power can be supplied to the LED and touch switch as shown in the diagra ===== Circuit Diagram -Model: image:touchSwitchDiagram.png[] -Circuit Diagram: +*Schematic Diagram:* image:touchSwitch.png[] ===== Functionality -Once the touch switch has been enabled, touching the sensor will turn the LED light on -and removing your finger from the sensor will turn the LED light off. +We can either open or close a circuit using touch switch when you touch it. ===== Testing the Circuit -To enable the touch switch: +Use the below commands to test the touch switch. +* `/enable` - turns on touch switch [source, bash] ---- -curl http://localhost:8080/touchSwitch/enable +$ curl http://localhost:8080/touchSwitch/enable ---- -To disable the touch switch: - +* `/disable` - turns off touch switch [source, bash] ---- -curl http://localhost:8080/touchSwitch/disable +$ curl http://localhost:8080/touchSwitch/disable ---- ===== Troubleshooting @@ -79,7 +77,7 @@ Make sure that all the pins on the touch switch are in the right spot and that e Also make sure that everything is properly secured to the breadboard. - Ensure a 220Ω resistor is being used -===== YAML Pin Order +===== YAML Configuration The YAML configuration for the LED is as follows: @@ -121,4 +119,4 @@ for more details. [source, java] ---- include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/TouchSwitchController.java[tag=ex] ----- +---- \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/ultraSonicSensor.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/ultraSonicSensor.adoc index a062b370..7f483a68 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/ultraSonicSensor.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/ultraSonicSensor.adoc @@ -11,7 +11,7 @@ endif::rootpath[] ==== Ultrasonic Sensor [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/ultraSonicSensor.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/inputComponents/ultraSonicSensor.adoc[Improve this doc] ===== Overview This document provides details of the Ultrasonic Sensor circuit, @@ -25,13 +25,10 @@ including its components, assembly instructions, and functionality. . Power source ===== Circuit Diagram -Model: image::ultrasonic_sensor_model.png[] - - -Circuit Diagram: +*Schematic Diagram:* image::ultrasonic_sensor_circuit.png[] @@ -40,15 +37,19 @@ The Ultrasonic Sensor uses sound waves to calculate the distance from itself to The resulting measurement is accurate within a range of 3mm of the true measurement. The Ultrasonic Sensor's signal is stable within 5m of the sensor, gradually weakening until the signal fully disappears at 7m. -Some information about the trigger and echo signals (from the sunfounder docs): -The timing diagram is shown below. You only need to supply a short 10us pulse for the trigger input to start the ranging, -and then the module will send out an 8 cycle burst of ultrasound at 40 kHz and raise its echo. -You can calculate the range through the time interval between sending trigger signal and receiving echo signal. +===== Testing + +Use the below commands to test the component. -Formula: us / 58 = centimeters or us / 148 =inch; or: the range = high level time * velocity (340M/S) / 2; -you are suggested to use measurement cycle over 60ms in order to prevent signal collisions of trigger signal and the echo signal. +[source, bash] +---- +$curl http://localhost:8080/ultraSound/enable +---- -image::ultrasonic_sensor_timing_diagram.png[] +* `/enable` - turns on ultrasonic sensor, starts measuring distance +* `/distance/cm` - returns distance to nearest object in centimeters +* `/distance/m` - returns distance to nearest object in meters +* `/disable` - turns off ultrasonic sensor @@ -56,40 +57,34 @@ image::ultrasonic_sensor_timing_diagram.png[] . Distance measurements not showing: Check all connections, ensure the sensor is placed correctly, and check the power source. -===== YAML Pin Order -The order for declaring the Trigger Pin for the Ultrasonic Sensor is as follows: - -[source, yaml] ----- -digital-input: - ultra-sonic-trig: - address: 23 ----- -So the Trigger Pin would be connected to GPIO 23. +===== YAML Configuration +The order for declaring the Trigger and Echo Pins of the Ultrasonic Sensor is as follows: -The order for declaring the Echo Pin for the Ultrasonic Sensor is as follows: +So the Trigger Pin would be connected to GPIO 23 and the Echo Pin would be connected to GPIO 24. [source, yaml] ---- -digital-output: +digital-input: ultra-sonic-echo: + name: UltraSonic Sensor Input address: 24 ----- -So the Echo Pin would be connected to GPIO 24. + pull: PULL_DOWN + debounce: 3000 + provider: pigpio-digital-input -===== Constructors - -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/UltraSonicSensorHelper.java[tag=const] +digital-output: + ultra-sonic-trig: + name: UltraSonic Sensor Output + address: 23 + shutdown: LOW + initial: LOW + provider: pigpio-digital-output ---- -===== Methods +===== Constructor and Methods -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/inputDevices/UltraSonicSensorHelper.java[tags=method] ----- +To see the constructor and methods of our UltraSonicSensor class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/UltraSonicSensorHelper.html[here] +for more details. ===== An Example Controller diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents.adoc index 1f7233be..2aa6278c 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents.adoc @@ -1,4 +1,6 @@ === Output Components [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/outputComponents.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents.adoc[Improve this doc] + +The Components that provide output signal either by emitting, displaying, lighting, etc. through Raspberry Pi GPIO pins. \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/activebuzzer.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/activebuzzer.adoc index b1828822..a6993fae 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/activebuzzer.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/activebuzzer.adoc @@ -41,24 +41,50 @@ This section provides details of the Active Buzzer, including the components and ===== Circuit Diagram -Schematic Diagram +image::active_buzzer-CD.png[] + +*Schematic Diagram* image::buzzer-SD.png[] +===== Functionality +Active Buzzer is PWM type and emits a beep tone, intermittent tone and a morseCode tone based on the frequency and the time interval. -Circuit Diagram +*Note:* If you use transistor in the circuit, it swaps the functionalities of the buzzer i.e., if you enable the buzzer, it actually disables it and vice versa. -image::active_buzzer-CD.png[] +===== Testing the circuit +Use the below command to test the component. -===== Functionality -Use: `curl http://localhost:8080/active-buzzer` to test the component. These following commands will test the component: +[source, bash] +---- +$curl http://localhost:8080/active-buzzer/enable +---- * `/enable` - Turns the Active Buzzer on. + +[source, bash] +---- +$curl http://localhost:8080/active-buzzer/disable +---- * `/disable` - Turns the Active Buzzer off. + +[source, bash] +---- +$curl http://localhost:8080/active-buzzer/beepTone +---- * `/beepTone` - Emits a beep sound from the Active Buzzer. + +[source, bash] +---- +$curl http://localhost:8080/active-buzzer/intermittentTone +---- * `/intermittentTone` - Emits an intermittent tone from the Active Buzzer. The total duration is twenty seconds: ten seconds of sound and ten seconds of silence. -* `/morseCode` - Emits the word "pi" in morse code. +[source, bash] +---- +$curl http://localhost:8080/active-buzzer/morseCode +---- +* `/morseCode` - Emits the word "pi" in morse code. ===== Troubleshooting @@ -67,17 +93,17 @@ Use: `curl http://localhost:8080/active-buzzer` to test the component. These fol * Verify that 1K resistor is used * Verify all wires are in appropriate slots. -===== YAML +===== YAML Configuration [source, yaml] - ---- - active-buzzer: - name: active-buzzer - address: 17 - pwmType: SOFTWARE - provider: pigpio-pwm - initial: 0 - shutdown: 0 +pwm: + active-buzzer: + name: active-buzzer + address: 17 + pwmType: SOFTWARE + provider: pigpio-pwm + initial: 0 + shutdown: 0 ---- ===== Constructor and Methods diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/lcd1602.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/lcd1602.adoc index 693ba2dc..f8417628 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/lcd1602.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/lcd1602.adoc @@ -11,10 +11,13 @@ endif::rootpath[] ==== LCD1602 [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/outputComponents/lcdScreen.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/lcdScreen.adoc[Improve this doc] ===== Overview -This section provides details of the LCD1602 (Liquid Crystal Display) circuit, including its components, assembly instructions, and functionality. The LCD1602 is a kind of dot matrix module that can show letters, numbers, and other characters. The number 1602 describes the display: 2 rows with 16 characters per row. NOTE: The LCD display only works on the 32 bit version of Raspberry Pi OS. +This section provides details of the LCD1602 (Liquid Crystal Display) circuit, +including its components, assembly instructions, and functionality. + +.Note: The LCD1602 only works on the 32-bit version of Raspberry Pi OS. ===== Components . LCD1602 @@ -36,7 +39,22 @@ Connect the 4 pins on the LCD1602 screen to the breadboard as described below an image::lcd1602-circuit.png[] ===== Functionality -The LCD1602 screen will light up once connected to a power source. + +The LCD1602 is a kind of dot matrix module that can show letters, numbers, and other characters. +The number 1602 describes the display: 2 rows with 16 characters per row. + +Use: `curl http://localhost:8080/lcd` to test the component. These following commands will test the component: + +* `/write/{text}` - writes *{text}* to lcd screen +* `/write/{text}/{line}` - writes *{text}* to lcd screen on line number *{line}* +* `/write/{text}/{line}/{pos}` - writes *{text}* to lcd screen on line number *{line}* at pos *{pos}* +* `/write/character/{charValue}` - writes character *{charValue}* to lcd screen +* `/backlight/{state}` - sets backlight to *{state}* (state must be set to *"on"* or *"off"*) +* `/clear/all` - clears lcd screen +* `/clear/{line}` - clears line number {line} of lcd screen +* `/turnOff` - turns off lcd screen + + ===== Testing the Circuit Write Hello to the LCD1602 screen @@ -105,7 +123,7 @@ $ sudo reboot $ uname -m ................. -===== YAML +===== YAML Configuration LCD1602 uses I2C communication for this circuit and configuration in the application.yml file is as follows [source, yaml] ---- @@ -116,19 +134,10 @@ i2c: device: 0x27 ---- -===== Constructors - -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputDevices/LCD1602Helper.java[tag=const] ----- - -===== Methods +===== Constructor and Methods -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputDevices/LCD1602Helper.java[tags=method] ----- +To see the constructor and methods of our LCD1602Helper class, see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/outputdevices/LCD1602Helper.html[here] +for more details. ===== An Example Controller diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/led.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/led.adoc index ed8764ac..bd4060a3 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/led.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/led.adoc @@ -11,7 +11,7 @@ endif::rootpath[] ==== LED [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/outputComponents/led.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/led.adoc[Improve this doc] ===== Overview This section provides details of the LED, including its components and assembly instructions. @@ -25,7 +25,7 @@ This section provides details of the LED, including its components and assembly * 1 x Resistor (220Ω) * Power source (appropriate voltage, typically 3.3V) -===== Assembly +===== Assembly Instructions * Place a single LED onto the Breadboard. * The LED will have two pins, a cathode and an anode. @@ -41,58 +41,53 @@ This section provides details of the LED, including its components and assembly image::LED_circuit.png[] -===== Testing - -Use: `curl http://localhost:8080/led/ledOn` to test the component. This will cause the LED to light. - ===== Functionality -Use: `curl http://localhost:8080/led` to test the component. The following commands will test the component: +LED can be turned on or off, switch state and set to blink for the provided duration in milliseconds. +===== Testing + +Use the below commands to test the component. This will cause the LED to light. +[source, bash] +---- +$ curl http://localhost:8080/led/ledOn +---- * `/ledOn` - Turns the led on. * `/ledOff` - Turns the led off. * `/switchState` - Switches the state of the led. -* `/blink/{duration}/` - Causes the led to blink for the desired duration. +* `/blink/{duration}/` - Causes the led to blink for the desired duration(milliseconds). ===== Troubleshooting - LED not lighting: Check the connections, and ensure the LED is placed correctly. Double-check the power source. - LED is too dim: Resistor value may be too high. Verify you're using 220Ω or adjust according to the power source your using as well as the LED specifications. -===== YAML +===== YAML Configuration [source, yaml] ---- -led: # <1> - name: LED Output # <2> - address: 17 # <3> - shutdown: HIGH # <4> - initial: HIGH # <5> - provider: pigpio-digital-output # <6> - -led2: - name: LED Output - address: 26 - shutdown: HIGH - initial: HIGH - provider: pigpio-digital-output +digital-output: + led: + name: LED Output + address: 17 + shutdown: LOW + initial: LOW + provider: pigpio-digital-output + led2: + name: LED Output + address: 26 + shutdown: HIGH + initial: HIGH + provider: pigpio-digital-output ---- -===== Constructors -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputDevices/LEDHelper.java[tag=const] ----- - -===== Methods +===== Constructor and Methods -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputDevices/LEDHelper.java[tags=method] ----- +To see the constructor and methods of our LEDHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/outputdevices/LEDHelper.html[here] +for more details. ===== An Example Controller [source, java] ---- -include:: ../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/LEDController.java[tags=method] +include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/LEDController.java[tag=ex] ---- diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/passivebuzzer.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/passivebuzzer.adoc index 194d83d5..735d7ef5 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/passivebuzzer.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/passivebuzzer.adoc @@ -45,16 +45,27 @@ This section provides details of the Passive Buzzer, including the components an ===== Circuit Diagram -Schematic Diagram -image::buzzer-SD.png[] +image::passive_buzzer-CD.png[] -Circuit Diagram +*Schematic Diagram* -image::passive_buzzer-CD.png[] +image::buzzer-SD.png[] ===== Functionality -Use: `curl http://localhost:8080/passive-buzzer` to test the component. These following commands will test the component: + +A passive buzzer is an electronic component that produces sound by using an external oscillation source. +To produce sound, a passive buzzer needs an external PWM signal supplied by Raspberry Pi. This signal controls the frequency of the sound produced, allowing for different tones or beeps. You can program specific melodies or sequences of beeps by changing the frequency of the PWM signal over time. + +*Note:* If you use transistor in the circuit, it swaps the functionalities of the buzzer i.e., if you enable the buzzer, it actually disables it and vice versa. + +===== Testing +Use the below commands to test the component. + +[source, bash] +---- +$ curl http://localhost:8080/passive-buzzer/enable +---- * `/enable` - Turns the Passive Buzzer on. * `/disable` - Turns the Passive Buzzer off. @@ -73,17 +84,18 @@ Use: `curl http://localhost:8080/passive-buzzer` to test the component. These fo * Verify all wires are in appropriate slots. * When using a file, verify that the file itself is scp'd to the raspberrypi (see PassiveBuzzerController for full information). -===== YAML +===== YAML Configuration [source, yaml] ---- - passive-buzzer: - name: passive-buzzer - address: 17 - pwmType: SOFTWARE - provider: pigpio-pwm - initial: 0 - shutdown: 0 +pwm: + passive-buzzer: + name: passive-buzzer + address: 17 + pwmType: SOFTWARE + provider: pigpio-pwm + initial: 0 + shutdown: 0 ---- ===== Constructors and Methods diff --git a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/rgbLed.adoc b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/rgbLed.adoc index 0f52215b..e7fc9aa7 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/rgbLed.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/rgbLed.adoc @@ -1,6 +1,6 @@ ==== RGB LED [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/outputComponents/rgbLed.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/rgbLed.adoc[Improve this doc] ===== Overview This document provides details of the RGB (Red-Green-Blue) LED circuit, @@ -14,7 +14,7 @@ including its components, assembly instructions, and functionality. . Power source (appropriate voltage, typically 3.3V or 5V) ===== Assembly Instructions -. Place the RGB LED on the Breadboard. The LED has four pins - one for each of the +. Place the RGB LED on the Breadboard. The LED has four pins—one for each of the colors (Red, Green, and Blue) and one common pin (either cathode or anode). . Connect the Resistors. Attach a 220Ω resistor to each of the RGB pins of the LED. This is to limit the current and protect the LED. @@ -27,11 +27,10 @@ positive voltage source (VCC) and the other ends of the resistors to the respect negative terminals (like GPIO pins set to OUTPUT and LOW on a microcontroller). ===== Circuit Diagram -Model: image::https://docs.sunfounder.com/projects/raphael-kit/en/latest/_images/image61.png[] -Circuit Diagram: +*Schematic Diagram:* image::https://docs.sunfounder.com/projects/raphael-kit/en/latest/_images/rgb_led_schematic.png[] @@ -48,17 +47,45 @@ produced. For instance: * Magenta: Power both Red and Blue pins while keeping Green off. * White: Power all three pins +===== Testing +Use the below commands to test the component. + +[source, bash] +---- +$ curl http://localhost:8080/rgb/ledOn +---- + +* `/ledOn` - turns on RGB LED +* `/ledOff` - turns off RGB LED +* `/setRed/{val}` - sets value of red to *{val}* +* `/setRed/{val},{frequency}` - sets value of red to *{val}* and frequency to *{frequency}* +* `/setGreen/{val}` - sets value of green to *{val}* +* `/setGreen/{val},{frequency}` - sets value of green to *{val}* and frequency to *{frequency}* +* `/setBlue/{val}` - sets value of blue to *{val}* +* `/setBlue/{val},{frequency}` - sets value of blue to *{val}* and frequency to *{frequency}* +* `/setColor/{redVal},{greenVal},{blueVal}` + - sets values of red *{redVal}*, green *{greenVal}*, and blue *{blueVal}* + +* `/setColor/{redVal},{greenVal},{blueVal},{frequency1},{frequency2},{frequency3}` + - sets values of red *{redVal}*, green *{greenVal}*, and blue *{blueVal}*, + and frequencies of red *{frequency1}*, green *{frequency2}*, and *{frequency3}* + +* `/setColorHex/{hexValue}` - sets color value using its hex value *{hexValue}* +* `/setColorHex/{hexValue},{frequency1},{frequency2},{frequency3}` + - sets color value using its hex value *{hexValue}* + and frequencies of red *{frequency1}*, green *{frequency2}*, and *{frequency3}* + + ===== Troubleshooting . LED not lighting up: Check all connections, ensure the LED is placed correctly, and check the power source. . Only one color is working: One of the pins might have a loose connection. Verify each color pin's connection. -. LED is too dim: The resistor value might be too high. Ensure you're using 220Ω or -adjust according to your power source and LED specifications +. LED is too dim: The resistor value might be too high. Ensure you're using 220Ω or adjust according to your power source and LED specifications -===== Note: The Hex value format must start with "0x" not "#" while passing it as a parameter of "setColorHex()" method. For example, use "0x0000ff" for blue. +*Note:* The Hex value format must start with "0x" not "#" while passing it as a parameter of "setColorHex()" method. For example, use "0x0000ff" for blue. -===== YAML Pin Order +===== YAML Configuration The order for declaring pins for a RGB LED component in the application.yaml file is as follows *RED-PIN-INFO, GREEN-PIN-INFO, BLUE-PIN-INFO* @@ -69,24 +96,27 @@ So in the case of ---- multi-pwm: rgb-led: + name: RGB LED addresses: 17, 18, 27 + pwmTypes: SOFTWARE, SOFTWARE, SOFTWARE + provider: pigpio-pwm + initials: 0, 0, 0 + shutdowns: 0, 0, 0 + rgb-led-2: + name: RGB LED 2 + addresses: 18, 27, 22 + pwmTypes: SOFTWARE, SOFTWARE, SOFTWARE + provider: pigpio-pwm + initials: 0, 0, 0 + shutdowns: 0, 0, 0 ---- the red pin would be the one connected to GPIO 17, green to GPIO 18, and blue to GPIO 27. All lists of values for RGB LED components will follow the same order. -===== Constructors +===== Constructor and Methods -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputDevices/RGBLEDHelper.java[tag=const] ----- - -===== Methods - -[source, java] ----- -include::../../../../../../pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputDevices/RGBLEDHelper.java[tags=method] ----- +To see the constructor and methods of our RGBLEDHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/outputdevices/RGBLEDHelper.html[here] +for more details. ===== An Example Controller diff --git a/pi4micronaut-utils/src/docs/asciidoc/contribute/contributingToLibrary.adoc b/pi4micronaut-utils/src/docs/asciidoc/contribute/contributingToLibrary.adoc index a2073c77..17e4effd 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/contribute/contributingToLibrary.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/contribute/contributingToLibrary.adoc @@ -1,4 +1,6 @@ == Contribute to the Pi4Micronaut Library +[.text-right] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/contribute/contributingToLibrary.adoc[Improve this doc] 1. Get Familiar with the Library diff --git a/pi4micronaut-utils/src/docs/asciidoc/contribute/newComponent.adoc b/pi4micronaut-utils/src/docs/asciidoc/contribute/newComponent.adoc index 69042bbe..aae5fc50 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/contribute/newComponent.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/contribute/newComponent.adoc @@ -1,37 +1,40 @@ === How to Create a New Component [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/contribute/newComponent.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/contribute/newComponent.adoc[Improve this doc] -If its compatible with a Raspberry Pi then it should work well with the Pi4Micronaut framework. The following steps should encompass how most components are added to the framework, but should more or different steps be needed, use the -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/contribute/newComponent.adoc[Improve this doc] link to suggest changes. +If its compatible with a Raspberry Pi then it should work well with the Pi4Micronaut. The following steps should encompass how most components are added to the library. Start by creating a new +https://github.com/oss-slu/Pi4Micronaut/issues/new/choose[Issue] to suggest changes. -1. Determine if the device is Input or Output +1. Determine the communication type for the component which you want to use. For example, Buzzer works with PWM and LCD1602 works with I2C. -2. Create a Controller: -** Controllers define and handle interactions with a given component. The Controller of a component will have a `@Controller("/example")` right above the class declaration that acts as the endpoint for requests to the component. Instead of "example", you should name the endpoint something that is identifiable to the component. Each method of the Controller should have a `@Get("/examppleendpoint")` above the method declaration. The endpoint for the method should have the same name as the method and any parameters should be included in the endpoint `/examppleendpoint/{parameter1},{parameter2}`. -** See the https://github.com/oss-slu/Pi4Micronaut/blob/develop/components/src/main/java/com/opensourcewithslu/components/controllers/rgbController.java[RGB Controller] for an example of a Controller. -** Consult the https://micronaut-projects.github.io/micronaut-docs-mn3/3.8.1/guide/#creatingClient[Micronaut Documentation] for more explanation on Controllers. -** All Controllers should be kept here: -`components\src\main\java\com\opensourcewithslu\components\controllers` +2. Setup the circuit. + +3. Add Component to the Application yml -3. Create a Helper: -** A Helper is what the Controller calls to do a action. For example, to change the color of an RGB LED the controller will take the request to change it. The Controller will then call the change color method in the helper. The helper then takes all the actions needed to change the color of the LED. -** See the https://github.com/oss-slu/Pi4Micronaut/blob/develop/micronautpi4j-utils/src/main/java/com/opensourcewithslu/outputdevices/RGBLEDHelper.java[RBG Helper] for an example of a Helper. +** The new component will need to be added to the application yml found at `components/src/main/resources/application.yml`. +** More information on the `application.yml` found in <> -** All Helpers should be kept here: `micronautpi4j-utils\src\main\java\com\opensourcewithslu\(inputdevices or outputdevices)` +4. Create a Helper: +** A Helper is what the Controller calls to do an action. For example, to change the color of an RGB LED the controller will take the request to change it. The Controller will then call the change color method in the helper. The helper then takes all the actions needed to change the color of the LED. +** See the https://github.com/oss-slu/Pi4Micronaut/blob/develop/pi4micronaut-utils/src/main/java/com/opensourcewithslu/outputdevices/RGBLEDHelper.java[RBG Helper] for an example of a Helper. -4. Add Component to the Application yml +** All Helpers should be kept here: `pi4micronaut-utils\src\main\java\com\opensourcewithslu\(inputdevices or outputdevices)` - ** The new component will need to be added to the application yml found at `components/src/main/resources/application.yml`. - ** More infomation on the `application.yml` found in <> +5. Create a Controller: +** Controllers define and handle interactions with a given component. The Controller of a component will have a `@Controller("/example")` right above the class declaration that acts as the endpoint for requests to the component. Instead of "example", you should name the endpoint something that is identifiable to the component. Each method of the Controller should have a `@Get("/exampleEndPoint")` above the method declaration. The endpoint for the method should have the same name as the method and any parameters should be included in the endpoint `/exampleEndPoint/{parameter1},{parameter2}`. +** See the https://github.com/oss-slu/Pi4Micronaut/blob/develop/components/src/main/java/com/opensourcewithslu/components/controllers/rgbController.java[RGB Controller] for an example of a Controller. +** Consult the https://micronaut-projects.github.io/micronaut-docs-mn3/3.8.1/guide/#creatingClient[Micronaut Documentation] for more explanation on Controllers. +** All Controllers should be kept here: +`components\src\main\java\com\opensourcewithslu\components\controllers` -5. Thoroughly test: +6. Thoroughly test: ** Contributors should thoroughly test their integrations ** When submitting a pull request, make sure to include how you tested the component, any circuits that you may have used, and how to run any examples you may have created. ** It is important that reviewers are able to replicated your work in order to properly test the implementation. -6. Create documentation for the component: + +7. Create documentation for the component: ** Create an .adoc file with the component name as the file name. ** Make sure to include all the information that the other components. Simply copy/paste an existing components documentation and edit as needed. - ** Add the file here: `micronautpi4j-utils/src/docs/asciidoc/components` under either input or output components. \ No newline at end of file + ** Add the file here: `pi4micronaut-utils/src/docs/asciidoc/components` under either input or output components. \ No newline at end of file diff --git a/pi4micronaut-utils/src/docs/asciidoc/index.adoc b/pi4micronaut-utils/src/docs/asciidoc/index.adoc index 0838fe8c..c9fa8ce8 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/index.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/index.adoc @@ -32,12 +32,8 @@ include::contribute/contributingToLibrary.adoc[] include::contribute/newComponent.adoc[] -include::adding_creating_App.adoc[] - -include::usingLibrary.adoc[] - -include::components.adoc[] +== Components include::components/commun_WithHardware.adoc[] diff --git a/pi4micronaut-utils/src/docs/asciidoc/introduction.adoc b/pi4micronaut-utils/src/docs/asciidoc/introduction.adoc index c5fbf5b8..24aa551a 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/introduction.adoc +++ b/pi4micronaut-utils/src/docs/asciidoc/introduction.adoc @@ -1,7 +1,7 @@ == Introduction [.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/introduction.adoc[Improve this doc] +https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/introduction.adoc[Improve this doc] diff --git a/pi4micronaut-utils/src/docs/asciidoc/style.css b/pi4micronaut-utils/src/docs/asciidoc/style.css index 67574cc9..1c9f7522 100644 --- a/pi4micronaut-utils/src/docs/asciidoc/style.css +++ b/pi4micronaut-utils/src/docs/asciidoc/style.css @@ -68,10 +68,11 @@ a { position: fixed; box-sizing: border-box; background-color: gainsboro; - max-width: 15.5%; - width: 100%; + max-width: 20%; + width: 20%; } + #toc a { color: royalblue; } @@ -126,19 +127,20 @@ h2 { overflow-y: auto; grid-area: content; padding: 1em; - max-width: 84%; + max-width: 80%; width: 100%; position: fixed; z-index: 1; max-height: 80%; height: 100%; - margin-left: 15.5%; + margin-left: 20%; margin-right: 0; margin-bottom: 1%; margin-top: 8%; padding-bottom: 100px; } + .hljs{ background: #cacbca !important; } diff --git a/pi4micronaut-utils/src/docs/asciidoc/usingLibrary.adoc b/pi4micronaut-utils/src/docs/asciidoc/usingLibrary.adoc deleted file mode 100644 index ebf04b9f..00000000 --- a/pi4micronaut-utils/src/docs/asciidoc/usingLibrary.adoc +++ /dev/null @@ -1,5 +0,0 @@ -== Using the library -[.text-right] -https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/usingLibrary.adoc[Improve this doc] - -TODO: outline the most basic use cases of the library, tbh now sure how this differs from the section above \ No newline at end of file