Skip to content

Commit 70b1d44

Browse files
Merge pull request #13 from Pi4J/feat/readme
Feature: Extend README with additional information
2 parents ad9d59d + 5d4a79b commit 70b1d44

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

README.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,130 @@ This project contains both example applications and ready-made component classes
99
[CrowPi](https://www.elecrow.com/crowpi-compact-raspberry-pi-educational-kit.html) using the Pi4J (V2) library. You can easily get started
1010
with electronics programming by testing and modifying the bundled examples or even write your own application.
1111

12+
## COMPONENTS
13+
14+
The provided component classes as part of this library provide an implementation for every available component of the CrowPi. The following
15+
table provides an overview of all supported components with a link to their implementation and example app:
16+
17+
| **Component** | **Example App** | **Implementation** |
18+
|---|---|---|
19+
| Button | [ButtonApp.java](src/main/java/com/pi4j/crowpi/applications/ButtonApp.java) | [ButtonComponent.java](src/main/java/com/pi4j/crowpi/components/ButtonComponent.java) |
20+
| ButtonMatrix | [ButtonApp.java](src/main/java/com/pi4j/crowpi/applications/ButtonApp.java) | [ButtonComponent.java](src/main/java/com/pi4j/crowpi/components/ButtonMatrixComponent.java) |
21+
| Buzzer | [BuzzerApp.java](src/main/java/com/pi4j/crowpi/applications/BuzzerApp.java) | [BuzzerComponent.java](src/main/java/com/pi4j/crowpi/components/BuzzerComponent.java) |
22+
| Humidity/Temperature Sensor | [HumiTempApp.java](src/main/java/com/pi4j/crowpi/applications/HumiTempApp.java) | [HumiTempComponent.java](src/main/java/com/pi4j/crowpi/components/HumiTempComponent.java) |
23+
| IR Receiver | [IrReceiverApp.java](src/main/java/com/pi4j/crowpi/applications/IrReceiverApp.java) | [IrReceiverComponent.java](src/main/java/com/pi4j/crowpi/components/IrReceiverComponent.java) |
24+
| LCD Display | [IrReceiverApp.java](src/main/java/com/pi4j/crowpi/applications/IrReceiverApp.java) | [IrReceiverComponent.java](src/main/java/com/pi4j/crowpi/components/LcdDisplayComponent.java) |
25+
| LED Matrix | [IrReceiverApp.java](src/main/java/com/pi4j/crowpi/applications/IrReceiverApp.java) | [IrReceiverComponent.java](src/main/java/com/pi4j/crowpi/components/LcdDisplayComponent.java) |
26+
| Light Sensor | [LightSensorApp.java](src/main/java/com/pi4j/crowpi/applications/LightSensorApp.java) | [LightSensorComponent.java](src/main/java/com/pi4j/crowpi/components/LightSensorComponent.java) |
27+
| PIR Motion Sensor | [PirMotionSensorApp.java](src/main/java/com/pi4j/crowpi/applications/PirMotionSensorApp.java) | [PirMotionSensorComponent.java](src/main/java/com/pi4j/crowpi/components/PirMotionSensorComponent.java) |
28+
| Relay | [RelayApp.java](src/main/java/com/pi4j/crowpi/applications/RelayApp.java) | [RelayComponent.java](src/main/java/com/pi4j/crowpi/components/RelayComponent.java) |
29+
| RFID | [RfidApp.java](src/main/java/com/pi4j/crowpi/applications/RfidApp.java) | [RfidComponent.java](src/main/java/com/pi4j/crowpi/components/RfidComponent.java) |
30+
| Servo Motor | [ServoMotorApp.java](src/main/java/com/pi4j/crowpi/applications/ServoMotorApp.java) | [ServoMotorComponent.java](src/main/java/com/pi4j/crowpi/components/ServoMotorComponent.java) |
31+
| Seven Segment Display | [SevenSegmentApp.java](src/main/java/com/pi4j/crowpi/applications/SevenSegmentApp.java) | [SevenSegmentComponent.java](src/main/java/com/pi4j/crowpi/components/SevenSegmentComponent.java) |
32+
| Step Motor | [StepMotorApp.java](src/main/java/com/pi4j/crowpi/applications/StepMotorApp.java) | [StepMotorComponent.java](src/main/java/com/pi4j/crowpi/components/StepMotorComponent.java) |
33+
| Tilt Sensor | [StepMotorApp.java](src/main/java/com/pi4j/crowpi/applications/StepMotorApp.java) | [StepMotorComponent.java](src/main/java/com/pi4j/crowpi/components/TiltSensorComponent.java) |
34+
| Touch Sensor | [TouchSensorApp.java](src/main/java/com/pi4j/crowpi/applications/TouchSensorApp.java) | [TouchSensorComponent.java](src/main/java/com/pi4j/crowpi/components/TouchSensorComponent.java) |
35+
| Ultrasonic Distance Sensor | [UltrasonicDistanceSensorApp.java](src/main/java/com/pi4j/crowpi/applications/UltrasonicDistanceSensorApp.java) | [UltrasonicDistanceSensorComponent.java](src/main/java/com/pi4j/crowpi/components/UltrasonicDistanceSensorComponent.java) |
36+
| Vibration Motor | [VibrationMotorApp.java](src/main/java/com/pi4j/crowpi/applications/VibrationMotorApp.java) | [VibrationMotorComponent.java](src/main/java/com/pi4j/crowpi/components/VibrationMotorComponent.java) |
37+
38+
Due to very tight timing constraints, two of the components had to use an alternative implementation without relying on Java. This could be
39+
improved in the future by moving this logic into native code using JNI or putting these components behind a dedicated microcontroller:
40+
41+
- **IR Receiver:** This component relies on the `mode2` binary for retrieving the signal pulses, provided as part of the LIRC software
42+
bundle. While all parsing and logic has been implemented in Java, measuring the pulses accurately enough was not possible.
43+
- **Humidity/Temperature Sensor:** Due to being based on a DHT11 sensor, this component requires an extreme amount of precision in terms of
44+
timing, resulting in measurement failures even when running as native code on a Raspberry Pi. To still provide some support for this
45+
component, it requires setting up the `dht11` [kernel module](https://github.com/torvalds/linux/blob/master/drivers/iio/humidity/dht11.c)
46+
which is part of Linux Industrial I/O.
47+
48+
The CrowPi OS image mentioned further down below supports both workarounds out of the box without further configuration.
49+
50+
## CUSTOM OS IMAGE
51+
52+
Each [tagged GitHub release](https://github.com/Pi4J/pi4j-example-crowpi/releases/latest) provides a pre-built version of the custom OS
53+
image called "CrowPi OS". It is based on the official "Raspberry Pi OS 2021-03-25" and automatically built using Packer. Using this image
54+
provides the following set of benefits:
55+
56+
- Preconfigured locale (en_US), keyboard (US) and timezone (Europe/Zurich)
57+
- Preconfigured wireless country (Switzerland) by default
58+
- Remote management via SSH and VNC possible without configuration
59+
- Preinstalled OpenJDK 11 with Gluon JavaFX to get quickly started
60+
- Preconfigured `/boot/config.txt` which supports all components out of the box
61+
- Dynamic wallpaper which shows Ethernet/WLAN address and hostname
62+
- Comes with `lirc` preinstalled to run the IR receiver component
63+
64+
You may download the zip-compressed archive `crowpi.img.zip`, extract it and flash it with the imaging tool of your choice to get started.
65+
The default installation provides an user account `pi` with the password `crowpi` and sudo privileges.
66+
67+
## FRAMEWORK
68+
69+
To simplify adding and launching new applications, a custom launcher has been built using PicoCLI.
70+
The [Launcher.java](src/main/java/com/pi4j/crowpi/Launcher.java)
71+
class contains a static list of available targets called `APPLICATIONS` which has to be adjusted when adding new applications to the
72+
project.
73+
74+
By default, an interactive menu gets shown which allows selecting a single target to launch. After executing this target, the application
75+
will automatically end. You may optionally specify the name of an application as the first argument, i.e. `BuzzerApp`, to directly launch
76+
this specific application.
77+
78+
If you want to comfortably test all supported components at once, you may specify the flag `--demo` which will return to the interactive
79+
launcher menu once a target has been executed.
80+
81+
Creating your own applications is as simple as implementing the provided [Application.java](src/main/java/com/pi4j/crowpi/Application.java)
82+
interface, which only requires a single `void execute(Context pi4j)` method.
83+
84+
## BUILD SYSTEM
85+
86+
This project uses Maven for building, testing and running the various applications. While it can be used directly on a Raspberry Pi /
87+
CrowPi, it also supports compiling everything together locally, then pushing the artifacts to the device and running them remotely. The
88+
build system defaults to local deployments, but the following set of Maven properties can be set for remote deployments:
89+
90+
- **`crowpi.remote.host` (required):** Current IP address of the CrowPi, e.g. `192.168.1.2`, used for SCP/SSH
91+
- **`crowpi.remote.port` (optional):** Port to use for SCP/SSH communication, defaults to `22`
92+
- **`crowpi.remote.username` (optional):** Username to use for SCP/SSH, defaults to `pi`
93+
- **`crowpi.remote.password` (optional):** Password to use for SCP/SSH, defaults to `crowpi`
94+
- **`crowpi.remote.target` (optional):** Default directory to temporarily store built artifacts, defaults to `/home/pi/deploy`
95+
- **`crowpi.remote.jvmOptions` (optional):** Additional JVM options, defaults to an empty string
96+
97+
In case of a remote deployment, the artifacts get pushed via SCP and will be automatically executed using SSH. Please note that any existing
98+
files in the deployment folder are being automatically overwritten.
99+
100+
Regardless of which deployment mode you have chosen, the property `crowpi.launcher.args` can be set to specify which arguments should be
101+
passed as-is when running the launcher. This can be used for launching demo mode or directly executing a single application.
102+
103+
## SYSTEM REQUIREMENTS
104+
105+
You may skip this section when using the pre-built CrowPi OS image. Should you choose to run your own image instead, you will need to ensure
106+
that the following lines are present in your `/boot/config.txt`:
107+
108+
```ini
109+
[all]
110+
# Enable X with 128MB GPU memory and support the custom resolution of the CrowPi LCD panel
111+
start_x = 1
112+
gpu_mem = 128
113+
hdmi_cvt 1024 600 60 6 0 0 0
114+
115+
# Enable I2C and SPI
116+
dtparam = i2c_arm=on
117+
dtparam = spi=on
118+
119+
# Enable audio
120+
dtparam = auto=on
121+
122+
# Enable GPIO-IR
123+
dtoverlay = gpio-ir,gpio_pin=20
124+
125+
# Enable DHT11
126+
dtoverlay = dht11,gpiopin=4
127+
128+
# Enable DRM VC4 V3D with up to 2 frame buffers
129+
dtoverlay = vc4-fkms-v3d
130+
max_framebuffers = 2
131+
```
132+
133+
If you want to use the IR receiver and/or humidity/temperature sensor component, you will have to ensure that the required dependencies
134+
mentioned in the "COMPONENTS" section of this README have also been fulfilled.
135+
12136
## RUNTIME DEPENDENCIES
13137

14138
This project has the following runtime dependency requirements:

0 commit comments

Comments
 (0)