GithubHelp home page GithubHelp logo

tinygo-org / gobadge Goto Github PK

View Code? Open in Web Editor NEW
37.0 7.0 23.0 80.17 MB

TinyGo powered badge using Adafruit Pybadge Hardware

Go 98.45% Makefile 1.13% Dockerfile 0.42%
adafruit badge golang hacktoberfest tinygo

gobadge's Introduction

GoBadge

TinyGo powered badge using the Adafruit Pybadge hardware aka "GoBadge".

https://www.adafruit.com/product/4200

How to install

  • Install TinyGo using the instructions from https://tinygo.org

  • Clone this repo

  • Change directories into the directory with the repo

  • Connect your Gobadge to your computer using a USB cable

  • Make sure to turn on the badge, flip the switch at the top of the board next to select to the on position. The screen should light up and might be showing a sine wave display (if it was not already flashed to something else). location of on off switch

Important Note

The first time you flash your new GoBadge, you will probably need to double-click the "Reset" button located on the back of the badge in order to put the badge into bootloader mode. This will only need to be done once on brand new badges, after that you can flash it normally.

  • Run this command to compile and flash the code to your Gobadge:

If you are running Mac or Linux, or have make installed you can run the following:

make flash

otherwise run tinygo directly

tinygo flash -target gobadge .

Note: if you get a permision denied error; please, consult this page for possible solution. You many need to restart the computer; afterward to get the group to stick.

  • To display a conference logo on your badge, use one of the following targets (depending on GC for Europe, UK, or US):
make flash-gceu
make flash-gcuk
make flash-gcus
  • To customize the Gobadge with your own name and information, use the NAME, TITLE1, and TITLE2 variables like this:
make flash-gcus NAME="@TinyGolang" TITLE1="Go compiler" TITLE2="small places"

Add an new logo

  • Create an image with a 160x128 pixels size, copy it into cmd/assets folder.
    For the moment only jpeg images are supported.
  • In cmd/main.go add the path to your file here
const (
gopherconEU22Logo = "./cmd/assets/gopherconeu-2022.jpg"
gopherconUK22Logo = "./cmd/assets/gopherconuk-2022.jpg"
gopherconUS22Logo = "./cmd/assets/gopherconus-2022.jpg"
yourPathLogoHere = "./your/path/to/the/logo"
)
  • Add the corresponding flag to the conf map:
func confs() map[string]string {
	return map[string]string{
		"gceu22"    : gopherconEU22Logo,
		"gcuk22"    : gopherconUK22Logo,
		"gcus22"    : gopherconUS22Logo,
		"flagLogo"  : yourPathLogoHere,
	}
}

Add a new target to the Makefile:

flash-yourconf:
	go run cmd/main.go -conf=flagLogo
	tinygo flash -target gobadge .

You can run:

make flash-yourconf

It will use cmd/logos/logo-template.txt to generate the image into a []color.RGBA. Then it is stored in variable in logo.go file.

package main

import "image/color"

var logoRGBA = []color.RGBA{ {255, 255, 255} }

After the image has been generated, the make command will flash it to the board.

๐Ÿ‘ Congratulations! It is now a GoBadge.

gobadge's People

Contributors

brunoga avatar conejoninja avatar deadprogram avatar didiermichel avatar doniacld avatar gdey avatar hervenicol avatar mrwormhole avatar orsinium avatar toejough avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gobadge's Issues

Light Sensor Example Idea

Hello, I have realized it is missing one sensor demo related to light sensor, I believe it would be highly beneficial

so my idea is "Light" under "Accelometer" example, I read the A7 pin and get values between 0-65535 then depending on the value I get, I show the value to the screen and make neopixels light up with white color,

level 1 -> 0-13107 (1 led white)
level 2 -> 13107-26214 (2 leds white)
... so forth and so on until level 5

due to missing docs; it took my 2-3 hours to figure out how to read analog sensor(machine.A7), I have gone through
https://cdn-learn.adafruit.com/downloads/pdf/adafruit-pybadge.pdf
https://trueblood.info/pwm-and-analog-input-using-tinygo-on-arduino-uno/
TSL2591 light sensor data sheets to write a driver

I do believe this example is gonna be beneficial for those people who are unfamiliar with tinygo and want to read an analog pin like arduino uno experience. My final thought is without docs, it is not obvious at all do InitADC() and Configure(machine.ADCConfig{})

Snake game is broken

The snake game once worked fine, but now I'm unable to make it work again.

Uncommenting commented code and enabling it again will result in a

panic: runtime error: index out of range

I could make several changes (declare colors as global variables for example) and then the error will be

panic: goroutine stack overflow

This happens even changing code that's not executed , for example in

func (game *Game) Start() {

The error will happen when powering the badge. I think it might be some compiler issue due to that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.