{"id":20427079,"url":"https://github.com/pi4j/pi4j-jbang","last_synced_at":"2025-04-12T19:10:18.680Z","repository":{"id":168338170,"uuid":"644038071","full_name":"Pi4J/pi4j-jbang","owner":"Pi4J","description":"JBang examples to get started with Pi4J V2","archived":false,"fork":false,"pushed_at":"2025-03-24T10:53:42.000Z","size":1467,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-09T14:03:03.825Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pi4J.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-22T17:19:36.000Z","updated_at":"2025-03-24T10:53:46.000Z","dependencies_parsed_at":"2023-10-11T22:12:17.175Z","dependency_job_id":"c56e65ec-bc41-418b-97aa-a24d75ff7e9c","html_url":"https://github.com/Pi4J/pi4j-jbang","commit_stats":null,"previous_names":["pi4j/pi4j-jbang"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-jbang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-jbang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-jbang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pi4J%2Fpi4j-jbang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pi4J","download_url":"https://codeload.github.com/Pi4J/pi4j-jbang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618277,"owners_count":21134200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T07:18:38.387Z","updated_at":"2025-04-12T19:10:18.650Z","avatar_url":"https://github.com/Pi4J.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nPi4J V2 :: Java I/O Library for Raspberry Pi :: JBang example code\n==================================================================\n\n[![Chat on Slack](https://img.shields.io/badge/Chat-on%20Slack-blue)](https://join.slack.com/t/pi4j/shared_invite/zt-1ttqt8wgj-E6t69qaLrNuCMPLiYnBCsg)\n[![Site](https://img.shields.io/badge/Website-pi4j.com-green)](https://pi4j.com)\n[![Twitter Follow](https://img.shields.io/twitter/follow/pi4j?label=Pi4J\u0026style=social)](https://twitter.com/pi4j)\n\nThis project contains several example applications that you can run as single files with JBang, using the Pi4J (V2) as demonstrated on Voxxed Days Brussels on May 23th 2023.\n\n[![Watch the video](https://img.youtube.com/vi/w4AR4hWP3Qk/maxresdefault.jpg)](https://youtu.be/w4AR4hWP3Qk)\n\nMore info is available on [pi4j.com: \"Running Pi4J with JBang\"](https://pi4j.com/documentation/building/jbang/).\n\n## PREREQUISITES\n\n* A Raspberry Pi with recent Raspberry Pi OS.\n* Install JBang as described on [jbang.dev/download](https://www.jbang.dev/download/). JBang will install Java if it's not installed yet.\n```shell\n# Install JBang\n$ curl -Ls https://sh.jbang.dev | bash -s - app setup\n\n# Check JBang by requesting its version\n$ jbang --version        \n0.109.0\n```\n* OPTIONAL: Use [Visual Studio Code](https://code.visualstudio.com/), the free IDE.\n```shell\n# Install Visual Studio Code\n$ sudo apt install code\n```\n* OPTIONAL: Install the following extensions in Visual Studio Code:\n  * [Language Support for Java(TM) by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java)\n  * [JBang](https://marketplace.visualstudio.com/items?itemName=jbangdev.jbang-vscode)\n\n## SCRIPTS IN THIS PROJECT\n\nThis project contains several examples to demonstrate both JBang and Pi4J. Each java-file is a full-containing runnable JBang application. This means you don't need Maven, Gradle, or other Java build tool.\n\nTo tell JBang that it must handle the file as a Java application and do some upfront preparation work, the first line in each file is: `///usr/bin/env jbang \"$0\" \"$@\" ; exit $?`.\n\nWhen an application needs dependencies, they are defined inside the file itself in a line starting with `//DEPS`. For instance, to use the Pi4J Core library: `//DEPS com.pi4j:pi4j-core:2.3.0`.\n\nProvided examples\n* Basic introduction\n  * `HelloWorld.java`: Basic Java example.\n* Using dependencies\n  * `JsonParsing.java`: Shows how to use dependencies, can be executed on any computer.\n* Pi4J Basics\n  * `Pi4JMinimalExample.java`: Basic example with Pi4J and a LED (DigitalOutput) and button (DigitalInput).\n* Pi4J with SPI\n  * `Pi4JLedMatrixSpi.java`: Controlling an 8x8 LED Matrix display with an MAX7219.\n  * `Pi4JTempHumPressSpi.java`: Reading temperature, humidity and pressure from a BME280 sensor via SPI.\n* Pi4J with I2C\n  * `Pi4JTempHumPressI2C.java`: Reading temperature, humidity and pressure from a BME280 sensor via I2C.\n* LED strips via serial connection to PixelBlaze Output Expander\n  * `PixelblazeOutputExpander.java`: Controlling LED strips via serial commands to the Pixelblaze Output Expander.\n  * `PixelblazeOutputExpanderImageMatrix8x8.java`: Similar to `PixelblazeOutputExpander.java` to output 8*8 images onto an RGB LED matrix.\n  * `PixelblazeOutputExpanderImageMatrix8x32.java`: Similar to `PixelblazeOutputExpander.java` to output 8*32 images onto an RGB LED matrix.\n\n### GET FROM GITHUB\n\nYou can clone this project to your Raspberry Pi in the terminal with the following commands:\n\n```bash\n$ git clone https://github.com/Pi4J/pi4j-jbang\n$ cd pi4j-jbang\n```\n\n### EXAMPLE USAGE\n\nCheck the **description of each example in the file itself** for more information! These are only a few examples:\n\n```bash\n// Execute HelloWorld \n$ jbang HelloWorld.java\n[jbang] Building jar...\nHello World\n\n// Execute JsonParsing that needs fasterxml libraries \n$ jbang JsonParsing.java \n[jbang] Resolving dependencies...\n[jbang]    com.fasterxml.jackson.core:jackson-annotations:2.14.1\n[jbang]    com.fasterxml.jackson.core:jackson-core:2.14.1\n[jbang]    com.fasterxml.jackson.core:jackson-databind:2.14.1\n[jbang] Dependencies resolved\n[jbang] Building jar...\nData loaded from JSON:\n\nLog message at 2023-02-08T14:39:44.342Z[UTC]\n        Severity: Informative message\n        Message: Program started\nLog message at 2023-02-08T14:39:45.921Z[UTC]\n        Severity: Warning message\n        Message: File X not found\nLog message at 2023-02-08T14:39:46.357Z[UTC]\n        Severity: Error message\n        Message: Error at line Y\n        \n// Execute Pi4JMinimalExample that needs the Pi4J and SLF4J libraries. \n// This example must be executed with sudo as described in the file itself.\n$ sudo `which jbang` Pi4JMinimalExample.java\n[jbang] Building jar...\n[main] INFO com.pi4j.Pi4J - New auto context\n[main] INFO com.pi4j.Pi4J - New context builder\n[main] INFO com.pi4j.platform.impl.DefaultRuntimePlatforms - adding platform to managed platform map [id=raspberrypi; name=RaspberryPi Platform; priority=5; class=com.pi4j.plugin.raspberrypi.platform.RaspberryPiPlatform]\n[main] INFO com.pi4j.util.Console - LED high\n[main] INFO com.pi4j.util.Console - LED low\n```\n\n## WIRING\n\nThe Pi4J examples in this project, require electronic components attached to the Raspberry Pi. In the code, you can find more information about the connections and here the wiring schemes are provided.\n\n### Pi4JMinimalExample.java\n\nTODO\n\n### Pi4JPixelBlazeOutputExpander.java\n\nTODO\n\n### Pi4JTempHumPressI2C.java\n\n![BME280 Wiring with I2C](wiring/bme280_wiring_i2c_breadboard.png)\n\n### Pi4JTempHumPressSpi.java\n\n![BME280 Wiring with SPI](wiring/bme280_wiring_spi_breadboard.png)\n\n## LICENSE\n\nPi4J Version 2.0 and later is licensed under the Apache License,\nVersion 2.0 (the \"License\"); you may not use this file except in\ncompliance with the License.  You may obtain a copy of the License at:\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpi4j%2Fpi4j-jbang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpi4j%2Fpi4j-jbang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpi4j%2Fpi4j-jbang/lists"}