Giter Club home page Giter Club logo

bobblehat's Introduction

bobbleHAT

A Go library for Raspberry Pi HATs (Hardware Attached on Top), starting with the Sense HAT.

GoDoc Build Status

Documentation

Screen

The Sense HAT has an 8x8 LED matrix that could be used to display the status of a headless server, to write a mini-game, or countless other possibilities.

You can create an 8x8 frame buffer, set pixels with (x,y) coordinates, and then draw the frame buffer to the screen.

fb := screen.NewFrameBuffer()
fb.SetPixel(0, 0, color.Red)
screen.Draw(fb)

Colors are specified as red, green, blue (RGB) components with a range of 0-255. However, these are converted down to 32 shades (0-31) before being sent to the screen.

cyan := color.New(0, 255, 255)

A frame buffer is an 8x8 texture that can be drawn to the screen, but you can also create textures of any size (width, height).

tx := texture.New(16, 16)
tx.SetPixel(8, 8, color.White)

Or load a PNG file into a new texture.

tx, err := texture.Load("image.png")

The blit function will copy between textures with destination and source offsets (x, y) and dimensions (width, height). See the image scrolling example for one use, but this can always be used to draw multi-pixels sprites (opaque).

texture.Blit(fb.Texture, 0, 0, tx, 0, 0, 8, 8)

Stick

The Sense HAT has a tiny joystick control.

input, err := stick.Open("/dev/input/event0")
if err != nil {
	log.Fatal(err)
}

for {
	select {
	case e := <-input.Events:
		switch e.Code {
		case stick.Enter:
			fmt.Println("⏎")
		case stick.Up:
			fmt.Println("↑")
		case stick.Down:
			fmt.Println("↓")
		case stick.Left:
			fmt.Println("←")
		case stick.Right:
			fmt.Println("→")
		}
	}
}

Motion

Gyroscope, Accelerometer, Magnetometer.

Not yet implemented.

Weather

Temperature, Humidity, Barometric pressure

Not yet implemented

Gopher Gala 2016

Team

Media

bobbleHAT in action:

Team:

License

The code is licensed under the Simplified BSD License. Copyright © 2016 bobbleHAT Authors.

The original Go gopher © 2009 Renée French. Used under Creative Commons Attribution 3.0 license.

Illustrations © 2016 Olga Shalakhina.

Related Projects

bobblehat's People

Contributors

carlisia avatar lanzafame avatar nathany avatar peterhellberg avatar

Watchers

 avatar

Forkers

zaprit

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.