{"id":21840509,"url":"https://github.com/rubiojr/go-pirateaudio","last_synced_at":"2025-04-14T10:51:55.195Z","repository":{"id":66323268,"uuid":"331632343","full_name":"rubiojr/go-pirateaudio","owner":"rubiojr","description":"Go module to control Pimoroni's Pirate Audio LCD and buttons.","archived":false,"fork":false,"pushed_at":"2024-06-20T10:52:06.000Z","size":29470,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T00:05:23.501Z","etag":null,"topics":["periphio","pimoroni","pirate-audio","st7789"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubiojr.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":"2021-01-21T13:13:22.000Z","updated_at":"2025-02-25T00:19:12.000Z","dependencies_parsed_at":"2024-11-27T21:39:08.535Z","dependency_job_id":null,"html_url":"https://github.com/rubiojr/go-pirateaudio","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiojr%2Fgo-pirateaudio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiojr%2Fgo-pirateaudio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiojr%2Fgo-pirateaudio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiojr%2Fgo-pirateaudio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubiojr","download_url":"https://codeload.github.com/rubiojr/go-pirateaudio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248868857,"owners_count":21174754,"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":["periphio","pimoroni","pirate-audio","st7789"],"created_at":"2024-11-27T21:26:32.195Z","updated_at":"2025-04-14T10:51:55.177Z","avatar_url":"https://github.com/rubiojr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Pirate Audio Go Module\n\nGo module to control Pimoroni's Pirate Audio LCD and buttons.\n\n⚠️   Highly Experimental, API subject to change, may set your device on fire ⚠️ \n\n![gadget.jpg](gadget.jpg)\n\nHead over to [the official Pirate Audio GitHub repository](https://github.com/pimoroni/pirate-audio) to configure your Raspberry to be able to use this library. You'll need the `config.txt` changes mentioned in the README.\n\n## ST7789\n\nThe driver package for the 240x240px [Pirate Audio display](https://shop.pimoroni.com/products/pirate-audio-headphone-amp).\n\nHeavily based on the [TinyGo](https://github.com/tinygo-org/drivers/tree/e376785596dc8269f3e8aa42a9bf75fb1457febc/st7789) driver, modified to work with mainline Go, using [periph.io](https://periph.io) to interface with the Raspberry PI (SPI/GPIO).\n\nAlso used the [Python driver](https://github.com/pimoroni/st7789-python) by [Philip Howard](https://github.com/Gadgetoid) as a reference.\n\n### Drawing an Image on the display\n\n```Go\n// Display a rotated image the display\npackage main\n\nimport (\n\t\"fmt\"\n\t\"image/color\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/rubiojr/go-pirateaudio/display\"\n)\n\nfunc main() {\n\tif len(os.Args) \u003c 2 {\n\t\tfmt.Fprintf(os.Stderr, \"Usage: %s \u003cimg-path\u003e\\n\", os.Args[0])\n\t\tos.Exit(1)\n\t}\n\n\tdsp, err := display.Init()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer dsp.Close()\n\n\t// Set the screen color to white\n\tdsp.FillScreen(color.RGBA{R: 0, G: 0, B: 0, A: 0})\n\n\timg, err := os.Open(os.Args[1])\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer img.Close()\n\n\t// Rotate before pushing pixels, so the image appears rotated\n\tdsp.Rotate(display.ROTATION_180)\n\tdsp.DrawImage(img)\n}\n```\n\n### Controlling the hardware buttons (A,B,X,Y)\n\n```Go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/rubiojr/go-pirateaudio/buttons\"\n)\n\nfunc main() {\n\tbuttons.OnButtonAPressed(func() {\n\t\tfmt.Println(\"Yo Dawg, A pressed\")\n\t})\n\n\tbuttons.OnButtonXPressed(func() {\n\t\tfmt.Println(\"Yo Dawg, X pressed\")\n\t})\n\n\tbuttons.OnButtonYPressed(func() {\n\t\tfmt.Println(\"Yo Dawg, Y pressed\")\n\t})\n\n\tbuttons.OnButtonBPressed(func() {\n\t\tfmt.Println(\"Yo Dawg, B pressed\")\n\t})\n\n\tfor {\n\t\ttime.Sleep(1)\n\t}\n}\n```\n\n### Combining HW buttons and image display\n\n![](images/rotate.gif)\n\n```Go\n// Rotate an image pressing the 'A' hardware button\npackage main\n\nimport (\n\t\"fmt\"\n\t\"image/color\"\n\t\"log\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/rubiojr/go-pirateaudio/buttons\"\n\t\"github.com/rubiojr/go-pirateaudio/display\"\n)\n\nfunc main() {\n\tif len(os.Args) \u003c 2 {\n\t\tfmt.Fprintf(os.Stderr, \"Usage: %s \u003cimg-path\u003e\\n\", os.Args[0])\n\t\tos.Exit(1)\n\t}\n\n\tdsp, err := display.Init()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer dsp.Close()\n\n\tdsp.FillScreen(color.RGBA{R: 0, G: 0, B: 0, A: 0})\n\n\tvar rotation display.Rotation\n\trotation = 0\n\tbuttons.OnButtonAPressed(func() {\n\t\tdsp.FillScreen(color.RGBA{R: 0, G: 0, B: 0, A: 0})\n\t\t// Rotate before pushing pixels, so the image appears rotated\n\t\tdsp.Rotate(rotation)\n\t\timg, err := os.Open(os.Args[1])\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tdefer img.Close()\n\t\tdsp.DrawImage(img)\n\t\trotation++\n\t\tif rotation \u003e 3 {\n\t\t\trotation = 0\n\t\t}\n\t})\n\n\tfor {\n\t\ttime.Sleep(1)\n\t}\n}\n```\n\n### Drawing text\n\n![](docs/images/matrix.gif)\n\n```Go\npackage main\n\nimport (\n\t\"time\"\n\n\t\"github.com/rubiojr/go-pirateaudio/textview\"\n)\n\nfunc main() {\n\topts := textview.DefaultOpts\n\topts.FGColor = textview.GREEN\n\ttv := textview.NewWithOptions(opts)\n\ttv.Draw(\"\")\n\ttime.Sleep(3 * time.Second)\n\ttv.DrawChars(\"Wake up, Neo...\")\n\ttime.Sleep(3 * time.Second)\n\ttv.DrawChars(\"The Matrix has you...\")\n\ttime.Sleep(3 * time.Second)\n\ttv.DrawChars(\"Follow the white rabbit.\")\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubiojr%2Fgo-pirateaudio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubiojr%2Fgo-pirateaudio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubiojr%2Fgo-pirateaudio/lists"}