diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 5586e60..0000000 --- a/AUTHORS +++ /dev/null @@ -1,4 +0,0 @@ -Karan Misra -Kunal Powar -Nikesh Vora -Akhil Sahdev diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 975aca7..d503cd1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,7 @@ This actually is really simple. A few simple guidelines and we can break for dinner: * EMBD is designed with a lot of affection, with utmost importance given to the dev experience (read: the API feel and style.) So always think from that angle when creating the pull request -* [Documentation](https://godoc.org/github.com/kidoman/embd) helps drive adoption. No exceptions +* [Documentation](https://godoc.org/github.com/cfreeman/embd) helps drive adoption. No exceptions When it comes to the code: @@ -23,7 +23,7 @@ When it comes to the code: this is inspired by Dave Cheney's gpio library and his work on EPOLL ``` -* Individual lines must be wrapped at the 70-char limit. Yeah, old school +* Individual lines must be wrapped at the 70-char limit. Yeah, old school * No trailing '.' And: diff --git a/CONTRIBUTORS b/CONTRIBUTORS deleted file mode 100644 index e3ca3e1..0000000 --- a/CONTRIBUTORS +++ /dev/null @@ -1,17 +0,0 @@ -adeschamps -alsm -Al S-M -Ben Delarre -Ben Schwartz -Gavin Cabbage -gotang -Kashyap Kopparam -Kunal Powar -Marco P. Monteiro -Matthew Dale -Nikesh Vora -SjB -Steve Beaulac -Thorsten von Eicken -wiless -Wu Jiang diff --git a/README.md b/README.md index 93896f8..3f8115f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# embd [![Build Status](https://travis-ci.org/kidoman/embd.svg?branch=master)](https://travis-ci.org/kidoman/embd) [![GoDoc](http://godoc.org/github.com/kidoman/embd?status.png)](http://godoc.org/github.com/kidoman/embd) +# embd [![GoDoc](http://godoc.org/github.com/cfreeman/embd?status.png)](http://godoc.org/github.com/cfreeman/embd) **embd** is a hardware abstraction layer (HAL) for embedded systems. @@ -18,11 +18,6 @@ What embd then adds is first a Golang library interface on top of the various Li devices and then another layer of user-level drivers for specific sensors and controllers that are connected to gpio pins or one of the buses. -Development supported and sponsored by [**SoStronk**](https://www.sostronk.com) and -[**ThoughtWorks**](http://www.thoughtworks.com/). - -Also, you might be interested in: [Why Golang?](https://github.com/kidoman/embd/wiki/Why-Go) - [Blog post introducing EMBD](http://kidoman.io/framework/embd.html) ## Getting Started @@ -37,8 +32,8 @@ package main import ( "time" - "github.com/kidoman/embd" - _ "github.com/kidoman/embd/host/rpi" // This loads the RPi driver + "github.com/cfreeman/embd" + _ "github.com/cfreeman/embd/host/rpi" // This loads the RPi driver ) func main() { @@ -51,7 +46,7 @@ func main() { Then install the EMBD package: - $ go get github.com/kidoman/embd + $ go get github.com/cfreeman/embd Build the binary for linux/ARM: @@ -74,22 +69,57 @@ Then on the rPi run the program with ```sudo```*: * Assuming your RaspberryPi has an IP address of ```192.168.2.2```. Substitute as necessary * `sudo` (root) permission is required as we are controlling the hardware by writing to special files * This sample program is optimized for brevity and does not clean up after itself. Click here to - see the [full version](https://github.com/kidoman/embd/blob/master/samples/fullblinker.go) + see the [full version](https://github.com/cfreeman/embd/blob/master/samples/fullblinker.go) -## Getting Help +## Supported Platforms -Join the [slack channel](https://gophers.slack.com/archives/embd) - -## Platforms Supported - -* [RaspberryPi](http://www.raspberrypi.org/) (including [A+](http://www.raspberrypi.org/products/model-a-plus/) and [B+](http://www.raspberrypi.org/products/model-b-plus/)) -* [RaspberryPi 2](http://www.raspberrypi.org/) -* [NextThing C.H.I.P](https://www.nextthing.co/pages/chip) * [BeagleBone Black](http://beagleboard.org/Products/BeagleBone%20Black) +* [Intel Edison](https://software.intel.com/en-us/iot/hardware/edison) +* [NextThing C.H.I.P](https://www.nextthing.co/pages/chip) +* [RaspberryPi 1 A+](http://www.raspberrypi.org/products/model-a-plus/) +* [RaspberryPi 1 B+](https://www.raspberrypi.org/products/model-b-plus/) +* [RaspberryPi 2](https://www.raspberrypi.org/products/raspberry-pi-2-model-b/) +* [RaspberryPi 3](https://www.raspberrypi.org/products/raspberry-pi-3-model-b/) + +## Supported Protocols + +* **Digital GPIO** [Documentation](http://godoc.org/github.com/cfreeman/embd#DigitalPin) +* **Analog GPIO** [Documentation](http://godoc.org/github.com/cfreeman/embd#AnalogPin) +* **PWM** [Documentation](http://godoc.org/github.com/cfreeman/embd#PWMPin) +* **I2C** [Documentation](http://godoc.org/github.com/cfreeman/embd#I2CBus) +* **LED** [Documentation](http://godoc.org/github.com/cfreeman/embd#LED) +* **SPI** [Documentation](http://godoc.org/github.com/cfreeman/embd#SPIBus) + +## Supported Sensors + +* **BH1750FVI** Luminosity sensor [Documentation](http://godoc.org/github.com/cfreeman/embd/sensor/bh1750fvi), [Datasheet](http://www.elechouse.com/elechouse/images/product/Digital%20light%20Sensor/bh1750fvi-e.pdf) +* **BME280** Pressure, Temperature and Humidity Sensor [Documentation](https://godoc.org/github.com/cfreeman/embd/sensor/bme280), [Datasheet](https://cdn-shop.adafruit.com/datasheets/BST-BME280_DS001-10.pdf) +* **BMP085** Barometric pressure sensor [Documentation](http://godoc.org/github.com/cfreeman/embd/sensor/bmp085), [Datasheet](https://www.sparkfun.com/datasheets/Components/General/BST-BMP085-DS000-05.pdf) +* **BMP180** Barometric pressure sensor [Documentation](http://godoc.org/github.com/cfreeman/embd/sensor/bmp180), [Datasheet](http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf) +* **L3GD20** Gyroscope [Documentation](http://godoc.org/github.com/cfreeman/embd/sensor/l3gd20), [Datasheet](http://www.adafruit.com/datasheets/L3GD20.pdf) +* **LSM303** Accelerometer and magnetometer [Documentation](http://godoc.org/github.com/cfreeman/embd/sensor/lsm303), [Datasheet](https://www.sparkfun.com/datasheets/Sensors/Magneto/LSM303%20Datasheet.pdf) +* **TMP006** Thermopile sensor [Documentation](http://godoc.org/github.com/cfreeman/embd/sensor/tmp006), [Datasheet](http://www.adafruit.com/datasheets/tmp006.pdf) +* **US020** Ultrasonic proximity sensor [Documentation](http://godoc.org/github.com/cfreeman/embd/sensor/us020), [Product Page](http://www.digibay.in/sensor/object-detection-and-proximity?product_id=239) +* **Watersensor** Based on LM393 (currently only provides digital support) [Documentation](http://godoc.org/github.com/cfreeman/embd/sensor/watersensor)[Datasheet](http://www.ti.com/lit/ds/symlink/lm393-n.pdf) + +## Interfaces + +* **Keypad(4x3)** [Product Page](http://www.adafruit.com/products/419#Learn) + +## Controllers + +* **PCA9685** 16-channel, 12-bit PWM Controller with I2C protocol [Documentation](http://godoc.org/github.com/cfreeman/embd/controller/pca9685), [Datasheet](http://www.adafruit.com/datasheets/PCA9685.pdf), [Product Page](http://www.adafruit.com/products/815) +* **MCP4725** 12-bit DAC [Documentation](http://godoc.org/github.com/cfreeman/embd/controller/mcp4725), [Datasheet](http://www.adafruit.com/datasheets/mcp4725.pdf), [Product Page](http://www.adafruit.com/products/935) +* **ServoBlaster** RPi PWM/PCM based PWM controller [Documentation](http://godoc.org/github.com/cfreeman/embd/controller/servoblaster), [Product Page](https://github.com/richardghirst/PiBits/tree/master/ServoBlaster) + +## Convertors + +* **MCP3008** 8-channel, 10-bit ADC with SPI protocol, [Datasheet](https://www.adafruit.com/datasheets/MCP3008.pdf) + ## The command line tool - go get github.com/kidoman/embd/embd + go get github.com/cfreeman/embd/embd will install a command line utility ```embd``` which will allow you to quickly get started with prototyping. The binary should be available in your ```$GOPATH/bin```. However, to be able to run this on a ARM based device, you will need to build it with ```GOOS=linux``` and ```GOARCH=arm``` environment variables set. @@ -107,14 +137,14 @@ Package **embd** provides a hardware abstraction layer for doing embedded progra on supported platforms like the Raspberry Pi and BeagleBone Black. Most of the examples below will work without change (i.e. the same binary) on all supported platforms. How cool is that? -Although samples are all present in the [samples](https://github.com/kidoman/embd/tree/master/samples) folder, +Although samples are all present in the [samples](https://github.com/cfreeman/embd/tree/master/samples) folder, we will show a few choice examples here. Use the **LED** driver to toggle LEDs on the BBB: ```go -import "github.com/kidoman/embd" -import _ "github.com/kidoman/embd/host/all" +import "github.com/cfreeman/embd" +import _ "github.com/cfreeman/embd/host/all" ... embd.InitLED() defer embd.CloseLED() @@ -127,8 +157,8 @@ led.Toggle() Even shorter when quickly trying things out: ```go -import "github.com/kidoman/embd" -import _ "github.com/kidoman/embd/host/all" +import "github.com/cfreeman/embd" +import _ "github.com/cfreeman/embd/host/all" ... embd.InitLED() defer embd.CloseLED() @@ -141,8 +171,8 @@ embd.ToggleLED(3) BBB + **PWM**: ```go -import "github.com/kidoman/embd" -import _ "github.com/kidoman/embd/host/all" +import "github.com/cfreeman/embd" +import _ "github.com/cfreeman/embd/host/all" ... embd.InitGPIO() defer embd.CloseGPIO() @@ -156,8 +186,8 @@ pwm.SetDuty(1000) Control **GPIO** pins on the RaspberryPi / BeagleBone Black: ```go -import "github.com/kidoman/embd" -import _ "github.com/kidoman/embd/host/all" +import "github.com/cfreeman/embd" +import _ "github.com/cfreeman/embd/host/all" ... embd.InitGPIO() defer embd.CloseGPIO() @@ -169,8 +199,8 @@ embd.DigitalWrite(10, embd.High) Could also do: ```go -import "github.com/kidoman/embd" -import _ "github.com/kidoman/embd/host/all" +import "github.com/cfreeman/embd" +import _ "github.com/cfreeman/embd/host/all" ... embd.InitGPIO() defer embd.CloseGPIO() @@ -184,9 +214,9 @@ pin.Write(embd.High) Or read data from the **Bosch BMP085** barometric sensor: ```go -import "github.com/kidoman/embd" -import "github.com/kidoman/embd/sensor/bmp085" -import _ "github.com/kidoman/embd/host/all" +import "github.com/cfreeman/embd" +import "github.com/cfreeman/embd/sensor/bmp085" +import _ "github.com/cfreeman/embd/host/all" ... bus := embd.NewI2CBus(1) ... @@ -199,9 +229,9 @@ altitude, err := baro.Altitude() Even find out the heading from the **LSM303** magnetometer: ```go -import "github.com/kidoman/embd" -import "github.com/kidoman/embd/sensor/lsm303" -import _ "github.com/kidoman/embd/host/all" +import "github.com/cfreeman/embd" +import "github.com/cfreeman/embd/sensor/lsm303" +import _ "github.com/cfreeman/embd/host/all" ... bus := embd.NewI2CBus(1) ... @@ -213,47 +243,22 @@ heading, err := mag.Heading() The above two examples depend on **I2C** and therefore will work without change on almost all platforms. -## Protocols Supported - -* **Digital GPIO** [Documentation](http://godoc.org/github.com/kidoman/embd#DigitalPin) -* **Analog GPIO** [Documentation](http://godoc.org/github.com/kidoman/embd#AnalogPin) -* **PWM** [Documentation](http://godoc.org/github.com/kidoman/embd#PWMPin) -* **I2C** [Documentation](http://godoc.org/github.com/kidoman/embd#I2CBus) -* **LED** [Documentation](http://godoc.org/github.com/kidoman/embd#LED) -* **SPI** [Documentation](http://godoc.org/github.com/kidoman/embd#SPIBus) - -## Sensors Supported - -* **TMP006** Thermopile sensor [Documentation](http://godoc.org/github.com/kidoman/embd/sensor/tmp006), [Datasheet](http://www.adafruit.com/datasheets/tmp006.pdf), [Userguide](http://www.adafruit.com/datasheets/tmp006ug.pdf) -* **BMP085** Barometric pressure sensor [Documentation](http://godoc.org/github.com/kidoman/embd/sensor/bmp085), [Datasheet](https://www.sparkfun.com/datasheets/Components/General/BST-BMP085-DS000-05.pdf) -* **BMP180** Barometric pressure sensor [Documentation](http://godoc.org/github.com/kidoman/embd/sensor/bmp180), [Datasheet](http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf) -* **LSM303** Accelerometer and magnetometer [Documentation](http://godoc.org/github.com/kidoman/embd/sensor/lsm303), [Datasheet](https://www.sparkfun.com/datasheets/Sensors/Magneto/LSM303%20Datasheet.pdf) -* **L3GD20** Gyroscope [Documentation](http://godoc.org/github.com/kidoman/embd/sensor/l3gd20), [Datasheet](http://www.adafruit.com/datasheets/L3GD20.pdf) -* **US020** Ultrasonic proximity sensor [Documentation](http://godoc.org/github.com/kidoman/embd/sensor/us020), [Product Page](http://www.digibay.in/sensor/object-detection-and-proximity?product_id=239) -* **BH1750FVI** Luminosity sensor [Documentation](http://godoc.org/github.com/kidoman/embd/sensor/bh1750fvi), [Datasheet](http://www.elechouse.com/elechouse/images/product/Digital%20light%20Sensor/bh1750fvi-e.pdf) - -## Interfaces - -* **Keypad(4x3)** [Product Page](http://www.adafruit.com/products/419#Learn) - -## Controllers - -* **PCA9685** 16-channel, 12-bit PWM Controller with I2C protocol [Documentation](http://godoc.org/github.com/kidoman/embd/controller/pca9685), [Datasheet](http://www.adafruit.com/datasheets/PCA9685.pdf), [Product Page](http://www.adafruit.com/products/815) -* **MCP4725** 12-bit DAC [Documentation](http://godoc.org/github.com/kidoman/embd/controller/mcp4725), [Datasheet](http://www.adafruit.com/datasheets/mcp4725.pdf), [Product Page](http://www.adafruit.com/products/935) -* **ServoBlaster** RPi PWM/PCM based PWM controller [Documentation](http://godoc.org/github.com/kidoman/embd/controller/servoblaster), [Product Page](https://github.com/richardghirst/PiBits/tree/master/ServoBlaster) - -## Convertors - -* **MCP3008** 8-channel, 10-bit ADC with SPI protocol, [Datasheet](https://www.adafruit.com/datasheets/MCP3008.pdf) - ## Contributing -[Pull requests](https://github.com/kidoman/embd/pulls) that follow the -[guidelines](https://github.com/kidoman/embd/blob/master/CONTRIBUTING.md) are very appreciated. +[Pull requests](https://github.com/cfreeman/embd/pulls) that follow the +[guidelines](https://github.com/cfreeman/embd/blob/master/CONTRIBUTING.md) are very appreciated. + If you find a problem but are not up to coding a fix please file an -[issue](https://github.com/kidoman/embd/issues). +[issue](https://github.com/cfreeman/embd/issues). Thank you! -## About +## ROADMAP -EMBD is affectionately designed/developed by Karan Misra ([kidoman](https://github.com/kidoman)), Kunal Powar ([kunalpowar](https://github.com/kunalpowar)) and [FRIENDS](https://github.com/kidoman/embd/blob/master/AUTHORS). We also have a list of [CONTRIBUTORS](https://github.com/kidoman/embd/blob/master/CONTRIBUTORS). +* Continue to tidy up the README and other documentation. +* move utils.go into util package +* Make sure there are samples for all supported hardware. Better organise samples move into godoc? +* Rummage through the old, largely abandoned parent repo and pull in as many of the requests as possible. +* A fully featured cli tool (**embd**) +* Continue to add support for additional sensors/controllers/convertors. +* Continue to add support for additional hosts (Cubietruck, Radxa, etc). +* Supporting something other than Linux diff --git a/ROADMAP.md b/ROADMAP.md deleted file mode 100644 index 257c8e0..0000000 --- a/ROADMAP.md +++ /dev/null @@ -1,14 +0,0 @@ -# embd roadmap - -The following features are planned (in no particular order): - -* A fully featured cli tool (**embd**) -* Support for UART, SPI -* Support for a whole range of sensors/controllers -* Support for Intel Galileo (will require a few changes to Golang, but not unsurmountable) -* Support for a lot of other ARM prototyping boards (Cubietruck, Radxa, etc.) -* Awesome documentation -* A embd UI (similar to the Arduino IDE) -* Supporting something other than Linux -* Support for vision processing (OpenCV ?) -* Allow remote instrumentation of the host via network/web sockets/etc. diff --git a/controller/apa102/apa102.go b/controller/apa102/apa102.go new file mode 100644 index 0000000..1ea27c6 --- /dev/null +++ b/controller/apa102/apa102.go @@ -0,0 +1,85 @@ +/* + * Copyright (c) Clinton Freeman 2017 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package apa102 + +import ( + "github.com/cfreeman/embd" +) + +const ( + MAX_BRIGHTNESS = 31 +) + +type APA102 struct { + Bus embd.SPIBus + LED []uint8 + nLED int +} + +func New(bus embd.SPIBus, numLEDs int) *APA102 { + res := &APA102{ + Bus: bus, + LED: make([]uint8, numLEDs*4), + nLED: numLEDs, + } + + // Init the intensity field for each LED which is + // 0b111 + 5 intensity bits. + for i := 0; i < (numLEDs * 4); i = i + 4 { + res.LED[i] = 224 + } + + return res +} + +func (a *APA102) SetLED(index int, r uint8, g uint8, b uint8, i uint8) error { + intensity := i + if i > 31 { + intensity = 31 + } + + ind := index * 4 + + a.LED[ind+0] = 224 + intensity // Brightness is 0b111 + 5 intensity bits + a.LED[ind+1] = b + a.LED[ind+2] = g + a.LED[ind+3] = r + + return a.Show() +} + +func (a *APA102) Show() error { + // Start frame is 32 zero bits. + err := a.Bus.TransferAndReceiveData([]uint8{0, 0, 0, 0}) + + // LED data. + // 111+5bits(intensity) + 1byte(Red) + 1byte(Green) + 1byte(Blue) + err = a.Bus.TransferAndReceiveData(a.LED) + if err != nil { + return err + } + + err = a.Bus.TransferAndReceiveData([]uint8{1, 1, 1, 1}) + if err != nil { + return err + } + + return nil +} diff --git a/controller/hd44780/hd44780.go b/controller/hd44780/hd44780.go index 88032d5..860d8b6 100644 --- a/controller/hd44780/hd44780.go +++ b/controller/hd44780/hd44780.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Matthew Dale 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + /* Package hd44780 allows controlling an HD44780-compatible character LCD controller. Currently the library is write-only and does not support @@ -15,8 +34,8 @@ package hd44780 import ( "time" + "github.com/cfreeman/embd" "github.com/golang/glog" - "github.com/kidoman/embd" ) type entryMode byte diff --git a/controller/hd44780/hd44780_test.go b/controller/hd44780/hd44780_test.go index eee375d..0c561ff 100644 --- a/controller/hd44780/hd44780_test.go +++ b/controller/hd44780/hd44780_test.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Matthew Dale 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package hd44780 import ( @@ -6,7 +25,7 @@ import ( "testing" "time" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" ) const ( diff --git a/controller/mcp4725/mcp4725.go b/controller/mcp4725/mcp4725.go index 1dcaa91..06e5d30 100644 --- a/controller/mcp4725/mcp4725.go +++ b/controller/mcp4725/mcp4725.go @@ -1,11 +1,30 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package mcp4725 allows interfacing with the MCP4725 DAC. package mcp4725 import ( "sync" + "github.com/cfreeman/embd" "github.com/golang/glog" - "github.com/kidoman/embd" ) const ( diff --git a/controller/pca9685/pca9685.go b/controller/pca9685/pca9685.go index 9a9407d..8af71f4 100644 --- a/controller/pca9685/pca9685.go +++ b/controller/pca9685/pca9685.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Kunal Powar 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package pca9685 allows interfacing with the pca9685 16-channel, 12-bit PWM Controller through I2C protocol. package pca9685 @@ -6,9 +25,9 @@ import ( "sync" "time" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/util" "github.com/golang/glog" - "github.com/kidoman/embd" - "github.com/kidoman/embd/util" ) const ( diff --git a/controller/pcal9535a/pcal9535a.go b/controller/pcal9535a/pcal9535a.go new file mode 100644 index 0000000..02e7414 --- /dev/null +++ b/controller/pcal9535a/pcal9535a.go @@ -0,0 +1,62 @@ +/* + * Copyright (c) Clinton Freeman 2016 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +// Package pcal9535a adds support for the low volage GPIO expander as found in the Raspberry +// Pi Relay board by Seeed Studio. +package pcal9535a + +import ( + "github.com/cfreeman/embd" +) + +// More details at - http://wiki.seeedstudio.com/wiki/Raspberry_Pi_Relay_Board_v1.0 +const ( + REG_MODE = 0x06 +) + +type PCAL9535A struct { + Bus embd.I2CBus + Addr byte + D byte +} + +// New creates and connects to a PCAL9535A GPIO expander. +func New(bus embd.I2CBus, addr byte) (*PCAL9535A, error) { + return &PCAL9535A{ + Bus: bus, + Addr: addr, + D: 0xff, + }, bus.WriteByteToReg(addr, REG_MODE, 0xff) +} + +// Sets the nominated GPIO pin to either high (on = true) or low (on = false) +func (c *PCAL9535A) SetPin(pin uint, on bool) error { + if on { + c.D &= ^(byte(0x1) << pin) + } else { + c.D |= (byte(0x1) << pin) + } + + return c.Bus.WriteByteToReg(c.Addr, REG_MODE, c.D) +} + +// Gets the state of supplied pin true = high or on, while false = low or off. +func (c *PCAL9535A) GetPin(pin uint) bool { + return (((c.D >> pin) & 1) == 0) +} diff --git a/controller/servoblaster/servoblaster.go b/controller/servoblaster/servoblaster.go index c9c3460..1619e38 100644 --- a/controller/servoblaster/servoblaster.go +++ b/controller/servoblaster/servoblaster.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package servoblaster allows interfacing with the software servoblaster driver. // // More details on ServoBlaster at: https://github.com/richardghirst/PiBits/tree/master/ServoBlaster diff --git a/convertors/mcp3008/mcp3008.go b/convertors/mcp3008/mcp3008.go index e5ecb99..4fda6e8 100644 --- a/convertors/mcp3008/mcp3008.go +++ b/convertors/mcp3008/mcp3008.go @@ -1,9 +1,28 @@ +/* + * Copyright (c) Kunal Powar 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package mcp3008 allows interfacing with the mcp3008 8-channel, 10-bit ADC through SPI protocol. package mcp3008 import ( + "github.com/cfreeman/embd" "github.com/golang/glog" - "github.com/kidoman/embd" ) // MCP3008 represents a mcp3008 8bit DAC. diff --git a/descriptor.go b/descriptor.go index b891008..6527c04 100644 --- a/descriptor.go +++ b/descriptor.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Host descriptor data structures. package embd diff --git a/detect.go b/detect.go index ac90872..66d0eeb 100644 --- a/detect.go +++ b/detect.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Host detection. package embd @@ -26,6 +45,9 @@ const ( // HostGalileo represents the Intel Galileo board. HostGalileo = "Intel Galileo" + // HostEdison represents teh Intel Edison board. + HostEdison = "Intel Edison" + // HostCubieTruck represents the Cubie Truck. HostCubieTruck = "CubieTruck" @@ -126,6 +148,8 @@ func DetectHost() (host Host, rev int, err error) { return HostBBB, rev, nil case strings.Contains(hardware, "BCM2708") || strings.Contains(hardware, "BCM2709") || strings.Contains(hardware, "BCM2835"): return HostRPi, rev, nil + case strings.Contains(model, "Genuine Intel(R) CPU 4000 @ 500MHz"): + return HostEdison, rev, nil case hardware == "Allwinner sun4i/sun5i Families": if major < 4 || (major == 4 && minor < 4) { return HostNull, 0, fmt.Errorf( @@ -134,6 +158,6 @@ func DetectHost() (host Host, rev int, err error) { } return HostCHIP, rev, nil default: - return HostNull, 0, fmt.Errorf(`embd: your host "%v:%v" is not supported at this moment. request support at https://github.com/kidoman/embd/issues`, host, model) + return HostNull, 0, fmt.Errorf(`embd: your host "%v:%v" is not supported at this moment. request support at https://github.com/cfreeman/embd/issues`, host, model) } } diff --git a/detect_test.go b/detect_test.go index 48c539e..f218b98 100644 --- a/detect_test.go +++ b/detect_test.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package embd import "testing" diff --git a/doc.go b/doc.go index a31cab1..e752408 100644 --- a/doc.go +++ b/doc.go @@ -22,7 +22,7 @@ called as 1-liners instead of first instantiating a DigitalPin and then writing To get started a host driver needs to be registered with the top-level embd package. This is most easily accomplished by doing an "underscore import" on of the sub-packages of embd/host, -e.g., `import _ "github.com/kidoman/embd/host/chip"`. An `Init()` function in the host driver +e.g., `import _ "github.com/cfreeman/embd/host/chip"`. An `Init()` function in the host driver registers all the individual drivers with embd. After getting the host driver the next step might be to instantiate a GPIO pin using @@ -38,7 +38,7 @@ This section shows a few choice samples, more are available in the samples folde Use the LED driver to toggle LEDs on the BBB: - import "github.com/kidoman/embd" + import "github.com/cfreeman/embd" ... embd.InitLED() defer embd.CloseLED() @@ -49,7 +49,7 @@ Use the LED driver to toggle LEDs on the BBB: Even shorter while prototyping: - import "github.com/kidoman/embd" + import "github.com/cfreeman/embd" ... embd.InitLED() defer embd.CloseLED() @@ -58,7 +58,7 @@ Even shorter while prototyping: BBB + PWM: - import "github.com/kidoman/embd" + import "github.com/cfreeman/embd" ... embd.InitGPIO() defer embd.CloseGPIO() @@ -70,7 +70,7 @@ BBB + PWM: Control GPIO pins on the RaspberryPi / BeagleBone Black: - import "github.com/kidoman/embd" + import "github.com/cfreeman/embd" ... embd.InitGPIO() defer embd.CloseGPIO() @@ -80,7 +80,7 @@ Control GPIO pins on the RaspberryPi / BeagleBone Black: Could also do: - import "github.com/kidoman/embd" + import "github.com/cfreeman/embd" ... embd.InitGPIO() defer embd.CloseGPIO() @@ -92,8 +92,8 @@ Could also do: Or read data from the Bosch BMP085 barometric sensor: - import "github.com/kidoman/embd" - import "github.com/kidoman/embd/sensor/bmp085" + import "github.com/cfreeman/embd" + import "github.com/cfreeman/embd/sensor/bmp085" ... bus := embd.NewI2CBus(1) ... @@ -104,8 +104,8 @@ Or read data from the Bosch BMP085 barometric sensor: Even find out the heading from the LSM303 magnetometer: - import "github.com/kidoman/embd" - import "github.com/kidoman/embd/sensor/lsm303" + import "github.com/cfreeman/embd" + import "github.com/cfreeman/embd/sensor/lsm303" ... bus := embd.NewI2CBus(1) ... diff --git a/embd/detect.go b/embd/detect.go index 6659980..b0d4251 100644 --- a/embd/detect.go +++ b/embd/detect.go @@ -1,11 +1,30 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package main import ( "fmt" "os" + "github.com/cfreeman/embd" "github.com/codegangsta/cli" - "github.com/kidoman/embd" ) func detect(c *cli.Context) { diff --git a/embd/main.go b/embd/main.go index 7ea7424..a344879 100644 --- a/embd/main.go +++ b/embd/main.go @@ -1,10 +1,29 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package main import ( "os" + _ "github.com/cfreeman/embd/host/all" "github.com/codegangsta/cli" - _ "github.com/kidoman/embd/host/all" ) var version = "0.1.0" diff --git a/gpio.go b/gpio.go index 3d7baf7..c804dfd 100644 --- a/gpio.go +++ b/gpio.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // GPIO support. package embd diff --git a/gpiodriver.go b/gpiodriver.go index be2f8d8..7bb7f39 100644 --- a/gpiodriver.go +++ b/gpiodriver.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Generic GPIO driver. package embd diff --git a/gpiodriver_test.go b/gpiodriver_test.go index fffedf4..54d08c4 100644 --- a/gpiodriver_test.go +++ b/gpiodriver_test.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package embd import ( diff --git a/host/all/all.go b/host/all/all.go index 5bfd7a9..fc16bc0 100644 --- a/host/all/all.go +++ b/host/all/all.go @@ -1,7 +1,27 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package all conviniently loads all the inbuilt/supported host drivers. package all import ( - _ "github.com/kidoman/embd/host/bbb" - _ "github.com/kidoman/embd/host/rpi" + _ "github.com/cfreeman/embd/host/bbb" + _ "github.com/cfreeman/embd/host/edison" + _ "github.com/cfreeman/embd/host/rpi" ) diff --git a/host/bbb/analogpin.go b/host/bbb/analogpin.go index e12b9dd..bbcf1d0 100644 --- a/host/bbb/analogpin.go +++ b/host/bbb/analogpin.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Analog I/O support on the BBB. package bbb @@ -9,7 +28,7 @@ import ( "strconv" "strings" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" ) type analogPin struct { diff --git a/host/bbb/analogpin_test.go b/host/bbb/analogpin_test.go index 49f22cb..8aa5519 100644 --- a/host/bbb/analogpin_test.go +++ b/host/bbb/analogpin_test.go @@ -1,9 +1,28 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package bbb import ( "testing" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" ) func TestAnalogPinClose(t *testing.T) { diff --git a/host/bbb/bbb.go b/host/bbb/bbb.go index 1f42d7d..445c340 100644 --- a/host/bbb/bbb.go +++ b/host/bbb/bbb.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + /* Package bbb provides BeagleBone Black support. The following features are supported on Linux kernel 3.8+ @@ -15,9 +34,9 @@ import ( "os" "strings" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/host/generic" "github.com/golang/glog" - "github.com/kidoman/embd" - "github.com/kidoman/embd/host/generic" ) var pins = embd.PinMap{ diff --git a/host/bbb/pwmpin.go b/host/bbb/pwmpin.go index 1bd6c95..aff8ed8 100644 --- a/host/bbb/pwmpin.go +++ b/host/bbb/pwmpin.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // PWM support on the BBB. package bbb @@ -10,9 +29,9 @@ import ( "strconv" "time" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/util" "github.com/golang/glog" - "github.com/kidoman/embd" - "github.com/kidoman/embd/util" ) const ( diff --git a/host/bbb/pwmpin_test.go b/host/bbb/pwmpin_test.go index 1c07ff3..083bb56 100644 --- a/host/bbb/pwmpin_test.go +++ b/host/bbb/pwmpin_test.go @@ -1,9 +1,28 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package bbb import ( "testing" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" ) func TestPWMPinClose(t *testing.T) { diff --git a/host/chip/README.md b/host/chip/README.md index 51fd49e..dc08314 100644 --- a/host/chip/README.md +++ b/host/chip/README.md @@ -1,7 +1,7 @@ # Using embd on CHIP The CHIP drivers support gpio, I2C, SPI, and pin interrupts. Not supported are PWM or LED. -The names of the pins on chip have multiple aliases. The official CHIP pin names are supported, +The names of the pins on chip have multiple aliases. The official CHIP pin names are supported, for example XIO-P1 or LCD-D2 and the pin number are also supported, such as U14-14 (same as XIO-P1) or U13-17. Some of the alternate function names are also supported, like "SPI2_MOSI", and the linux 4.4 kernel gpio pin numbers as well, e.g., 1017 for XIO-P1. Finally, the official GPIO pins @@ -13,8 +13,8 @@ A simple demo to blink an LED connected with a small resistor between XIO-P6 and package main import ( "time" - "github.com/kidoman/embd" - _ "github.com/kidoman/embd/host/chip" + "github.com/cfreeman/embd" + _ "github.com/cfreeman/embd/host/chip" ) func main() { diff --git a/host/chip/chip.go b/host/chip/chip.go index d849df4..afd94d1 100644 --- a/host/chip/chip.go +++ b/host/chip/chip.go @@ -1,4 +1,21 @@ -// Copyright 2016 by Thorsten von Eicken, see LICENSE file +/* + * Copyright (c) Thorsten von Eicken 2016 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ // Package chip provides NextThing C.H.I.P. support. // References: @@ -14,8 +31,8 @@ package chip import ( - "github.com/kidoman/embd" - "github.com/kidoman/embd/host/generic" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/host/generic" ) var spiDeviceMinor = 32766 diff --git a/host/edison/edison.go b/host/edison/edison.go new file mode 100644 index 0000000..62be092 --- /dev/null +++ b/host/edison/edison.go @@ -0,0 +1,68 @@ +/* + * Copyright (c) Clinton Freeman 2016 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +// Package edison Provides Intel Edison support. +package edison + +import ( + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/host/generic" +) + +var pins = embd.PinMap{ + &embd.PinDesc{ID: "P1_12", Aliases: []string{"12", "GPIO_12"}, Caps: embd.CapDigital, DigitalLogical: 12}, // PWM? + &embd.PinDesc{ID: "P1_13", Aliases: []string{"13", "GPIO_13"}, Caps: embd.CapDigital, DigitalLogical: 13}, // PWM? + &embd.PinDesc{ID: "P1_14", Aliases: []string{"14", "GPIO_14"}, Caps: embd.CapDigital, DigitalLogical: 14}, + &embd.PinDesc{ID: "P1_15", Aliases: []string{"15", "GPIO_15"}, Caps: embd.CapDigital, DigitalLogical: 15}, + &embd.PinDesc{ID: "P1_44", Aliases: []string{"44", "GPIO_44"}, Caps: embd.CapDigital, DigitalLogical: 44}, + &embd.PinDesc{ID: "P1_45", Aliases: []string{"45", "GPIO_45"}, Caps: embd.CapDigital, DigitalLogical: 45}, + &embd.PinDesc{ID: "P1_46", Aliases: []string{"46", "GPIO_46"}, Caps: embd.CapDigital, DigitalLogical: 46}, + &embd.PinDesc{ID: "P1_47", Aliases: []string{"47", "GPIO_47"}, Caps: embd.CapDigital, DigitalLogical: 47}, + &embd.PinDesc{ID: "P1_48", Aliases: []string{"48", "GPIO_48"}, Caps: embd.CapDigital, DigitalLogical: 48}, + &embd.PinDesc{ID: "P1_49", Aliases: []string{"49", "GPIO_49"}, Caps: embd.CapDigital, DigitalLogical: 49}, + &embd.PinDesc{ID: "P1_128", Aliases: []string{"128", "GPIO_128"}, Caps: embd.CapDigital, DigitalLogical: 128}, //CTS? + &embd.PinDesc{ID: "P1_129", Aliases: []string{"129", "GPIO_129"}, Caps: embd.CapDigital, DigitalLogical: 129}, //RTS? + &embd.PinDesc{ID: "P1_130", Aliases: []string{"130", "GPIO_130", "RXD", "UART0_RXD"}, Caps: embd.CapDigital | embd.CapUART, DigitalLogical: 130}, + &embd.PinDesc{ID: "P1_131", Aliases: []string{"131", "GPIO_131", "TXD", "UART0_TXD"}, Caps: embd.CapDigital | embd.CapUART, DigitalLogical: 131}, + &embd.PinDesc{ID: "P1_182", Aliases: []string{"182", "GPIO_182"}, Caps: embd.CapDigital, DigitalLogical: 182}, // PWM? + &embd.PinDesc{ID: "P1_183", Aliases: []string{"183", "GPIO_183"}, Caps: embd.CapDigital, DigitalLogical: 183}, // PWM? +} + +var ledMap = embd.LEDMap{} + +var spiDeviceMinor = 0 // Check?? + +func init() { + embd.Register(embd.HostEdison, func(rev int) *embd.Descriptor { + return &embd.Descriptor{ + GPIODriver: func() embd.GPIODriver { + return embd.NewGPIODriver(pins, generic.NewDigitalPin, nil, nil) + }, + I2CDriver: func() embd.I2CDriver { + return embd.NewI2CDriver(generic.NewI2CBus) + }, + LEDDriver: func() embd.LEDDriver { + return embd.NewLEDDriver(ledMap, generic.NewLED) + }, + SPIDriver: func() embd.SPIDriver { + return embd.NewSPIDriver(spiDeviceMinor, generic.NewSPIBus, nil) + }, + } + }) +} diff --git a/host/generic/digitalpin.go b/host/generic/digitalpin.go index 525eeb4..d4400f1 100644 --- a/host/generic/digitalpin.go +++ b/host/generic/digitalpin.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Digital IO support. // This driver requires kernel version 3.8+ and should work uniformly // across all supported devices. @@ -13,7 +32,7 @@ import ( "syscall" "time" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" ) type digitalPin struct { diff --git a/host/generic/digitalpin_test.go b/host/generic/digitalpin_test.go index 18e900e..f80ab2d 100644 --- a/host/generic/digitalpin_test.go +++ b/host/generic/digitalpin_test.go @@ -1,9 +1,28 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package generic import ( "testing" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" ) func TestDigitalPinClose(t *testing.T) { diff --git a/host/generic/i2cbus.go b/host/generic/i2cbus.go index fbe6f55..91cde71 100644 --- a/host/generic/i2cbus.go +++ b/host/generic/i2cbus.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // I²C support. package generic @@ -11,8 +30,8 @@ import ( "time" "unsafe" + "github.com/cfreeman/embd" "github.com/golang/glog" - "github.com/kidoman/embd" ) const ( diff --git a/host/generic/interrupt.go b/host/generic/interrupt.go index 7f9b766..5642550 100644 --- a/host/generic/interrupt.go +++ b/host/generic/interrupt.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Generic Interrupt Pins. package generic @@ -8,7 +27,7 @@ import ( "sync" "syscall" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" ) const ( diff --git a/host/generic/led.go b/host/generic/led.go index 67f56c9..58e01f3 100644 --- a/host/generic/led.go +++ b/host/generic/led.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // LED control support. package generic @@ -8,7 +27,7 @@ import ( "os" "strings" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" ) type led struct { diff --git a/host/generic/spibus.go b/host/generic/spibus.go index a33576f..b9fd1a2 100644 --- a/host/generic/spibus.go +++ b/host/generic/spibus.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package generic import ( @@ -7,8 +26,8 @@ import ( "syscall" "unsafe" + "github.com/cfreeman/embd" "github.com/golang/glog" - "github.com/kidoman/embd" ) const ( diff --git a/host/rpi/rpi.go b/host/rpi/rpi.go index 9279ca8..cfad850 100644 --- a/host/rpi/rpi.go +++ b/host/rpi/rpi.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + /* Package rpi provides Raspberry Pi (including A+/B+) support. The following features are supported on Linux kernel 3.8+ @@ -9,8 +28,8 @@ package rpi import ( - "github.com/kidoman/embd" - "github.com/kidoman/embd/host/generic" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/host/generic" ) var spiDeviceMinor = 0 diff --git a/i2c.go b/i2c.go index 6a5d1ec..a7e83a7 100644 --- a/i2c.go +++ b/i2c.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // I2C support. package embd diff --git a/i2cdriver.go b/i2cdriver.go index e3aac3e..c9d7941 100644 --- a/i2cdriver.go +++ b/i2cdriver.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Generic I²C driver. package embd diff --git a/interface/display/characterdisplay/characterdisplay.go b/interface/display/characterdisplay/characterdisplay.go index ca866d9..fe4f7b0 100644 --- a/interface/display/characterdisplay/characterdisplay.go +++ b/interface/display/characterdisplay/characterdisplay.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Matthew Dale 2015 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + /* Package characterdisplay provides an ease-of-use layer on top of a character display controller. diff --git a/interface/display/characterdisplay/characterdisplay_test.go b/interface/display/characterdisplay/characterdisplay_test.go index 4bd6c39..402d567 100644 --- a/interface/display/characterdisplay/characterdisplay_test.go +++ b/interface/display/characterdisplay/characterdisplay_test.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Matthew Dale 2015 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package characterdisplay import ( diff --git a/interface/keypad/matrix4x3/matrix4x3.go b/interface/keypad/matrix4x3/matrix4x3.go index 6ef984f..f10799f 100644 --- a/interface/keypad/matrix4x3/matrix4x3.go +++ b/interface/keypad/matrix4x3/matrix4x3.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Kunal Powar 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package matrix4x3 allows interfacing 4x3 keypad with Raspberry pi. package matrix4x3 @@ -6,7 +25,7 @@ import ( "sync" "time" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" ) type Key int diff --git a/led.go b/led.go index d9c309f..cb39867 100644 --- a/led.go +++ b/led.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // LED support. package embd diff --git a/leddriver.go b/leddriver.go index 943e9e8..334c7fc 100644 --- a/leddriver.go +++ b/leddriver.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Generic LED driver. package embd diff --git a/motion/servo/servo.go b/motion/servo/servo.go index c0876d2..8e8bd91 100644 --- a/motion/servo/servo.go +++ b/motion/servo/servo.go @@ -1,9 +1,28 @@ +/* + * Copyright (c) Kunal Powar 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package servo allows control of servos using a PWM controller. package servo import ( + "github.com/cfreeman/embd/util" "github.com/golang/glog" - "github.com/kidoman/embd/util" ) const ( diff --git a/pin.go b/pin.go index 4d33252..6ca9c75 100644 --- a/pin.go +++ b/pin.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Pin mapping support. package embd diff --git a/pin_test.go b/pin_test.go index ea1acf5..5da3f31 100644 --- a/pin_test.go +++ b/pin_test.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package embd import "testing" diff --git a/samples/28bjy-48.go b/samples/28bjy-48.go index 456b7db..6cd3c92 100644 --- a/samples/28bjy-48.go +++ b/samples/28bjy-48.go @@ -18,8 +18,8 @@ import ( "os/signal" "time" - "github.com/kidoman/embd" - _ "github.com/kidoman/embd/host/rpi" + "github.com/cfreeman/embd" + _ "github.com/cfreeman/embd/host/rpi" ) func main() { diff --git a/samples/analog.go b/samples/analog.go index 687ecd5..b9620b3 100644 --- a/samples/analog.go +++ b/samples/analog.go @@ -9,9 +9,9 @@ import ( "os/signal" "time" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/analogshort.go b/samples/analogshort.go index 064be32..6cd8954 100644 --- a/samples/analogshort.go +++ b/samples/analogshort.go @@ -6,9 +6,9 @@ import ( "flag" "fmt" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/apa102.go b/samples/apa102.go new file mode 100644 index 0000000..babebeb --- /dev/null +++ b/samples/apa102.go @@ -0,0 +1,45 @@ +/* + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +// +build ignore + +package main + +import ( + "fmt" + + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/controller/apa102" + _ "github.com/cfreeman/embd/host/all" +) + +func main() { + if err := embd.InitSPI(); err != nil { + panic(err) + } + defer embd.CloseSPI() + + spiBus := embd.NewSPIBus(embd.SPIMode0, 0, 8000000, 8, 0) + defer spiBus.Close() + + strip := apa102.New(spiBus, 5) + err := strip.SetLED(0, 255, 0, 0, 31) + if err != nil { + fmt.Printf("ERROR Unable to set LED.") + fmt.Printf("%s", err) + } +} diff --git a/samples/bh1750fvi.go b/samples/bh1750fvi.go index 83e9a72..597b19b 100644 --- a/samples/bh1750fvi.go +++ b/samples/bh1750fvi.go @@ -7,10 +7,10 @@ import ( "fmt" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/sensor/bh1750fvi" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/sensor/bh1750fvi" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/bmp085.go b/samples/bmp085.go index 0fa56ad..2171b64 100644 --- a/samples/bmp085.go +++ b/samples/bmp085.go @@ -7,10 +7,10 @@ import ( "fmt" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/sensor/bmp085" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/sensor/bmp085" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/bmp180.go b/samples/bmp180.go index 845e771..cf2934e 100644 --- a/samples/bmp180.go +++ b/samples/bmp180.go @@ -7,10 +7,10 @@ import ( "fmt" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/sensor/bmp180" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/sensor/bmp180" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/characterdisplay.go b/samples/characterdisplay.go index 7a054aa..a31fff7 100644 --- a/samples/characterdisplay.go +++ b/samples/characterdisplay.go @@ -6,11 +6,11 @@ import ( "flag" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/controller/hd44780" - "github.com/kidoman/embd/interface/display/characterdisplay" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/controller/hd44780" + "github.com/cfreeman/embd/interface/display/characterdisplay" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/fullblinker.go b/samples/fullblinker.go index 7e43b36..42e17e6 100644 --- a/samples/fullblinker.go +++ b/samples/fullblinker.go @@ -11,8 +11,8 @@ import ( "os/signal" "time" - "github.com/kidoman/embd" - _ "github.com/kidoman/embd/host/rpi" + "github.com/cfreeman/embd" + _ "github.com/cfreeman/embd/host/rpi" ) func main() { diff --git a/samples/gpio.go b/samples/gpio.go index b3769eb..d5dbe66 100644 --- a/samples/gpio.go +++ b/samples/gpio.go @@ -6,9 +6,9 @@ import ( "flag" "time" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/gpiodetect.go b/samples/gpiodetect.go index 8bc5f78..d07934a 100644 --- a/samples/gpiodetect.go +++ b/samples/gpiodetect.go @@ -6,9 +6,9 @@ import ( "flag" "time" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/gpiodirect.go b/samples/gpiodirect.go index 85bd22c..de1c965 100644 --- a/samples/gpiodirect.go +++ b/samples/gpiodirect.go @@ -6,9 +6,9 @@ import ( "flag" "time" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/gpiointerrupt.go b/samples/gpiointerrupt.go index 9b6ccc9..211a5b8 100644 --- a/samples/gpiointerrupt.go +++ b/samples/gpiointerrupt.go @@ -6,9 +6,9 @@ import ( "flag" "fmt" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/gpioshort.go b/samples/gpioshort.go index b1c5c2c..5f1a55e 100644 --- a/samples/gpioshort.go +++ b/samples/gpioshort.go @@ -5,9 +5,9 @@ package main import ( "flag" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/hd44780.go b/samples/hd44780.go index 418fa7e..21a51d3 100644 --- a/samples/hd44780.go +++ b/samples/hd44780.go @@ -6,10 +6,10 @@ import ( "flag" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/controller/hd44780" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/controller/hd44780" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/keypad/matrix4x3.go b/samples/keypad/matrix4x3.go index 9b4feda..26b630c 100644 --- a/samples/keypad/matrix4x3.go +++ b/samples/keypad/matrix4x3.go @@ -5,8 +5,8 @@ package main import ( "fmt" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/interface/keypad/matrix4x3" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/interface/keypad/matrix4x3" ) func main() { diff --git a/samples/l3gd20.go b/samples/l3gd20.go index f0a94e6..63692a1 100644 --- a/samples/l3gd20.go +++ b/samples/l3gd20.go @@ -9,10 +9,10 @@ import ( "os/signal" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/sensor/l3gd20" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/sensor/l3gd20" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/led.go b/samples/led.go index 82650d0..18fdb40 100644 --- a/samples/led.go +++ b/samples/led.go @@ -11,9 +11,9 @@ import ( "os/signal" "time" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" - _ "github.com/kidoman/embd/host/bbb" + _ "github.com/cfreeman/embd/host/bbb" ) func main() { diff --git a/samples/ledshort.go b/samples/ledshort.go index 64a01ce..d2b834f 100644 --- a/samples/ledshort.go +++ b/samples/ledshort.go @@ -8,9 +8,9 @@ import ( "flag" "time" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" - _ "github.com/kidoman/embd/host/bbb" + _ "github.com/cfreeman/embd/host/bbb" ) func main() { diff --git a/samples/lsm303.go b/samples/lsm303.go index e4461de..7e41dd7 100644 --- a/samples/lsm303.go +++ b/samples/lsm303.go @@ -7,10 +7,10 @@ import ( "fmt" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/sensor/lsm303" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/sensor/lsm303" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/mcp3008.go b/samples/mcp3008.go index 791d56a..34afe86 100644 --- a/samples/mcp3008.go +++ b/samples/mcp3008.go @@ -8,9 +8,9 @@ import ( "fmt" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/convertors/mcp3008" - _ "github.com/kidoman/embd/host/all" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/convertors/mcp3008" + _ "github.com/cfreeman/embd/host/all" ) const ( diff --git a/samples/mcp4725.go b/samples/mcp4725.go index ad80967..01b7fe0 100644 --- a/samples/mcp4725.go +++ b/samples/mcp4725.go @@ -9,10 +9,10 @@ import ( "os" "os/signal" - "github.com/kidoman/embd" - "github.com/kidoman/embd/controller/mcp4725" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/controller/mcp4725" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/pca9685.go b/samples/pca9685.go index 9976340..cb822f3 100644 --- a/samples/pca9685.go +++ b/samples/pca9685.go @@ -8,10 +8,10 @@ import ( "os/signal" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/controller/pca9685" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/controller/pca9685" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/pwm.go b/samples/pwm.go index cecbc4d..b64b112 100644 --- a/samples/pwm.go +++ b/samples/pwm.go @@ -8,10 +8,10 @@ import ( "flag" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/host/bbb" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/host/bbb" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/servo.go b/samples/servo.go index 2e82dd8..d816e09 100644 --- a/samples/servo.go +++ b/samples/servo.go @@ -8,11 +8,11 @@ import ( "os/signal" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/controller/pca9685" - "github.com/kidoman/embd/motion/servo" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/controller/pca9685" + "github.com/cfreeman/embd/motion/servo" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/servobbb.go b/samples/servobbb.go index fbf0db1..244b036 100644 --- a/samples/servobbb.go +++ b/samples/servobbb.go @@ -8,10 +8,10 @@ import ( "os/signal" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/motion/servo" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/motion/servo" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/servoblaster.go b/samples/servoblaster.go index b2d4cdf..6188d1c 100644 --- a/samples/servoblaster.go +++ b/samples/servoblaster.go @@ -8,10 +8,10 @@ import ( "os/signal" "time" - "github.com/kidoman/embd/controller/servoblaster" - "github.com/kidoman/embd/motion/servo" + "github.com/cfreeman/embd/controller/servoblaster" + "github.com/cfreeman/embd/motion/servo" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/simpleblinker.go b/samples/simpleblinker.go index 9e4f780..f9bea32 100644 --- a/samples/simpleblinker.go +++ b/samples/simpleblinker.go @@ -8,8 +8,8 @@ package main import ( "time" - "github.com/kidoman/embd" - _ "github.com/kidoman/embd/host/rpi" // This loads the RPi driver + "github.com/cfreeman/embd" + _ "github.com/cfreeman/embd/host/rpi" // This loads the RPi driver ) func main() { diff --git a/samples/spi.go b/samples/spi.go index 20d606c..d3801c1 100644 --- a/samples/spi.go +++ b/samples/spi.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // +build ignore package main @@ -5,8 +24,8 @@ package main import ( "fmt" - "github.com/kidoman/embd" - _ "github.com/kidoman/embd/host/all" + "github.com/cfreeman/embd" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/spimcp3008.go b/samples/spimcp3008.go index 394243e..5ac86ed 100644 --- a/samples/spimcp3008.go +++ b/samples/spimcp3008.go @@ -7,8 +7,8 @@ import ( "fmt" "time" - "github.com/kidoman/embd" - _ "github.com/kidoman/embd/host/all" + "github.com/cfreeman/embd" + _ "github.com/cfreeman/embd/host/all" ) const ( diff --git a/samples/tmp006.go b/samples/tmp006.go index 6252b00..354ca3e 100644 --- a/samples/tmp006.go +++ b/samples/tmp006.go @@ -8,10 +8,10 @@ import ( "os" "os/signal" - "github.com/kidoman/embd" - "github.com/kidoman/embd/sensor/tmp006" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/sensor/tmp006" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/universalblinker.go b/samples/universalblinker.go index 190ae1d..6562245 100644 --- a/samples/universalblinker.go +++ b/samples/universalblinker.go @@ -10,8 +10,8 @@ import ( "os/signal" "time" - "github.com/kidoman/embd" - _ "github.com/kidoman/embd/host/all" + "github.com/cfreeman/embd" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/us020.go b/samples/us020.go index f0e7537..b9576e4 100644 --- a/samples/us020.go +++ b/samples/us020.go @@ -9,10 +9,10 @@ import ( "os/signal" "time" - "github.com/kidoman/embd" - "github.com/kidoman/embd/sensor/us020" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/sensor/us020" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/samples/watersensor.go b/samples/watersensor.go index ff4ba8a..ac0267b 100644 --- a/samples/watersensor.go +++ b/samples/watersensor.go @@ -6,11 +6,11 @@ import ( "flag" "time" + "github.com/cfreeman/embd" + "github.com/cfreeman/embd/sensor/watersensor" "github.com/golang/glog" - "github.com/kidoman/embd" - "github.com/kidoman/embd/sensor/watersensor" - _ "github.com/kidoman/embd/host/all" + _ "github.com/cfreeman/embd/host/all" ) func main() { diff --git a/sensor/bh1750fvi/bh1750fvi.go b/sensor/bh1750fvi/bh1750fvi.go index 6903bb8..1bd37ac 100644 --- a/sensor/bh1750fvi/bh1750fvi.go +++ b/sensor/bh1750fvi/bh1750fvi.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2013 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package BH1750FVI allows interfacing with the BH1750FVI ambient light sensor through I2C. package bh1750fvi @@ -5,7 +24,7 @@ import ( "sync" "time" - "github.com/kidoman/embd" + "github.com/cfreeman/embd" ) //accuracy = sensorValue/actualValue] (min = 0.96, typ = 1.2, max = 1.44 diff --git a/sensor/bme280/bme280.go b/sensor/bme280/bme280.go new file mode 100644 index 0000000..e2ea379 --- /dev/null +++ b/sensor/bme280/bme280.go @@ -0,0 +1,387 @@ +/* + * Copyright (c) Clinton Freeman 2016 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +// Package bme280 allows interfacing with Bosch BME280 digital humidity, pressure +// and temperature sensor. +package bme280 + +import ( + "github.com/cfreeman/embd" +) + +const ( + CAL_T1_LSB_REG = 0x88 + CAL_T1_MSB_REG = 0x89 + CAL_T2_LSB_REG = 0x8A + CAL_T2_MSB_REG = 0x8B + CAL_T3_LSB_REG = 0x8C + CAL_T3_MSB_REG = 0x8D + + CAL_P1_LSB_REG = 0x8E + CAL_P1_MSB_REG = 0x8F + CAL_P2_LSB_REG = 0x90 + CAL_P2_MSB_REG = 0x91 + CAL_P3_LSB_REG = 0x92 + CAL_P3_MSB_REG = 0x93 + CAL_P4_LSB_REG = 0x94 + CAL_P4_MSB_REG = 0x95 + CAL_P5_LSB_REG = 0x96 + CAL_P5_MSB_REG = 0x97 + CAL_P6_LSB_REG = 0x98 + CAL_P6_MSB_REG = 0x99 + CAL_P7_LSB_REG = 0x9A + CAL_P7_MSB_REG = 0x9B + CAL_P8_LSB_REG = 0x9C + CAL_P8_MSB_REG = 0x9D + CAL_P9_LSB_REG = 0x9E + CAL_P9_MSB_REG = 0x9F + + CAL_H1_REG = 0xA1 + CAL_H2_LSB_REG = 0xE1 + CAL_H2_MSB_REG = 0xE2 + CAL_H3_REG = 0xE3 + CAL_H4_MSB_REG = 0xE4 + CAL_H4_LSB_REG = 0xE5 + CAL_H5_MSB_REG = 0xE6 + CAL_H6_REG = 0xE7 + + MEASUREMENT_START_REG = 0xF7 + PRESSURE_MSB_IDX = 0 + PRESSURE_LSB_IDX = 1 + PRESSURE_XLSB_IDX = 2 + + TMP_MSB_IDX = 3 + TMP_LSB_IDX = 4 + TMP_XLSB_IDX = 5 + + HUMIDITY_MSB_IDX = 6 + HUMIDITY_LSB_IDX = 7 + + CTRL_MEAS_REG = 0xF4 + CONFIG_REG = 0xF5 + CTRL_HUMIDITY_REG = 0xF2 + RESET_REG = 0xE0 + + //RunMode can be: + // 0, Sleep mode + // 1 or 2, Forced mode + // 3, Normal mode + RunMode = uint8(3) + + //Standby can be: + // 0, 0.5ms + // 1, 62.5ms + // 2, 125ms + // 3, 250ms + // 4, 500ms + // 5, 1000ms + // 6, 10ms + // 7, 20ms + Standby = uint8(0) + + //Filter can be off or number of FIR coefficients to use: + // 0, filter off + // 1, coefficients = 2 + // 2, coefficients = 4 + // 3, coefficients = 8 + // 4, coefficients = 16 + Filter = uint8(0) + + //TempOverSample can be: + // 0, skipped + // 1 through 5, oversampling *1, *2, *4, *8, *16 respectivel + TempOverSample = uint8(1) + + //PressOverSample can be: + // 0, skipped + // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively + PressOverSample = uint8(1) + + //HumidOverSample can be: + // 0, skipped + // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively + HumidOverSample = uint8(1) +) + +type Calibration struct { + T1 uint16 + T2, T3 int16 + + P1, P2, P3, P4, P5, P6, P7, P8, P9 int64 + H1, H2, H3, H4, H5, H6 float64 +} + +type BME280 struct { + Bus embd.I2CBus + Addr byte + + Cal Calibration +} + +func readUInt16(lsb byte, msb byte, bus embd.I2CBus, addr byte) (uint16, error) { + lsbv, err := bus.ReadByteFromReg(addr, lsb) + if err != nil { + return 0, err + } + msbv, err := bus.ReadByteFromReg(addr, msb) + if err != nil { + return 0, err + } + + return (uint16(msbv) << 8) | uint16(lsbv), nil +} + +func readInt16(lsb byte, msb byte, bus embd.I2CBus, addr byte) (int16, error) { + lsbv, err := bus.ReadByteFromReg(addr, lsb) + if err != nil { + return 0, err + } + msbv, err := bus.ReadByteFromReg(addr, msb) + if err != nil { + return 0, err + } + + return (int16(msbv) << 8) | int16(lsbv), nil +} + +// New creates and calibrates a connection to a BME280 sensor on the supplied i2c bus +// at the nominated i2c address. +func New(bus embd.I2CBus, addr byte) (*BME280, error) { + s := &BME280{ + Bus: bus, + Addr: addr, + } + + var err error + var msb, lsb byte + + // Get calibrate information. + s.Cal.T1, err = readUInt16(CAL_T1_LSB_REG, CAL_T1_MSB_REG, bus, addr) + if err != nil { + return s, err + } + + s.Cal.T2, err = readInt16(CAL_T2_LSB_REG, CAL_T2_MSB_REG, bus, addr) + if err != nil { + return s, err + } + + s.Cal.T3, err = readInt16(CAL_T3_LSB_REG, CAL_T3_MSB_REG, bus, addr) + if err != nil { + return s, err + } + + pu, err := readUInt16(CAL_P1_LSB_REG, CAL_P1_MSB_REG, bus, addr) + if err != nil { + return s, err + } + s.Cal.P1 = int64(pu) + + p, err := readInt16(CAL_P2_LSB_REG, CAL_P2_MSB_REG, bus, addr) + if err != nil { + return s, err + } + s.Cal.P2 = int64(p) + + p, err = readInt16(CAL_P3_LSB_REG, CAL_P3_MSB_REG, bus, addr) + if err != nil { + return s, err + } + s.Cal.P3 = int64(p) + + p, err = readInt16(CAL_P4_LSB_REG, CAL_P4_MSB_REG, bus, addr) + if err != nil { + return s, err + } + s.Cal.P4 = int64(p) + + p, err = readInt16(CAL_P5_LSB_REG, CAL_P5_MSB_REG, bus, addr) + if err != nil { + return s, err + } + s.Cal.P5 = int64(p) + + p, err = readInt16(CAL_P6_LSB_REG, CAL_P6_MSB_REG, bus, addr) + if err != nil { + return s, err + } + s.Cal.P6 = int64(p) + + p, err = readInt16(CAL_P7_LSB_REG, CAL_P7_MSB_REG, bus, addr) + if err != nil { + return s, err + } + s.Cal.P7 = int64(p) + + p, err = readInt16(CAL_P8_LSB_REG, CAL_P8_MSB_REG, bus, addr) + if err != nil { + return s, err + } + s.Cal.P8 = int64(p) + + p, err = readInt16(CAL_P9_LSB_REG, CAL_P9_MSB_REG, bus, addr) + if err != nil { + return s, err + } + s.Cal.P9 = int64(p) + + msb, err = bus.ReadByteFromReg(addr, CAL_H1_REG) + if err != nil { + return s, err + } + s.Cal.H1 = float64(msb) + + h2, err := readInt16(CAL_H2_LSB_REG, CAL_H2_MSB_REG, bus, addr) + if err != nil { + return s, err + } + s.Cal.H2 = float64(h2) + + msb, err = bus.ReadByteFromReg(addr, CAL_H3_REG) + if err != nil { + return s, err + } + s.Cal.H3 = float64(msb) + + // H4 and H5 share three registers. + msb, err = bus.ReadByteFromReg(addr, CAL_H4_MSB_REG) + if err != nil { + return s, err + } + lsb, err = bus.ReadByteFromReg(addr, CAL_H4_LSB_REG) + if err != nil { + return s, err + } + s.Cal.H4 = float64((int16(msb) << 4) | int16(lsb)&0x0F) + + msb, err = bus.ReadByteFromReg(addr, CAL_H5_MSB_REG) + if err != nil { + return s, err + } + lsb, err = bus.ReadByteFromReg(addr, CAL_H4_LSB_REG) + if err != nil { + return s, err + } + s.Cal.H5 = float64((int16(msb) << 4) | (int16(lsb)>>4)&0x0F) + + msb, err = bus.ReadByteFromReg(addr, CAL_H6_REG) + if err != nil { + return s, err + } + s.Cal.H6 = float64(msb) + + // Put the sensor in sleep mode and configure. + err = bus.WriteByteToReg(addr, CTRL_MEAS_REG, 0x00) + if err != nil { + return s, err + } + + // Set the config word. + dataToWrite := (Standby << 0x5) & 0xE0 + dataToWrite = dataToWrite | ((Filter << 0x02) & 0x1C) + err = bus.WriteByteToReg(addr, CONFIG_REG, dataToWrite) + if err != nil { + return s, err + } + + dataToWrite = HumidOverSample & 0x07 + err = bus.WriteByteToReg(addr, CTRL_HUMIDITY_REG, dataToWrite) + if err != nil { + return s, err + } + + dataToWrite = (TempOverSample << 0x5) & 0xE0 + dataToWrite = dataToWrite | ((PressOverSample << 0x02) & 0x1C) + dataToWrite = dataToWrite | (RunMode & 0x03) + err = bus.WriteByteToReg(addr, CTRL_MEAS_REG, dataToWrite) + if err != nil { + return s, err + } + + _, err = bus.ReadByteFromReg(s.Addr, 0xD0) + return s, err +} + +func (s *BME280) fineT(d []byte) int32 { + adcT := int32((uint32(d[TMP_MSB_IDX])<<12)|(uint32(d[TMP_LSB_IDX])<<4)) | ((int32(d[TMP_XLSB_IDX]) >> 4) & 0x0F) + + var1 := (((adcT >> 3) - (int32(s.Cal.T1) << 1)) * (int32(s.Cal.T2))) >> 11 + var2 := (((((adcT >> 4) - (int32(s.Cal.T1))) * ((adcT >> 4) - (int32(s.Cal.T1)))) >> 12) * (int32(s.Cal.T3))) >> 14 + + return (var1 + var2) +} + +// Reads all measurements from the sensor. Call Humidity, Pressure or Temperature to retrieve calibrated readings. +func (s *BME280) Measurements() ([]byte, error) { + buf := make([]byte, 8) + err := s.Bus.ReadFromReg(s.Addr, MEASUREMENT_START_REG, buf) + + return buf, err +} + +// Humdity returns the relative humidity from the supplied measurements. Output value of "46.332" represents 46.332 %rH. +func (s *BME280) Humidity(d []byte) float64 { + fineT := s.fineT(d) + adcH := (uint16(d[HUMIDITY_MSB_IDX]) << 8) | uint16(d[HUMIDITY_LSB_IDX]) + + varH := float64(fineT) - 76800.0 + varH = (float64(adcH) - (s.Cal.H4*64.0 + s.Cal.H5/16384.0*varH)) * + (s.Cal.H2 / 65536.0 * (1.0 + s.Cal.H6/67108864.0*varH*(1.0+s.Cal.H3/67108864*varH))) + varH = varH * (1.0 - s.Cal.H1*varH/524288.0) + if varH > 100.0 { + varH = 100.0 + } else if varH < 0.0 { + varH = 0.0 + } + + return varH +} + +// Returns the pressure in Pascals from the supplied measurements. A value of "96386.2" equals 963.862 hPa. +func (s *BME280) Pressure(d []byte) float64 { + fineT := s.fineT(d) + + adcP := int32((uint32(d[PRESSURE_MSB_IDX])<<12)| + (uint32(d[PRESSURE_LSB_IDX])<<4)) | + ((int32(d[PRESSURE_XLSB_IDX]) >> 4) & 0x0F) + + var1 := int64(fineT) - 128000 + var2 := var1 * var1 * s.Cal.P6 + var2 = var2 + (var1 * s.Cal.P5 << 17) + var2 = var2 + (s.Cal.P4 << 35) + var1 = (var1 * var1 * s.Cal.P3 >> 8) + (var1 * s.Cal.P2 << 12) + var1 = ((int64(1) << 47) + var1) * s.Cal.P1 >> 33 + if var1 == 0 { + return 0 // avoid exception caused by division by zero + } + p_acc := 1048576 - int64(adcP) + p_acc = (((p_acc << 31) - var2) * 3125) / var1 + var1 = (s.Cal.P9 * (p_acc >> 13) * (p_acc >> 13)) >> 25 + var2 = (s.Cal.P8 * p_acc) >> 19 + p_acc = ((p_acc + var1 + var2) >> 8) + (s.Cal.P7 << 4) + + p_acc = p_acc >> 8 // /256 + return float64(p_acc) +} + +// Temperature returns the temperature in Degrees Celcius from the supplied measurements. Output value of "30.33" equals 30.33°C. +func (s *BME280) Temperature(d []byte) float64 { + fineT := s.fineT(d) + return (float64(fineT) / 5120.0) +} diff --git a/sensor/bmp085/bmp085.go b/sensor/bmp085/bmp085.go index b58b37b..4b84e12 100644 --- a/sensor/bmp085/bmp085.go +++ b/sensor/bmp085/bmp085.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2013 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package bmp085 allows interfacing with Bosch BMP085 barometric pressure sensor. This sensor // has the ability to provided compensated temperature and pressure readings. package bmp085 @@ -7,8 +26,8 @@ import ( "sync" "time" + "github.com/cfreeman/embd" "github.com/golang/glog" - "github.com/kidoman/embd" ) const ( diff --git a/sensor/bmp180/bmp180.go b/sensor/bmp180/bmp180.go index fdc46f3..ef4f694 100644 --- a/sensor/bmp180/bmp180.go +++ b/sensor/bmp180/bmp180.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package bmp180 allows interfacing with Bosch BMP180 barometric pressure sensor. This sensor // has the ability to provided compensated temperature and pressure readings. package bmp180 @@ -7,8 +26,8 @@ import ( "sync" "time" + "github.com/cfreeman/embd" "github.com/golang/glog" - "github.com/kidoman/embd" ) const ( diff --git a/sensor/l3gd20/l3gd20.go b/sensor/l3gd20/l3gd20.go index c3ad94a..d0bf892 100644 --- a/sensor/l3gd20/l3gd20.go +++ b/sensor/l3gd20/l3gd20.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package l3gd20 allows interacting with L3GD20 gyroscoping sensor. package l3gd20 @@ -7,8 +26,8 @@ import ( "sync" "time" + "github.com/cfreeman/embd" "github.com/golang/glog" - "github.com/kidoman/embd" ) const ( diff --git a/sensor/lsm303/lsm303.go b/sensor/lsm303/lsm303.go index 583a0a8..6637b2a 100644 --- a/sensor/lsm303/lsm303.go +++ b/sensor/lsm303/lsm303.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2013 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package lsm303 allows interfacing with the LSM303 magnetometer. package lsm303 @@ -6,8 +25,8 @@ import ( "sync" "time" + "github.com/cfreeman/embd" "github.com/golang/glog" - "github.com/kidoman/embd" ) const ( diff --git a/sensor/tmp006/tmp006.go b/sensor/tmp006/tmp006.go index 842204b..cce81f4 100644 --- a/sensor/tmp006/tmp006.go +++ b/sensor/tmp006/tmp006.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package tmp006 allows interfacing with the TMP006 thermopile. package tmp006 @@ -8,8 +27,8 @@ import ( "sync" "time" + "github.com/cfreeman/embd" "github.com/golang/glog" - "github.com/kidoman/embd" ) const ( diff --git a/sensor/us020/us020.go b/sensor/us020/us020.go index b7d400a..78609de 100644 --- a/sensor/us020/us020.go +++ b/sensor/us020/us020.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Nikesh Vora 2013 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package us020 allows interfacing with the US020 ultrasonic range finder. package us020 @@ -5,8 +24,8 @@ import ( "sync" "time" + "github.com/cfreeman/embd" "github.com/golang/glog" - "github.com/kidoman/embd" ) const ( diff --git a/sensor/watersensor/watersensor.go b/sensor/watersensor/watersensor.go index c83628e..890c7ac 100644 --- a/sensor/watersensor/watersensor.go +++ b/sensor/watersensor/watersensor.go @@ -1,11 +1,30 @@ +/* + * Copyright (c) Kashyap Kopparam 2013 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // Package watersensor allows interfacing with the water sensor. package watersensor import ( "sync" + "github.com/cfreeman/embd" "github.com/golang/glog" - "github.com/kidoman/embd" ) // WaterSensor represents a water sensor. diff --git a/spi.go b/spi.go index db5b029..4372d2b 100644 --- a/spi.go +++ b/spi.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Kunal Powar 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + // SPI support. package embd diff --git a/spidriver.go b/spidriver.go index a145155..3e6915b 100644 --- a/spidriver.go +++ b/spidriver.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Kunal Powar 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package embd import "sync" diff --git a/update_contributors.sh b/update_contributors.sh deleted file mode 100755 index 1446108..0000000 --- a/update_contributors.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -git log --all --format='%cN <%cE>' | sort -u | grep -v karan.misra@gmail.com |\ - grep -v noreply@ | cat CONTRIBUTORS - | sort | uniq > CONTRIBUTORS.new -mv CONTRIBUTORS.new CONTRIBUTORS diff --git a/util/map_test.go b/util/map_test.go index 949364b..dbcd402 100644 --- a/util/map_test.go +++ b/util/map_test.go @@ -1,3 +1,22 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + package util import "testing" diff --git a/utils.go b/utils.go index a2e0c32..797a105 100644 --- a/utils.go +++ b/utils.go @@ -1,3 +1,21 @@ +/* + * Copyright (c) Karan Misra 2014 + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ package embd import "path/filepath"