Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/elehobica/pico_tinygo_buttons

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/elehobica/pico_tinygo_buttons

  • v0.0.0-20230402054818-f92ff75bc4da
  • Source
  • Go
  • Socket score

Version published
Created
Source

Raspberry Pi Pico TinyGo Buttons

Overview

This project is a library for handling multiple buttons on Raspberry Pi Pico by TinyGo.

  • confirmed with TinyGo 0.27.0

This project features to detect:

  • Single Push event
  • Repeated Single Push event
  • Multiple Push event (exclusive with Repeated Single)
  • Long (Long) Push event (exclusive with Repeated Single)

Supported Board and Device

  • Raspberry Pi Pico
  • 5 Way Switch + 2 Buttons

Pin Assignment & Connection

5 Way Switch + 2 Buttons

Pico Pin #Pin NameFunctionConnection
23GNDGNDCOM
24GP18GPIO InputRESET
25GP19GPIO InputSET
26GP20GPIO InputCENTER
27GP21GPIO InputRIGHT
29GP22GPIO InputLEFT
31GP26GPIO InputDOWN
32GP27GPIO InputUP

How to build

  • Build is confirmed only in TinyGo Docker environment with Windows WSL2 integration
  • Before starting docker, clone repository to your local enviroment (by GitBash etc.)
> cd /d/somewhere/share
> git clone -b main https://github.com/elehobica/pico_tinygo_buttons.git
  • Docker
> wsl
(in WSL2 shell)
$ docker pull tinygo/tinygo:0.27.0
$ docker images
$ docker run -it -v /mnt/d/somewhere/share:/share tinygo/tinygo:0.27.0 /bin/bash
(in docker container)
# cd /share

(copy repository for docker native directory for best performance of WSL2, otherwise stay /share)
(# cp -r /share/pico_tinygo_buttons ~/ && cd ~ )

# cd pico_tinygo_buttons
  • Go Module Configuration
# go mod init github.com/elehobica/pico_tinygo_buttons
# go mod tidy
  • TinyGo Build
# tinygo build -target=pico --serial uart -o pico_tinygo_buttons.uf2

(copy UF2 back to Windows local if working on docker native directory)
(# cp pico_tinygo_buttons.uf2 /share/pico_tinygo_buttons/ )
  • Put UF2

Then, go back to Windows environment and put "pico_tinygo_buttons.uf2" on RPI-RP2 drive

Usage Guide

Button Function Assignment

  • Multiple / Long / LongLong detection for Center button
  • Single / Repeated Single detection for Left/Right/Up/Down buttons
  • Single detection for Set/Reset buttons

Note

  • If Multiple detection enabled, time lag defined by 'actFinishCnt' is needed to determine action
  • Repeat count information of Repeated Single detection is served for UI items to accelerate something by continuous button push
  • Use NewButtonConfig() for customizing button detection parameters other than default configurations
  • Trriple clicks of Center button shows processing time of button scan function (in this example project)

Log Example

=========================
== pico_tinygo_buttons ==
=========================
center: 1
left: 1
right: 1
up: 1
up: 1
right: 1
down: 1
down: 1 (Repeated 1)
down: 1 (Repeated 2)
center: 2
set: 1
reset: 1
center: Long
center: LongLong
center: 3
time 41us (scan: 650)

FAQs

Package last updated on 02 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc