{"id":13395628,"url":"https://github.com/jkransen/framboos","last_synced_at":"2026-03-15T06:35:31.565Z","repository":{"id":3977166,"uuid":"5072457","full_name":"jkransen/framboos","owner":"jkransen","description":"Pure Java (Scala) implementation for accessing low-level GPIO on Raspberry Pi, BeagleBoard etc","archived":false,"fork":false,"pushed_at":"2020-02-11T05:46:03.000Z","size":219,"stargazers_count":91,"open_issues_count":2,"forks_count":20,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-07-31T18:15:19.374Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/jkransen.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}},"created_at":"2012-07-16T19:41:35.000Z","updated_at":"2023-10-19T12:06:47.000Z","dependencies_parsed_at":"2022-08-31T14:11:47.420Z","dependency_job_id":null,"html_url":"https://github.com/jkransen/framboos","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jkransen/framboos","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkransen%2Fframboos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkransen%2Fframboos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkransen%2Fframboos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkransen%2Fframboos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jkransen","download_url":"https://codeload.github.com/jkransen/framboos/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkransen%2Fframboos/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30536235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-15T05:01:24.307Z","status":"ssl_error","status_checked_at":"2026-03-15T04:58:50.392Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-07-30T18:00:26.791Z","updated_at":"2026-03-15T06:35:31.545Z","avatar_url":"https://github.com/jkransen.png","language":"Java","funding_links":[],"categories":["Framework"],"sub_categories":[],"readme":"Java GPIO access\n----------------\n\nFramboos is a small Java wrapper around the default GPIO driver on Linux boards like Raspberry Pi \nand BeagleBoard. It does not depend on any additional native libraries. The program that uses it \nmust be run as root in order to access the driver files under /sys/class/gpio/. It supports input \nand output pins, as well as serial (UART) communication. It does not support PWM, SPI or I2C. If \nyou need any of that, use [Pi4J](http://pi4j.com) instead, which includes native code and the \nwiringPi library. This is meant to be a pure Java (Scala) implementation that can be added as a \nsimple Maven dependency to any Java project.\n\nJava code example to use an input pin:\n\n    import framboos.InPin;\n    InPin button = new InPin(8);\n    boolean isButtonPressed = button.getValue();\n    button.close();\n  \nJava code example to use an output pin:\n\n    import framboos.OutPin;\n    OutPin led = new Outpin(0);\n    led.setValue(true);\n    led.close();\n\nScala code example to use an input pin:\n\n    import framboos.InPin\n    val button = InPin(8)\n    val isButtonPressed = button.value\n    button.close\n  \nScala code example to use an output pin:\n\n    import framboos.OutPin\n    val led = Outpin(0)\n    led.setValue(true)\n    led.close\n\nIt is important to close pins that are created, so that they are released for other programs.\n\nExtensions for Akka and asynchronous programming\n------------------------------------------------\n\nInstead of creating and polling an input pin yourself, you can create an Observer that will run \na function any time the pin value changes. \n\nSample scala code to observe an input pin:\n\n    import framboos.async.ObservableInPin\n    val inPin = ObservableInPin(8)\n    inPin.subscribe(newValue =\u003e println(s\"New value $newValue\")\n\nIn an Akka application, you can create Actors that create GPIO/UART output based on received \nAkka messages, or that send Akka messages themselves on changed GPIO/UART input. \n\nWireUp is a provided sample Akka actor, that shows what the InPinActor, OutPinActor and \nSerialPortActor can do:\n\n    val inPin8 = context.actorOf(Props(new InPinActor(8)), name = \"inPin8\")\n    inPin8 ! AddListener(self)\n\n    val outPin0 = context.actorOf(Props(new OutPinActor(0)), name = \"outPin0\")\n\n    val serialPort = context.actorOf(Props(new SerialPortActor(\"ttyAMA0\")), name = \"serialPort\")\n    serialPort ! AddListener(self)\n\n    def receive: Receive = {\n        case NewValue(value: Boolean) =\u003e {\n            outPin0 ! NewValue(value)\n            val pressed = if (value) \"pressed\" else \"released\"\n            serialPort ! SendMessage(s\"Button $pressed at ${System.currentTimeMillis}\\n\")\n        }\n        case ReceiveMessage(message: String) =\u003e {\n            outPin0 ! NewValue(true)\n            serialPort ! SendMessage(s\"Received your message: $message\\n\")\n        }\n    }\n\nInPinActor will send NewValue messages, containing a boolean of the new value. SerialPortActor \nwill send ReceiveMessage messages for every line of text received on the serial port (which here \nis /dev/ttyAMA0, the default serial Rx/Tx pins on the GPIO header of the Raspberry Pi). \n\nOutPin will accept NewValue(boolean) messages, and set the output pin accordingly. SerialPortActor \nacccepts SendMessage messages as well, and will send the containing String over the serial line. \n\nWired up like this, incoming serial input will be sent back with a prefix, and make the LED light \nup. Pressing the button will light the LED as well, and send a text over the serial line. Releasing \nthe button will make the LED go off (even if it was triggered by incoming serial text).\n\nPin assignment\n--------------\n\nWhen passing an integer to a constructor it will default to the wiringPi layout. When passing a \nString representation (i.e. \"GPIO2_1\" for BeagleBone) it will directly address the pin, bypassing \nthe wiringPi numbering. Note that this library does not depend on or use wiringPi under the hood, \nbut by default it uses its numbering scheme instead of e.g. the native Broadcom numbers in the \ncase of Raspberry Pi.\n\nGPIO pins in the numbering used by wiringPi: \n\n\n|   |   |GND|   |   | 1 |   | 4 | 5 |   | 6 | 10|   |\n|---|---|---|---|---|---|---|---|---|---|---|---|---|\n|   | 8 | 9 | 7 |   | 0 | 2 | 3 |   |   |   |   |   |\n\nThe same diagram as seen when the Pi is held upside down, with the GPIO headers towards you:\n\n|   |   |   |   |   | 3 | 2 | 0 |   | 7 | 9 | 8 |   |\n|---|---|---|---|---|---|---|---|---|---|---|---|---|\n|   | 10| 6 |   | 5 | 4 |   | 1 |   |   |GND|   |   |\n\nFor simplicity sake, the assignments of the other pins are left out.\n\nProvided sample code\n--------------------\n\nNext to the wrapper classes, I made some classes that make connected LEDs  light up in different \npatterns. For this to work, you need to connect the LEDs like I did. I use the Starter Kit from \nSK Pang, which contains a couple of LEDs, 2 buttons and 10 wires. At first I used 9 LEDs minus \nthe number of buttons used, as the Starter Kit has limited wires, but later I decided to wire all \n9 LEDs with custom wires, so there is no need to rewire when switching algorithms.\n\nFor the Nine LED algorithms, connect pins 0 to 7 in that order to the LEDs, and 10 as ninth.\nAdd button 1 to pin 8, and button 2 to pin 9. These pins have pull-up resistors to allow simple \nbuttons that short-circuit when pressed.\n\nUsage\n-----\n\nTo control the pins directly from your own code, simply add this dependency to your pom.xml:\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003eframboos\u003c/groupId\u003e\n        \u003cartifactId\u003eframboos\u003c/artifactId\u003e\n        \u003cversion\u003e0.0.1-SNAPSHOT\u003c/version\u003e\n    \u003c/dependency\u003e\n\nAnd run this from the root of the framboos project:\n\n    mvn install\n\nThis will create a file target/framboos-X.Y.Z.jar and install it into your local repository.\n\nTo run one of the patterns, run the application itself inside the jar:\n\n    java -jar target/framboos-X.Y.Z.jar\n\nThis will pick a random pattern to light up the LEDs. You can also specify the pattern you want \nto run, like this:\n\n    java -jar target/framboos-X.Y.Z.jar caterpillar\n\nFor a complete list of available pattern algorithms, examine this file:\n\n    META-INF/services/framboos.algorithm.Algorithm\n\nWiring notes\n------------\n\nPlease do use the resistors that come with the Starter Kit (or your own resistors if you don't \nuse that kit) when connecting LEDs, or the current will fry them. Connect them serially, which \nmeans like this: connect one leg of the resistor to the - (minus) bottom line of the breadboard, \nwhere you also connected the ground of the Raspberry Pi. Connect the other side of the resistor \nwith the short leg of the LED. Connect the long leg of the LED to whatever port you\nconnect it to.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkransen%2Fframboos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjkransen%2Fframboos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkransen%2Fframboos/lists"}