Skip to content
This repository was archived by the owner on Jan 29, 2026. It is now read-only.

Latest commit

 

History

History
36 lines (25 loc) · 847 Bytes

File metadata and controls

36 lines (25 loc) · 847 Bytes

sense-joystick

A node module to interface with the sense-hat library on the raspberry pi.

Interface

The module exposes a single function; getJoystick, which returns a promise that resolves with an event emitter. The events that can be subscribed to are:

  • press - Emitted when a joystick direction is pressed
  • release - Emitted when a joystick direction is released
  • hold - Emmitted periodically when a joystick direction is held down

Each event is coupled with a direction, which is one of:

  • left
  • right
  • up
  • down
  • click (When pressing the joystick inwards)

Examples

Capturing button presses

senseJoystick = require('sense-joystick');

senseJoystick.getJoystick()
.then((joystick) => {
	joystick.on('press', (direction) => {
		console.log('Got button press in the direction: ', direction);
	}
});