1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-29 13:49:14 +08:00

45 lines
951 B
Go
Raw Normal View History

2014-04-27 18:54:41 -07:00
package i2c
2014-09-11 15:38:08 -05:00
import (
"github.com/hybridgroup/gobot"
)
var rgb = map[string]interface{}{
"red": 1.0,
"green": 1.0,
"blue": 1.0,
}
func castColor(color string) byte {
return byte(rgb[color].(float64))
}
var red = castColor("red")
var green = castColor("green")
var blue = castColor("blue")
type i2cTestAdaptor struct {
gobot.Adaptor
2014-09-11 15:38:08 -05:00
i2cReadImpl func() []byte
}
2014-11-19 16:56:48 -08:00
func (t *i2cTestAdaptor) I2cStart(byte) (err error) { return nil }
func (t *i2cTestAdaptor) I2cRead(uint) (data []byte, err error) {
return t.i2cReadImpl(), nil
}
2014-11-19 16:56:48 -08:00
func (t *i2cTestAdaptor) I2cWrite([]byte) (err error) { return nil }
func (t *i2cTestAdaptor) Connect() error { return nil }
func (t *i2cTestAdaptor) Finalize() error { return nil }
func newI2cTestAdaptor(name string) *i2cTestAdaptor {
return &i2cTestAdaptor{
2014-07-07 16:59:19 -07:00
Adaptor: *gobot.NewAdaptor(
name,
"I2cTestAdaptor",
),
2014-09-11 15:38:08 -05:00
i2cReadImpl: func() []byte {
return []byte{}
},
}
}