Update digispark package
This commit is contained in:
parent
27f0c3c796
commit
8c41b83316
|
@ -1,4 +1,4 @@
|
|||
package gobotDigispark
|
||||
package digispark
|
||||
|
||||
import (
|
||||
"github.com/hybridgroup/gobot"
|
||||
|
@ -7,54 +7,59 @@ import (
|
|||
|
||||
type DigisparkAdaptor struct {
|
||||
gobot.Adaptor
|
||||
LittleWire *LittleWire
|
||||
littleWire *LittleWire
|
||||
servo bool
|
||||
pwm bool
|
||||
connect func(*DigisparkAdaptor)
|
||||
}
|
||||
|
||||
var connect = func() *LittleWire {
|
||||
return LittleWireConnect()
|
||||
func NewDigisparkAdaptor() *DigisparkAdaptor {
|
||||
return &DigisparkAdaptor{
|
||||
connect: func(d *DigisparkAdaptor) {
|
||||
d.littleWire = LittleWireConnect()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (da *DigisparkAdaptor) Connect() bool {
|
||||
da.LittleWire = connect()
|
||||
da.Connected = true
|
||||
func (d *DigisparkAdaptor) Connect() bool {
|
||||
d.connect(d)
|
||||
d.Connected = true
|
||||
return true
|
||||
}
|
||||
|
||||
func (da *DigisparkAdaptor) Reconnect() bool {
|
||||
return da.Connect()
|
||||
func (d *DigisparkAdaptor) Reconnect() bool {
|
||||
return d.Connect()
|
||||
}
|
||||
|
||||
func (da *DigisparkAdaptor) Finalize() bool { return true }
|
||||
func (da *DigisparkAdaptor) Disconnect() bool { return true }
|
||||
func (d *DigisparkAdaptor) Finalize() bool { return true }
|
||||
func (d *DigisparkAdaptor) Disconnect() bool { return true }
|
||||
|
||||
func (da *DigisparkAdaptor) DigitalWrite(pin string, level byte) {
|
||||
func (d *DigisparkAdaptor) DigitalWrite(pin string, level byte) {
|
||||
p, _ := strconv.Atoi(pin)
|
||||
|
||||
da.LittleWire.PinMode(uint8(p), 0)
|
||||
da.LittleWire.DigitalWrite(uint8(p), level)
|
||||
d.littleWire.PinMode(uint8(p), 0)
|
||||
d.littleWire.DigitalWrite(uint8(p), level)
|
||||
}
|
||||
func (da *DigisparkAdaptor) DigitalRead(pin string, level byte) {}
|
||||
func (da *DigisparkAdaptor) PwmWrite(pin string, value byte) {
|
||||
if da.pwm == false {
|
||||
da.LittleWire.PwmInit()
|
||||
da.LittleWire.PwmUpdatePrescaler(1)
|
||||
da.pwm = true
|
||||
func (d *DigisparkAdaptor) DigitalRead(pin string, level byte) {}
|
||||
func (d *DigisparkAdaptor) PwmWrite(pin string, value byte) {
|
||||
if d.pwm == false {
|
||||
d.littleWire.PwmInit()
|
||||
d.littleWire.PwmUpdatePrescaler(1)
|
||||
d.pwm = true
|
||||
}
|
||||
da.LittleWire.PwmUpdateCompare(value, value)
|
||||
d.littleWire.PwmUpdateCompare(value, value)
|
||||
}
|
||||
func (da *DigisparkAdaptor) AnalogRead(string) int { return -1 }
|
||||
func (d *DigisparkAdaptor) AnalogRead(string) int { return -1 }
|
||||
|
||||
func (da *DigisparkAdaptor) InitServo() {}
|
||||
func (da *DigisparkAdaptor) ServoWrite(pin string, angle uint8) {
|
||||
if da.servo == false {
|
||||
da.LittleWire.ServoInit()
|
||||
da.servo = true
|
||||
func (d *DigisparkAdaptor) InitServo() {}
|
||||
func (d *DigisparkAdaptor) ServoWrite(pin string, angle uint8) {
|
||||
if d.servo == false {
|
||||
d.littleWire.ServoInit()
|
||||
d.servo = true
|
||||
}
|
||||
da.LittleWire.ServoUpdateLocation(angle, angle)
|
||||
d.littleWire.ServoUpdateLocation(angle, angle)
|
||||
}
|
||||
|
||||
func (da *DigisparkAdaptor) I2cStart(byte) {}
|
||||
func (da *DigisparkAdaptor) I2cRead(uint16) []uint16 { return make([]uint16, 0) }
|
||||
func (da *DigisparkAdaptor) I2cWrite([]uint16) {}
|
||||
func (d *DigisparkAdaptor) I2cStart(byte) {}
|
||||
func (d *DigisparkAdaptor) I2cRead(uint16) []uint16 { return make([]uint16, 0) }
|
||||
func (d *DigisparkAdaptor) I2cWrite([]uint16) {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package gobotDigispark
|
||||
package digispark
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
|
@ -7,26 +7,24 @@ import (
|
|||
|
||||
var _ = Describe("Digispark", func() {
|
||||
var (
|
||||
adaptor *DigisparkAdaptor
|
||||
d *DigisparkAdaptor
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
adaptor = new(DigisparkAdaptor)
|
||||
connect = func() *LittleWire {
|
||||
return nil
|
||||
}
|
||||
d = NewDigisparkAdaptor()
|
||||
d.connect = func(d *DigisparkAdaptor) {}
|
||||
})
|
||||
|
||||
It("Must be able to Finalize", func() {
|
||||
Expect(adaptor.Finalize()).To(Equal(true))
|
||||
Expect(d.Finalize()).To(Equal(true))
|
||||
})
|
||||
It("Must be able to Connect", func() {
|
||||
Expect(adaptor.Connect()).To(Equal(true))
|
||||
Expect(d.Connect()).To(Equal(true))
|
||||
})
|
||||
It("Must be able to Disconnect", func() {
|
||||
Expect(adaptor.Disconnect()).To(Equal(true))
|
||||
Expect(d.Disconnect()).To(Equal(true))
|
||||
})
|
||||
It("Must be able to Reconnect", func() {
|
||||
Expect(adaptor.Reconnect()).To(Equal(true))
|
||||
Expect(d.Reconnect()).To(Equal(true))
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/hybridgroup/gobot"
|
||||
"github.com/hybridgroup/gobot-digispark"
|
||||
"github.com/hybridgroup/gobot-gpio"
|
||||
)
|
||||
|
||||
func main() {
|
||||
master := gobot.GobotMaster()
|
||||
gobot.Api(master)
|
||||
|
||||
digispark := new(gobotDigispark.DigisparkAdaptor)
|
||||
digispark.Name = "digispark"
|
||||
|
||||
led := gobotGPIO.NewLed(digispark)
|
||||
led.Name = "led"
|
||||
led.Pin = "0"
|
||||
|
||||
master.Robots = append(master.Robots, &gobot.Robot{
|
||||
Name: "digispark",
|
||||
Connections: []gobot.Connection{digispark},
|
||||
Devices: []gobot.Device{led},
|
||||
})
|
||||
|
||||
master.Start()
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package gobotDigispark
|
||||
package digispark
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package gobotDigispark
|
||||
package digispark
|
||||
|
||||
//#cgo LDFLAGS: -lusb
|
||||
//#include "littleWire.h"
|
||||
|
@ -28,20 +28,20 @@ type LittleWire struct {
|
|||
|
||||
//littleWire* littleWire_connect();
|
||||
func LittleWireConnect() *LittleWire {
|
||||
littleWire := new(LittleWire)
|
||||
littleWire.lwHandle = C.littleWire_connect()
|
||||
return littleWire
|
||||
return &LittleWire{
|
||||
lwHandle: C.littleWire_connect(),
|
||||
}
|
||||
}
|
||||
|
||||
//unsigned char readFirmwareVersion(littleWire* lwHandle);
|
||||
func (littleWire *LittleWire) ReadFirmwareVersion() string {
|
||||
version := uint8(C.readFirmwareVersion(littleWire.lwHandle))
|
||||
func (l *LittleWire) ReadFirmwareVersion() string {
|
||||
version := uint8(C.readFirmwareVersion(l.lwHandle))
|
||||
return fmt.Sprintf("%v.%v", version&0xF0>>4, version&0x0F)
|
||||
}
|
||||
|
||||
//void changeSerialNumber(littleWire* lwHandle,int serialNumber);
|
||||
func (littleWire *LittleWire) ChangeSerialNumber(serialNumber int) {
|
||||
C.changeSerialNumber(littleWire.lwHandle, C.int(serialNumber))
|
||||
func (l *LittleWire) ChangeSerialNumber(serialNumber int) {
|
||||
C.changeSerialNumber(l.lwHandle, C.int(serialNumber))
|
||||
}
|
||||
|
||||
//int customMessage(littleWire* lwHandle,unsigned char* receiveBuffer,unsigned char command,unsigned char d1,unsigned char d2, unsigned char d3, unsigned char d4);
|
||||
|
@ -50,7 +50,7 @@ func (littleWire *LittleWire) ChangeSerialNumber(serialNumber int) {
|
|||
//}
|
||||
|
||||
//int littleWire_error ();
|
||||
func (littleWire *LittleWire) LittleWireError() int {
|
||||
func (l *LittleWire) LittleWireError() int {
|
||||
return int(C.littleWire_error())
|
||||
}
|
||||
|
||||
|
@ -60,58 +60,58 @@ func (littleWire *LittleWire) LittleWireError() int {
|
|||
//}
|
||||
|
||||
//void digitalWrite(littleWire* lwHandle, unsigned char pin, unsigned char state);
|
||||
func (littleWire *LittleWire) DigitalWrite(pin uint8, state uint8) {
|
||||
C.digitalWrite(littleWire.lwHandle, C.uchar(pin), C.uchar(state))
|
||||
func (l *LittleWire) DigitalWrite(pin uint8, state uint8) {
|
||||
C.digitalWrite(l.lwHandle, C.uchar(pin), C.uchar(state))
|
||||
}
|
||||
|
||||
//void pinMode(littleWire* lwHandle, unsigned char pin, unsigned char mode);
|
||||
func (littleWire *LittleWire) PinMode(pin uint8, mode uint8) {
|
||||
C.pinMode(littleWire.lwHandle, C.uchar(pin), C.uchar(mode))
|
||||
func (l *LittleWire) PinMode(pin uint8, mode uint8) {
|
||||
C.pinMode(l.lwHandle, C.uchar(pin), C.uchar(mode))
|
||||
}
|
||||
|
||||
//unsigned char digitalRead(littleWire* lwHandle, unsigned char pin);
|
||||
func (littleWire *LittleWire) DigitalRead(pin uint8) uint8 {
|
||||
return uint8(C.digitalRead(littleWire.lwHandle, C.uchar(pin)))
|
||||
func (l *LittleWire) DigitalRead(pin uint8) uint8 {
|
||||
return uint8(C.digitalRead(l.lwHandle, C.uchar(pin)))
|
||||
}
|
||||
|
||||
//void internalPullup(littleWire* lwHandle, unsigned char pin, unsigned char state);
|
||||
func (littleWire *LittleWire) InternalPullup(pin uint8, state uint8) {
|
||||
C.internalPullup(littleWire.lwHandle, C.uchar(pin), C.uchar(state))
|
||||
func (l *LittleWire) InternalPullup(pin uint8, state uint8) {
|
||||
C.internalPullup(l.lwHandle, C.uchar(pin), C.uchar(state))
|
||||
}
|
||||
|
||||
//void analog_init(littleWire* lwHandle, unsigned char voltageRef);
|
||||
func (littleWire *LittleWire) AnalogInit(voltageRef uint8) {
|
||||
C.analog_init(littleWire.lwHandle, C.uchar(voltageRef))
|
||||
func (l *LittleWire) AnalogInit(voltageRef uint8) {
|
||||
C.analog_init(l.lwHandle, C.uchar(voltageRef))
|
||||
}
|
||||
|
||||
//unsigned int analogRead(littleWire* lwHandle, unsigned char channel);
|
||||
func (littleWire *LittleWire) AnalogRead(channel uint8) uint {
|
||||
return uint(C.analogRead(littleWire.lwHandle, C.uchar(channel)))
|
||||
func (l *LittleWire) AnalogRead(channel uint8) uint {
|
||||
return uint(C.analogRead(l.lwHandle, C.uchar(channel)))
|
||||
}
|
||||
|
||||
//void pwm_init(littleWire* lwHandle);
|
||||
func (littleWire *LittleWire) PwmInit() {
|
||||
C.pwm_init(littleWire.lwHandle)
|
||||
func (l *LittleWire) PwmInit() {
|
||||
C.pwm_init(l.lwHandle)
|
||||
}
|
||||
|
||||
//void pwm_stop(littleWire* lwHandle);
|
||||
func (littleWire *LittleWire) PwmStop() {
|
||||
C.pwm_stop(littleWire.lwHandle)
|
||||
func (l *LittleWire) PwmStop() {
|
||||
C.pwm_stop(l.lwHandle)
|
||||
}
|
||||
|
||||
//void pwm_updateCompare(littleWire* lwHandle, unsigned char channelA, unsigned char channelB);
|
||||
func (littleWire *LittleWire) PwmUpdateCompare(channelA uint8, channelB uint8) {
|
||||
C.pwm_updateCompare(littleWire.lwHandle, C.uchar(channelA), C.uchar(channelB))
|
||||
func (l *LittleWire) PwmUpdateCompare(channelA uint8, channelB uint8) {
|
||||
C.pwm_updateCompare(l.lwHandle, C.uchar(channelA), C.uchar(channelB))
|
||||
}
|
||||
|
||||
//void pwm_updatePrescaler(littleWire* lwHandle, unsigned int value);
|
||||
func (littleWire *LittleWire) PwmUpdatePrescaler(value uint) {
|
||||
C.pwm_updatePrescaler(littleWire.lwHandle, C.uint(value))
|
||||
func (l *LittleWire) PwmUpdatePrescaler(value uint) {
|
||||
C.pwm_updatePrescaler(l.lwHandle, C.uint(value))
|
||||
}
|
||||
|
||||
//void spi_init(littleWire* lwHandle);
|
||||
func (littleWire *LittleWire) SpiInit() {
|
||||
C.spi_init(littleWire.lwHandle)
|
||||
func (l *LittleWire) SpiInit() {
|
||||
C.spi_init(l.lwHandle)
|
||||
}
|
||||
|
||||
//void spi_sendMessage(littleWire* lwHandle, unsigned char * sendBuffer, unsigned char * inputBuffer, unsigned char length ,unsigned char mode);
|
||||
|
@ -120,23 +120,23 @@ func (littleWire *LittleWire) SpiInit() {
|
|||
//}
|
||||
|
||||
//unsigned char debugSpi(littleWire* lwHandle, unsigned char message);
|
||||
func (littleWire *LittleWire) DebugSpi(message uint8) uint8 {
|
||||
return uint8(C.debugSpi(littleWire.lwHandle, C.uchar(message)))
|
||||
func (l *LittleWire) DebugSpi(message uint8) uint8 {
|
||||
return uint8(C.debugSpi(l.lwHandle, C.uchar(message)))
|
||||
}
|
||||
|
||||
//void spi_updateDelay(littleWire* lwHandle, unsigned int duration);
|
||||
func (littleWire *LittleWire) SpiUpdateDelay(duration uint) {
|
||||
C.spi_updateDelay(littleWire.lwHandle, C.uint(duration))
|
||||
func (l *LittleWire) SpiUpdateDelay(duration uint) {
|
||||
C.spi_updateDelay(l.lwHandle, C.uint(duration))
|
||||
}
|
||||
|
||||
//void i2c_init(littleWire* lwHandle);
|
||||
func (littleWire *LittleWire) I2cInit() {
|
||||
C.i2c_init(littleWire.lwHandle)
|
||||
func (l *LittleWire) I2cInit() {
|
||||
C.i2c_init(l.lwHandle)
|
||||
}
|
||||
|
||||
//unsigned char i2c_start(littleWire* lwHandle, unsigned char address7bit, unsigned char direction);
|
||||
func (littleWire *LittleWire) I2cStart(address7bit uint8, direction uint8) uint8 {
|
||||
return uint8(C.i2c_start(littleWire.lwHandle, C.uchar(address7bit), C.uchar(direction)))
|
||||
func (l *LittleWire) I2cStart(address7bit uint8, direction uint8) uint8 {
|
||||
return uint8(C.i2c_start(l.lwHandle, C.uchar(address7bit), C.uchar(direction)))
|
||||
}
|
||||
|
||||
//void i2c_write(littleWire* lwHandle, unsigned char* sendBuffer, unsigned char length, unsigned char endWithStop);
|
||||
|
@ -150,66 +150,66 @@ func (littleWire *LittleWire) I2cStart(address7bit uint8, direction uint8) uint8
|
|||
//}
|
||||
|
||||
//void i2c_updateDelay(littleWire* lwHandle, unsigned int duration);
|
||||
func (littleWire *LittleWire) I2cUpdateDelay(duration uint) {
|
||||
C.i2c_updateDelay(littleWire.lwHandle, C.uint(duration))
|
||||
func (l *LittleWire) I2cUpdateDelay(duration uint) {
|
||||
C.i2c_updateDelay(l.lwHandle, C.uint(duration))
|
||||
}
|
||||
|
||||
//void onewire_sendBit(littleWire* lwHandle, unsigned char bitValue);
|
||||
func (littleWire *LittleWire) OneWireSendBit(bitValue uint8) {
|
||||
C.onewire_sendBit(littleWire.lwHandle, C.uchar(bitValue))
|
||||
func (l *LittleWire) OneWireSendBit(bitValue uint8) {
|
||||
C.onewire_sendBit(l.lwHandle, C.uchar(bitValue))
|
||||
}
|
||||
|
||||
//void onewire_writeByte(littleWire* lwHandle, unsigned char messageToSend);
|
||||
func (littleWire *LittleWire) OneWireWriteByte(messageToSend uint8) {
|
||||
C.onewire_writeByte(littleWire.lwHandle, C.uchar(messageToSend))
|
||||
func (l *LittleWire) OneWireWriteByte(messageToSend uint8) {
|
||||
C.onewire_writeByte(l.lwHandle, C.uchar(messageToSend))
|
||||
}
|
||||
|
||||
//unsigned char onewire_readByte(littleWire* lwHandle);
|
||||
func (littleWire *LittleWire) OneWireReadByte() uint8 {
|
||||
return uint8(C.onewire_readByte(littleWire.lwHandle))
|
||||
func (l *LittleWire) OneWireReadByte() uint8 {
|
||||
return uint8(C.onewire_readByte(l.lwHandle))
|
||||
}
|
||||
|
||||
//unsigned char onewire_readBit(littleWire* lwHandle);
|
||||
func (littleWire *LittleWire) OneWireReadBit() uint8 {
|
||||
return uint8(C.onewire_readBit(littleWire.lwHandle))
|
||||
func (l *LittleWire) OneWireReadBit() uint8 {
|
||||
return uint8(C.onewire_readBit(l.lwHandle))
|
||||
}
|
||||
|
||||
//unsigned char onewire_resetPulse(littleWire* lwHandle);
|
||||
func (littleWire *LittleWire) OneWireResetPulse() uint8 {
|
||||
return uint8(C.onewire_resetPulse(littleWire.lwHandle))
|
||||
func (l *LittleWire) OneWireResetPulse() uint8 {
|
||||
return uint8(C.onewire_resetPulse(l.lwHandle))
|
||||
}
|
||||
|
||||
//int onewire_firstAddress(littleWire* lwHandle);
|
||||
func (littleWire *LittleWire) OneWireFirstAddress() int {
|
||||
return int(C.onewire_firstAddress(littleWire.lwHandle))
|
||||
func (l *LittleWire) OneWireFirstAddress() int {
|
||||
return int(C.onewire_firstAddress(l.lwHandle))
|
||||
}
|
||||
|
||||
//int onewire_nextAddress(littleWire* lwHandle);
|
||||
func (littleWire *LittleWire) OneWireNextAddress() int {
|
||||
return int(C.onewire_nextAddress(littleWire.lwHandle))
|
||||
func (l *LittleWire) OneWireNextAddress() int {
|
||||
return int(C.onewire_nextAddress(l.lwHandle))
|
||||
}
|
||||
|
||||
//void softPWM_state(littleWire* lwHandle,unsigned char state);
|
||||
func (littleWire *LittleWire) SoftPWMState(state uint8) {
|
||||
C.softPWM_state(littleWire.lwHandle, C.uchar(state))
|
||||
func (l *LittleWire) SoftPWMState(state uint8) {
|
||||
C.softPWM_state(l.lwHandle, C.uchar(state))
|
||||
}
|
||||
|
||||
//void softPWM_write(littleWire* lwHandle,unsigned char ch1,unsigned char ch2,unsigned char ch3);
|
||||
func (littleWire *LittleWire) SoftPWMWrite(ch1 uint8, ch2 uint8, ch3 uint8) {
|
||||
C.softPWM_write(littleWire.lwHandle, C.uchar(ch1), C.uchar(ch2), C.uchar(ch3))
|
||||
func (l *LittleWire) SoftPWMWrite(ch1 uint8, ch2 uint8, ch3 uint8) {
|
||||
C.softPWM_write(l.lwHandle, C.uchar(ch1), C.uchar(ch2), C.uchar(ch3))
|
||||
}
|
||||
|
||||
//void ws2812_write(littleWire* lwHandle, unsigned char pin,unsigned char r,unsigned char g,unsigned char b);
|
||||
func (littleWire *LittleWire) Ws2812Write(pin uint8, r uint8, g uint8, b uint8) {
|
||||
C.ws2812_write(littleWire.lwHandle, C.uchar(pin), C.uchar(r), C.uchar(g), C.uchar(b))
|
||||
func (l *LittleWire) Ws2812Write(pin uint8, r uint8, g uint8, b uint8) {
|
||||
C.ws2812_write(l.lwHandle, C.uchar(pin), C.uchar(r), C.uchar(g), C.uchar(b))
|
||||
}
|
||||
|
||||
//void ws2812_flush(littleWire* lwHandle, unsigned char pin);
|
||||
func (littleWire *LittleWire) Ws2812Flush(pin uint8) {
|
||||
C.ws2812_flush(littleWire.lwHandle, C.uchar(pin))
|
||||
func (l *LittleWire) Ws2812Flush(pin uint8) {
|
||||
C.ws2812_flush(l.lwHandle, C.uchar(pin))
|
||||
}
|
||||
|
||||
//void ws2812_preload(littleWire* lwHandle, unsigned char r,unsigned char g,unsigned char b);
|
||||
func (littleWire *LittleWire) Ws2812Preload(r uint8, g uint8, b uint8) {
|
||||
C.ws2812_preload(littleWire.lwHandle, C.uchar(r), C.uchar(g), C.uchar(b))
|
||||
func (l *LittleWire) Ws2812Preload(r uint8, g uint8, b uint8) {
|
||||
C.ws2812_preload(l.lwHandle, C.uchar(r), C.uchar(g), C.uchar(b))
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package gobotDigispark
|
||||
package digispark
|
||||
|
||||
//#include "littleWire_servo.h"
|
||||
import "C"
|
||||
|
||||
//void servo_init(littleWire* lwHandle);
|
||||
func (littleWire *LittleWire) ServoInit() {
|
||||
C.servo_init(littleWire.lwHandle)
|
||||
func (l *LittleWire) ServoInit() {
|
||||
C.servo_init(l.lwHandle)
|
||||
}
|
||||
|
||||
//void servo_updateLocation(littleWire* lwHandle,unsigned char locationChannelA,unsigned char locationChannelB);
|
||||
func (littleWire *LittleWire) ServoUpdateLocation(locationChannelA uint8, locationChannelB uint8) {
|
||||
C.servo_updateLocation(littleWire.lwHandle, C.uchar(locationChannelA), C.uchar(locationChannelB))
|
||||
func (l *LittleWire) ServoUpdateLocation(locationChannelA uint8, locationChannelB uint8) {
|
||||
C.servo_updateLocation(l.lwHandle, C.uchar(locationChannelA), C.uchar(locationChannelB))
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package gobotDigispark
|
||||
package digispark
|
||||
|
||||
//#include "littleWire_util.h"
|
||||
import "C"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package gobotDigispark
|
||||
package digispark
|
||||
|
||||
/*
|
||||
#include <opendevice.h>
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/hybridgroup/gobot"
|
||||
"github.com/hybridgroup/gobot/digispark"
|
||||
"github.com/hybridgroup/gobot/gpio"
|
||||
)
|
||||
|
||||
func main() {
|
||||
master := gobot.NewMaster()
|
||||
gobot.StartApi(master)
|
||||
|
||||
digisparkAdaptor := digispark.NewDigisparkAdaptor()
|
||||
digisparkAdaptor.Name = "Digispark"
|
||||
|
||||
led := gpio.NewLed(digisparkAdaptor)
|
||||
led.Name = "led"
|
||||
led.Pin = "0"
|
||||
|
||||
master.Robots = append(master.Robots, &gobot.Robot{
|
||||
Name: "digispark",
|
||||
Connections: []gobot.Connection{digisparkAdaptor},
|
||||
Devices: []gobot.Device{led},
|
||||
})
|
||||
|
||||
master.Start()
|
||||
}
|
|
@ -2,16 +2,15 @@ package main
|
|||
|
||||
import (
|
||||
"github.com/hybridgroup/gobot"
|
||||
"github.com/hybridgroup/gobot-digispark"
|
||||
"github.com/hybridgroup/gobot-gpio"
|
||||
"github.com/hybridgroup/gobot/digispark"
|
||||
"github.com/hybridgroup/gobot/gpio"
|
||||
)
|
||||
|
||||
func main() {
|
||||
digisparkAdaptor := digispark.NewDigisparkAdaptor()
|
||||
digisparkAdaptor.Name = "Digispark"
|
||||
|
||||
digispark := new(gobotDigispark.DigisparkAdaptor)
|
||||
digispark.Name = "Digispark"
|
||||
|
||||
led := gobotGPIO.NewLed(digispark)
|
||||
led := gpio.NewLedDriver(digisparkAdaptor)
|
||||
led.Name = "led"
|
||||
led.Pin = "0"
|
||||
|
||||
|
@ -22,7 +21,7 @@ func main() {
|
|||
}
|
||||
|
||||
robot := gobot.Robot{
|
||||
Connections: []gobot.Connection{digispark},
|
||||
Connections: []gobot.Connection{digisparkAdaptor},
|
||||
Devices: []gobot.Device{led},
|
||||
Work: work,
|
||||
}
|
|
@ -2,16 +2,15 @@ package main
|
|||
|
||||
import (
|
||||
"github.com/hybridgroup/gobot"
|
||||
"github.com/hybridgroup/gobot-digispark"
|
||||
"github.com/hybridgroup/gobot-gpio"
|
||||
"github.com/hybridgroup/gobot/digispark"
|
||||
"github.com/hybridgroup/gobot/gpio"
|
||||
)
|
||||
|
||||
func main() {
|
||||
digisparkAdaptor := digispark.NewDigisparkAdaptor()
|
||||
digisparkAdaptor.Name = "digispark"
|
||||
|
||||
digispark := new(gobotDigispark.DigisparkAdaptor)
|
||||
digispark.Name = "Digispark"
|
||||
|
||||
led := gobotGPIO.NewLed(digispark)
|
||||
led := gpio.NewLedDriver(digisparkAdaptor)
|
||||
led.Name = "led"
|
||||
led.Pin = "0"
|
||||
|
||||
|
@ -29,7 +28,7 @@ func main() {
|
|||
}
|
||||
|
||||
robot := gobot.Robot{
|
||||
Connections: []gobot.Connection{digispark},
|
||||
Connections: []gobot.Connection{digisparkAdaptor},
|
||||
Devices: []gobot.Device{led},
|
||||
Work: work,
|
||||
}
|
|
@ -3,16 +3,15 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"github.com/hybridgroup/gobot"
|
||||
"github.com/hybridgroup/gobot-digispark"
|
||||
"github.com/hybridgroup/gobot-gpio"
|
||||
"github.com/hybridgroup/gobot/digispark"
|
||||
"github.com/hybridgroup/gobot/gpio"
|
||||
)
|
||||
|
||||
func main() {
|
||||
digisparkAdaptor := digispark.NewDigisparkAdaptor()
|
||||
digisparkAdaptor.Name = "digispark"
|
||||
|
||||
digispark := new(gobotDigispark.DigisparkAdaptor)
|
||||
digispark.Name = "digispark"
|
||||
|
||||
servo := gobotGPIO.NewServo(digispark)
|
||||
servo := gpio.NewServoDriver(digisparkAdaptor)
|
||||
servo.Name = "servo"
|
||||
servo.Pin = "0"
|
||||
|
||||
|
@ -25,7 +24,7 @@ func main() {
|
|||
}
|
||||
|
||||
robot := gobot.Robot{
|
||||
Connections: []gobot.Connection{digispark},
|
||||
Connections: []gobot.Connection{digisparkAdaptor},
|
||||
Devices: []gobot.Device{servo},
|
||||
Work: work,
|
||||
}
|
Loading…
Reference in New Issue