Skip to content

Commit

Permalink
Adoc Updates (#188)
Browse files Browse the repository at this point in the history
* updating adocs

* how to use pi4micronaut

* how to use pi4micronaut adoc updates

* adoc updates

* indent fix

* adoc changes addressed

* adoc changes

* adoc link updates

* adoc indent fix

* adoc fix

* adoc final updates

* adoc final final updates
  • Loading branch information
joefol authored Mar 14, 2024
1 parent 375d03a commit 456cc0d
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,13 @@ ifdef::rootpath[]
:imagesdir: {rootpath}{imagesdir}
endif::rootpath[]

=== Getting Started With Pi4Micronaut!
This section describes how to build and run the jar file from the Pi4Micronaut project on your raspberry pi.

Note: this is not a tutorial on how to use the Pi4Micronaut library, simply a setup guide.

==== Prerequisites
. Clone our Github repo onto your system
+
https://github.com/oss-slu/Pi4Micronaut/tree/main
=== Build and Run the Jar File on Raspberry Pi
This section describes how to build and run the jar file from the Pi4Micronaut project demo on your raspberry pi.

==== Set up Raspberry Pi OS
. Start by installing the Raspberry Pi Imager
. To install the Imager, follow this guide by the Raspberry Pi Foundation:
+
https://www.raspberrypi.com/documentation/computers/getting-started.html#install-using-imager
. To install the Imager, follow this guide by the Raspberry Pi Foundation
https://www.raspberrypi.com/documentation/computers/getting-started.html#install-using-imager[here].
+
Note: use the same wifi network for your raspberry pi that your system is connected to
. Your configuration should look something like this:
Expand Down Expand Up @@ -51,10 +43,8 @@ ssh test@raspberrypi-test

.. Using the IP address of your Pi:
+
Follow the instructions outlined in this article:
+
https://docs.sunfounder.com/projects/picar-s/en/latest/get_started_with_raspberry_pi.html#get-the-ip-address

Follow the instructions outlined in this article
https://docs.sunfounder.com/projects/picar-s/en/latest/get_started_with_raspberry_pi.html#get-the-ip-address[here].

==== Installing Java
. First, make sure your Raspberry Pi's package list is up-to-date by running the following commands in your Pi's terminal:
Expand Down Expand Up @@ -86,53 +76,62 @@ sudo apt-get install pigpio

==== Build and Copy Over Jar File
. Open your terminal of choice
. Navigate to the Pi4Micronaut root directory
. Navigate to the project root directory
. Enter the following command into the terminal to build the jar file:
+
[source, bash]
----
./gradlew build
----
. The necessary components jar file can be found under "../Pi4Micronaut/components/build/libs/"
+
image:build.png[]
. The necessary jar file can be found under "Demo_Pi4Micronaut/build/libs/Demo_Pi4Micronaut-0.1-all.jar"
+
image:Locate_Jar_File.png[]
. Once you have navigated to this directory, enter the following command:
+
[source, bash]
----
scp components-0.1-all.jar {username}@{hostname}:~
scp Demo_Pi4Micronaut-0.1-all.jar {username}@{hostname}:~
----
+
.. Following our configuration from earlier, this would look like
.. Here is an example command, that looks like
+
[source, bash]
----
scp components-0.1-all.jar test@raspberrypi-test:~
scp Demo_Pi4Micronaut-0.1-all.jar test@raspberrypi-test:~
----
+
image:Copying_Jar_File_To_Pi.png[]

==== Almost Done!
. To test if you've set up Pi4Micronaut correctly on your raspberry pi, we have some sample commands for you run.
. Open a new Windows Powershell and ssh into your raspberry pi.
. 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:
+
[source, bash]
----
sudo java -jar components-0.1-all.jar
sudo java -jar Demo_Pi4Micronaut-0.1-all.jar
----
+
The output should look like this:
+
image::running_jar.png[]
image:SSH_to_Pi_And_Run_Jar_File.png[]
+
With this, a Micronaut localhost server will start running on your machine

. Let's test the https://oss-slu.github.io/Pi4Micronaut/#_led[LED] component which you have setup.

. After getting everything set up, open up a new terminal and ssh into your pi once more.

. Let's test one of the components. Take a look at our documentation for setting up the LED component:
+
https://oss-slu.github.io/Pi4Micronaut/#_led
. After getting everything set up, open up a new PowerShell and ssh into your pi once more.
. Enter the following command to test the turn on function for an LED light:
+
"curl http://localhost:8080/led/ledOn"
. If this command works and the LED has lit up, congratulations! You have successfully built and run one of our components!
[source, bash]
----
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
:imagesdir: img/

ifndef::rootpath[]
:rootpath: ../
endif::rootpath[]

ifdef::rootpath[]
:imagesdir: {rootpath}{imagesdir}
endif::rootpath[]


=== How to use the Pi4Micronaut library

This section will walk you through the process of creating a basic
Micronaut application and the configuration for developing
with Pi4Micronaut. As a demo, this will include the configuration and sample code.

==== Creating A Micronaut Project
. Go to Micronaut's website https://micronaut.io/launch/[here].
. Make sure you have selected Micronaut version 3.10.1 or lower with Java version 17.
. Click Generate Project and download the zip.
. Export the contents of the zip file and open it in IntelliJ or any IDE of your choice.
+
It should look like:
image:Using_Micronaut.png[]

==== Add Dependency
. Go to the build.gradle file and find the dependencies.
. Add the Pi4Micronaut dependency to the list.
+
[source, gradle]
----
implementation("io.github.oss-slu:pi4micronaut-utils:v1.0:all")
----
+
It should look like:
image:Adding_Dependency.png[]

==== Setup Configuration
. Go to the application.yml file and add the configuration of your circuit setup:
+
path: Demo_Pi4Micronaut/src/main/resources/application.yml
. Create a new tree in the yml file as shown below.
+
[source, yaml]
----
pi4j:
digital-output:
led:
name: LED
address: 17
shutdown: LOW
initial: LOW
provider: pigpio-digital-output
----
+
Here we are specifying a led as a digital output type with name LED, address 17, etc.
For more information on the LED setup guide, see our documentation https://oss-slu.github.io/Pi4Micronaut/#_led[here].
+
It should look like:
image:Add_Configuration.png[]

==== Creating Component Class
. Create a new class in the project's src directory as shown below.
+
path: Demo_Pi4Micronaut/src/main/java/com.demoPi4Micronaut
+
This is where you use the implemented LED functions from Pi4Micronaut library.

. Our example code is:
+
image:Add_Class.png[]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== Currently Supported Hardware
== Currently Supported Hardware
[.text-right]
https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/Introduction/supportedHardware.adoc[Improve this doc]

Expand All @@ -10,7 +10,12 @@ We plan on offering support for many more hardware components in the future. If
* Slide Switch
* Rotary Encoder
* RFID Scanner
* LEDs
* RGB LEDs
* LCDs
* Photosensors
* LED
* RGB LED
* LCD Screen
* Photosensor
* Touch Switch Sensor
* Active Buzzer
* Passive Buzzer
* PIR Motion Sensor
* Ultrasonic Sensor
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions pi4micronaut-utils/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ link:javadoc/index.html[API References]

include::introduction.adoc[]

include::Introduction/supportedHardware.adoc[]
include::Introduction/howToUsePi4Micronaut.adoc[]

include::Introduction/gettingStarted.adoc[]
include::Introduction/buildAndRun.adoc[]

include::Introduction/exampleApplications.adoc[]

include::Introduction/supportedHardware.adoc[]

include::contribute/contributingToLibrary.adoc[]

include::contribute/newComponent.adoc[]
Expand Down

0 comments on commit 456cc0d

Please sign in to comment.