Skip to content

Library to use Sense Hat with Raspberry Pi. Written entirely in Go language.

Notifications You must be signed in to change notification settings

akshaynawale/gorpisense

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

gorpisense

Library to use Raspberry Pi Sense Hat. Written in Golang.

Basic Usage:

Installation:

go get github.com/akshaynawale/gorpisense/joyst

Import the library in your program file with:

import "github.com/akshaynawale/gorpisense/joyst"

Create a channel of type Event which will be written by the lib function whenever any event happens.

echan := make(chan joyst.Event)

Create a joyst struct

joy := joyst.Joystick{}

Call the Poll method on the joyst struct to get the events from joystick in a go routine and pass the event channel (echan) to it.

go joy.Poll(echan)

The Poll method will write to the echan, whenever we receive a joystick event. For contineously reading this channel you can use a for loop. Use the joyst lib constants (i.e. joyst.LEFT etc.) to compare the event.Code values to know which buttton is pressed. perform actions based on button pressed.

for {
  event := <-echan
  Switch event.Code {
    case joyst.LEFT:
      // do somthing
      fmt.Println("LEFT Pressed")
    case joyst.RIGHT:
      // do something 
      fmt.Println("RIGHT Pressed")
    case joyst.DOWN:
      // do something
      fmt.Println("DOWN Pressed")
    case joyst.UP:
      // do something
      fmt.Println("UP Pressed")
    case joyst.Enter:
      // do something
      fmt.Println("Enter Pressed")
  }
}

More libs for controlling temperature, gyroscope and LED comming soon... :)

Happy Coding...

About

Library to use Sense Hat with Raspberry Pi. Written entirely in Go language.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages