id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
156,600 | hybridgroup/gobot | platforms/particle/adaptor.go | ServoWrite | func (s *Adaptor) ServoWrite(pin string, angle byte) (err error) {
if _, present := s.servoPins[pin]; !present {
err = s.servoPinOpen(pin)
if err != nil {
return
}
}
params := url.Values{
"params": {fmt.Sprintf("%v,%v", pin, angle)},
"access_token": {s.AccessToken},
}
url := fmt.Sprintf("%v/ser... | go | func (s *Adaptor) ServoWrite(pin string, angle byte) (err error) {
if _, present := s.servoPins[pin]; !present {
err = s.servoPinOpen(pin)
if err != nil {
return
}
}
params := url.Values{
"params": {fmt.Sprintf("%v,%v", pin, angle)},
"access_token": {s.AccessToken},
}
url := fmt.Sprintf("%v/ser... | [
"func",
"(",
"s",
"*",
"Adaptor",
")",
"ServoWrite",
"(",
"pin",
"string",
",",
"angle",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"if",
"_",
",",
"present",
":=",
"s",
".",
"servoPins",
"[",
"pin",
"]",
";",
"!",
"present",
"{",
"err",
"=",
... | // ServoWrite writes the 0-180 degree angle to the specified pin.
// To use it requires installing the "tinker-servo" sketch on your
// Particle device. not just the default "tinker". | [
"ServoWrite",
"writes",
"the",
"0",
"-",
"180",
"degree",
"angle",
"to",
"the",
"specified",
"pin",
".",
"To",
"use",
"it",
"requires",
"installing",
"the",
"tinker",
"-",
"servo",
"sketch",
"on",
"your",
"Particle",
"device",
".",
"not",
"just",
"the",
... | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/particle/adaptor.go#L133-L148 |
156,601 | hybridgroup/gobot | platforms/particle/adaptor.go | Variable | func (s *Adaptor) Variable(name string) (result string, err error) {
url := fmt.Sprintf("%v/%s?access_token=%s", s.deviceURL(), name, s.AccessToken)
resp, err := s.request("GET", url, nil)
if err != nil {
return
}
val := resp["result"]
switch val.(type) {
case bool:
result = strconv.FormatBool(val.(bool))
... | go | func (s *Adaptor) Variable(name string) (result string, err error) {
url := fmt.Sprintf("%v/%s?access_token=%s", s.deviceURL(), name, s.AccessToken)
resp, err := s.request("GET", url, nil)
if err != nil {
return
}
val := resp["result"]
switch val.(type) {
case bool:
result = strconv.FormatBool(val.(bool))
... | [
"func",
"(",
"s",
"*",
"Adaptor",
")",
"Variable",
"(",
"name",
"string",
")",
"(",
"result",
"string",
",",
"err",
"error",
")",
"{",
"url",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
".",
"deviceURL",
"(",
")",
",",
"name",
",",
... | // Variable returns a core variable value as a string | [
"Variable",
"returns",
"a",
"core",
"variable",
"value",
"as",
"a",
"string"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/particle/adaptor.go#L190-L209 |
156,602 | hybridgroup/gobot | platforms/particle/adaptor.go | Function | func (s *Adaptor) Function(name string, args string) (val int, err error) {
params := url.Values{
"args": {args},
"access_token": {s.AccessToken},
}
url := fmt.Sprintf("%s/%s", s.deviceURL(), name)
resp, err := s.request("POST", url, params)
if err != nil {
return -1, err
}
val = int(resp["retur... | go | func (s *Adaptor) Function(name string, args string) (val int, err error) {
params := url.Values{
"args": {args},
"access_token": {s.AccessToken},
}
url := fmt.Sprintf("%s/%s", s.deviceURL(), name)
resp, err := s.request("POST", url, params)
if err != nil {
return -1, err
}
val = int(resp["retur... | [
"func",
"(",
"s",
"*",
"Adaptor",
")",
"Function",
"(",
"name",
"string",
",",
"args",
"string",
")",
"(",
"val",
"int",
",",
"err",
"error",
")",
"{",
"params",
":=",
"url",
".",
"Values",
"{",
"\"",
"\"",
":",
"{",
"args",
"}",
",",
"\"",
"\"... | // Function executes a core function and
// returns value from request.
// Takes a String as the only argument and returns an Int.
// If function is not defined in core, it will time out | [
"Function",
"executes",
"a",
"core",
"function",
"and",
"returns",
"value",
"from",
"request",
".",
"Takes",
"a",
"String",
"as",
"the",
"only",
"argument",
"and",
"returns",
"an",
"Int",
".",
"If",
"function",
"is",
"not",
"defined",
"in",
"core",
"it",
... | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/particle/adaptor.go#L215-L230 |
156,603 | hybridgroup/gobot | platforms/particle/adaptor.go | deviceURL | func (s *Adaptor) deviceURL() string {
if len(s.APIServer) <= 0 {
s.setAPIServer("https://api.particle.io")
}
return fmt.Sprintf("%v/v1/devices/%v", s.APIServer, s.DeviceID)
} | go | func (s *Adaptor) deviceURL() string {
if len(s.APIServer) <= 0 {
s.setAPIServer("https://api.particle.io")
}
return fmt.Sprintf("%v/v1/devices/%v", s.APIServer, s.DeviceID)
} | [
"func",
"(",
"s",
"*",
"Adaptor",
")",
"deviceURL",
"(",
")",
"string",
"{",
"if",
"len",
"(",
"s",
".",
"APIServer",
")",
"<=",
"0",
"{",
"s",
".",
"setAPIServer",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\... | // deviceURL constructs device url to make requests from Particle cloud api | [
"deviceURL",
"constructs",
"device",
"url",
"to",
"make",
"requests",
"from",
"Particle",
"cloud",
"api"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/particle/adaptor.go#L238-L243 |
156,604 | hybridgroup/gobot | platforms/particle/adaptor.go | request | func (s *Adaptor) request(method string, url string, params url.Values) (m map[string]interface{}, err error) {
var resp *http.Response
if method == "POST" {
resp, err = http.PostForm(url, params)
} else if method == "GET" {
resp, err = http.Get(url)
}
if err != nil {
return
}
buf, err := ioutil.ReadAll... | go | func (s *Adaptor) request(method string, url string, params url.Values) (m map[string]interface{}, err error) {
var resp *http.Response
if method == "POST" {
resp, err = http.PostForm(url, params)
} else if method == "GET" {
resp, err = http.Get(url)
}
if err != nil {
return
}
buf, err := ioutil.ReadAll... | [
"func",
"(",
"s",
"*",
"Adaptor",
")",
"request",
"(",
"method",
"string",
",",
"url",
"string",
",",
"params",
"url",
".",
"Values",
")",
"(",
"m",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"var",
"resp",
"... | // request makes request to Particle cloud server, return err != nil if there is
// any issue with the request. | [
"request",
"makes",
"request",
"to",
"Particle",
"cloud",
"server",
"return",
"err",
"!",
"=",
"nil",
"if",
"there",
"is",
"any",
"issue",
"with",
"the",
"request",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/particle/adaptor.go#L255-L283 |
156,605 | hybridgroup/gobot | platforms/intel-iot/curie/imu_driver.go | NewIMUDriver | func NewIMUDriver(a *firmata.Adaptor) *IMUDriver {
imu := &IMUDriver{
name: gobot.DefaultName("CurieIMU"),
connection: a,
Eventer: gobot.NewEventer(),
}
return imu
} | go | func NewIMUDriver(a *firmata.Adaptor) *IMUDriver {
imu := &IMUDriver{
name: gobot.DefaultName("CurieIMU"),
connection: a,
Eventer: gobot.NewEventer(),
}
return imu
} | [
"func",
"NewIMUDriver",
"(",
"a",
"*",
"firmata",
".",
"Adaptor",
")",
"*",
"IMUDriver",
"{",
"imu",
":=",
"&",
"IMUDriver",
"{",
"name",
":",
"gobot",
".",
"DefaultName",
"(",
"\"",
"\"",
")",
",",
"connection",
":",
"a",
",",
"Eventer",
":",
"gobot... | // NewIMUDriver returns a new IMUDriver | [
"NewIMUDriver",
"returns",
"a",
"new",
"IMUDriver"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/intel-iot/curie/imu_driver.go#L65-L73 |
156,606 | hybridgroup/gobot | platforms/intel-iot/curie/imu_driver.go | Start | func (imu *IMUDriver) Start() (err error) {
imu.connection.On("SysexResponse", func(res interface{}) {
data := res.([]byte)
imu.handleEvent(data)
})
return
} | go | func (imu *IMUDriver) Start() (err error) {
imu.connection.On("SysexResponse", func(res interface{}) {
data := res.([]byte)
imu.handleEvent(data)
})
return
} | [
"func",
"(",
"imu",
"*",
"IMUDriver",
")",
"Start",
"(",
")",
"(",
"err",
"error",
")",
"{",
"imu",
".",
"connection",
".",
"On",
"(",
"\"",
"\"",
",",
"func",
"(",
"res",
"interface",
"{",
"}",
")",
"{",
"data",
":=",
"res",
".",
"(",
"[",
"... | // Start starts up the IMUDriver | [
"Start",
"starts",
"up",
"the",
"IMUDriver"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/intel-iot/curie/imu_driver.go#L76-L82 |
156,607 | hybridgroup/gobot | platforms/intel-iot/curie/imu_driver.go | ReadAccelerometer | func (imu *IMUDriver) ReadAccelerometer() error {
return imu.connection.WriteSysex([]byte{CURIE_IMU, CURIE_IMU_READ_ACCEL})
} | go | func (imu *IMUDriver) ReadAccelerometer() error {
return imu.connection.WriteSysex([]byte{CURIE_IMU, CURIE_IMU_READ_ACCEL})
} | [
"func",
"(",
"imu",
"*",
"IMUDriver",
")",
"ReadAccelerometer",
"(",
")",
"error",
"{",
"return",
"imu",
".",
"connection",
".",
"WriteSysex",
"(",
"[",
"]",
"byte",
"{",
"CURIE_IMU",
",",
"CURIE_IMU_READ_ACCEL",
"}",
")",
"\n",
"}"
] | // ReadAccelerometer calls the Curie's built-in accelerometer. The result will
// be returned by the Sysex response message | [
"ReadAccelerometer",
"calls",
"the",
"Curie",
"s",
"built",
"-",
"in",
"accelerometer",
".",
"The",
"result",
"will",
"be",
"returned",
"by",
"the",
"Sysex",
"response",
"message"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/intel-iot/curie/imu_driver.go#L100-L102 |
156,608 | hybridgroup/gobot | platforms/intel-iot/curie/imu_driver.go | ReadGyroscope | func (imu *IMUDriver) ReadGyroscope() error {
return imu.connection.WriteSysex([]byte{CURIE_IMU, CURIE_IMU_READ_GYRO})
} | go | func (imu *IMUDriver) ReadGyroscope() error {
return imu.connection.WriteSysex([]byte{CURIE_IMU, CURIE_IMU_READ_GYRO})
} | [
"func",
"(",
"imu",
"*",
"IMUDriver",
")",
"ReadGyroscope",
"(",
")",
"error",
"{",
"return",
"imu",
".",
"connection",
".",
"WriteSysex",
"(",
"[",
"]",
"byte",
"{",
"CURIE_IMU",
",",
"CURIE_IMU_READ_GYRO",
"}",
")",
"\n",
"}"
] | // ReadGyroscope calls the Curie's built-in gyroscope. The result will
// be returned by the Sysex response message | [
"ReadGyroscope",
"calls",
"the",
"Curie",
"s",
"built",
"-",
"in",
"gyroscope",
".",
"The",
"result",
"will",
"be",
"returned",
"by",
"the",
"Sysex",
"response",
"message"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/intel-iot/curie/imu_driver.go#L106-L108 |
156,609 | hybridgroup/gobot | platforms/intel-iot/curie/imu_driver.go | ReadTemperature | func (imu *IMUDriver) ReadTemperature() error {
return imu.connection.WriteSysex([]byte{CURIE_IMU, CURIE_IMU_READ_TEMP})
} | go | func (imu *IMUDriver) ReadTemperature() error {
return imu.connection.WriteSysex([]byte{CURIE_IMU, CURIE_IMU_READ_TEMP})
} | [
"func",
"(",
"imu",
"*",
"IMUDriver",
")",
"ReadTemperature",
"(",
")",
"error",
"{",
"return",
"imu",
".",
"connection",
".",
"WriteSysex",
"(",
"[",
"]",
"byte",
"{",
"CURIE_IMU",
",",
"CURIE_IMU_READ_TEMP",
"}",
")",
"\n",
"}"
] | // ReadTemperature calls the Curie's built-in temperature sensor.
// The result will be returned by the Sysex response message | [
"ReadTemperature",
"calls",
"the",
"Curie",
"s",
"built",
"-",
"in",
"temperature",
"sensor",
".",
"The",
"result",
"will",
"be",
"returned",
"by",
"the",
"Sysex",
"response",
"message"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/intel-iot/curie/imu_driver.go#L112-L114 |
156,610 | hybridgroup/gobot | platforms/intel-iot/curie/imu_driver.go | ReadMotion | func (imu *IMUDriver) ReadMotion() error {
return imu.connection.WriteSysex([]byte{CURIE_IMU, CURIE_IMU_READ_MOTION})
} | go | func (imu *IMUDriver) ReadMotion() error {
return imu.connection.WriteSysex([]byte{CURIE_IMU, CURIE_IMU_READ_MOTION})
} | [
"func",
"(",
"imu",
"*",
"IMUDriver",
")",
"ReadMotion",
"(",
")",
"error",
"{",
"return",
"imu",
".",
"connection",
".",
"WriteSysex",
"(",
"[",
"]",
"byte",
"{",
"CURIE_IMU",
",",
"CURIE_IMU_READ_MOTION",
"}",
")",
"\n",
"}"
] | // ReadMotion calls the Curie's built-in accelerometer & gyroscope.
// The result will be returned by the Sysex response message | [
"ReadMotion",
"calls",
"the",
"Curie",
"s",
"built",
"-",
"in",
"accelerometer",
"&",
"gyroscope",
".",
"The",
"result",
"will",
"be",
"returned",
"by",
"the",
"Sysex",
"response",
"message"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/intel-iot/curie/imu_driver.go#L148-L150 |
156,611 | hybridgroup/gobot | platforms/leap/parser.go | ParseFrame | func (l *Driver) ParseFrame(data []byte) Frame {
var frame Frame
json.Unmarshal(data, &frame)
return frame
} | go | func (l *Driver) ParseFrame(data []byte) Frame {
var frame Frame
json.Unmarshal(data, &frame)
return frame
} | [
"func",
"(",
"l",
"*",
"Driver",
")",
"ParseFrame",
"(",
"data",
"[",
"]",
"byte",
")",
"Frame",
"{",
"var",
"frame",
"Frame",
"\n",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"frame",
")",
"\n",
"return",
"frame",
"\n",
"}"
] | // ParseFrame converts json data to a Frame | [
"ParseFrame",
"converts",
"json",
"data",
"to",
"a",
"Frame"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/leap/parser.go#L88-L92 |
156,612 | hybridgroup/gobot | drivers/gpio/rgb_led_driver.go | On | func (l *RgbLedDriver) On() (err error) {
if err = l.SetLevel(l.pinRed, l.redColor); err != nil {
return
}
if err = l.SetLevel(l.pinGreen, l.greenColor); err != nil {
return
}
if err = l.SetLevel(l.pinBlue, l.blueColor); err != nil {
return
}
l.high = true
return
} | go | func (l *RgbLedDriver) On() (err error) {
if err = l.SetLevel(l.pinRed, l.redColor); err != nil {
return
}
if err = l.SetLevel(l.pinGreen, l.greenColor); err != nil {
return
}
if err = l.SetLevel(l.pinBlue, l.blueColor); err != nil {
return
}
l.high = true
return
} | [
"func",
"(",
"l",
"*",
"RgbLedDriver",
")",
"On",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"l",
".",
"SetLevel",
"(",
"l",
".",
"pinRed",
",",
"l",
".",
"redColor",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n... | // On sets the led's pins to their various states | [
"On",
"sets",
"the",
"led",
"s",
"pins",
"to",
"their",
"various",
"states"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/gpio/rgb_led_driver.go#L95-L110 |
156,613 | hybridgroup/gobot | drivers/gpio/rgb_led_driver.go | Off | func (l *RgbLedDriver) Off() (err error) {
if err = l.SetLevel(l.pinRed, 0); err != nil {
return
}
if err = l.SetLevel(l.pinGreen, 0); err != nil {
return
}
if err = l.SetLevel(l.pinBlue, 0); err != nil {
return
}
l.high = false
return
} | go | func (l *RgbLedDriver) Off() (err error) {
if err = l.SetLevel(l.pinRed, 0); err != nil {
return
}
if err = l.SetLevel(l.pinGreen, 0); err != nil {
return
}
if err = l.SetLevel(l.pinBlue, 0); err != nil {
return
}
l.high = false
return
} | [
"func",
"(",
"l",
"*",
"RgbLedDriver",
")",
"Off",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"l",
".",
"SetLevel",
"(",
"l",
".",
"pinRed",
",",
"0",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"err"... | // Off sets the led to black. | [
"Off",
"sets",
"the",
"led",
"to",
"black",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/gpio/rgb_led_driver.go#L113-L128 |
156,614 | hybridgroup/gobot | drivers/gpio/rgb_led_driver.go | SetLevel | func (l *RgbLedDriver) SetLevel(pin string, level byte) (err error) {
if writer, ok := l.connection.(PwmWriter); ok {
return writer.PwmWrite(pin, level)
}
return ErrPwmWriteUnsupported
} | go | func (l *RgbLedDriver) SetLevel(pin string, level byte) (err error) {
if writer, ok := l.connection.(PwmWriter); ok {
return writer.PwmWrite(pin, level)
}
return ErrPwmWriteUnsupported
} | [
"func",
"(",
"l",
"*",
"RgbLedDriver",
")",
"SetLevel",
"(",
"pin",
"string",
",",
"level",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"if",
"writer",
",",
"ok",
":=",
"l",
".",
"connection",
".",
"(",
"PwmWriter",
")",
";",
"ok",
"{",
"return",
... | // SetLevel sets the led to the specified color level | [
"SetLevel",
"sets",
"the",
"led",
"to",
"the",
"specified",
"color",
"level"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/gpio/rgb_led_driver.go#L141-L146 |
156,615 | hybridgroup/gobot | drivers/gpio/rgb_led_driver.go | SetRGB | func (l *RgbLedDriver) SetRGB(r, g, b byte) error {
l.redColor = r
l.greenColor = g
l.blueColor = b
return l.On()
} | go | func (l *RgbLedDriver) SetRGB(r, g, b byte) error {
l.redColor = r
l.greenColor = g
l.blueColor = b
return l.On()
} | [
"func",
"(",
"l",
"*",
"RgbLedDriver",
")",
"SetRGB",
"(",
"r",
",",
"g",
",",
"b",
"byte",
")",
"error",
"{",
"l",
".",
"redColor",
"=",
"r",
"\n",
"l",
".",
"greenColor",
"=",
"g",
"\n",
"l",
".",
"blueColor",
"=",
"b",
"\n\n",
"return",
"l",... | // SetRGB sets the Red Green Blue value of the LED. | [
"SetRGB",
"sets",
"the",
"Red",
"Green",
"Blue",
"value",
"of",
"the",
"LED",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/gpio/rgb_led_driver.go#L149-L155 |
156,616 | hybridgroup/gobot | platforms/ble/ble_client_adaptor.go | NewClientAdaptor | func NewClientAdaptor(address string) *ClientAdaptor {
return &ClientAdaptor{
name: gobot.DefaultName("BLEClient"),
address: address,
DeviceName: "default",
connected: false,
withoutResponses: false,
}
} | go | func NewClientAdaptor(address string) *ClientAdaptor {
return &ClientAdaptor{
name: gobot.DefaultName("BLEClient"),
address: address,
DeviceName: "default",
connected: false,
withoutResponses: false,
}
} | [
"func",
"NewClientAdaptor",
"(",
"address",
"string",
")",
"*",
"ClientAdaptor",
"{",
"return",
"&",
"ClientAdaptor",
"{",
"name",
":",
"gobot",
".",
"DefaultName",
"(",
"\"",
"\"",
")",
",",
"address",
":",
"address",
",",
"DeviceName",
":",
"\"",
"\"",
... | // NewClientAdaptor returns a new ClientAdaptor given an address or peripheral name | [
"NewClientAdaptor",
"returns",
"a",
"new",
"ClientAdaptor",
"given",
"an",
"address",
"or",
"peripheral",
"name"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/ble/ble_client_adaptor.go#L51-L59 |
156,617 | hybridgroup/gobot | platforms/ble/ble_client_adaptor.go | Connect | func (b *ClientAdaptor) Connect() (err error) {
bleMutex.Lock()
defer bleMutex.Unlock()
b.device, err = getBLEDevice(b.DeviceName)
if err != nil {
return errors.Wrap(err, "can't connect to device "+b.DeviceName)
}
var cln blelib.Client
cln, err = blelib.Connect(context.Background(), filter(b.Address()))
if... | go | func (b *ClientAdaptor) Connect() (err error) {
bleMutex.Lock()
defer bleMutex.Unlock()
b.device, err = getBLEDevice(b.DeviceName)
if err != nil {
return errors.Wrap(err, "can't connect to device "+b.DeviceName)
}
var cln blelib.Client
cln, err = blelib.Connect(context.Background(), filter(b.Address()))
if... | [
"func",
"(",
"b",
"*",
"ClientAdaptor",
")",
"Connect",
"(",
")",
"(",
"err",
"error",
")",
"{",
"bleMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"bleMutex",
".",
"Unlock",
"(",
")",
"\n\n",
"b",
".",
"device",
",",
"err",
"=",
"getBLEDevice",
"("... | // Connect initiates a connection to the BLE peripheral. Returns true on successful connection. | [
"Connect",
"initiates",
"a",
"connection",
"to",
"the",
"BLE",
"peripheral",
".",
"Returns",
"true",
"on",
"successful",
"connection",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/ble/ble_client_adaptor.go#L75-L104 |
156,618 | hybridgroup/gobot | platforms/ble/ble_client_adaptor.go | Reconnect | func (b *ClientAdaptor) Reconnect() (err error) {
if b.connected {
b.Disconnect()
}
return b.Connect()
} | go | func (b *ClientAdaptor) Reconnect() (err error) {
if b.connected {
b.Disconnect()
}
return b.Connect()
} | [
"func",
"(",
"b",
"*",
"ClientAdaptor",
")",
"Reconnect",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"b",
".",
"connected",
"{",
"b",
".",
"Disconnect",
"(",
")",
"\n",
"}",
"\n",
"return",
"b",
".",
"Connect",
"(",
")",
"\n",
"}"
] | // Reconnect attempts to reconnect to the BLE peripheral. If it has an active connection
// it will first close that connection and then establish a new connection.
// Returns true on Successful reconnection | [
"Reconnect",
"attempts",
"to",
"reconnect",
"to",
"the",
"BLE",
"peripheral",
".",
"If",
"it",
"has",
"an",
"active",
"connection",
"it",
"will",
"first",
"close",
"that",
"connection",
"and",
"then",
"establish",
"a",
"new",
"connection",
".",
"Returns",
"t... | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/ble/ble_client_adaptor.go#L109-L114 |
156,619 | hybridgroup/gobot | platforms/ble/ble_client_adaptor.go | ReadCharacteristic | func (b *ClientAdaptor) ReadCharacteristic(cUUID string) (data []byte, err error) {
if !b.connected {
log.Fatalf("Cannot read from BLE device until connected")
return
}
uuid, _ := blelib.Parse(cUUID)
if u := b.profile.Find(blelib.NewCharacteristic(uuid)); u != nil {
data, err = b.client.ReadCharacteristic(u... | go | func (b *ClientAdaptor) ReadCharacteristic(cUUID string) (data []byte, err error) {
if !b.connected {
log.Fatalf("Cannot read from BLE device until connected")
return
}
uuid, _ := blelib.Parse(cUUID)
if u := b.profile.Find(blelib.NewCharacteristic(uuid)); u != nil {
data, err = b.client.ReadCharacteristic(u... | [
"func",
"(",
"b",
"*",
"ClientAdaptor",
")",
"ReadCharacteristic",
"(",
"cUUID",
"string",
")",
"(",
"data",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"if",
"!",
"b",
".",
"connected",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
")",
"\n",
... | // ReadCharacteristic returns bytes from the BLE device for the
// requested characteristic uuid | [
"ReadCharacteristic",
"returns",
"bytes",
"from",
"the",
"BLE",
"device",
"for",
"the",
"requested",
"characteristic",
"uuid"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/ble/ble_client_adaptor.go#L129-L142 |
156,620 | hybridgroup/gobot | platforms/ble/ble_client_adaptor.go | Subscribe | func (b *ClientAdaptor) Subscribe(cUUID string, f func([]byte, error)) (err error) {
if !b.connected {
log.Fatalf("Cannot subscribe to BLE device until connected")
return
}
uuid, _ := blelib.Parse(cUUID)
if u := b.profile.Find(blelib.NewCharacteristic(uuid)); u != nil {
h := func(req []byte) { f(req, nil) }... | go | func (b *ClientAdaptor) Subscribe(cUUID string, f func([]byte, error)) (err error) {
if !b.connected {
log.Fatalf("Cannot subscribe to BLE device until connected")
return
}
uuid, _ := blelib.Parse(cUUID)
if u := b.profile.Find(blelib.NewCharacteristic(uuid)); u != nil {
h := func(req []byte) { f(req, nil) }... | [
"func",
"(",
"b",
"*",
"ClientAdaptor",
")",
"Subscribe",
"(",
"cUUID",
"string",
",",
"f",
"func",
"(",
"[",
"]",
"byte",
",",
"error",
")",
")",
"(",
"err",
"error",
")",
"{",
"if",
"!",
"b",
".",
"connected",
"{",
"log",
".",
"Fatalf",
"(",
... | // Subscribe subscribes to notifications from the BLE device for the
// requested service and characteristic | [
"Subscribe",
"subscribes",
"to",
"notifications",
"from",
"the",
"BLE",
"device",
"for",
"the",
"requested",
"service",
"and",
"characteristic"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/ble/ble_client_adaptor.go#L163-L181 |
156,621 | hybridgroup/gobot | platforms/ble/ble_client_adaptor.go | getBLEDevice | func getBLEDevice(impl string) (d *blelib.Device, err error) {
if currentDevice != nil {
return currentDevice, nil
}
dev, e := defaultDevice(impl)
if e != nil {
return nil, errors.Wrap(e, "can't get device")
}
blelib.SetDefaultDevice(dev)
currentDevice = &dev
d = &dev
return
} | go | func getBLEDevice(impl string) (d *blelib.Device, err error) {
if currentDevice != nil {
return currentDevice, nil
}
dev, e := defaultDevice(impl)
if e != nil {
return nil, errors.Wrap(e, "can't get device")
}
blelib.SetDefaultDevice(dev)
currentDevice = &dev
d = &dev
return
} | [
"func",
"getBLEDevice",
"(",
"impl",
"string",
")",
"(",
"d",
"*",
"blelib",
".",
"Device",
",",
"err",
"error",
")",
"{",
"if",
"currentDevice",
"!=",
"nil",
"{",
"return",
"currentDevice",
",",
"nil",
"\n",
"}",
"\n\n",
"dev",
",",
"e",
":=",
"defa... | // getBLEDevice is singleton for blelib HCI device connection | [
"getBLEDevice",
"is",
"singleton",
"for",
"blelib",
"HCI",
"device",
"connection"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/ble/ble_client_adaptor.go#L184-L198 |
156,622 | hybridgroup/gobot | platforms/leap/leap_motion_adaptor.go | NewAdaptor | func NewAdaptor(port string) *Adaptor {
return &Adaptor{
name: gobot.DefaultName("LeapMotion"),
port: port,
connect: func(host string) (io.ReadWriteCloser, error) {
return websocket.Dial("ws://"+host+"/v3.json", "", "http://"+host)
},
}
} | go | func NewAdaptor(port string) *Adaptor {
return &Adaptor{
name: gobot.DefaultName("LeapMotion"),
port: port,
connect: func(host string) (io.ReadWriteCloser, error) {
return websocket.Dial("ws://"+host+"/v3.json", "", "http://"+host)
},
}
} | [
"func",
"NewAdaptor",
"(",
"port",
"string",
")",
"*",
"Adaptor",
"{",
"return",
"&",
"Adaptor",
"{",
"name",
":",
"gobot",
".",
"DefaultName",
"(",
"\"",
"\"",
")",
",",
"port",
":",
"port",
",",
"connect",
":",
"func",
"(",
"host",
"string",
")",
... | // NewAdaptor creates a new leap motion adaptor using specified port,
// which is this case is the host IP or name of the Leap Motion daemon | [
"NewAdaptor",
"creates",
"a",
"new",
"leap",
"motion",
"adaptor",
"using",
"specified",
"port",
"which",
"is",
"this",
"case",
"is",
"the",
"host",
"IP",
"or",
"name",
"of",
"the",
"Leap",
"Motion",
"daemon"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/leap/leap_motion_adaptor.go#L21-L29 |
156,623 | hybridgroup/gobot | platforms/leap/leap_motion_adaptor.go | Connect | func (l *Adaptor) Connect() (err error) {
ws, e := l.connect(l.Port())
if e != nil {
return e
}
l.ws = ws
return
} | go | func (l *Adaptor) Connect() (err error) {
ws, e := l.connect(l.Port())
if e != nil {
return e
}
l.ws = ws
return
} | [
"func",
"(",
"l",
"*",
"Adaptor",
")",
"Connect",
"(",
")",
"(",
"err",
"error",
")",
"{",
"ws",
",",
"e",
":=",
"l",
".",
"connect",
"(",
"l",
".",
"Port",
"(",
")",
")",
"\n",
"if",
"e",
"!=",
"nil",
"{",
"return",
"e",
"\n",
"}",
"\n\n",... | // Connect returns true if connection to leap motion is established successfully | [
"Connect",
"returns",
"true",
"if",
"connection",
"to",
"leap",
"motion",
"is",
"established",
"successfully"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/leap/leap_motion_adaptor.go#L41-L49 |
156,624 | hybridgroup/gobot | drivers/i2c/mpl115a2_driver.go | Start | func (h *MPL115A2Driver) Start() (err error) {
if err := h.initialization(); err != nil {
return err
}
return
} | go | func (h *MPL115A2Driver) Start() (err error) {
if err := h.initialization(); err != nil {
return err
}
return
} | [
"func",
"(",
"h",
"*",
"MPL115A2Driver",
")",
"Start",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"h",
".",
"initialization",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"\n",
"}"
] | // Start writes initialization bytes and reads from adaptor
// using specified interval to accelerometer andtemperature data | [
"Start",
"writes",
"initialization",
"bytes",
"and",
"reads",
"from",
"adaptor",
"using",
"specified",
"interval",
"to",
"accelerometer",
"andtemperature",
"data"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mpl115a2_driver.go#L79-L85 |
156,625 | hybridgroup/gobot | drivers/i2c/mpl115a2_driver.go | Pressure | func (h *MPL115A2Driver) Pressure() (p float32, err error) {
p, _, err = h.getData()
return
} | go | func (h *MPL115A2Driver) Pressure() (p float32, err error) {
p, _, err = h.getData()
return
} | [
"func",
"(",
"h",
"*",
"MPL115A2Driver",
")",
"Pressure",
"(",
")",
"(",
"p",
"float32",
",",
"err",
"error",
")",
"{",
"p",
",",
"_",
",",
"err",
"=",
"h",
".",
"getData",
"(",
")",
"\n",
"return",
"\n",
"}"
] | // Pressure fetches the latest data from the MPL115A2, and returns the pressure | [
"Pressure",
"fetches",
"the",
"latest",
"data",
"from",
"the",
"MPL115A2",
"and",
"returns",
"the",
"pressure"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mpl115a2_driver.go#L91-L94 |
156,626 | hybridgroup/gobot | drivers/i2c/mpl115a2_driver.go | Temperature | func (h *MPL115A2Driver) Temperature() (t float32, err error) {
_, t, err = h.getData()
return
} | go | func (h *MPL115A2Driver) Temperature() (t float32, err error) {
_, t, err = h.getData()
return
} | [
"func",
"(",
"h",
"*",
"MPL115A2Driver",
")",
"Temperature",
"(",
")",
"(",
"t",
"float32",
",",
"err",
"error",
")",
"{",
"_",
",",
"t",
",",
"err",
"=",
"h",
".",
"getData",
"(",
")",
"\n",
"return",
"\n",
"}"
] | // Temperature fetches the latest data from the MPL115A2, and returns the temperature | [
"Temperature",
"fetches",
"the",
"latest",
"data",
"from",
"the",
"MPL115A2",
"and",
"returns",
"the",
"temperature"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mpl115a2_driver.go#L97-L100 |
156,627 | hybridgroup/gobot | drivers/i2c/mpl115a2_driver.go | getData | func (h *MPL115A2Driver) getData() (p, t float32, err error) {
var temperature uint16
var pressure uint16
var pressureComp float32
if _, err = h.connection.Write([]byte{MPL115A2_REGISTER_STARTCONVERSION, 0}); err != nil {
return
}
time.Sleep(5 * time.Millisecond)
if _, err = h.connection.Write([]byte{MPL115A... | go | func (h *MPL115A2Driver) getData() (p, t float32, err error) {
var temperature uint16
var pressure uint16
var pressureComp float32
if _, err = h.connection.Write([]byte{MPL115A2_REGISTER_STARTCONVERSION, 0}); err != nil {
return
}
time.Sleep(5 * time.Millisecond)
if _, err = h.connection.Write([]byte{MPL115A... | [
"func",
"(",
"h",
"*",
"MPL115A2Driver",
")",
"getData",
"(",
")",
"(",
"p",
",",
"t",
"float32",
",",
"err",
"error",
")",
"{",
"var",
"temperature",
"uint16",
"\n",
"var",
"pressure",
"uint16",
"\n",
"var",
"pressureComp",
"float32",
"\n\n",
"if",
"_... | // getData fetches the latest data from the MPL115A2 | [
"getData",
"fetches",
"the",
"latest",
"data",
"from",
"the",
"MPL115A2"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mpl115a2_driver.go#L142-L177 |
156,628 | hybridgroup/gobot | drivers/i2c/adxl345_driver.go | Start | func (h *ADXL345Driver) Start() (err error) {
bus := h.GetBusOrDefault(h.connector.GetDefaultBus())
address := h.GetAddressOrDefault(ADXL345AddressLow)
h.connection, err = h.connector.GetConnection(address, bus)
if err != nil {
return err
}
if _, err := h.connection.Write([]byte{ADXL345_REG_BW_RATE, h.bwRate.... | go | func (h *ADXL345Driver) Start() (err error) {
bus := h.GetBusOrDefault(h.connector.GetDefaultBus())
address := h.GetAddressOrDefault(ADXL345AddressLow)
h.connection, err = h.connector.GetConnection(address, bus)
if err != nil {
return err
}
if _, err := h.connection.Write([]byte{ADXL345_REG_BW_RATE, h.bwRate.... | [
"func",
"(",
"h",
"*",
"ADXL345Driver",
")",
"Start",
"(",
")",
"(",
"err",
"error",
")",
"{",
"bus",
":=",
"h",
".",
"GetBusOrDefault",
"(",
"h",
".",
"connector",
".",
"GetDefaultBus",
"(",
")",
")",
"\n",
"address",
":=",
"h",
".",
"GetAddressOrDe... | // Start initialized the adxl345 | [
"Start",
"initialized",
"the",
"adxl345"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adxl345_driver.go#L159-L181 |
156,629 | hybridgroup/gobot | drivers/i2c/adxl345_driver.go | XYZ | func (h *ADXL345Driver) XYZ() (float64, float64, float64, error) {
err := h.update()
return h.x, h.y, h.z, err
} | go | func (h *ADXL345Driver) XYZ() (float64, float64, float64, error) {
err := h.update()
return h.x, h.y, h.z, err
} | [
"func",
"(",
"h",
"*",
"ADXL345Driver",
")",
"XYZ",
"(",
")",
"(",
"float64",
",",
"float64",
",",
"float64",
",",
"error",
")",
"{",
"err",
":=",
"h",
".",
"update",
"(",
")",
"\n",
"return",
"h",
".",
"x",
",",
"h",
".",
"y",
",",
"h",
".",... | // XYZ returns the adjusted x, y and z axis from the adxl345 | [
"XYZ",
"returns",
"the",
"adjusted",
"x",
"y",
"and",
"z",
"axis",
"from",
"the",
"adxl345"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adxl345_driver.go#L203-L206 |
156,630 | hybridgroup/gobot | drivers/i2c/adxl345_driver.go | RawXYZ | func (h *ADXL345Driver) RawXYZ() (int16, int16, int16, error) {
err := h.update()
return h.rawX, h.rawY, h.rawZ, err
} | go | func (h *ADXL345Driver) RawXYZ() (int16, int16, int16, error) {
err := h.update()
return h.rawX, h.rawY, h.rawZ, err
} | [
"func",
"(",
"h",
"*",
"ADXL345Driver",
")",
"RawXYZ",
"(",
")",
"(",
"int16",
",",
"int16",
",",
"int16",
",",
"error",
")",
"{",
"err",
":=",
"h",
".",
"update",
"(",
")",
"\n",
"return",
"h",
".",
"rawX",
",",
"h",
".",
"rawY",
",",
"h",
"... | // XYZ returns the raw x,y and z axis from the adxl345 | [
"XYZ",
"returns",
"the",
"raw",
"x",
"y",
"and",
"z",
"axis",
"from",
"the",
"adxl345"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adxl345_driver.go#L209-L212 |
156,631 | hybridgroup/gobot | drivers/i2c/adxl345_driver.go | SetRange | func (h *ADXL345Driver) SetRange(sensorRange byte) (err error) {
if sensorRange != ADXL345_RANGE_2G &&
sensorRange != ADXL345_RANGE_4G &&
sensorRange != ADXL345_RANGE_8G &&
sensorRange != ADXL345_RANGE_16G {
return errors.New("not a valid range")
}
h.dataFormat.sensorRange = sensorRange & 0x03
if _, err := ... | go | func (h *ADXL345Driver) SetRange(sensorRange byte) (err error) {
if sensorRange != ADXL345_RANGE_2G &&
sensorRange != ADXL345_RANGE_4G &&
sensorRange != ADXL345_RANGE_8G &&
sensorRange != ADXL345_RANGE_16G {
return errors.New("not a valid range")
}
h.dataFormat.sensorRange = sensorRange & 0x03
if _, err := ... | [
"func",
"(",
"h",
"*",
"ADXL345Driver",
")",
"SetRange",
"(",
"sensorRange",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"if",
"sensorRange",
"!=",
"ADXL345_RANGE_2G",
"&&",
"sensorRange",
"!=",
"ADXL345_RANGE_4G",
"&&",
"sensorRange",
"!=",
"ADXL345_RANGE_8G",
... | // SetRange change the current range of the sensor | [
"SetRange",
"change",
"the",
"current",
"range",
"of",
"the",
"sensor"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adxl345_driver.go#L266-L278 |
156,632 | hybridgroup/gobot | drivers/i2c/adxl345_driver.go | ConvertToSI | func (d *adxl345DataFormat) ConvertToSI(rawValue int16) float64 {
switch d.sensorRange {
case ADXL345_RANGE_2G:
return float64(rawValue) * 2 / 512
case ADXL345_RANGE_4G:
return float64(rawValue) * 4 / 512
case ADXL345_RANGE_8G:
return float64(rawValue) * 8 / 512
case ADXL345_RANGE_16G:
return float64(rawVa... | go | func (d *adxl345DataFormat) ConvertToSI(rawValue int16) float64 {
switch d.sensorRange {
case ADXL345_RANGE_2G:
return float64(rawValue) * 2 / 512
case ADXL345_RANGE_4G:
return float64(rawValue) * 4 / 512
case ADXL345_RANGE_8G:
return float64(rawValue) * 8 / 512
case ADXL345_RANGE_16G:
return float64(rawVa... | [
"func",
"(",
"d",
"*",
"adxl345DataFormat",
")",
"ConvertToSI",
"(",
"rawValue",
"int16",
")",
"float64",
"{",
"switch",
"d",
".",
"sensorRange",
"{",
"case",
"ADXL345_RANGE_2G",
":",
"return",
"float64",
"(",
"rawValue",
")",
"*",
"2",
"/",
"512",
"\n",
... | // ConvertToSI adjusts the raw values from the adxl345 with the range configuration | [
"ConvertToSI",
"adjusts",
"the",
"raw",
"values",
"from",
"the",
"adxl345",
"with",
"the",
"range",
"configuration"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adxl345_driver.go#L281-L294 |
156,633 | hybridgroup/gobot | drivers/i2c/adxl345_driver.go | toByte | func (p *adxl345PowerCtl) toByte() (bits uint8) {
bits = 0x00
bits = bits | (p.link << 5)
bits = bits | (p.autoSleep << 4)
bits = bits | (p.measure << 3)
bits = bits | (p.sleep << 2)
bits = bits | p.wakeUp
return bits
} | go | func (p *adxl345PowerCtl) toByte() (bits uint8) {
bits = 0x00
bits = bits | (p.link << 5)
bits = bits | (p.autoSleep << 4)
bits = bits | (p.measure << 3)
bits = bits | (p.sleep << 2)
bits = bits | p.wakeUp
return bits
} | [
"func",
"(",
"p",
"*",
"adxl345PowerCtl",
")",
"toByte",
"(",
")",
"(",
"bits",
"uint8",
")",
"{",
"bits",
"=",
"0x00",
"\n",
"bits",
"=",
"bits",
"|",
"(",
"p",
".",
"link",
"<<",
"5",
")",
"\n",
"bits",
"=",
"bits",
"|",
"(",
"p",
".",
"aut... | // toByte returns a byte from the powerCtl configuration | [
"toByte",
"returns",
"a",
"byte",
"from",
"the",
"powerCtl",
"configuration"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adxl345_driver.go#L297-L306 |
156,634 | hybridgroup/gobot | drivers/i2c/adxl345_driver.go | toByte | func (d *adxl345DataFormat) toByte() (bits uint8) {
bits = 0x00
bits = bits | (d.selfTest << 7)
bits = bits | (d.spi << 6)
bits = bits | (d.intInvert << 5)
bits = bits | (d.fullRes << 3)
bits = bits | (d.justify << 2)
bits = bits | d.sensorRange
return bits
} | go | func (d *adxl345DataFormat) toByte() (bits uint8) {
bits = 0x00
bits = bits | (d.selfTest << 7)
bits = bits | (d.spi << 6)
bits = bits | (d.intInvert << 5)
bits = bits | (d.fullRes << 3)
bits = bits | (d.justify << 2)
bits = bits | d.sensorRange
return bits
} | [
"func",
"(",
"d",
"*",
"adxl345DataFormat",
")",
"toByte",
"(",
")",
"(",
"bits",
"uint8",
")",
"{",
"bits",
"=",
"0x00",
"\n",
"bits",
"=",
"bits",
"|",
"(",
"d",
".",
"selfTest",
"<<",
"7",
")",
"\n",
"bits",
"=",
"bits",
"|",
"(",
"d",
".",
... | // toByte returns a byte from the dataFormat configuration | [
"toByte",
"returns",
"a",
"byte",
"from",
"the",
"dataFormat",
"configuration"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adxl345_driver.go#L309-L319 |
156,635 | hybridgroup/gobot | drivers/i2c/adxl345_driver.go | toByte | func (b *adxl345BwRate) toByte() (bits uint8) {
bits = 0x00
bits = bits | (b.lowPower << 4)
bits = bits | b.rate
return bits
} | go | func (b *adxl345BwRate) toByte() (bits uint8) {
bits = 0x00
bits = bits | (b.lowPower << 4)
bits = bits | b.rate
return bits
} | [
"func",
"(",
"b",
"*",
"adxl345BwRate",
")",
"toByte",
"(",
")",
"(",
"bits",
"uint8",
")",
"{",
"bits",
"=",
"0x00",
"\n",
"bits",
"=",
"bits",
"|",
"(",
"b",
".",
"lowPower",
"<<",
"4",
")",
"\n",
"bits",
"=",
"bits",
"|",
"b",
".",
"rate",
... | // toByte returns a byte from the bwRate configuration | [
"toByte",
"returns",
"a",
"byte",
"from",
"the",
"bwRate",
"configuration"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adxl345_driver.go#L322-L328 |
156,636 | hybridgroup/gobot | drivers/i2c/pca9685_driver.go | Start | func (p *PCA9685Driver) Start() (err error) {
bus := p.GetBusOrDefault(p.connector.GetDefaultBus())
address := p.GetAddressOrDefault(pca9685Address)
p.connection, err = p.connector.GetConnection(address, bus)
if err != nil {
return err
}
if _, err := p.connection.Write([]byte{PCA9685_MODE1, 0x00}); err != nil... | go | func (p *PCA9685Driver) Start() (err error) {
bus := p.GetBusOrDefault(p.connector.GetDefaultBus())
address := p.GetAddressOrDefault(pca9685Address)
p.connection, err = p.connector.GetConnection(address, bus)
if err != nil {
return err
}
if _, err := p.connection.Write([]byte{PCA9685_MODE1, 0x00}); err != nil... | [
"func",
"(",
"p",
"*",
"PCA9685Driver",
")",
"Start",
"(",
")",
"(",
"err",
"error",
")",
"{",
"bus",
":=",
"p",
".",
"GetBusOrDefault",
"(",
"p",
".",
"connector",
".",
"GetDefaultBus",
"(",
")",
")",
"\n",
"address",
":=",
"p",
".",
"GetAddressOrDe... | // Start initializes the pca9685 | [
"Start",
"initializes",
"the",
"pca9685"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/pca9685_driver.go#L95-L113 |
156,637 | hybridgroup/gobot | drivers/i2c/pca9685_driver.go | Halt | func (p *PCA9685Driver) Halt() (err error) {
_, err = p.connection.Write([]byte{PCA9685_ALLLED_OFF_H, 0x10})
return
} | go | func (p *PCA9685Driver) Halt() (err error) {
_, err = p.connection.Write([]byte{PCA9685_ALLLED_OFF_H, 0x10})
return
} | [
"func",
"(",
"p",
"*",
"PCA9685Driver",
")",
"Halt",
"(",
")",
"(",
"err",
"error",
")",
"{",
"_",
",",
"err",
"=",
"p",
".",
"connection",
".",
"Write",
"(",
"[",
"]",
"byte",
"{",
"PCA9685_ALLLED_OFF_H",
",",
"0x10",
"}",
")",
"\n",
"return",
"... | // Halt stops the device | [
"Halt",
"stops",
"the",
"device"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/pca9685_driver.go#L116-L119 |
156,638 | hybridgroup/gobot | drivers/i2c/pca9685_driver.go | SetPWMFreq | func (p *PCA9685Driver) SetPWMFreq(freq float32) error {
// IC oscillator frequency is 25 MHz
var prescalevel float32 = 25000000
// Find frequency of PWM waveform
prescalevel /= 4096
// Ratio between desired frequency and maximum
prescalevel /= freq
prescalevel -= 1
// Round value to nearest whole
prescale := ... | go | func (p *PCA9685Driver) SetPWMFreq(freq float32) error {
// IC oscillator frequency is 25 MHz
var prescalevel float32 = 25000000
// Find frequency of PWM waveform
prescalevel /= 4096
// Ratio between desired frequency and maximum
prescalevel /= freq
prescalevel -= 1
// Round value to nearest whole
prescale := ... | [
"func",
"(",
"p",
"*",
"PCA9685Driver",
")",
"SetPWMFreq",
"(",
"freq",
"float32",
")",
"error",
"{",
"// IC oscillator frequency is 25 MHz",
"var",
"prescalevel",
"float32",
"=",
"25000000",
"\n",
"// Find frequency of PWM waveform",
"prescalevel",
"/=",
"4096",
"\n"... | // SetPWMFreq sets the PWM frequency in Hz | [
"SetPWMFreq",
"sets",
"the",
"PWM",
"frequency",
"in",
"Hz"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/pca9685_driver.go#L138-L180 |
156,639 | hybridgroup/gobot | platforms/pebble/pebble_driver.go | PublishEvent | func (d *Driver) PublishEvent(name string, data string) {
d.Publish(d.Event(name), data)
} | go | func (d *Driver) PublishEvent(name string, data string) {
d.Publish(d.Event(name), data)
} | [
"func",
"(",
"d",
"*",
"Driver",
")",
"PublishEvent",
"(",
"name",
"string",
",",
"data",
"string",
")",
"{",
"d",
".",
"Publish",
"(",
"d",
".",
"Event",
"(",
"name",
")",
",",
"data",
")",
"\n",
"}"
] | // PublishEvent publishes event with specified name and data in gobot | [
"PublishEvent",
"publishes",
"event",
"with",
"specified",
"name",
"and",
"data",
"in",
"gobot"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/pebble/pebble_driver.go#L64-L66 |
156,640 | hybridgroup/gobot | platforms/pebble/pebble_driver.go | SendNotification | func (d *Driver) SendNotification(message string) string {
d.Messages = append(d.Messages, message)
return message
} | go | func (d *Driver) SendNotification(message string) string {
d.Messages = append(d.Messages, message)
return message
} | [
"func",
"(",
"d",
"*",
"Driver",
")",
"SendNotification",
"(",
"message",
"string",
")",
"string",
"{",
"d",
".",
"Messages",
"=",
"append",
"(",
"d",
".",
"Messages",
",",
"message",
")",
"\n",
"return",
"message",
"\n",
"}"
] | // SendNotification appends message to list of notifications to be sent to watch | [
"SendNotification",
"appends",
"message",
"to",
"list",
"of",
"notifications",
"to",
"be",
"sent",
"to",
"watch"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/pebble/pebble_driver.go#L69-L72 |
156,641 | hybridgroup/gobot | drivers/i2c/adafruit_driver.go | Start | func (a *AdafruitMotorHatDriver) Start() (err error) {
bus := a.GetBusOrDefault(a.connector.GetDefaultBus())
if a.servoHatConnection, err = a.connector.GetConnection(servoHatAddress, bus); err != nil {
return
}
if err = a.startDriver(a.servoHatConnection); err != nil {
return
}
if a.motorHatConnection, err... | go | func (a *AdafruitMotorHatDriver) Start() (err error) {
bus := a.GetBusOrDefault(a.connector.GetDefaultBus())
if a.servoHatConnection, err = a.connector.GetConnection(servoHatAddress, bus); err != nil {
return
}
if err = a.startDriver(a.servoHatConnection); err != nil {
return
}
if a.motorHatConnection, err... | [
"func",
"(",
"a",
"*",
"AdafruitMotorHatDriver",
")",
"Start",
"(",
")",
"(",
"err",
"error",
")",
"{",
"bus",
":=",
"a",
".",
"GetBusOrDefault",
"(",
"a",
".",
"connector",
".",
"GetDefaultBus",
"(",
")",
")",
"\n\n",
"if",
"a",
".",
"servoHatConnecti... | // Start initializes both I2C-addressable Adafruit Motor HAT drivers | [
"Start",
"initializes",
"both",
"I2C",
"-",
"addressable",
"Adafruit",
"Motor",
"HAT",
"drivers"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adafruit_driver.go#L201-L221 |
156,642 | hybridgroup/gobot | drivers/i2c/adafruit_driver.go | SetServoMotorFreq | func (a *AdafruitMotorHatDriver) SetServoMotorFreq(freq float64) (err error) {
if err = a.setPWMFreq(a.servoHatConnection, freq); err != nil {
return
}
return
} | go | func (a *AdafruitMotorHatDriver) SetServoMotorFreq(freq float64) (err error) {
if err = a.setPWMFreq(a.servoHatConnection, freq); err != nil {
return
}
return
} | [
"func",
"(",
"a",
"*",
"AdafruitMotorHatDriver",
")",
"SetServoMotorFreq",
"(",
"freq",
"float64",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"a",
".",
"setPWMFreq",
"(",
"a",
".",
"servoHatConnection",
",",
"freq",
")",
";",
"err",
"!=",
"n... | // SetServoMotorFreq sets the frequency for the currently addressed PWM Servo HAT. | [
"SetServoMotorFreq",
"sets",
"the",
"frequency",
"for",
"the",
"currently",
"addressed",
"PWM",
"Servo",
"HAT",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adafruit_driver.go#L244-L249 |
156,643 | hybridgroup/gobot | drivers/i2c/adafruit_driver.go | SetServoMotorPulse | func (a *AdafruitMotorHatDriver) SetServoMotorPulse(channel byte, on, off int32) (err error) {
if err = a.setPWM(a.servoHatConnection, channel, on, off); err != nil {
return
}
return
} | go | func (a *AdafruitMotorHatDriver) SetServoMotorPulse(channel byte, on, off int32) (err error) {
if err = a.setPWM(a.servoHatConnection, channel, on, off); err != nil {
return
}
return
} | [
"func",
"(",
"a",
"*",
"AdafruitMotorHatDriver",
")",
"SetServoMotorPulse",
"(",
"channel",
"byte",
",",
"on",
",",
"off",
"int32",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"a",
".",
"setPWM",
"(",
"a",
".",
"servoHatConnection",
",",
"cha... | // SetServoMotorPulse is a convenience function to specify the 'tick' value,
// between 0-4095, when the signal will turn on, and when it will turn off. | [
"SetServoMotorPulse",
"is",
"a",
"convenience",
"function",
"to",
"specify",
"the",
"tick",
"value",
"between",
"0",
"-",
"4095",
"when",
"the",
"signal",
"will",
"turn",
"on",
"and",
"when",
"it",
"will",
"turn",
"off",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adafruit_driver.go#L253-L258 |
156,644 | hybridgroup/gobot | drivers/i2c/adafruit_driver.go | setPWMFreq | func (a *AdafruitMotorHatDriver) setPWMFreq(conn Connection, freq float64) (err error) {
// 25MHz
preScaleVal := 25000000.0
// 12-bit
preScaleVal /= 4096.0
preScaleVal /= freq
preScaleVal -= 1.0
preScale := math.Floor(preScaleVal + 0.5)
if adafruitDebug {
log.Printf("Setting PWM frequency to: %.2f Hz", freq)
... | go | func (a *AdafruitMotorHatDriver) setPWMFreq(conn Connection, freq float64) (err error) {
// 25MHz
preScaleVal := 25000000.0
// 12-bit
preScaleVal /= 4096.0
preScaleVal /= freq
preScaleVal -= 1.0
preScale := math.Floor(preScaleVal + 0.5)
if adafruitDebug {
log.Printf("Setting PWM frequency to: %.2f Hz", freq)
... | [
"func",
"(",
"a",
"*",
"AdafruitMotorHatDriver",
")",
"setPWMFreq",
"(",
"conn",
"Connection",
",",
"freq",
"float64",
")",
"(",
"err",
"error",
")",
"{",
"// 25MHz",
"preScaleVal",
":=",
"25000000.0",
"\n",
"// 12-bit",
"preScaleVal",
"/=",
"4096.0",
"\n",
... | // setPWMFreq adjusts the PWM frequency which determines how many full
// pulses per second are generated by the integrated circuit. The frequency
// determines how "long" each pulse is in duration from start to finish,
// taking into account the high and low segments of the pulse. | [
"setPWMFreq",
"adjusts",
"the",
"PWM",
"frequency",
"which",
"determines",
"how",
"many",
"full",
"pulses",
"per",
"second",
"are",
"generated",
"by",
"the",
"integrated",
"circuit",
".",
"The",
"frequency",
"determines",
"how",
"long",
"each",
"pulse",
"is",
... | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adafruit_driver.go#L264-L305 |
156,645 | hybridgroup/gobot | drivers/i2c/adafruit_driver.go | setAllPWM | func (a *AdafruitMotorHatDriver) setAllPWM(conn Connection, on, off int32) (err error) {
// register and values to be written to that register
regVals := make(map[int][]byte)
regVals[0] = []byte{byte(_AllLedOnL), byte(on & 0xff)}
regVals[1] = []byte{byte(_AllLedOnH), byte(on >> 8)}
regVals[2] = []byte{byte(_AllLed... | go | func (a *AdafruitMotorHatDriver) setAllPWM(conn Connection, on, off int32) (err error) {
// register and values to be written to that register
regVals := make(map[int][]byte)
regVals[0] = []byte{byte(_AllLedOnL), byte(on & 0xff)}
regVals[1] = []byte{byte(_AllLedOnH), byte(on >> 8)}
regVals[2] = []byte{byte(_AllLed... | [
"func",
"(",
"a",
"*",
"AdafruitMotorHatDriver",
")",
"setAllPWM",
"(",
"conn",
"Connection",
",",
"on",
",",
"off",
"int32",
")",
"(",
"err",
"error",
")",
"{",
"// register and values to be written to that register",
"regVals",
":=",
"make",
"(",
"map",
"[",
... | // setAllPWM sets all PWM channels for the given address | [
"setAllPWM",
"sets",
"all",
"PWM",
"channels",
"for",
"the",
"given",
"address"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adafruit_driver.go#L308-L321 |
156,646 | hybridgroup/gobot | drivers/i2c/adafruit_driver.go | SetDCMotorSpeed | func (a *AdafruitMotorHatDriver) SetDCMotorSpeed(dcMotor int, speed int32) (err error) {
if err = a.setPWM(a.motorHatConnection, a.dcMotors[dcMotor].pwmPin, 0, speed*16); err != nil {
return
}
return
} | go | func (a *AdafruitMotorHatDriver) SetDCMotorSpeed(dcMotor int, speed int32) (err error) {
if err = a.setPWM(a.motorHatConnection, a.dcMotors[dcMotor].pwmPin, 0, speed*16); err != nil {
return
}
return
} | [
"func",
"(",
"a",
"*",
"AdafruitMotorHatDriver",
")",
"SetDCMotorSpeed",
"(",
"dcMotor",
"int",
",",
"speed",
"int32",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"a",
".",
"setPWM",
"(",
"a",
".",
"motorHatConnection",
",",
"a",
".",
"dcMoto... | // SetDCMotorSpeed will set the appropriate pins to run the specified DC motor
// for the given speed. | [
"SetDCMotorSpeed",
"will",
"set",
"the",
"appropriate",
"pins",
"to",
"run",
"the",
"specified",
"DC",
"motor",
"for",
"the",
"given",
"speed",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adafruit_driver.go#L335-L340 |
156,647 | hybridgroup/gobot | drivers/i2c/adafruit_driver.go | RunDCMotor | func (a *AdafruitMotorHatDriver) RunDCMotor(dcMotor int, dir AdafruitDirection) (err error) {
switch {
case dir == AdafruitForward:
if err = a.setPin(a.motorHatConnection, a.dcMotors[dcMotor].in2Pin, 0); err != nil {
return
}
if err = a.setPin(a.motorHatConnection, a.dcMotors[dcMotor].in1Pin, 1); err != nil... | go | func (a *AdafruitMotorHatDriver) RunDCMotor(dcMotor int, dir AdafruitDirection) (err error) {
switch {
case dir == AdafruitForward:
if err = a.setPin(a.motorHatConnection, a.dcMotors[dcMotor].in2Pin, 0); err != nil {
return
}
if err = a.setPin(a.motorHatConnection, a.dcMotors[dcMotor].in1Pin, 1); err != nil... | [
"func",
"(",
"a",
"*",
"AdafruitMotorHatDriver",
")",
"RunDCMotor",
"(",
"dcMotor",
"int",
",",
"dir",
"AdafruitDirection",
")",
"(",
"err",
"error",
")",
"{",
"switch",
"{",
"case",
"dir",
"==",
"AdafruitForward",
":",
"if",
"err",
"=",
"a",
".",
"setPi... | // RunDCMotor will set the appropriate pins to run the specified DC motor for
// the given direction | [
"RunDCMotor",
"will",
"set",
"the",
"appropriate",
"pins",
"to",
"run",
"the",
"specified",
"DC",
"motor",
"for",
"the",
"given",
"direction"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adafruit_driver.go#L344-L370 |
156,648 | hybridgroup/gobot | drivers/i2c/adafruit_driver.go | SetStepperMotorSpeed | func (a *AdafruitMotorHatDriver) SetStepperMotorSpeed(stepperMotor int, rpm int) (err error) {
revSteps := a.stepperMotors[stepperMotor].revSteps
a.stepperMotors[stepperMotor].secPerStep = 60.0 / float64(revSteps*rpm)
a.stepperMotors[stepperMotor].stepCounter = 0
return
} | go | func (a *AdafruitMotorHatDriver) SetStepperMotorSpeed(stepperMotor int, rpm int) (err error) {
revSteps := a.stepperMotors[stepperMotor].revSteps
a.stepperMotors[stepperMotor].secPerStep = 60.0 / float64(revSteps*rpm)
a.stepperMotors[stepperMotor].stepCounter = 0
return
} | [
"func",
"(",
"a",
"*",
"AdafruitMotorHatDriver",
")",
"SetStepperMotorSpeed",
"(",
"stepperMotor",
"int",
",",
"rpm",
"int",
")",
"(",
"err",
"error",
")",
"{",
"revSteps",
":=",
"a",
".",
"stepperMotors",
"[",
"stepperMotor",
"]",
".",
"revSteps",
"\n",
"... | // SetStepperMotorSpeed sets the seconds-per-step for the given Stepper Motor. | [
"SetStepperMotorSpeed",
"sets",
"the",
"seconds",
"-",
"per",
"-",
"step",
"for",
"the",
"given",
"Stepper",
"Motor",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adafruit_driver.go#L493-L498 |
156,649 | hybridgroup/gobot | drivers/i2c/adafruit_driver.go | Step | func (a *AdafruitMotorHatDriver) Step(motor, steps int, dir AdafruitDirection, style AdafruitStepStyle) (err error) {
secPerStep := a.stepperMotors[motor].secPerStep
latestStep := 0
if style == AdafruitInterleave {
secPerStep = secPerStep / 2.0
}
if style == AdafruitMicrostep {
secPerStep /= float64(stepperMic... | go | func (a *AdafruitMotorHatDriver) Step(motor, steps int, dir AdafruitDirection, style AdafruitStepStyle) (err error) {
secPerStep := a.stepperMotors[motor].secPerStep
latestStep := 0
if style == AdafruitInterleave {
secPerStep = secPerStep / 2.0
}
if style == AdafruitMicrostep {
secPerStep /= float64(stepperMic... | [
"func",
"(",
"a",
"*",
"AdafruitMotorHatDriver",
")",
"Step",
"(",
"motor",
",",
"steps",
"int",
",",
"dir",
"AdafruitDirection",
",",
"style",
"AdafruitStepStyle",
")",
"(",
"err",
"error",
")",
"{",
"secPerStep",
":=",
"a",
".",
"stepperMotors",
"[",
"mo... | // Step will rotate the stepper motor the given number of steps, in the given direction and step style. | [
"Step",
"will",
"rotate",
"the",
"stepper",
"motor",
"the",
"given",
"number",
"of",
"steps",
"in",
"the",
"given",
"direction",
"and",
"step",
"style",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/adafruit_driver.go#L501-L531 |
156,650 | hybridgroup/gobot | platforms/digispark/digispark_i2c.go | NewDigisparkI2cConnection | func NewDigisparkI2cConnection(adaptor *Adaptor, address uint8) (connection *digisparkI2cConnection) {
return &digisparkI2cConnection{adaptor: adaptor, address: address}
} | go | func NewDigisparkI2cConnection(adaptor *Adaptor, address uint8) (connection *digisparkI2cConnection) {
return &digisparkI2cConnection{adaptor: adaptor, address: address}
} | [
"func",
"NewDigisparkI2cConnection",
"(",
"adaptor",
"*",
"Adaptor",
",",
"address",
"uint8",
")",
"(",
"connection",
"*",
"digisparkI2cConnection",
")",
"{",
"return",
"&",
"digisparkI2cConnection",
"{",
"adaptor",
":",
"adaptor",
",",
"address",
":",
"address",
... | // NewDigisparkI2cConnection creates an i2c connection to an i2c device at
// the specified address | [
"NewDigisparkI2cConnection",
"creates",
"an",
"i2c",
"connection",
"to",
"an",
"i2c",
"device",
"at",
"the",
"specified",
"address"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/digispark/digispark_i2c.go#L14-L16 |
156,651 | hybridgroup/gobot | platforms/digispark/digispark_i2c.go | Init | func (c *digisparkI2cConnection) Init() (err error) {
if !c.adaptor.i2c {
if err = c.adaptor.littleWire.i2cInit(); err != nil {
return
}
c.adaptor.i2c = true
}
return
} | go | func (c *digisparkI2cConnection) Init() (err error) {
if !c.adaptor.i2c {
if err = c.adaptor.littleWire.i2cInit(); err != nil {
return
}
c.adaptor.i2c = true
}
return
} | [
"func",
"(",
"c",
"*",
"digisparkI2cConnection",
")",
"Init",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"!",
"c",
".",
"adaptor",
".",
"i2c",
"{",
"if",
"err",
"=",
"c",
".",
"adaptor",
".",
"littleWire",
".",
"i2cInit",
"(",
")",
";",
"err"... | // Init makes sure that the i2c device is already initialized | [
"Init",
"makes",
"sure",
"that",
"the",
"i2c",
"device",
"is",
"already",
"initialized"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/digispark/digispark_i2c.go#L19-L27 |
156,652 | hybridgroup/gobot | platforms/digispark/digispark_i2c.go | UpdateDelay | func (c *digisparkI2cConnection) UpdateDelay(duration uint) error {
if !c.adaptor.i2c {
return errors.New("Digispark i2c not initialized")
}
return c.adaptor.littleWire.i2cUpdateDelay(duration)
} | go | func (c *digisparkI2cConnection) UpdateDelay(duration uint) error {
if !c.adaptor.i2c {
return errors.New("Digispark i2c not initialized")
}
return c.adaptor.littleWire.i2cUpdateDelay(duration)
} | [
"func",
"(",
"c",
"*",
"digisparkI2cConnection",
")",
"UpdateDelay",
"(",
"duration",
"uint",
")",
"error",
"{",
"if",
"!",
"c",
".",
"adaptor",
".",
"i2c",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"c",
... | // UpdateDelay updates i2c signal delay amount; tune if neccessary to fit your requirements | [
"UpdateDelay",
"updates",
"i2c",
"signal",
"delay",
"amount",
";",
"tune",
"if",
"neccessary",
"to",
"fit",
"your",
"requirements"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/digispark/digispark_i2c.go#L38-L43 |
156,653 | hybridgroup/gobot | platforms/microbit/button_driver.go | NewButtonDriver | func NewButtonDriver(a ble.BLEConnector) *ButtonDriver {
n := &ButtonDriver{
name: gobot.DefaultName("Microbit Button"),
connection: a,
Eventer: gobot.NewEventer(),
}
n.AddEvent(ButtonA)
n.AddEvent(ButtonB)
return n
} | go | func NewButtonDriver(a ble.BLEConnector) *ButtonDriver {
n := &ButtonDriver{
name: gobot.DefaultName("Microbit Button"),
connection: a,
Eventer: gobot.NewEventer(),
}
n.AddEvent(ButtonA)
n.AddEvent(ButtonB)
return n
} | [
"func",
"NewButtonDriver",
"(",
"a",
"ble",
".",
"BLEConnector",
")",
"*",
"ButtonDriver",
"{",
"n",
":=",
"&",
"ButtonDriver",
"{",
"name",
":",
"gobot",
".",
"DefaultName",
"(",
"\"",
"\"",
")",
",",
"connection",
":",
"a",
",",
"Eventer",
":",
"gobo... | // NewButtonDriver creates a Microbit ButtonDriver | [
"NewButtonDriver",
"creates",
"a",
"Microbit",
"ButtonDriver"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/microbit/button_driver.go#L31-L42 |
156,654 | hybridgroup/gobot | platforms/microbit/temperature_driver.go | NewTemperatureDriver | func NewTemperatureDriver(a ble.BLEConnector) *TemperatureDriver {
n := &TemperatureDriver{
name: gobot.DefaultName("Microbit Temperature"),
connection: a,
Eventer: gobot.NewEventer(),
}
n.AddEvent(Temperature)
return n
} | go | func NewTemperatureDriver(a ble.BLEConnector) *TemperatureDriver {
n := &TemperatureDriver{
name: gobot.DefaultName("Microbit Temperature"),
connection: a,
Eventer: gobot.NewEventer(),
}
n.AddEvent(Temperature)
return n
} | [
"func",
"NewTemperatureDriver",
"(",
"a",
"ble",
".",
"BLEConnector",
")",
"*",
"TemperatureDriver",
"{",
"n",
":=",
"&",
"TemperatureDriver",
"{",
"name",
":",
"gobot",
".",
"DefaultName",
"(",
"\"",
"\"",
")",
",",
"connection",
":",
"a",
",",
"Eventer",... | // NewTemperatureDriver creates a Microbit TemperatureDriver | [
"NewTemperatureDriver",
"creates",
"a",
"Microbit",
"TemperatureDriver"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/microbit/temperature_driver.go#L29-L39 |
156,655 | hybridgroup/gobot | platforms/parrot/bebop/bebop_driver.go | TakeOff | func (a *Driver) TakeOff() {
a.Publish(a.Event("flying"), a.adaptor().drone.TakeOff())
} | go | func (a *Driver) TakeOff() {
a.Publish(a.Event("flying"), a.adaptor().drone.TakeOff())
} | [
"func",
"(",
"a",
"*",
"Driver",
")",
"TakeOff",
"(",
")",
"{",
"a",
".",
"Publish",
"(",
"a",
".",
"Event",
"(",
"\"",
"\"",
")",
",",
"a",
".",
"adaptor",
"(",
")",
".",
"drone",
".",
"TakeOff",
"(",
")",
")",
"\n",
"}"
] | // TakeOff makes the drone start flying | [
"TakeOff",
"makes",
"the",
"drone",
"start",
"flying"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/parrot/bebop/bebop_driver.go#L55-L57 |
156,656 | hybridgroup/gobot | platforms/parrot/bebop/bebop_driver.go | Up | func (a *Driver) Up(speed int) {
a.adaptor().drone.Up(speed)
} | go | func (a *Driver) Up(speed int) {
a.adaptor().drone.Up(speed)
} | [
"func",
"(",
"a",
"*",
"Driver",
")",
"Up",
"(",
"speed",
"int",
")",
"{",
"a",
".",
"adaptor",
"(",
")",
".",
"drone",
".",
"Up",
"(",
"speed",
")",
"\n",
"}"
] | // Up makes the drone gain altitude.
// speed can be a value from `0` to `100`. | [
"Up",
"makes",
"the",
"drone",
"gain",
"altitude",
".",
"speed",
"can",
"be",
"a",
"value",
"from",
"0",
"to",
"100",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/parrot/bebop/bebop_driver.go#L66-L68 |
156,657 | hybridgroup/gobot | platforms/parrot/bebop/bebop_driver.go | Down | func (a *Driver) Down(speed int) {
a.adaptor().drone.Down(speed)
} | go | func (a *Driver) Down(speed int) {
a.adaptor().drone.Down(speed)
} | [
"func",
"(",
"a",
"*",
"Driver",
")",
"Down",
"(",
"speed",
"int",
")",
"{",
"a",
".",
"adaptor",
"(",
")",
".",
"drone",
".",
"Down",
"(",
"speed",
")",
"\n",
"}"
] | // Down makes the drone reduce altitude.
// speed can be a value from `0` to `100`. | [
"Down",
"makes",
"the",
"drone",
"reduce",
"altitude",
".",
"speed",
"can",
"be",
"a",
"value",
"from",
"0",
"to",
"100",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/parrot/bebop/bebop_driver.go#L72-L74 |
156,658 | hybridgroup/gobot | platforms/parrot/bebop/bebop_driver.go | Left | func (a *Driver) Left(speed int) {
a.adaptor().drone.Left(speed)
} | go | func (a *Driver) Left(speed int) {
a.adaptor().drone.Left(speed)
} | [
"func",
"(",
"a",
"*",
"Driver",
")",
"Left",
"(",
"speed",
"int",
")",
"{",
"a",
".",
"adaptor",
"(",
")",
".",
"drone",
".",
"Left",
"(",
"speed",
")",
"\n",
"}"
] | // Left causes the drone to bank to the left, controls the roll, which is
// a horizontal movement using the camera as a reference point.
// speed can be a value from `0` to `100`. | [
"Left",
"causes",
"the",
"drone",
"to",
"bank",
"to",
"the",
"left",
"controls",
"the",
"roll",
"which",
"is",
"a",
"horizontal",
"movement",
"using",
"the",
"camera",
"as",
"a",
"reference",
"point",
".",
"speed",
"can",
"be",
"a",
"value",
"from",
"0",... | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/parrot/bebop/bebop_driver.go#L79-L81 |
156,659 | hybridgroup/gobot | platforms/parrot/bebop/bebop_driver.go | Right | func (a *Driver) Right(speed int) {
a.adaptor().drone.Right(speed)
} | go | func (a *Driver) Right(speed int) {
a.adaptor().drone.Right(speed)
} | [
"func",
"(",
"a",
"*",
"Driver",
")",
"Right",
"(",
"speed",
"int",
")",
"{",
"a",
".",
"adaptor",
"(",
")",
".",
"drone",
".",
"Right",
"(",
"speed",
")",
"\n",
"}"
] | // Right causes the drone to bank to the right, controls the roll, which is
// a horizontal movement using the camera as a reference point.
// speed can be a value from `0` to `100`. | [
"Right",
"causes",
"the",
"drone",
"to",
"bank",
"to",
"the",
"right",
"controls",
"the",
"roll",
"which",
"is",
"a",
"horizontal",
"movement",
"using",
"the",
"camera",
"as",
"a",
"reference",
"point",
".",
"speed",
"can",
"be",
"a",
"value",
"from",
"0... | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/parrot/bebop/bebop_driver.go#L86-L88 |
156,660 | hybridgroup/gobot | platforms/parrot/bebop/bebop_driver.go | Forward | func (a *Driver) Forward(speed int) {
a.adaptor().drone.Forward(speed)
} | go | func (a *Driver) Forward(speed int) {
a.adaptor().drone.Forward(speed)
} | [
"func",
"(",
"a",
"*",
"Driver",
")",
"Forward",
"(",
"speed",
"int",
")",
"{",
"a",
".",
"adaptor",
"(",
")",
".",
"drone",
".",
"Forward",
"(",
"speed",
")",
"\n",
"}"
] | // Forward causes the drone go forward, controls the pitch.
// speed can be a value from `0` to `100`. | [
"Forward",
"causes",
"the",
"drone",
"go",
"forward",
"controls",
"the",
"pitch",
".",
"speed",
"can",
"be",
"a",
"value",
"from",
"0",
"to",
"100",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/parrot/bebop/bebop_driver.go#L92-L94 |
156,661 | hybridgroup/gobot | platforms/parrot/bebop/bebop_driver.go | Backward | func (a *Driver) Backward(speed int) {
a.adaptor().drone.Backward(speed)
} | go | func (a *Driver) Backward(speed int) {
a.adaptor().drone.Backward(speed)
} | [
"func",
"(",
"a",
"*",
"Driver",
")",
"Backward",
"(",
"speed",
"int",
")",
"{",
"a",
".",
"adaptor",
"(",
")",
".",
"drone",
".",
"Backward",
"(",
"speed",
")",
"\n",
"}"
] | // Backward causes the drone go forward, controls the pitch.
// speed can be a value from `0` to `100`. | [
"Backward",
"causes",
"the",
"drone",
"go",
"forward",
"controls",
"the",
"pitch",
".",
"speed",
"can",
"be",
"a",
"value",
"from",
"0",
"to",
"100",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/parrot/bebop/bebop_driver.go#L98-L100 |
156,662 | hybridgroup/gobot | platforms/parrot/bebop/bebop_driver.go | Clockwise | func (a *Driver) Clockwise(speed int) {
a.adaptor().drone.Clockwise(speed)
} | go | func (a *Driver) Clockwise(speed int) {
a.adaptor().drone.Clockwise(speed)
} | [
"func",
"(",
"a",
"*",
"Driver",
")",
"Clockwise",
"(",
"speed",
"int",
")",
"{",
"a",
".",
"adaptor",
"(",
")",
".",
"drone",
".",
"Clockwise",
"(",
"speed",
")",
"\n",
"}"
] | // Clockwise causes the drone to spin in clockwise direction
// speed can be a value from `0` to `100`. | [
"Clockwise",
"causes",
"the",
"drone",
"to",
"spin",
"in",
"clockwise",
"direction",
"speed",
"can",
"be",
"a",
"value",
"from",
"0",
"to",
"100",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/parrot/bebop/bebop_driver.go#L104-L106 |
156,663 | hybridgroup/gobot | platforms/parrot/bebop/bebop_driver.go | CounterClockwise | func (a *Driver) CounterClockwise(speed int) {
a.adaptor().drone.CounterClockwise(speed)
} | go | func (a *Driver) CounterClockwise(speed int) {
a.adaptor().drone.CounterClockwise(speed)
} | [
"func",
"(",
"a",
"*",
"Driver",
")",
"CounterClockwise",
"(",
"speed",
"int",
")",
"{",
"a",
".",
"adaptor",
"(",
")",
".",
"drone",
".",
"CounterClockwise",
"(",
"speed",
")",
"\n",
"}"
] | // CounterClockwise the drone to spin in counter clockwise direction
// speed can be a value from `0` to `100`. | [
"CounterClockwise",
"the",
"drone",
"to",
"spin",
"in",
"counter",
"clockwise",
"direction",
"speed",
"can",
"be",
"a",
"value",
"from",
"0",
"to",
"100",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/parrot/bebop/bebop_driver.go#L110-L112 |
156,664 | hybridgroup/gobot | platforms/parrot/bebop/bebop_driver.go | Outdoor | func (a *Driver) Outdoor(outdoor bool) error {
return a.adaptor().drone.Outdoor(outdoor)
} | go | func (a *Driver) Outdoor(outdoor bool) error {
return a.adaptor().drone.Outdoor(outdoor)
} | [
"func",
"(",
"a",
"*",
"Driver",
")",
"Outdoor",
"(",
"outdoor",
"bool",
")",
"error",
"{",
"return",
"a",
".",
"adaptor",
"(",
")",
".",
"drone",
".",
"Outdoor",
"(",
"outdoor",
")",
"\n",
"}"
] | // Outdoor tells the drone if flying Outdoor or not. This is needed to adjust flight characteristics of the Bebop. | [
"Outdoor",
"tells",
"the",
"drone",
"if",
"flying",
"Outdoor",
"or",
"not",
".",
"This",
"is",
"needed",
"to",
"adjust",
"flight",
"characteristics",
"of",
"the",
"Bebop",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/parrot/bebop/bebop_driver.go#L140-L142 |
156,665 | hybridgroup/gobot | platforms/parrot/bebop/bebop_driver.go | VideoStreamMode | func (a *Driver) VideoStreamMode(mode int8) error {
return a.adaptor().drone.VideoStreamMode(mode)
} | go | func (a *Driver) VideoStreamMode(mode int8) error {
return a.adaptor().drone.VideoStreamMode(mode)
} | [
"func",
"(",
"a",
"*",
"Driver",
")",
"VideoStreamMode",
"(",
"mode",
"int8",
")",
"error",
"{",
"return",
"a",
".",
"adaptor",
"(",
")",
".",
"drone",
".",
"VideoStreamMode",
"(",
"mode",
")",
"\n",
"}"
] | // VideoStreamMode tells the drone what mode to use for streaming video | [
"VideoStreamMode",
"tells",
"the",
"drone",
"what",
"mode",
"to",
"use",
"for",
"streaming",
"video"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/parrot/bebop/bebop_driver.go#L150-L152 |
156,666 | hybridgroup/gobot | api/cors.go | AllowRequestsFrom | func AllowRequestsFrom(allowedOrigins ...string) http.HandlerFunc {
c := &CORS{
AllowOrigins: allowedOrigins,
AllowMethods: []string{"GET", "POST"},
AllowHeaders: []string{"Origin", "Content-Type"},
ContentType: "application/json; charset=utf-8",
}
c.generatePatterns()
return func(w http.ResponseWriter, ... | go | func AllowRequestsFrom(allowedOrigins ...string) http.HandlerFunc {
c := &CORS{
AllowOrigins: allowedOrigins,
AllowMethods: []string{"GET", "POST"},
AllowHeaders: []string{"Origin", "Content-Type"},
ContentType: "application/json; charset=utf-8",
}
c.generatePatterns()
return func(w http.ResponseWriter, ... | [
"func",
"AllowRequestsFrom",
"(",
"allowedOrigins",
"...",
"string",
")",
"http",
".",
"HandlerFunc",
"{",
"c",
":=",
"&",
"CORS",
"{",
"AllowOrigins",
":",
"allowedOrigins",
",",
"AllowMethods",
":",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
... | // AllowRequestsFrom returns handler to verify that requests come from allowedOrigins | [
"AllowRequestsFrom",
"returns",
"handler",
"to",
"verify",
"that",
"requests",
"come",
"from",
"allowedOrigins"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/api/cors.go#L19-L38 |
156,667 | hybridgroup/gobot | api/cors.go | isOriginAllowed | func (c *CORS) isOriginAllowed(origin string) (allowed bool) {
for _, allowedOriginPattern := range c.allowOriginPatterns {
allowed, _ = regexp.MatchString(allowedOriginPattern, origin)
if allowed {
return
}
}
return
} | go | func (c *CORS) isOriginAllowed(origin string) (allowed bool) {
for _, allowedOriginPattern := range c.allowOriginPatterns {
allowed, _ = regexp.MatchString(allowedOriginPattern, origin)
if allowed {
return
}
}
return
} | [
"func",
"(",
"c",
"*",
"CORS",
")",
"isOriginAllowed",
"(",
"origin",
"string",
")",
"(",
"allowed",
"bool",
")",
"{",
"for",
"_",
",",
"allowedOriginPattern",
":=",
"range",
"c",
".",
"allowOriginPatterns",
"{",
"allowed",
",",
"_",
"=",
"regexp",
".",
... | // isOriginAllowed returns true if origin matches an allowed origin pattern. | [
"isOriginAllowed",
"returns",
"true",
"if",
"origin",
"matches",
"an",
"allowed",
"origin",
"pattern",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/api/cors.go#L41-L49 |
156,668 | hybridgroup/gobot | api/cors.go | generatePatterns | func (c *CORS) generatePatterns() {
if c.AllowOrigins != nil {
for _, origin := range c.AllowOrigins {
pattern := regexp.QuoteMeta(origin)
pattern = strings.Replace(pattern, "\\*", ".*", -1)
pattern = strings.Replace(pattern, "\\?", ".", -1)
c.allowOriginPatterns = append(c.allowOriginPatterns, "^"+patte... | go | func (c *CORS) generatePatterns() {
if c.AllowOrigins != nil {
for _, origin := range c.AllowOrigins {
pattern := regexp.QuoteMeta(origin)
pattern = strings.Replace(pattern, "\\*", ".*", -1)
pattern = strings.Replace(pattern, "\\?", ".", -1)
c.allowOriginPatterns = append(c.allowOriginPatterns, "^"+patte... | [
"func",
"(",
"c",
"*",
"CORS",
")",
"generatePatterns",
"(",
")",
"{",
"if",
"c",
".",
"AllowOrigins",
"!=",
"nil",
"{",
"for",
"_",
",",
"origin",
":=",
"range",
"c",
".",
"AllowOrigins",
"{",
"pattern",
":=",
"regexp",
".",
"QuoteMeta",
"(",
"origi... | // generatePatterns generates regex expression for AllowOrigins | [
"generatePatterns",
"generates",
"regex",
"expression",
"for",
"AllowOrigins"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/api/cors.go#L52-L61 |
156,669 | hybridgroup/gobot | drivers/aio/analog_sensor_driver.go | Read | func (a *AnalogSensorDriver) Read() (val int, err error) {
return a.connection.AnalogRead(a.Pin())
} | go | func (a *AnalogSensorDriver) Read() (val int, err error) {
return a.connection.AnalogRead(a.Pin())
} | [
"func",
"(",
"a",
"*",
"AnalogSensorDriver",
")",
"Read",
"(",
")",
"(",
"val",
"int",
",",
"err",
"error",
")",
"{",
"return",
"a",
".",
"connection",
".",
"AnalogRead",
"(",
"a",
".",
"Pin",
"(",
")",
")",
"\n",
"}"
] | // Read returns the current reading from the Analog Sensor | [
"Read",
"returns",
"the",
"current",
"reading",
"from",
"the",
"Analog",
"Sensor"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/aio/analog_sensor_driver.go#L103-L105 |
156,670 | hybridgroup/gobot | platforms/parrot/ardrone/ardrone_adaptor.go | Connect | func (a *Adaptor) Connect() (err error) {
d, err := a.connect(a)
if err != nil {
return err
}
a.drone = d
return
} | go | func (a *Adaptor) Connect() (err error) {
d, err := a.connect(a)
if err != nil {
return err
}
a.drone = d
return
} | [
"func",
"(",
"a",
"*",
"Adaptor",
")",
"Connect",
"(",
")",
"(",
"err",
"error",
")",
"{",
"d",
",",
"err",
":=",
"a",
".",
"connect",
"(",
"a",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"a",
".",
"drone",
... | // Connect establishes a connection to the ardrone | [
"Connect",
"establishes",
"a",
"connection",
"to",
"the",
"ardrone"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/parrot/ardrone/ardrone_adaptor.go#L58-L65 |
156,671 | hybridgroup/gobot | drivers/i2c/mcp23017_driver.go | WithMCP23017Bank | func WithMCP23017Bank(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Bank = val
} else {
panic("trying to set bank for non-MCP23017Driver")
}
}
} | go | func WithMCP23017Bank(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Bank = val
} else {
panic("trying to set bank for non-MCP23017Driver")
}
}
} | [
"func",
"WithMCP23017Bank",
"(",
"val",
"uint8",
")",
"func",
"(",
"Config",
")",
"{",
"return",
"func",
"(",
"c",
"Config",
")",
"{",
"d",
",",
"ok",
":=",
"c",
".",
"(",
"*",
"MCP23017Driver",
")",
"\n",
"if",
"ok",
"{",
"d",
".",
"MCPConf",
".... | // WithMCP23017Bank option sets the MCP23017Driver bank option | [
"WithMCP23017Bank",
"option",
"sets",
"the",
"MCP23017Driver",
"bank",
"option"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mcp23017_driver.go#L65-L74 |
156,672 | hybridgroup/gobot | drivers/i2c/mcp23017_driver.go | WithMCP23017Mirror | func WithMCP23017Mirror(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Mirror = val
} else {
panic("Trying to set Mirror for non-MCP23017Driver")
}
}
} | go | func WithMCP23017Mirror(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Mirror = val
} else {
panic("Trying to set Mirror for non-MCP23017Driver")
}
}
} | [
"func",
"WithMCP23017Mirror",
"(",
"val",
"uint8",
")",
"func",
"(",
"Config",
")",
"{",
"return",
"func",
"(",
"c",
"Config",
")",
"{",
"d",
",",
"ok",
":=",
"c",
".",
"(",
"*",
"MCP23017Driver",
")",
"\n",
"if",
"ok",
"{",
"d",
".",
"MCPConf",
... | // WithMCP23017Mirror option sets the MCP23017Driver Mirror option | [
"WithMCP23017Mirror",
"option",
"sets",
"the",
"MCP23017Driver",
"Mirror",
"option"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mcp23017_driver.go#L77-L86 |
156,673 | hybridgroup/gobot | drivers/i2c/mcp23017_driver.go | WithMCP23017Seqop | func WithMCP23017Seqop(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Seqop = val
} else {
panic("Trying to set Seqop for non-MCP23017Driver")
}
}
} | go | func WithMCP23017Seqop(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Seqop = val
} else {
panic("Trying to set Seqop for non-MCP23017Driver")
}
}
} | [
"func",
"WithMCP23017Seqop",
"(",
"val",
"uint8",
")",
"func",
"(",
"Config",
")",
"{",
"return",
"func",
"(",
"c",
"Config",
")",
"{",
"d",
",",
"ok",
":=",
"c",
".",
"(",
"*",
"MCP23017Driver",
")",
"\n",
"if",
"ok",
"{",
"d",
".",
"MCPConf",
"... | // WithMCP23017Seqop option sets the MCP23017Driver Seqop option | [
"WithMCP23017Seqop",
"option",
"sets",
"the",
"MCP23017Driver",
"Seqop",
"option"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mcp23017_driver.go#L89-L98 |
156,674 | hybridgroup/gobot | drivers/i2c/mcp23017_driver.go | WithMCP23017Disslw | func WithMCP23017Disslw(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Disslw = val
} else {
panic("Trying to set Disslw for non-MCP23017Driver")
}
}
} | go | func WithMCP23017Disslw(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Disslw = val
} else {
panic("Trying to set Disslw for non-MCP23017Driver")
}
}
} | [
"func",
"WithMCP23017Disslw",
"(",
"val",
"uint8",
")",
"func",
"(",
"Config",
")",
"{",
"return",
"func",
"(",
"c",
"Config",
")",
"{",
"d",
",",
"ok",
":=",
"c",
".",
"(",
"*",
"MCP23017Driver",
")",
"\n",
"if",
"ok",
"{",
"d",
".",
"MCPConf",
... | // WithMCP23017Disslw option sets the MCP23017Driver Disslw option | [
"WithMCP23017Disslw",
"option",
"sets",
"the",
"MCP23017Driver",
"Disslw",
"option"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mcp23017_driver.go#L101-L110 |
156,675 | hybridgroup/gobot | drivers/i2c/mcp23017_driver.go | WithMCP23017Haen | func WithMCP23017Haen(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Haen = val
} else {
panic("Trying to set Haen for non-MCP23017Driver")
}
}
} | go | func WithMCP23017Haen(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Haen = val
} else {
panic("Trying to set Haen for non-MCP23017Driver")
}
}
} | [
"func",
"WithMCP23017Haen",
"(",
"val",
"uint8",
")",
"func",
"(",
"Config",
")",
"{",
"return",
"func",
"(",
"c",
"Config",
")",
"{",
"d",
",",
"ok",
":=",
"c",
".",
"(",
"*",
"MCP23017Driver",
")",
"\n",
"if",
"ok",
"{",
"d",
".",
"MCPConf",
".... | // WithMCP23017Haen option sets the MCP23017Driver Haen option | [
"WithMCP23017Haen",
"option",
"sets",
"the",
"MCP23017Driver",
"Haen",
"option"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mcp23017_driver.go#L113-L122 |
156,676 | hybridgroup/gobot | drivers/i2c/mcp23017_driver.go | WithMCP23017Odr | func WithMCP23017Odr(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Odr = val
} else {
panic("Trying to set Odr for non-MCP23017Driver")
}
}
} | go | func WithMCP23017Odr(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Odr = val
} else {
panic("Trying to set Odr for non-MCP23017Driver")
}
}
} | [
"func",
"WithMCP23017Odr",
"(",
"val",
"uint8",
")",
"func",
"(",
"Config",
")",
"{",
"return",
"func",
"(",
"c",
"Config",
")",
"{",
"d",
",",
"ok",
":=",
"c",
".",
"(",
"*",
"MCP23017Driver",
")",
"\n",
"if",
"ok",
"{",
"d",
".",
"MCPConf",
"."... | // WithMCP23017Odr option sets the MCP23017Driver Odr option | [
"WithMCP23017Odr",
"option",
"sets",
"the",
"MCP23017Driver",
"Odr",
"option"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mcp23017_driver.go#L125-L134 |
156,677 | hybridgroup/gobot | drivers/i2c/mcp23017_driver.go | WithMCP23017Intpol | func WithMCP23017Intpol(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Intpol = val
} else {
panic("Trying to set Intpol for non-MCP23017Driver")
}
}
} | go | func WithMCP23017Intpol(val uint8) func(Config) {
return func(c Config) {
d, ok := c.(*MCP23017Driver)
if ok {
d.MCPConf.Intpol = val
} else {
panic("Trying to set Intpol for non-MCP23017Driver")
}
}
} | [
"func",
"WithMCP23017Intpol",
"(",
"val",
"uint8",
")",
"func",
"(",
"Config",
")",
"{",
"return",
"func",
"(",
"c",
"Config",
")",
"{",
"d",
",",
"ok",
":=",
"c",
".",
"(",
"*",
"MCP23017Driver",
")",
"\n",
"if",
"ok",
"{",
"d",
".",
"MCPConf",
... | // WithMCP23017Intpol option sets the MCP23017Driver Intpol option | [
"WithMCP23017Intpol",
"option",
"sets",
"the",
"MCP23017Driver",
"Intpol",
"option"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mcp23017_driver.go#L137-L146 |
156,678 | hybridgroup/gobot | drivers/i2c/mcp23017_driver.go | Start | func (m *MCP23017Driver) Start() (err error) {
bus := m.GetBusOrDefault(m.connector.GetDefaultBus())
address := m.GetAddressOrDefault(mcp23017Address)
m.connection, err = m.connector.GetConnection(address, bus)
if err != nil {
return err
}
// Set IOCON register with MCP23017 configuration.
ioconReg := m.getPo... | go | func (m *MCP23017Driver) Start() (err error) {
bus := m.GetBusOrDefault(m.connector.GetDefaultBus())
address := m.GetAddressOrDefault(mcp23017Address)
m.connection, err = m.connector.GetConnection(address, bus)
if err != nil {
return err
}
// Set IOCON register with MCP23017 configuration.
ioconReg := m.getPo... | [
"func",
"(",
"m",
"*",
"MCP23017Driver",
")",
"Start",
"(",
")",
"(",
"err",
"error",
")",
"{",
"bus",
":=",
"m",
".",
"GetBusOrDefault",
"(",
"m",
".",
"connector",
".",
"GetDefaultBus",
"(",
")",
")",
"\n",
"address",
":=",
"m",
".",
"GetAddressOrD... | // Start writes the device configuration. | [
"Start",
"writes",
"the",
"device",
"configuration",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mcp23017_driver.go#L208-L223 |
156,679 | hybridgroup/gobot | drivers/i2c/mcp23017_driver.go | write | func (m *MCP23017Driver) write(reg uint8, pin uint8, val uint8) (err error) {
if debug {
log.Printf("write: MCP address: 0x%X, register:0x%X,value: 0x%X\n", m.GetAddressOrDefault(mcp23017Address), reg, val)
}
if _, err = m.connection.Write([]uint8{reg, val}); err != nil {
return err
}
return nil
} | go | func (m *MCP23017Driver) write(reg uint8, pin uint8, val uint8) (err error) {
if debug {
log.Printf("write: MCP address: 0x%X, register:0x%X,value: 0x%X\n", m.GetAddressOrDefault(mcp23017Address), reg, val)
}
if _, err = m.connection.Write([]uint8{reg, val}); err != nil {
return err
}
return nil
} | [
"func",
"(",
"m",
"*",
"MCP23017Driver",
")",
"write",
"(",
"reg",
"uint8",
",",
"pin",
"uint8",
",",
"val",
"uint8",
")",
"(",
"err",
"error",
")",
"{",
"if",
"debug",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"m",
".",
"GetAddress... | // write gets the value of the passed in register, and then overwrites
// the bit specified by the pin, with the given value. | [
"write",
"gets",
"the",
"value",
"of",
"the",
"passed",
"in",
"register",
"and",
"then",
"overwrites",
"the",
"bit",
"specified",
"by",
"the",
"pin",
"with",
"the",
"given",
"value",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mcp23017_driver.go#L305-L313 |
156,680 | hybridgroup/gobot | drivers/i2c/mcp23017_driver.go | read | func (m *MCP23017Driver) read(reg uint8) (val uint8, err error) {
buf := []byte{0}
if _, err := m.connection.Write([]uint8{reg}); err != nil {
return val, err
}
bytesRead, err := m.connection.Read(buf)
if err != nil {
return val, err
}
if bytesRead != 1 {
err = ErrNotEnoughBytes
return
}
if debug {
l... | go | func (m *MCP23017Driver) read(reg uint8) (val uint8, err error) {
buf := []byte{0}
if _, err := m.connection.Write([]uint8{reg}); err != nil {
return val, err
}
bytesRead, err := m.connection.Read(buf)
if err != nil {
return val, err
}
if bytesRead != 1 {
err = ErrNotEnoughBytes
return
}
if debug {
l... | [
"func",
"(",
"m",
"*",
"MCP23017Driver",
")",
"read",
"(",
"reg",
"uint8",
")",
"(",
"val",
"uint8",
",",
"err",
"error",
")",
"{",
"buf",
":=",
"[",
"]",
"byte",
"{",
"0",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"m",
".",
"connection",
".",
... | // read get the data from a given register | [
"read",
"get",
"the",
"data",
"from",
"a",
"given",
"register"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mcp23017_driver.go#L316-L333 |
156,681 | hybridgroup/gobot | drivers/i2c/mcp23017_driver.go | getUint8Value | func (mc *MCP23017Config) getUint8Value() uint8 {
return mc.Bank<<7 | mc.Mirror<<6 | mc.Seqop<<5 | mc.Disslw<<4 | mc.Haen<<3 | mc.Odr<<2 | mc.Intpol<<1
} | go | func (mc *MCP23017Config) getUint8Value() uint8 {
return mc.Bank<<7 | mc.Mirror<<6 | mc.Seqop<<5 | mc.Disslw<<4 | mc.Haen<<3 | mc.Odr<<2 | mc.Intpol<<1
} | [
"func",
"(",
"mc",
"*",
"MCP23017Config",
")",
"getUint8Value",
"(",
")",
"uint8",
"{",
"return",
"mc",
".",
"Bank",
"<<",
"7",
"|",
"mc",
".",
"Mirror",
"<<",
"6",
"|",
"mc",
".",
"Seqop",
"<<",
"5",
"|",
"mc",
".",
"Disslw",
"<<",
"4",
"|",
"... | // getUint8Value returns the configuration data as a packed value. | [
"getUint8Value",
"returns",
"the",
"configuration",
"data",
"as",
"a",
"packed",
"value",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mcp23017_driver.go#L350-L352 |
156,682 | hybridgroup/gobot | drivers/i2c/mcp23017_driver.go | clearBit | func clearBit(n uint8, pos uint8) uint8 {
mask := ^uint8(1 << pos)
n &= mask
return n
} | go | func clearBit(n uint8, pos uint8) uint8 {
mask := ^uint8(1 << pos)
n &= mask
return n
} | [
"func",
"clearBit",
"(",
"n",
"uint8",
",",
"pos",
"uint8",
")",
"uint8",
"{",
"mask",
":=",
"^",
"uint8",
"(",
"1",
"<<",
"pos",
")",
"\n",
"n",
"&=",
"mask",
"\n",
"return",
"n",
"\n",
"}"
] | // clearBit is used to set a bit at a given position to 0. | [
"clearBit",
"is",
"used",
"to",
"set",
"a",
"bit",
"at",
"a",
"given",
"position",
"to",
"0",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/mcp23017_driver.go#L361-L365 |
156,683 | hybridgroup/gobot | drivers/i2c/drv2605l_driver.go | SetMode | func (d *DRV2605LDriver) SetMode(newMode DRV2605Mode) (err error) {
mode, err := d.connection.ReadByteData(drv2605RegMode)
if err != nil {
return err
}
// clear mode bits (lower three bits)
mode &= 0xf8
// set new mode bits
mode |= uint8(newMode)
err = d.connection.WriteByteData(drv2605RegMode, mode)
retu... | go | func (d *DRV2605LDriver) SetMode(newMode DRV2605Mode) (err error) {
mode, err := d.connection.ReadByteData(drv2605RegMode)
if err != nil {
return err
}
// clear mode bits (lower three bits)
mode &= 0xf8
// set new mode bits
mode |= uint8(newMode)
err = d.connection.WriteByteData(drv2605RegMode, mode)
retu... | [
"func",
"(",
"d",
"*",
"DRV2605LDriver",
")",
"SetMode",
"(",
"newMode",
"DRV2605Mode",
")",
"(",
"err",
"error",
")",
"{",
"mode",
",",
"err",
":=",
"d",
".",
"connection",
".",
"ReadByteData",
"(",
"drv2605RegMode",
")",
"\n",
"if",
"err",
"!=",
"nil... | // SetMode sets the device in one of the eight modes as described in the
// datasheet. Defaults to mode 0, internal trig. | [
"SetMode",
"sets",
"the",
"device",
"in",
"one",
"of",
"the",
"eight",
"modes",
"as",
"described",
"in",
"the",
"datasheet",
".",
"Defaults",
"to",
"mode",
"0",
"internal",
"trig",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/drv2605l_driver.go#L179-L193 |
156,684 | hybridgroup/gobot | drivers/i2c/drv2605l_driver.go | SetStandbyMode | func (d *DRV2605LDriver) SetStandbyMode(standby bool) (err error) {
modeVal, err := d.connection.ReadByteData(drv2605RegMode)
if err != nil {
return err
}
if standby {
modeVal |= drv2605Standby
} else {
modeVal &= 0xFF ^ drv2605Standby
}
err = d.connection.WriteByteData(drv2605RegMode, modeVal)
return e... | go | func (d *DRV2605LDriver) SetStandbyMode(standby bool) (err error) {
modeVal, err := d.connection.ReadByteData(drv2605RegMode)
if err != nil {
return err
}
if standby {
modeVal |= drv2605Standby
} else {
modeVal &= 0xFF ^ drv2605Standby
}
err = d.connection.WriteByteData(drv2605RegMode, modeVal)
return e... | [
"func",
"(",
"d",
"*",
"DRV2605LDriver",
")",
"SetStandbyMode",
"(",
"standby",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"modeVal",
",",
"err",
":=",
"d",
".",
"connection",
".",
"ReadByteData",
"(",
"drv2605RegMode",
")",
"\n",
"if",
"err",
"!=",
"... | // SetStandbyMode controls device low power mode | [
"SetStandbyMode",
"controls",
"device",
"low",
"power",
"mode"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/drv2605l_driver.go#L196-L210 |
156,685 | hybridgroup/gobot | drivers/i2c/drv2605l_driver.go | SelectLibrary | func (d *DRV2605LDriver) SelectLibrary(library uint8) (err error) {
err = d.connection.WriteByteData(drv2605RegLibrary, library&0x7)
return err
} | go | func (d *DRV2605LDriver) SelectLibrary(library uint8) (err error) {
err = d.connection.WriteByteData(drv2605RegLibrary, library&0x7)
return err
} | [
"func",
"(",
"d",
"*",
"DRV2605LDriver",
")",
"SelectLibrary",
"(",
"library",
"uint8",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"d",
".",
"connection",
".",
"WriteByteData",
"(",
"drv2605RegLibrary",
",",
"library",
"&",
"0x7",
")",
"\n",
"return... | // SelectLibrary selects which waveform library to play from, 1-7.
// See datasheet for more info. | [
"SelectLibrary",
"selects",
"which",
"waveform",
"library",
"to",
"play",
"from",
"1",
"-",
"7",
".",
"See",
"datasheet",
"for",
"more",
"info",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/drv2605l_driver.go#L214-L217 |
156,686 | hybridgroup/gobot | drivers/i2c/drv2605l_driver.go | Go | func (d *DRV2605LDriver) Go() (err error) {
err = d.connection.WriteByteData(drv2605RegGo, 1)
return err
} | go | func (d *DRV2605LDriver) Go() (err error) {
err = d.connection.WriteByteData(drv2605RegGo, 1)
return err
} | [
"func",
"(",
"d",
"*",
"DRV2605LDriver",
")",
"Go",
"(",
")",
"(",
"err",
"error",
")",
"{",
"err",
"=",
"d",
".",
"connection",
".",
"WriteByteData",
"(",
"drv2605RegGo",
",",
"1",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Go plays the current sequence of waveforms. | [
"Go",
"plays",
"the",
"current",
"sequence",
"of",
"waveforms",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/drv2605l_driver.go#L253-L256 |
156,687 | hybridgroup/gobot | drivers/i2c/drv2605l_driver.go | Halt | func (d *DRV2605LDriver) Halt() (err error) {
if d.connection != nil {
// stop playback
if err = d.connection.WriteByteData(drv2605RegGo, 0); err != nil {
return err
}
// enter standby
return d.SetStandbyMode(true)
}
return
} | go | func (d *DRV2605LDriver) Halt() (err error) {
if d.connection != nil {
// stop playback
if err = d.connection.WriteByteData(drv2605RegGo, 0); err != nil {
return err
}
// enter standby
return d.SetStandbyMode(true)
}
return
} | [
"func",
"(",
"d",
"*",
"DRV2605LDriver",
")",
"Halt",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"d",
".",
"connection",
"!=",
"nil",
"{",
"// stop playback",
"if",
"err",
"=",
"d",
".",
"connection",
".",
"WriteByteData",
"(",
"drv2605RegGo",
",",... | // Halt halts the device. | [
"Halt",
"halts",
"the",
"device",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/drv2605l_driver.go#L259-L270 |
156,688 | hybridgroup/gobot | platforms/mqtt/mqtt_driver.go | On | func (m *Driver) On(n string, f func(msg interface{})) error {
// TODO: also be able to subscribe to Error updates
f1 := func(msg Message) {
f(msg)
}
m.adaptor().On(m.topic, f1)
return nil
} | go | func (m *Driver) On(n string, f func(msg interface{})) error {
// TODO: also be able to subscribe to Error updates
f1 := func(msg Message) {
f(msg)
}
m.adaptor().On(m.topic, f1)
return nil
} | [
"func",
"(",
"m",
"*",
"Driver",
")",
"On",
"(",
"n",
"string",
",",
"f",
"func",
"(",
"msg",
"interface",
"{",
"}",
")",
")",
"error",
"{",
"// TODO: also be able to subscribe to Error updates",
"f1",
":=",
"func",
"(",
"msg",
"Message",
")",
"{",
"f",
... | // On subscribes to data updates for the current device topic,
// and then calls the message handler function when data is received | [
"On",
"subscribes",
"to",
"data",
"updates",
"for",
"the",
"current",
"device",
"topic",
"and",
"then",
"calls",
"the",
"message",
"handler",
"function",
"when",
"data",
"is",
"received"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/mqtt/mqtt_driver.go#L77-L84 |
156,689 | hybridgroup/gobot | platforms/keyboard/keyboard.go | restore | func restore() (err error) {
if _, err = stty("echo"); err != nil {
return
}
if _, err = stty(originalState); err != nil {
return
}
return
} | go | func restore() (err error) {
if _, err = stty("echo"); err != nil {
return
}
if _, err = stty(originalState); err != nil {
return
}
return
} | [
"func",
"restore",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"_",
",",
"err",
"=",
"stty",
"(",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"err",
"=",
"stty",
"(",
"originalState",
")",
";... | // restores the TTY to the original state | [
"restores",
"the",
"TTY",
"to",
"the",
"original",
"state"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/platforms/keyboard/keyboard.go#L139-L149 |
156,690 | hybridgroup/gobot | master.go | NewJSONMaster | func NewJSONMaster(gobot *Master) *JSONMaster {
jsonGobot := &JSONMaster{
Robots: []*JSONRobot{},
Commands: []string{},
}
for command := range gobot.Commands() {
jsonGobot.Commands = append(jsonGobot.Commands, command)
}
gobot.robots.Each(func(r *Robot) {
jsonGobot.Robots = append(jsonGobot.Robots, New... | go | func NewJSONMaster(gobot *Master) *JSONMaster {
jsonGobot := &JSONMaster{
Robots: []*JSONRobot{},
Commands: []string{},
}
for command := range gobot.Commands() {
jsonGobot.Commands = append(jsonGobot.Commands, command)
}
gobot.robots.Each(func(r *Robot) {
jsonGobot.Robots = append(jsonGobot.Robots, New... | [
"func",
"NewJSONMaster",
"(",
"gobot",
"*",
"Master",
")",
"*",
"JSONMaster",
"{",
"jsonGobot",
":=",
"&",
"JSONMaster",
"{",
"Robots",
":",
"[",
"]",
"*",
"JSONRobot",
"{",
"}",
",",
"Commands",
":",
"[",
"]",
"string",
"{",
"}",
",",
"}",
"\n\n",
... | // NewJSONMaster returns a JSONMaster given a Gobot Master. | [
"NewJSONMaster",
"returns",
"a",
"JSONMaster",
"given",
"a",
"Gobot",
"Master",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/master.go#L18-L32 |
156,691 | hybridgroup/gobot | master.go | NewMaster | func NewMaster() *Master {
m := &Master{
robots: &Robots{},
trap: func(c chan os.Signal) {
signal.Notify(c, os.Interrupt)
},
AutoRun: true,
Commander: NewCommander(),
Eventer: NewEventer(),
}
m.running.Store(false)
return m
} | go | func NewMaster() *Master {
m := &Master{
robots: &Robots{},
trap: func(c chan os.Signal) {
signal.Notify(c, os.Interrupt)
},
AutoRun: true,
Commander: NewCommander(),
Eventer: NewEventer(),
}
m.running.Store(false)
return m
} | [
"func",
"NewMaster",
"(",
")",
"*",
"Master",
"{",
"m",
":=",
"&",
"Master",
"{",
"robots",
":",
"&",
"Robots",
"{",
"}",
",",
"trap",
":",
"func",
"(",
"c",
"chan",
"os",
".",
"Signal",
")",
"{",
"signal",
".",
"Notify",
"(",
"c",
",",
"os",
... | // NewMaster returns a new Gobot Master | [
"NewMaster",
"returns",
"a",
"new",
"Gobot",
"Master"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/master.go#L46-L58 |
156,692 | hybridgroup/gobot | master.go | Start | func (g *Master) Start() (err error) {
if rerr := g.robots.Start(!g.AutoRun); rerr != nil {
err = multierror.Append(err, rerr)
return
}
g.running.Store(true)
if g.AutoRun {
c := make(chan os.Signal, 1)
g.trap(c)
// waiting for interrupt coming on the channel
<-c
// Stop calls the Stop method on ea... | go | func (g *Master) Start() (err error) {
if rerr := g.robots.Start(!g.AutoRun); rerr != nil {
err = multierror.Append(err, rerr)
return
}
g.running.Store(true)
if g.AutoRun {
c := make(chan os.Signal, 1)
g.trap(c)
// waiting for interrupt coming on the channel
<-c
// Stop calls the Stop method on ea... | [
"func",
"(",
"g",
"*",
"Master",
")",
"Start",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"rerr",
":=",
"g",
".",
"robots",
".",
"Start",
"(",
"!",
"g",
".",
"AutoRun",
")",
";",
"rerr",
"!=",
"nil",
"{",
"err",
"=",
"multierror",
".",
"A... | // Start calls the Start method on each robot in its collection of robots. On
// error, call Stop to ensure that all robots are returned to a sane, stopped
// state. | [
"Start",
"calls",
"the",
"Start",
"method",
"on",
"each",
"robot",
"in",
"its",
"collection",
"of",
"robots",
".",
"On",
"error",
"call",
"Stop",
"to",
"ensure",
"that",
"all",
"robots",
"are",
"returned",
"to",
"a",
"sane",
"stopped",
"state",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/master.go#L63-L83 |
156,693 | hybridgroup/gobot | master.go | Stop | func (g *Master) Stop() (err error) {
if rerr := g.robots.Stop(); rerr != nil {
err = multierror.Append(err, rerr)
}
g.running.Store(false)
return
} | go | func (g *Master) Stop() (err error) {
if rerr := g.robots.Stop(); rerr != nil {
err = multierror.Append(err, rerr)
}
g.running.Store(false)
return
} | [
"func",
"(",
"g",
"*",
"Master",
")",
"Stop",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"rerr",
":=",
"g",
".",
"robots",
".",
"Stop",
"(",
")",
";",
"rerr",
"!=",
"nil",
"{",
"err",
"=",
"multierror",
".",
"Append",
"(",
"err",
",",
"re... | // Stop calls the Stop method on each robot in its collection of robots. | [
"Stop",
"calls",
"the",
"Stop",
"method",
"on",
"each",
"robot",
"in",
"its",
"collection",
"of",
"robots",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/master.go#L86-L93 |
156,694 | hybridgroup/gobot | master.go | AddRobot | func (g *Master) AddRobot(r *Robot) *Robot {
*g.robots = append(*g.robots, r)
return r
} | go | func (g *Master) AddRobot(r *Robot) *Robot {
*g.robots = append(*g.robots, r)
return r
} | [
"func",
"(",
"g",
"*",
"Master",
")",
"AddRobot",
"(",
"r",
"*",
"Robot",
")",
"*",
"Robot",
"{",
"*",
"g",
".",
"robots",
"=",
"append",
"(",
"*",
"g",
".",
"robots",
",",
"r",
")",
"\n",
"return",
"r",
"\n",
"}"
] | // AddRobot adds a new robot to the internal collection of robots. Returns the
// added robot | [
"AddRobot",
"adds",
"a",
"new",
"robot",
"to",
"the",
"internal",
"collection",
"of",
"robots",
".",
"Returns",
"the",
"added",
"robot"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/master.go#L107-L110 |
156,695 | hybridgroup/gobot | master.go | Robot | func (g *Master) Robot(name string) *Robot {
for _, robot := range *g.Robots() {
if robot.Name == name {
return robot
}
}
return nil
} | go | func (g *Master) Robot(name string) *Robot {
for _, robot := range *g.Robots() {
if robot.Name == name {
return robot
}
}
return nil
} | [
"func",
"(",
"g",
"*",
"Master",
")",
"Robot",
"(",
"name",
"string",
")",
"*",
"Robot",
"{",
"for",
"_",
",",
"robot",
":=",
"range",
"*",
"g",
".",
"Robots",
"(",
")",
"{",
"if",
"robot",
".",
"Name",
"==",
"name",
"{",
"return",
"robot",
"\n... | // Robot returns a robot given name. Returns nil if the Robot does not exist. | [
"Robot",
"returns",
"a",
"robot",
"given",
"name",
".",
"Returns",
"nil",
"if",
"the",
"Robot",
"does",
"not",
"exist",
"."
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/master.go#L113-L120 |
156,696 | hybridgroup/gobot | drivers/i2c/sht3x_driver.go | Start | func (s *SHT3xDriver) Start() (err error) {
bus := s.GetBusOrDefault(s.connector.GetDefaultBus())
address := s.GetAddressOrDefault(s.sht3xAddress)
s.connection, err = s.connector.GetConnection(address, bus)
return
} | go | func (s *SHT3xDriver) Start() (err error) {
bus := s.GetBusOrDefault(s.connector.GetDefaultBus())
address := s.GetAddressOrDefault(s.sht3xAddress)
s.connection, err = s.connector.GetConnection(address, bus)
return
} | [
"func",
"(",
"s",
"*",
"SHT3xDriver",
")",
"Start",
"(",
")",
"(",
"err",
"error",
")",
"{",
"bus",
":=",
"s",
".",
"GetBusOrDefault",
"(",
"s",
".",
"connector",
".",
"GetDefaultBus",
"(",
")",
")",
"\n",
"address",
":=",
"s",
".",
"GetAddressOrDefa... | // Start initializes the SHT3x | [
"Start",
"initializes",
"the",
"SHT3x"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/sht3x_driver.go#L104-L110 |
156,697 | hybridgroup/gobot | drivers/i2c/sht3x_driver.go | SetAccuracy | func (s *SHT3xDriver) SetAccuracy(a byte) (err error) {
switch a {
case SHT3xAccuracyLow:
s.delay = 5 * time.Millisecond // Actual max is 4, wait 1 ms longer
case SHT3xAccuracyMedium:
s.delay = 7 * time.Millisecond // Actual max is 6, wait 1 ms longer
case SHT3xAccuracyHigh:
s.delay = 16 * time.Millisecond //... | go | func (s *SHT3xDriver) SetAccuracy(a byte) (err error) {
switch a {
case SHT3xAccuracyLow:
s.delay = 5 * time.Millisecond // Actual max is 4, wait 1 ms longer
case SHT3xAccuracyMedium:
s.delay = 7 * time.Millisecond // Actual max is 6, wait 1 ms longer
case SHT3xAccuracyHigh:
s.delay = 16 * time.Millisecond //... | [
"func",
"(",
"s",
"*",
"SHT3xDriver",
")",
"SetAccuracy",
"(",
"a",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"switch",
"a",
"{",
"case",
"SHT3xAccuracyLow",
":",
"s",
".",
"delay",
"=",
"5",
"*",
"time",
".",
"Millisecond",
"// Actual max is 4, wait 1... | // SetAccuracy sets the accuracy of the sampling | [
"SetAccuracy",
"sets",
"the",
"accuracy",
"of",
"the",
"sampling"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/sht3x_driver.go#L122-L138 |
156,698 | hybridgroup/gobot | drivers/i2c/sht3x_driver.go | SerialNumber | func (s *SHT3xDriver) SerialNumber() (sn uint32, err error) {
ret, err := s.sendCommandDelayGetResponse([]byte{0x37, 0x80}, nil, 2)
if nil == err {
sn = (uint32(ret[0]) << 16) | uint32(ret[1])
}
return
} | go | func (s *SHT3xDriver) SerialNumber() (sn uint32, err error) {
ret, err := s.sendCommandDelayGetResponse([]byte{0x37, 0x80}, nil, 2)
if nil == err {
sn = (uint32(ret[0]) << 16) | uint32(ret[1])
}
return
} | [
"func",
"(",
"s",
"*",
"SHT3xDriver",
")",
"SerialNumber",
"(",
")",
"(",
"sn",
"uint32",
",",
"err",
"error",
")",
"{",
"ret",
",",
"err",
":=",
"s",
".",
"sendCommandDelayGetResponse",
"(",
"[",
"]",
"byte",
"{",
"0x37",
",",
"0x80",
"}",
",",
"n... | // SerialNumber returns the serial number of the chip | [
"SerialNumber",
"returns",
"the",
"serial",
"number",
"of",
"the",
"chip"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/sht3x_driver.go#L141-L148 |
156,699 | hybridgroup/gobot | drivers/i2c/sht3x_driver.go | Heater | func (s *SHT3xDriver) Heater() (status bool, err error) {
sr, err := s.getStatusRegister()
if err == nil {
if (1 << 13) == (sr & (1 << 13)) {
status = true
}
}
return
} | go | func (s *SHT3xDriver) Heater() (status bool, err error) {
sr, err := s.getStatusRegister()
if err == nil {
if (1 << 13) == (sr & (1 << 13)) {
status = true
}
}
return
} | [
"func",
"(",
"s",
"*",
"SHT3xDriver",
")",
"Heater",
"(",
")",
"(",
"status",
"bool",
",",
"err",
"error",
")",
"{",
"sr",
",",
"err",
":=",
"s",
".",
"getStatusRegister",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"if",
"(",
"1",
"<<",
"13... | // Heater returns true if the heater is enabled | [
"Heater",
"returns",
"true",
"if",
"the",
"heater",
"is",
"enabled"
] | 58db149a40a113aec7d6068fb9418b7e05de1802 | https://github.com/hybridgroup/gobot/blob/58db149a40a113aec7d6068fb9418b7e05de1802/drivers/i2c/sht3x_driver.go#L151-L159 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.