{"id":19156861,"url":"https://github.com/bertrandmartel/fadecandy-android","last_synced_at":"2025-05-07T07:46:33.693Z","repository":{"id":94808322,"uuid":"67318732","full_name":"bertrandmartel/fadecandy-android","owner":"bertrandmartel","description":":sparkles: Fadecandy server library to manage your Fadecandy USB controlled LED driver on Android","archived":false,"fork":false,"pushed_at":"2020-02-11T11:41:45.000Z","size":6033,"stargazers_count":25,"open_issues_count":4,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-19T20:17:30.090Z","etag":null,"topics":["android-library","android-service","fadecandy","fadecandy-server","led-controlling"],"latest_commit_sha":null,"homepage":"https://bertrandmartel.github.io/fadecandy-android","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bertrandmartel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2016-09-04T00:56:41.000Z","updated_at":"2024-05-13T15:32:52.000Z","dependencies_parsed_at":"2023-03-16T12:15:49.545Z","dependency_job_id":null,"html_url":"https://github.com/bertrandmartel/fadecandy-android","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertrandmartel%2Ffadecandy-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertrandmartel%2Ffadecandy-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertrandmartel%2Ffadecandy-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bertrandmartel%2Ffadecandy-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bertrandmartel","download_url":"https://codeload.github.com/bertrandmartel/fadecandy-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252838721,"owners_count":21812082,"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":["android-library","android-service","fadecandy","fadecandy-server","led-controlling"],"created_at":"2024-11-09T08:36:09.947Z","updated_at":"2025-05-07T07:46:33.671Z","avatar_url":"https://github.com/bertrandmartel.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fadecandy Android\n\n[![CircleCI](https://img.shields.io/circleci/project/bertrandmartel/fadecandy-android.svg?maxAge=2592000?style=plastic)](https://circleci.com/gh/bertrandmartel/fadecandy-android) \n[ ![Download](https://api.bintray.com/packages/bertrandmartel/maven/fadecandy-server-android/images/download.svg) ](https://bintray.com/bertrandmartel/maven/fadecandy-server-android/_latestVersion) \n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/fr.bmartel/fadecandy-service/badge.svg)](https://maven-badges.herokuapp.com/maven-central/fr.bmartel/fadecandy-service)\n[![Javadoc](http://javadoc-badge.appspot.com/fr.bmartel/fadecandy-service.svg?label=javadoc)](http://javadoc-badge.appspot.com/fr.bmartel/fadecandy-service)\n[![License](http://img.shields.io/:license-mit-blue.svg)](LICENSE.md)\n\nThe [Fadecandy](https://github.com/scanlime/fadecandy) server library for Android devices\n\nControl your Fadecandy USB LED controller plugged into your Android device\n\nTry Fadecandy server / client with the [sample app](https://play.google.com/store/apps/details?id=fr.bmartel.fadecandy) available on the Playstore.\n\n**No root required**\n\n[![Download Fadecandy from Google Play](http://www.android.com/images/brand/android_app_on_play_large.png)](https://play.google.com/store/apps/details?id=fr.bmartel.fadecandy)\n\n![fadecandy](https://github.com/bertrandmartel/fadecandy-android/raw/master/img/fadecandy.gif)\n\nYou can control your Fadecandy device from :\n* Android smartphone\n* Android tablet\n* Android TV (the sample app is not available on Android TV Playstore but you can upload the apk anyway)\n\n## What is Fadecandy ?\n\nFadecandy is a USB controlled LED driver with on-board dithering. One Fadecandy device support up to 8 strips of 64 Leds that gives you a maximum of 512 Leds/Fadecandy device.\n\n![notif](https://github.com/bertrandmartel/fadecandy-android/raw/master/img/fadecandy.jpg)\n\nCheck [official Fadecandy repository](https://github.com/scanlime/fadecandy) for more information about Fadecandy device\n\n## What is Fadecandy Server ?\n\nFadecandy server is a TCP server embedded in Fadecandy project which is used to remotely control Fadecandy USB devices through [Open Pixel Control protocol](http://openpixelcontrol.org/), a custom TCP protocol tailored to control LEDs\n\nCheck [official Fadecandy repository](https://github.com/scanlime/fadecandy#open-pixel-control-server) for more information about Open Pixel Control Server\n\n## How does it work ? \n\nFadecandy Android fork is available at https://github.com/bertrandmartel/fadecandy\n\nOriginally, Fadecandy server uses libusbx to interface with Fadecandy USB devices. In Android, a regular user has to grant permission for the application to open an USB device.\n\nUsing [Fadecandy Android app](https://play.google.com/store/apps/details?id=fr.bmartel.fadecandy), when you plug a Fadecandy in your Android device, you will see this pop-up :\n\n![notif](https://github.com/bertrandmartel/fadecandy-android/raw/master/screen/permission_pop.png)\n\nIf user click on `Use by default for this USB device`, it wont be asked again for this USB device when the device is re-plugged again.\n\nWhat differs between libusbx Fadecandy server \u0026 Android Fadecandy server is that All USB operations including USB attached/detached events are catch using Java API :\n\n* start server flow :\n\n| order | description  | language |\n|---|--------------------------------------------------------------------------|-------|\n| 1 | register a USB event receiver (for a specific product/vendor ID)         | Kotlin  |\n| 2 | start Fadecandy server                                                   | C++   | \n\n* USB attached flow :\n\n| order | description  | language |\n|---|--------------------------------------------------------------------------|-------|\n| 1 | catch a USB device attached event                                        | Kotlin  |\n| 2 | check if this Fadecandy USB is allowed                                   | Kotlin  |\n| 3 | ask permission if device is not allowed                                  | Kotlin  |\n| 4 | open the device if permission is granted                                 | Kotlin  |\n| 5 | notify Fadecandy server that a new device is attached                    | C++   |                             \n\n* USB detached flow :\n\n| order | description | language |\n|---|-------------------|--------|\n| 1 | catch a USB device detached event | Kotlin |\n| 2 | notify Fadecandy server that a device is detached | C++ |\n\n\n* USB write flow :\n\n| order | description | language |\n|-------|-------------|----------|\n| 1     | prepare data to be written | C++ |\n| 2     | perform a bulk transfer on `UsbDeviceConnection` | Kotlin |\n\nFor writing to USB device, Fadecandy server is calling from C++ a Kotlin method to perform a bulk transfer\n\n## How to include it in your Android project ?\n\n* with Gradle, from jcenter :\n\n```gradle\ncompile 'fr.bmartel:fadecandy-service:1.62'\n```\n\n## How to use it ?\n\n* Use `FadecandyClient` service wrapper : \n\n\n```java\nmFadecandyClient = new FadecandyClient(mContext,\n    new IFcServerEventListener() {\n        @Override\n        public void onServerStart() {\n            // server is started\n        }\n        @Override\n        public void onServerClose() {\n            // server is closed\n        }\n        @Override\n        public void onServerError(ServerError error) {\n            // a server error occured\n        }\n    }, new IUsbEventListener() {\n        @Override\n        public void onUsbDeviceAttached(UsbItem usbItem) {\n            // a Fadecandy device has been attached\n        }\n        @Override\n        public void onUsbDeviceDetached(UsbItem usbItem) {\n            // a Fadecandy device has been detached\n        }\n    },\n    \"com.your.package/.activity.MainActivity\"\n);\n```\n\n`FadecandyClient` will give you an easy-to-use interface between Fadecandy Service and your application\n\n\n### Start Fadecandy server \n\n```java\nmFadecandyClient.startServer();\n```\n\n`startServer()` will internally stop the server if already running before starting\n\n### Start Fadecandy server with custom server config\n\n```java\nmFadecandyClient.startServer(yourConfig);\n```\n\nFadecandy server configuration is a JSON document, check [server config doc](https://github.com/scanlime/fadecandy/blob/master/doc/fc_server_config.md)\n\n### Stop Fadecandy server\n\n```java\nmFadecandyClient.closeServer();\n```\n\n### Check if server is running \n\n```java\nboolean isRunning = mFadecandyClient.isServerRunning();\n```\n\n### Get last server IP/host \u0026 last server port\n\n```java\nString serverAdress = mFadecandyClient.getIpAddress();\n\nint serverPort = mFadecandyClient.getServerPort();\n```\n\n### Set server IP/host \u0026 server port \n\n```java\nmFadecandyClient.setServerAddress(\"127.0.0.1\");\n\nmFadecandyClient.setServerPort(7890);\n```\n\nYou will need to call `startServer()` to restart the server after modifying these parameters\n\n### Set server configuration\n\n```java\nmFadecandyClient.setConfig(myConfig);\n```\n\nFadecandy server configuration is a JSON document, check [server config doc](https://github.com/scanlime/fadecandy/blob/master/doc/fc_server_config.md)\n\n### Get list of Fadecandy USB devices attached\n\n```java\nHashMap\u003cInteger, UsbItem\u003e usbDevices = mFadecandyClient.getUsbDeviceMap();\n```\n\nThe key is the USB device file descriptor, The value is an `UsbItem` object encapsulating :\n\n| Class       | description    |\n|-------------|----------------|\n| `UsbDevice` | features attached USB device     |\n| `UsbConnection` | send/receive data from an UBS device |\n| `UsbEndpoint` | channel used for sending/receiving data   |\n\n### Get Fadecandy server configuration \n\n```java\nString config = mFadecandyClient.getConfig();\n```\n\nFadecandy configuration is composed of the Top level object defined in [Fadecandy Server configuration documentation](https://github.com/scanlime/fadecandy/blob/master/doc/fc_server_config.md#top-level-object)\n\n### Set Fadecandy service type \n\n * Set the Fadecandy service as `PERSISTENT` (default value) which means the service will stay in background, a notification will be present in notification view. The user can kill the service by clicking on \"close background service\" on the notification :\n\n```java\nmFadecandyClient.setServiceType(ServiceType.PERSISTENT_SERVICE);\n```\n\n![notif](https://github.com/bertrandmartel/fadecandy-android/raw/master/screen/notif.png)\n\n * Set the Fadencandy service as `NON_PERSISTENT`. The service will be killed as soon as no application is bound to it\n\n```java\nmFadecandyClient.setServiceType(ServiceType.NON_PERSISTENT_SERVICE);\n```\n\n### Bind Fadecandy service without starting server\n\n```java\nmFadecandyClient.connect();\n```\n\n### Unbind Fadecandy service\n\n```java\nmFadecandyClient.disconnect();\n```\n\nAssure you call `disconnect()` to close service \u0026 unregister client receiver when you are done with Fadecandy Service (eg exit your application)\n\n### Proguard\n\nIf you are using proguard add this to your `proguard-rules.pro` : \n\n```proguard\n-keep class fr.bmartel.android.fadecandy.service.FadecandyService { *; }\n\n-keepclassmembers,allowobfuscation class fr.bmartel.android.fadecandy.service.FadecandyService.** {\n    \u003cmethods\u003e;\n}\n```\n\nThis will keep methods in `FadecandyService` to preserve calls from native code to this class\n\n## Build Library\n\n### Get source code\n\n```bash\ngit clone git@github.com:bertrandmartel/fadecandy-android.git\ncd fadecandy-android\ngit submodule update --init --recursive\n```\n\n### Build\n\n```bash\n./gradlew build\n```\n\n## Open Source components\n\n### Fadecandy Service\n\n* Fadecandy : https://github.com/scanlime/fadecandy\n* rapidjson : https://github.com/scanlime/rapidjson\n* libwebsockets : https://github.com/bertrandmartel/libwebsockets\n* Android support-v4\n\n### Fadecandy Application\n\n* DiscreteSeekBar : https://github.com/AnderWeb/discreteSeekBar\n* Android Holo ColorPicker : https://github.com/LarsWerkman/HoloColorPicker\n* Open Pixel Control Library : https://github.com/bertrandmartel/opc-java\n* AndroidAsync : https://github.com/koush/AndroidAsync\n* Ace editor : https://github.com/ajaxorg/ace\n* JS Beautifier : https://github.com/beautify-web/js-beautify\n* Led Icon by Kenneth Appiah, CA (Pulic Domain) : https://thenounproject.com/search/?q=led\u0026i=3156\n* appcompat-v7, design \u0026 recyclerview-v7\n\n## License\n\n```\nThe MIT License (MIT) Copyright (c) 2016-2018 Bertrand Martel\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbertrandmartel%2Ffadecandy-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbertrandmartel%2Ffadecandy-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbertrandmartel%2Ffadecandy-android/lists"}