{"id":29052967,"url":"https://github.com/efcasado/flix","last_synced_at":"2025-07-06T13:40:05.112Z","repository":{"id":48252014,"uuid":"349175841","full_name":"efcasado/flix","owner":"efcasado","description":"An Elixir client for the Flic button.","archived":false,"fork":false,"pushed_at":"2021-08-05T09:13:08.000Z","size":88,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T02:46:44.405Z","etag":null,"topics":["elixir","flic"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/efcasado.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-18T18:18:15.000Z","updated_at":"2025-04-19T07:00:14.000Z","dependencies_parsed_at":"2022-08-31T17:14:16.602Z","dependency_job_id":null,"html_url":"https://github.com/efcasado/flix","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/efcasado/flix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efcasado%2Fflix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efcasado%2Fflix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efcasado%2Fflix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efcasado%2Fflix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/efcasado","download_url":"https://codeload.github.com/efcasado/flix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efcasado%2Fflix/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261953199,"owners_count":23235453,"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":["elixir","flic"],"created_at":"2025-06-27T01:01:11.275Z","updated_at":"2025-06-27T01:02:59.202Z","avatar_url":"https://github.com/efcasado.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flix\n\n[![Build Status](https://efcasado.semaphoreci.com/badges/flix/branches/master.svg?style=shields)](https://efcasado.semaphoreci.com/projects/flix) [![Hex.pm](https://img.shields.io/hexpm/v/flix.svg)](https://hex.pm/packages/flix)  [![Hexdocs.pm]()](https://hexdocs.pm/flix/0.1.0/)\n\nAn Elixir client for the [Flic](https://flic.io/) button.\n\n### What's in the name?\n\nThe name `Flix` is the result of combining `Fli(c)`, the name of the button, and\n`(e)x`, the extension used by Elixir source files.\n\n[Flix](https://en.wikipedia.org/wiki/Flix) is also a town in the beautiful\nprovince of Tarragona, Catalonia, Spain.\n\n\n### The Flic protocol\n\n`Flix` implements the full Flic protocol as per described in the\nofficial fliclib-linux-hci [GitHub repository](https://github.com/50ButtonsEach/fliclib-linux-hci/blob/master/ProtocolDocumentation.md).\n\n\n### Usage\n\nFlic buttons don't connect directly to `Flix` nor the other way around. Flic buttons connect\nto a `flicd` via bluetooth. `Flix` applications also connect to `flicd` but via a TCP. See\nthe diagram below.\n\n```\n+------------+  command(s)  +---------+               +---------------+\n|            +-------------\u003e|         |               |               |\n|  Flix App  |     TCP      |  flicd  |\u003c--------------+  Flic Button  |\n|            |\u003c-------------+         |   Bluetooth   |               |\n+------------+   event(s)   +---------+               +---------------+\n```\n\nYou can find more information about Flic's `flicd` in its\n[official page](https://github.com/50ButtonsEach/fliclib-linux-hci).\n\nWriting a Flix application is as simple as defining a new Elixir module,\nusing Flix's `__using__` macro (ie. `use Flix`) and implementing Flix's\n`handle_event/2` callback function.\n\n```elixir\ndefmodule MyFlixApp do\n  use Flix\n\n  def handle_event(event, state) do\n    new_state = do_something(event, state)\n    {:ok, new_state}\n  end\nend\n```\n\nBelow is a full example of a Flix application where a counter is initialised to `0`\nand increased or decreased by one when someone does single- or double-clicks a Flic\nbutton, respectively. The code makes the following assumptions:\n- `flicd` is running and reachable on `raspberrypi.local:5551`.\n- The Flic button (ie. `\"80:E4:DA:78:45:1B\"`) has already been paired with `flicd`.\n\n```elixir\ndefmodule Flix.Examples.Counter do\n  use Flix\n\n  alias Flix.Protocol.Events.ButtonSingleOrDoubleClickOrHold\n  alias Flix.Protocol.Enums.ClickType\n\n  def start(host \\\\ 'raspberrypi.local', port \\\\ 5551) do\n    {:ok, client} = Flix.start(__MODULE__, 0, host, port)\n    :ok = set_up(client)\n    {:ok, client}\n  end\n\n  def start_link(host \\\\ 'raspberrypi.local', port \\\\ 5551) do\n    {:ok, client} = Flix.start_link(__MODULE__, 0, host, port)\n    :ok = set_up(client)\n    {:ok, client}\n  end\n\n  def set_up(client) do\n    :ok = Flix.create_connection_channel(client, \"80:E4:DA:78:45:1B\", 1)\n  end\n\n  def stop(client) do\n    :ok = Flix.stop(client)\n  end\n\n  def handle_event(\n    %ButtonSingleOrDoubleClickOrHold{click_type: ClickType.SingleClick},\n    count\n  ) do\n    new_count = count + 1\n    IO.puts \"Count = #{new_count}\"\n    {:ok, new_count}\n  end\n  def handle_event(\n    %ButtonSingleOrDoubleClickOrHold{click_type: ClickType.DoubleClick},\n    count\n  ) do\n    new_count = count - 1\n    IO.puts \"Count = #{new_count}\"\n    {:ok, new_count}\n  end\n  def handle_event(event, count) do\n    require Logger\n    Logger.debug(\"No handle_event/2 clause in #{__MODULE__} for #{inspect(event)}\")\n    {:ok, count}\n  end\nend\n```\n\n\n### Author(s)\n\n- Enrique Fernandez `\u003cefcasado@gmail.com\u003e`\n\n\n### Acknowledgements\n\nI would like to thank [BlueLabs](https://www.bluelabs.eu/) for sponsoring the\ndevelopment of `Flix` by creating an opportunity for me to work on this project.\n\nThis project was conceived during BlueLabs' 2nd Hackathon (22-23 July, 2021).\n\n[![BlueLabs](images/bluelabs-logo.png?raw=true \"BlueLabs\")](https://www.bluelabs.eu/)\n\n\n### License\n\n\u003e The MIT License (MIT)\n\u003e\n\u003e Copyright (c) 2021, Enrique Fernandez\n\u003e\n\u003e Permission is hereby granted, free of charge, to any person obtaining a copy\n\u003e of this software and associated documentation files (the \"Software\"), to deal\n\u003e in the Software without restriction, including without limitation the rights\n\u003e to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\u003e copies of the Software, and to permit persons to whom the Software is\n\u003e furnished to do so, subject to the following conditions:\n\u003e\n\u003e The above copyright notice and this permission notice shall be included in\n\u003e all copies or substantial portions of the Software.\n\u003e\n\u003e THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\u003e IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\u003e FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\u003e AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\u003e LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\u003e OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\u003e THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefcasado%2Fflix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fefcasado%2Fflix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefcasado%2Fflix/lists"}