digispark

package
Version: v0.0.0-...-d941a39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2014 License: Apache-2.0, Apache-2.0 Imports: 4 Imported by: 0

README

Digispark

This package provides the Gobot adaptor for the Digispark ATTiny-based USB development board with the Little Wire protocol firmware installed.

Getting Started

This package requires libusb.

OSX

To install libusb on OSX using Homebrew:

$ brew install libusb
Ubuntu

To install libusb on linux:

$ sudo apt-get install libusb-dev

Now you can install the package with

go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/platforms/digispark

Examples

package main

import (
    "github.com/hybridgroup/gobot"
    "github.com/hybridgroup/gobot/platforms/digispark"
    "github.com/hybridgroup/gobot/platforms/gpio"
    "time"
)

func main() {
    gbot := gobot.NewGobot()
    adaptor := digispark.NewDigisparkAdaptor("Digispark")
    led := gpio.NewLedDriver(adaptor, "led", "0")

    work := func() {
        gobot.Every(1*time.Second, func() {
            led.Toggle()
        })
    }

    gbot.Robots = append(gbot.Robots,
        gobot.NewRobot("blinkBot", []gobot.Connection{adaptor}, []gobot.Device{led}, work))
    gbot.Start()
}

Connecting to Digispark

If your Digispark already has the Little Wire protocol firmware installed, you can connect right away with Gobot.

Otherwise, for instructions on how to install Little Wire on a Digispark check out http://digistump.com/board/index.php/topic,160.0.html

OSX
Important: 2012 MBP The USB ports on the 2012 MBPs (Retina and non) cause issues due to their USB3 controllers,
currently the best work around is to use a cheap USB hub (non USB3) - we are working on future solutions. The hub on a Cinema display will work as well.

Plug the Digispark into your computer via the USB port and you're ready to go!

Ubuntu

Ubuntu requires a few extra steps to set up the digispark for communication with Gobot:

  • Add a udev rule to allow access to the Digispark device
  • Plug in the Digispark to the USB port
  • Connect to the device via Gobot

First, you must add a udev rule, so that Gobot can communicate with the USB device. Ubuntu and other modern Linux distibutions use udev to manage device files when USB devices are added and removed. By default, udev will create a device with read-only permission which will not allow to you download code. You must place the udev rules below into a file named /etc/udev/rules.d/49-micronucleus.rules.

# UDEV Rules for Micronucleus boards including the Digispark.
# This file must be placed at:
#
# /etc/udev/rules.d/49-micronucleus.rules    (preferred location)
#   or
# /lib/udev/rules.d/49-micronucleus.rules    (req'd on some broken systems)
#
# After this file is copied, physically unplug and reconnect the board.
#
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1781", ATTRS{idProduct}=="0c9f", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="1781", ATTRS{idProduct}=="0c9f", MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1"

SUBSYSTEMS=="usb", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="0753", MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
#
# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
# GROUP:="somegroupname" and mange access using standard unix groups.

Thanks to @bluebie for these instructions! (https://github.com/Bluebie/micronucleus-t85/wiki/Ubuntu-Linux)

Now plug the Digispark into your computer via the USB port.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delay

func Delay(duration uint)

void delay(unsigned int duration);

Types

type DigisparkAdaptor

type DigisparkAdaptor struct {
	gobot.Adaptor
	// contains filtered or unexported fields
}

func NewDigisparkAdaptor

func NewDigisparkAdaptor(name string) *DigisparkAdaptor

func (*DigisparkAdaptor) AnalogRead

func (d *DigisparkAdaptor) AnalogRead(string) int

func (*DigisparkAdaptor) Connect

func (d *DigisparkAdaptor) Connect() bool

func (*DigisparkAdaptor) DigitalRead

func (d *DigisparkAdaptor) DigitalRead(pin string, level byte)

func (*DigisparkAdaptor) DigitalWrite

func (d *DigisparkAdaptor) DigitalWrite(pin string, level byte)

func (*DigisparkAdaptor) Disconnect

func (d *DigisparkAdaptor) Disconnect() bool

func (*DigisparkAdaptor) Finalize

func (d *DigisparkAdaptor) Finalize() bool

func (*DigisparkAdaptor) I2cRead

func (d *DigisparkAdaptor) I2cRead(uint16) []uint16

func (*DigisparkAdaptor) I2cStart

func (d *DigisparkAdaptor) I2cStart(byte)

func (*DigisparkAdaptor) I2cWrite

func (d *DigisparkAdaptor) I2cWrite([]uint16)

func (*DigisparkAdaptor) InitServo

func (d *DigisparkAdaptor) InitServo()

func (*DigisparkAdaptor) PwmWrite

func (d *DigisparkAdaptor) PwmWrite(pin string, value byte)

func (*DigisparkAdaptor) Reconnect

func (d *DigisparkAdaptor) Reconnect() bool

func (*DigisparkAdaptor) ServoWrite

func (d *DigisparkAdaptor) ServoWrite(pin string, angle uint8)

type LittleWire

type LittleWire struct {
	// contains filtered or unexported fields
}

func LittleWireConnect

func LittleWireConnect() *LittleWire

littleWire* littleWire_connect();

func (*LittleWire) AnalogInit

func (l *LittleWire) AnalogInit(voltageRef uint8)

void analog_init(littleWire* lwHandle, unsigned char voltageRef);

func (*LittleWire) AnalogRead

func (l *LittleWire) AnalogRead(channel uint8) uint

unsigned int analogRead(littleWire* lwHandle, unsigned char channel);

func (*LittleWire) ChangeSerialNumber

func (l *LittleWire) ChangeSerialNumber(serialNumber int)

void changeSerialNumber(littleWire* lwHandle,int serialNumber);

func (*LittleWire) DebugSpi

func (l *LittleWire) DebugSpi(message uint8) uint8

unsigned char debugSpi(littleWire* lwHandle, unsigned char message);

func (*LittleWire) DigitalRead

func (l *LittleWire) DigitalRead(pin uint8) uint8

unsigned char digitalRead(littleWire* lwHandle, unsigned char pin);

func (*LittleWire) DigitalWrite

func (l *LittleWire) DigitalWrite(pin uint8, state uint8)

void digitalWrite(littleWire* lwHandle, unsigned char pin, unsigned char state);

func (*LittleWire) I2cInit

func (l *LittleWire) I2cInit()

void i2c_init(littleWire* lwHandle);

func (*LittleWire) I2cStart

func (l *LittleWire) I2cStart(address7bit uint8, direction uint8) uint8

unsigned char i2c_start(littleWire* lwHandle, unsigned char address7bit, unsigned char direction);

func (*LittleWire) I2cUpdateDelay

func (l *LittleWire) I2cUpdateDelay(duration uint)

void i2c_updateDelay(littleWire* lwHandle, unsigned int duration);

func (*LittleWire) InternalPullup

func (l *LittleWire) InternalPullup(pin uint8, state uint8)

void internalPullup(littleWire* lwHandle, unsigned char pin, unsigned char state);

func (*LittleWire) LittleWireError

func (l *LittleWire) LittleWireError() int

int littleWire_error ();

func (*LittleWire) OneWireFirstAddress

func (l *LittleWire) OneWireFirstAddress() int

int onewire_firstAddress(littleWire* lwHandle);

func (*LittleWire) OneWireNextAddress

func (l *LittleWire) OneWireNextAddress() int

int onewire_nextAddress(littleWire* lwHandle);

func (*LittleWire) OneWireReadBit

func (l *LittleWire) OneWireReadBit() uint8

unsigned char onewire_readBit(littleWire* lwHandle);

func (*LittleWire) OneWireReadByte

func (l *LittleWire) OneWireReadByte() uint8

unsigned char onewire_readByte(littleWire* lwHandle);

func (*LittleWire) OneWireResetPulse

func (l *LittleWire) OneWireResetPulse() uint8

unsigned char onewire_resetPulse(littleWire* lwHandle);

func (*LittleWire) OneWireSendBit

func (l *LittleWire) OneWireSendBit(bitValue uint8)

void onewire_sendBit(littleWire* lwHandle, unsigned char bitValue);

func (*LittleWire) OneWireWriteByte

func (l *LittleWire) OneWireWriteByte(messageToSend uint8)

void onewire_writeByte(littleWire* lwHandle, unsigned char messageToSend);

func (*LittleWire) PinMode

func (l *LittleWire) PinMode(pin uint8, mode uint8)

void pinMode(littleWire* lwHandle, unsigned char pin, unsigned char mode);

func (*LittleWire) PwmInit

func (l *LittleWire) PwmInit()

void pwm_init(littleWire* lwHandle);

func (*LittleWire) PwmStop

func (l *LittleWire) PwmStop()

void pwm_stop(littleWire* lwHandle);

func (*LittleWire) PwmUpdateCompare

func (l *LittleWire) PwmUpdateCompare(channelA uint8, channelB uint8)

void pwm_updateCompare(littleWire* lwHandle, unsigned char channelA, unsigned char channelB);

func (*LittleWire) PwmUpdatePrescaler

func (l *LittleWire) PwmUpdatePrescaler(value uint)

void pwm_updatePrescaler(littleWire* lwHandle, unsigned int value);

func (*LittleWire) ReadFirmwareVersion

func (l *LittleWire) ReadFirmwareVersion() string

unsigned char readFirmwareVersion(littleWire* lwHandle);

func (*LittleWire) ServoInit

func (l *LittleWire) ServoInit()

void servo_init(littleWire* lwHandle);

func (*LittleWire) ServoUpdateLocation

func (l *LittleWire) ServoUpdateLocation(locationChannelA uint8, locationChannelB uint8)

void servo_updateLocation(littleWire* lwHandle,unsigned char locationChannelA,unsigned char locationChannelB);

func (*LittleWire) SoftPWMState

func (l *LittleWire) SoftPWMState(state uint8)

void softPWM_state(littleWire* lwHandle,unsigned char state);

func (*LittleWire) SoftPWMWrite

func (l *LittleWire) SoftPWMWrite(ch1 uint8, ch2 uint8, ch3 uint8)

void softPWM_write(littleWire* lwHandle,unsigned char ch1,unsigned char ch2,unsigned char ch3);

func (*LittleWire) SpiInit

func (l *LittleWire) SpiInit()

void spi_init(littleWire* lwHandle);

func (*LittleWire) SpiUpdateDelay

func (l *LittleWire) SpiUpdateDelay(duration uint)

void spi_updateDelay(littleWire* lwHandle, unsigned int duration);

func (*LittleWire) Ws2812Flush

func (l *LittleWire) Ws2812Flush(pin uint8)

void ws2812_flush(littleWire* lwHandle, unsigned char pin);

func (*LittleWire) Ws2812Preload

func (l *LittleWire) Ws2812Preload(r uint8, g uint8, b uint8)

void ws2812_preload(littleWire* lwHandle, unsigned char r,unsigned char g,unsigned char b);

func (*LittleWire) Ws2812Write

func (l *LittleWire) Ws2812Write(pin uint8, r uint8, g uint8, b uint8)

void ws2812_write(littleWire* lwHandle, unsigned char pin,unsigned char r,unsigned char g,unsigned char b);

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL