Compare commits

...

99 Commits

Author SHA1 Message Date
58c800e246 upm: version 0.3.2
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-12 17:03:58 -07:00
48a8d3e0cc cmake: fixed IPK version tag
Broken when RPM support was added and incompatible with current IPK naming strings

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-12 14:07:46 -07:00
1fe9b9eb1d docs: final batch of header files reviewed
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-12 14:03:08 -07:00
04edb9be04 docs: more header files edited
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-12 12:21:16 -07:00
55e8076988 eboled: Initial implementation
This driver supports the Sparkfun 64x48 pixel OLED Edison block:

https://www.sparkfun.com/products/13035

It is based on an ssd1306, but with some modifications (custom COM pin
mapping and a custom column offset).  It uses SPI to communicate, and
since it is an Edison Block, you don't really have any options for
different bus and pin assignments.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-12 11:20:14 -07:00
9db2d57de3 docs: header files for sensors starting with [a] reviewed.
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-07 13:57:52 -07:00
de49bb0e42 docs: removed mpu9150 from list of known limitations and added bmp180
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-06 17:27:09 -07:00
93595bcd35 adafruitss: removed ambiguous servo() overload
Overload is unnecessary and SWIG can't handle overloads with the same number of arguments
thus it would break the js and py bindings

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-05 11:55:47 -07:00
7260c78c33 adafruitss: fix the period setting in setPWMFreq()
Tweak the fudge factor so it is more accurate for 50Hz and 60Hz periods. (Tested on Logic 4 and it is spot on now)
Get rid of compiler warnings when -Wall is set
Allow for float angle to be passed into the servo() method for more accurate positioning

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-05 11:16:06 -07:00
197b56003c lcd: jhd1313m1 example: sleep a bit so we can see the display
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-05 11:13:31 -07:00
f133b6eb4c lcd: jhd1313m1: rewrite to use Lcm1602 as a base class
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-05 11:13:23 -07:00
cb62f06197 lcd: lcm1602: modifications for eventual use as a base class for jhd1313m1
We add a new bool isExpander to the the I2C constructor.  This allows
us (in the case we are not dealing with an expander) to just
initialize the i2c context only and bail in the constructor.  The
default is true to preserve backward compatibility.

Additionally, add two new virtual protected methods, data() and
command() for sending data or commands to the controller.  The default
implementation in lcm1602 will work for 4bit GPIO and expander use.

In the case of jhd1313m1, they will need to be redefined in that class
as the sematics for sending data and commands are different.

All of the underlying functionality will use command() or data() as
appropriate.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-05 11:13:15 -07:00
a2e4fb5d7a lcd: add missing functionality to lcm1602
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-05 11:13:00 -07:00
36b0e1dce0 lsm9ds0: Initial implementation
This module implements support for the LSM9DS0 accelerometer,
magnetometer, and gyroscope.

It was developed on the Sparkfun 9DOF sensor block for Intel Edison.

https://www.sparkfun.com/products/13033

Commonly used capabilities are supported, and methods/register
definitions exist to easily implement any desired functionality that
is missing.  Interrupt support has also been added.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-08-04 15:56:25 -07:00
03e72e02f8 mpu9150: rewrite from scratch
This driver has been rewritten from scratch.  It is implemented as 3
seperate drivers now (but all included as part of the mpu9150 UPM
library):

AK8975 (Magnetometer)
MPU60X0 (Accelerometer, Gyroscope, and Temperature sensor)
MPU9150 (composed of AK8975 and MPU60X0)

Each driver can be used independently and includes examples in
C++/JS/Python.

Commonly used capabilities are supported, and methods/register
definitions exist to easily implement any desired functionality that
is missing.  Interrupt support has also been added.

Scaling support has also been properly implemented for both the
Accelerometer and Gyroscope.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-29 13:25:05 -07:00
6613dea552 cmake: adds option to use different lib&class names with python docs
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-22 11:48:17 -07:00
ef173ebeaf sainsmartks: Initial Implementation
This driver was developed with a Sainsmart LCD Keypad Shield.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:38:52 -07:00
5a6fb122ec lcm1602: add 4-bit gpio support with RS and Enable pins
In addition, move the command/data sending methods into the protected
block so that derived classes can use them if need be.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:38:01 -07:00
8462e8ce52 jhd1313m1: add createChar() method, as it should be supported by this device
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:37:06 -07:00
1647f572ff lcd: remove i2c context from LCD base class
This commit removes the I2C context from the LCD base class and moves
it into each of the drivers.

In addition, the createChar() virtual function was removed from the
base class, as it directly used the now non-existant i2c context, and
it would not work on anything other than hd44780 based controllers and
displays anyway. Also, it is likely the capability itself, as well as
the data required to implement it, is going to be different from
device to device.

createChar() has been added to the Lcm1602 driver which can support it.

While doing this work, the LCD base class m_name is now set appropriately
in the driver constructors.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:36:09 -07:00
56f7e97536 lcd: move the hd44780 controller bit definitions into a separate header
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:35:09 -07:00
3aaafdcecf lcd: rename I2CLcd class to LCD
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:34:13 -07:00
99651d2239 lcd: rename i2clcd.{h,cxx} to lcd.{h,cxx}
We keep the same upm module library name (i2clcd), and the header
documentation still specifies @library i2clcd.

These will need to be changed when the actual library is renamed.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 17:33:15 -07:00
c586cd5177 pn532: initial implementation
This driver was written using an Adafruit PN532 board:

http://www.adafruit.com/products/364

It is based heavily on their arduino code, with significant
modifications.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Zion Orent <zorent@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-21 16:29:58 -07:00
fc3a884024 cmake: tweaked RPM generation and made arch detection global
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-20 11:59:55 -07:00
a91f1e5095 cmake: enabled RPM packaging
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-17 16:46:23 -07:00
2314bc2f59 grovecircularled: updated description
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-10 17:10:14 -07:00
af2281057a ht9170: added image for DTMF shield
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-10 17:02:25 -07:00
e85c98062b adxl335: added image for adxl335
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-10 17:00:18 -07:00
c1cde01424 lol: added image for lol shield
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-10 16:57:43 -07:00
54cda32a94 waterlevel: updated description and few changes to header
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-10 16:53:00 -07:00
2e36b8dc21 images: Added few images and modified few header files
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2015-07-08 11:46:30 -07:00
f4a5c9a391 hp20x: Initial implementation
This module implements support for the hp20x family of high accuracy
barometers.  It was developed on the Grove Barometer (High Accuracy)
based on the HP206C.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-07-06 15:19:18 -07:00
08ff50067a hcsr04: Fixed compilation error after MRAA enum renaming
Closes #214.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
2015-07-06 18:45:27 +02:00
cff584d8b9 docs: implement broken link fix in cmake configuration file instead
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 14:15:04 -07:00
abb9c91320 revert: "docs: fix for broken index image links after move"
This reverts commit a03d0c7e95.
Fix can be implemented easier in cmake configuration instead.
2015-06-29 14:00:57 -07:00
a03d0c7e95 docs: fix for broken index image links after move
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 13:31:31 -07:00
231a1f1b43 rgbringcoder: Initial implementation.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 10:28:13 -07:00
c313e3ae69 grovecircularled: Initial import/implementation
This code is based off ofthe my9221 driver.  This modification was
done by Jun Kato, but abandoned.

This driver will not work correctly on Galileo.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 10:02:53 -07:00
f2503c6167 cmake: Change error message when git not found to say UPM
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 09:41:05 -07:00
7a7b8324b4 at42qt1070: fix invalid assignment
Signed-off-by: Wouter van Verre <wouter.van.verre@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 09:36:23 -07:00
057fa03723 at42qt1070: Add additional functionality
Add functionality to read and set the low-power mode settings
Add functions to read and set the averaging factor per key
Add functions to read and set the adjecent key suppression (AKS) groups
Add a function to read the ID register
Add a sanity check to the constructor

Signed-off-by: Wouter van Verre <wouter.van.verre@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 09:36:01 -07:00
f64c710c12 at42qt1070: code style changes
Run .clang-format on the header and source files
Add missing braces

Signed-off-by: Wouter van Verre <wouter.van.verre@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-29 09:35:41 -07:00
32921ff2b1 upm: updated headers of sensors in home automation kit
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-24 13:39:09 -07:00
6c7928fc92 upm: updated headers of sensors in environmental kit
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-24 13:25:29 -07:00
fd29a7409e upm: added kit tags to @ingroup too
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-24 13:16:52 -07:00
61c95088af upm: updated headers of sensors in transportation kit
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 16:47:11 -07:00
24bda4741c upm: updated headers of sensors in robotics kit
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 16:35:50 -07:00
172124f20a mhz16: fixed connection type in @ingroup
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 12:03:07 -07:00
17dbadfe9f grovescam: fixed tag names in header
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 11:18:03 -07:00
e71ae67b4e hm11: updated header tag names and new @altid tag
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 11:13:02 -07:00
e00ee9b777 a110x: updated header with new @altid tag
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 10:52:56 -07:00
0f015354ef doxygen: new @altid tag for sensors supporting multiple chip variants
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-23 10:50:26 -07:00
3ed6e09f20 changelog: added sensors to the list for the latest versions
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-19 11:59:53 -07:00
0dbfa06359 jhd1313m1: modified destructor to clear and turn off lcd on delete
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-16 17:02:21 -07:00
2fda38f7b1 i2clcd: added virtual destructor to base lcd class
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-16 16:48:27 -07:00
ec1828f2bc changelog: rephrased an item from the list
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-16 12:15:45 -07:00
3e6ec5087b docs: made a few modifications in known limitations, changelog and building instructions
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-16 11:58:00 -07:00
a3b4d466d7 docs: moved API images used on links to their own subfolder
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-12 13:46:24 -07:00
1ddd325e18 images: added CC BY-NC-SA 3.0 license file for Sparkfun images
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-12 11:36:36 -07:00
3d453811fb upm: update to version 0.3.1
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 12:35:00 -07:00
67b0b9b219 joystick12: fixed typo in library display name
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 11:02:28 -07:00
502b928aff adis16448: fixed typo in library display name
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 11:01:05 -07:00
a9cb0718fe hm11: example: make sure buffer is 0 terminated
defect 4374

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:56:28 -07:00
a1dac4228a tm1637: example: avoid buffer overflow and possible NULL derefs
defects 398, 399

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:55:55 -07:00
6e2587576d stepmotor: various functions should return a value
defects 386, 387

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:55:22 -07:00
f8179328cf ssd1327: various functions should return values
defects 377, 378, 379, 380

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:54:50 -07:00
dae5c67c02 ssd1327-oled: main should return a value
defect 376

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:54:18 -07:00
eb2ff59fe5 ssd1308: writeChar(), setAddressingMode() should return a value
defect #373, 374

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:53:45 -07:00
b36eb487eb ssd1308: example main() should return 0
defect #371

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:53:14 -07:00
bc61e9f86b servo: return a value in setAngle()
defect #356

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:52:42 -07:00
61175740f6 pulsensor: do_sample needs to return a value (NULL)
defect #346

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:52:09 -07:00
a41f59984f otp538u: searching otp538u_vt_table could overflow array bounds
defect #341

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:51:35 -07:00
0bab36a95a mpu9150: getData() does not return a value
defect #242

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:51:00 -07:00
ff88313462 lcm1602: example main() should return 0
defect #200

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:50:25 -07:00
3f5c357971 jhd1313m1: example main() should return 0
defect #194

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:49:50 -07:00
d2e11d6f11 itg3200: calibrate() doesn't return anything
defect #191

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:49:17 -07:00
3e82dd8d0a lcd: return a proper value in write()
defect #156

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:48:43 -07:00
4f5030ecf7 htu21d: declare resetSensor() as void
defect #148

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:47:54 -07:00
784e8a3eb8 hmtrp: example: make sure string read is 0 terminated
defect #146

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:46:49 -07:00
7fbe71102a adafruitss: initialize duration
defect #25

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:45:40 -07:00
6f34162ac5 pca9685: enableRestart() does not return anything, so make it void
fixes defect #21

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-11 10:44:05 -07:00
46ab65a344 images: Added few more images and updated corresponding header files
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2015-06-10 20:55:42 -07:00
d8cf4c82a5 docs: changed landing page links for c/c++ documentation to sensors page
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-09 11:42:18 -07:00
ab14f4f82e images: added few sparkfun images and updated respective license info
Signed-off-by: sisinty sasmita patra <sisinty.s.patra@intel.com>
2015-06-05 11:10:45 -07:00
56cbeb6183 flex: added Sparkfun image and updated license info
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-04 16:51:07 -07:00
6efe6916ba docs: modified index pages for documentation to link to samples repo
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-04 15:16:25 -07:00
ea544e8391 yuidoc: formated main.css style file and added missing semicolons
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-04 12:59:57 -07:00
0c46dd28be yuidoc: updated generators and templates to fix IE sidebar issue
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-04 10:31:38 -07:00
d493c015fd sphinx: inserted links to other language APIs
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-03 15:57:16 -07:00
1e3797ec48 yuidoc: added custom index file for node documentation and fixed image links
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-03 15:36:56 -07:00
6effb25bd6 cmake: changed to generic way to copy png files for documentation links
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-03 12:11:16 -07:00
796f188cb3 upm: updated year in license file
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-03 12:02:36 -07:00
e0bc9573d4 docs: updated links to documentation pages from readme.md and for porting example
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-03 11:58:13 -07:00
5733918a2f m24lr64e: Initial Implementation
This module was developed and tested on the Grove NFC Tag.  It is an
8KB EEPROM accessable (with various protection capabilites) via I2C
and NFC capable devices.

The code was based on the Seeed Studio example code with some help
from the datasheet.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-03 09:58:55 -07:00
6740932c47 sphinx: small changes to index and added link to node documentation
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-03 09:32:05 -07:00
9fb0ca3466 cmake: fixed indentation and V8 version string
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-02 13:55:59 -07:00
d6ce082274 uart: result of mraa_uart_get_dev_path is a const
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-02 09:52:24 -07:00
3587162611 bmpx8x: Fix typo BPM -> BMP
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2015-06-02 09:51:20 -07:00
282 changed files with 16104 additions and 3532 deletions

View File

@ -15,7 +15,7 @@ find_package (PkgConfig REQUIRED)
# force a libmraa search and minimum required version every time a config is generated
unset(MRAA_FOUND CACHE)
pkg_check_modules (MRAA REQUIRED mraa>=0.6.0)
pkg_check_modules (MRAA REQUIRED mraa>=0.6.2)
message (INFO " found libmraa version: ${MRAA_VERSION}")
# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
@ -29,8 +29,8 @@ include(GNUInstallDirs)
include (GetGitRevisionDescription)
git_describe (VERSION "--tags")
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
message (WARNING " - Install git to compile a production libmraa!")
set (VERSION "v0.3.0-dirty")
message (WARNING " - Install git to compile a production UPM!")
set (VERSION "v0.3.2-dirty")
endif ()
message (INFO " - UPM Version ${VERSION}")
@ -53,18 +53,28 @@ set (upm_VERSION_STRING ${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_
set (CMAKE_SWIG_FLAGS "")
option (IPK "Generate IPK using CPack" OFF)
option (BUILDDOC "Build all doc." OFF)
option (BUILDSWIG "Build swig modules." ON)
option (BUILDSWIGPYTHON "Build swig python modules." ON)
option (BUILDSWIGNODE "Build swig node modules." ON)
option (BUILDEXAMPLES "Build C++ example binaries" OFF)
option (IPK "Generate IPK using CPack" OFF)
option (RPM "Generate RPM using CPack" OFF)
# detect arch
include (TargetArch)
target_architecture (DETECTED_ARCH)
message( INFO " - Target arch is ${DETECTED_ARCH}")
if (BUILDDOC)
# add a target to generate API documentation with Doxygen
find_package (Doxygen)
if (DOXYGEN_FOUND)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
file(GLOB PNG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/docs docs/icons/*.png)
foreach(PNG_FILE ${PNG_FILES})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/${PNG_FILE} ${CMAKE_CURRENT_BINARY_DIR}/html/docs/${PNG_FILE} COPYONLY)
endforeach()
add_custom_target (doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
@ -90,7 +100,7 @@ if (BUILDDOC)
# todo: use a separate cmake FILE module for string replacement instead
COMMAND ${SPHINX_EXECUTABLE} -b html pydoc html/python
COMMAND sed -i.bak s|\">pyupm_|\">|g html/python/index.html html/python/modules.html
COMMAND sed -i.bak s|[[:space:]]module</a>|</a>|g html/python/index.html html/python/modules.html
COMMAND sed -i.bak s|[[:space:]][mM]odule</a>|</a>|g html/python/index.html html/python/modules.html
DEPENDS doc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Sphinx" VERBATIM
@ -106,7 +116,7 @@ if (BUILDDOC)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxy/node/${JSDOC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${JSDOC_FILE} COPYONLY)
endforeach()
add_custom_target(jsdoc ALL
COMMAND ${NODE_EXECUTABLE} docgen -m upm -i xml -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../../../docs/images/
COMMAND ${NODE_EXECUTABLE} docgen -m upm -i xml -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../
COMMAND ${YUIDOC_EXECUTABLE} -C --no-sort --helpers generators/yuidoc/helper.js --themedir generators/yuidoc/tmpl -o html/node jsdoc/yuidoc/upm
COMMAND ${NODE_EXECUTABLE} tolower -i html/node
DEPENDS doc
@ -117,10 +127,7 @@ if (BUILDDOC)
endif()
if (IPK)
include (TargetArch)
target_architecture (DETECTED_ARCH)
message( INFO " - Target arch is ${DETECTED_ARCH}")
message (INFO " - IPK packaging enabled for ${DETECTED_ARCH}")
set(CPACK_GENERATOR "DEB" "TGZ")
set(OPKG_ARCH ${DETECTED_ARCH})
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
@ -143,6 +150,28 @@ if (IPK)
include (CPack)
endif()
if (RPM)
message (INFO " - RPM packaging enabled for ${DETECTED_ARCH}")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_GENERATOR "RPM")
set(CPACK_PACKAGE_NAME "libupm${upm_VERSION_MAJOR}")
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_VERSION
"${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}-${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
set(CPACK_PACKAGE_CONTACT "Intel IoT-Devkit")
set(CPACK_PACKAGE_VENDOR "Intel IoT-Devkit")
set(CPACK_RPM_PACKAGE_REQUIRES "libmraa0 >= ${MRAA_VERSION}")
set(CPACK_RPM_PACKAGE_PROVIDES "${CPACK_PACKAGE_NAME}-devel")
EXECUTE_PROCESS(COMMAND rpm --showrc
COMMAND grep -E "dist[[:space:]]*\\."
COMMAND sed -e "s/^.*dist\\s*\\.//"
COMMAND tr \\n \\t
COMMAND sed -e s/\\t//
OUTPUT_VARIABLE DIST_TAG)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${DIST_TAG}.${DETECTED_ARCH}")
include(CPack)
endif()
add_subdirectory (src)
if(BUILDEXAMPLES)

View File

@ -1,4 +1,4 @@
Copyright © 2014 Intel Corporation
Copyright © 2014-2015 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@ -23,6 +23,9 @@ may also create more complex structures in order to interface with them.
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples).
Multi-sensor samples for the starter and specialized kits can be found in the
[iot-devkit-samples](https://github.com/intel-iot-devkit/iot-devkit-samples) repository.
### Supported Sensors
Supported [sensor list](http://iotdk.intel.com/docs/master/upm/modules.html) from API documentation.
@ -57,10 +60,16 @@ Make sure you add yourself as an author on every new code file submitted.
If you are providing a fix with significant changes, feel free to add yourself
as a contributor. Signing-off your commits is mandatory.
C/C++ API Documentation
API Documentation
==============
The C/C++ documentation is available [here](http://iotdk.intel.com/docs/master/upm/).
@htmlonly
<a href="http://iotdk.intel.com/docs/master/upm/modules.html"><img src="docs/icons/c++.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/icons/python.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/icons/node.png"/></a>
@endhtmlonly
Version @ref changelog [here](docs/changelog.md).

View File

@ -38,6 +38,7 @@ if (NODE_EXECUTABLE)
set (V8_VERSION_STRING ${_V8_VERSION})
string (REPLACE "." ";" _V8_VERSION_LIST "${_V8_VERSION}")
string (REPLACE "." "" V8_DEFINE_STRING "${_V8_VERSION}")
string (STRIP ${V8_DEFINE_STRING} V8_DEFINE_STRING)
list (GET _V8_VERSION_LIST 0 V8_VERSION_MAJOR)
list (GET _V8_VERSION_LIST 1 V8_VERSION_MINOR)
list (GET _V8_VERSION_LIST 2 V8_VERSION_PATCH)
@ -49,8 +50,8 @@ if (NODE_EXECUTABLE)
set (NODE_VERSION_MINOR "10")
set (NODE_VERSION_PATCH "30")
set (V8_VERSION_MAJOR "3")
set (V8_VERSION_MAJOR "14")
set (V8_VERSION_MAJOR "5")
set (V8_VERSION_MINOR "28")
set (V8_VERSION_PATCH "72")
set (V8_VERSION_STRING "3.28.72")
message ("defaulted to node 0.10.30")
endif ()

View File

@ -3,8 +3,7 @@ Building UPM {#building}
UPM uses cmake in order to make compilation relatively painless. Cmake runs
build out of tree so the recommended way is to clone from git and make a build/
directory. Failure to do an out-of-source build may cause issues when
rebuilding later on.
directory.
This project depends on libmraa, so that needs to be installed first. Use the
following environment variables to configure the paths:
@ -25,7 +24,8 @@ make install
~~~~~~~~~~~~~
The last command will create the include/ and lib/ directories with a copy of
the headers and library objects respectively in your build location.
the headers and library objects respectively in your build location. Note that
doing an out-of-source build may cause issues when rebuilding later on.
Our cmake configure has a number of options, *cmake-gui* or *ccmake* can show
you all the options. The interesting ones are detailed below:
@ -61,7 +61,11 @@ Setting the python library to use:
~~~~~~~~~~~~~
Building doxygen doc
~~~~~~~~~~~~~
-BUILDDOC=ON
-DBUILDDOC=ON
~~~~~~~~~~~~~
Build C++ example binaries
~~~~~~~~~~~~~
-DBUILDEXAMPLES=ON
~~~~~~~~~~~~~
If you intend to turn on all the options and build everything at once (C++,

View File

@ -4,15 +4,38 @@ Changelog {#changelog}
Here's a list summarizing some of the key undergoing changes to our library
from earlier versions:
### v0.3.2
* Introduced RPM package generation feature from cmake via cpack
* Performed a thorough documentation review and merged resulting changes,
includes last remaining images and grouping sensors by kits
* Added support for Sparkfun Sensor Blocks (OLED & IMU)
* Fully reworked API for at42qt1070, mpu9150 and lcd classes, while
maintaining backwards compatibility for existing lcd displays.
* Extended doxygen tags for better integration with automated documentation
generators
* New sensors: rgbringcoder, hp20x, pn532, sainsmartks, lsm9ds0, eboled
### v0.3.1
* Updated index pages for API documentation and cross-linked them
* More images were added for Grove, Adafruit and Sparkfun sensors along with
licensing information
* Applied a set of patches to improve code robustness
* Added support for Grove NFC Tag sensor
* Fixed several typos in library and sensor names
* New sensor: m24lr64e
### v0.3.0
* New CMake targets to build python and node documentation with Sphinx and
Yuidoc
* Provided automated, updated and comprehensive sensor API documentation for
C++, Python and JavaScript
* Edited sensor names, library descriptions and doxygen tags for consistency
* Added support for several new sensors
* Fixed the TH02 sensor driver and made major improvements to i2clcd driver
* Updated and added new images for a lot of the existing sensors
* Added this changelog
* Added new and updated images for numerous new and existing sensors
* Started this changelog
* New sensors: sx6119, si114x, maxsonarez, hm11, ht9170, h3lis331dl, ad8232,
grovescam
### v0.2.0
@ -23,6 +46,10 @@ from earlier versions:
* Fixed the buzzer and servo drivers for the Intel Edison
* Renamed bmp and gp2y sensor classes to be more generic
* Completely revamped implementation for tm1637
* New sensors: mma7660, cjq4435, adxl335, hmtrp, nunchuck, otp538u, l298,
groveelectromagnet, grovecollision, adis16448, at42qt1070, grovemd, ina132,
grovegsr, groveo2, groveemg, pca9685, pca9685ss, adafruitms1438, hx711, flex,
groveeldriver, mhz16, apds9002, waterlevel, zfm20, uln200xa, grovewfs, isd1820
### v0.1.9
@ -31,6 +58,12 @@ from earlier versions:
* Several examples and documentation updates submitted
* Wrote new proper SWIG typemaps for arrays
* Fixed the i2clcd write function, improved several other sensors
* New sensors: rpr220, rotaryencoder, biss0001, rfr359f, grovespeaker, mq303a,
ppd42ns, wt5001, yg1006, ublox6, mpr121, groveloudness, guvas12d, grovewater,
grovevdiv, grovelinefinder, ta12200, groveehr, grovemoisture, gp2y0a, a110x,
ds1307, adc121c021, enc03r, ttp223, itg3200, am2315, tp401, ldt0028, htu21d,
mpl3115a2, lsm303, joystick12, tsl2561, groverotary, groveslider, adxl345,
grovebutton, lol, groverelay
### v0.1.8

View File

@ -28,6 +28,7 @@ Here's an example (disregard the "@verbatim" tags in your actual code):
* @sensor <chip-id>
* @comname <component-name>
* @altname <alt-name>
* @altid <alt-id>
* @type <component-category>
* @man <component-manufacturer>
* @web <component-weblinks>
@ -52,8 +53,8 @@ Here's an example (disregard the "@verbatim" tags in your actual code):
available or relevant, use a unique descriptor that makes sense. *Mandatory*
- `<component-name>` A short name for your sensor, can include manufacturer
name. *Mandatory*
- `<alt-name>` Alternative names or chip-ids that your sensor driver might
have or support respectively. *Optional*
- `<alt-name>` Alternative names that your sensor driver might have. *Optional*
- `<alt-id>` Alternative chip-ids that your sensor driver supports. *Optional*
- `<component-category>` Mention one or more categories the sensor fits in. Can
be 'other'. *Mandatory*
- `<component-manufacturer>` Sensor manufacturer. Can be 'generic'. *Mandatory*

BIN
docs/icons/c++.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
docs/icons/node.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
docs/icons/python.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,361 @@
Creative Commons Legal Code
Attribution-NonCommercial-ShareAlike 3.0 Unported
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
DAMAGES RESULTING FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and
other pre-existing works, such as a translation, adaptation,
derivative work, arrangement of music or other alterations of a
literary or artistic work, or phonogram or performance and includes
cinematographic adaptations or any other form in which the Work may be
recast, transformed, or adapted including in any form recognizably
derived from the original, except that a work that constitutes a
Collection will not be considered an Adaptation for the purpose of
this License. For the avoidance of doubt, where the Work is a musical
work, performance or phonogram, the synchronization of the Work in
timed-relation with a moving image ("synching") will be considered an
Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as
encyclopedias and anthologies, or performances, phonograms or
broadcasts, or other works or subject matter other than works listed
in Section 1(g) below, which, by reason of the selection and
arrangement of their contents, constitute intellectual creations, in
which the Work is included in its entirety in unmodified form along
with one or more other contributions, each constituting separate and
independent works in themselves, which together are assembled into a
collective whole. A work that constitutes a Collection will not be
considered an Adaptation (as defined above) for the purposes of this
License.
c. "Distribute" means to make available to the public the original and
copies of the Work or Adaptation, as appropriate, through sale or
other transfer of ownership.
d. "License Elements" means the following high-level license attributes
as selected by Licensor and indicated in the title of this License:
Attribution, Noncommercial, ShareAlike.
e. "Licensor" means the individual, individuals, entity or entities that
offer(s) the Work under the terms of this License.
f. "Original Author" means, in the case of a literary or artistic work,
the individual, individuals, entity or entities who created the Work
or if no individual or entity can be identified, the publisher; and in
addition (i) in the case of a performance the actors, singers,
musicians, dancers, and other persons who act, sing, deliver, declaim,
play in, interpret or otherwise perform literary or artistic works or
expressions of folklore; (ii) in the case of a phonogram the producer
being the person or legal entity who first fixes the sounds of a
performance or other sounds; and, (iii) in the case of broadcasts, the
organization that transmits the broadcast.
g. "Work" means the literary and/or artistic work offered under the terms
of this License including without limitation any production in the
literary, scientific and artistic domain, whatever may be the mode or
form of its expression including digital form, such as a book,
pamphlet and other writing; a lecture, address, sermon or other work
of the same nature; a dramatic or dramatico-musical work; a
choreographic work or entertainment in dumb show; a musical
composition with or without words; a cinematographic work to which are
assimilated works expressed by a process analogous to cinematography;
a work of drawing, painting, architecture, sculpture, engraving or
lithography; a photographic work to which are assimilated works
expressed by a process analogous to photography; a work of applied
art; an illustration, map, plan, sketch or three-dimensional work
relative to geography, topography, architecture or science; a
performance; a broadcast; a phonogram; a compilation of data to the
extent it is protected as a copyrightable work; or a work performed by
a variety or circus performer to the extent it is not otherwise
considered a literary or artistic work.
h. "You" means an individual or entity exercising rights under this
License who has not previously violated the terms of this License with
respect to the Work, or who has received express permission from the
Licensor to exercise rights under this License despite a previous
violation.
i. "Publicly Perform" means to perform public recitations of the Work and
to communicate to the public those public recitations, by any means or
process, including by wire or wireless means or public digital
performances; to make available to the public Works in such a way that
members of the public may access these Works from a place and at a
place individually chosen by them; to perform the Work to the public
by any means or process and the communication to the public of the
performances of the Work, including by public digital performance; to
broadcast and rebroadcast the Work by any means including signs,
sounds or images.
j. "Reproduce" means to make copies of the Work by any means including
without limitation by sound or visual recordings and the right of
fixation and reproducing fixations of the Work, including storage of a
protected performance or phonogram in digital form or other electronic
medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
limit, or restrict any uses free from copyright or rights arising from
limitations or exceptions that are provided for in connection with the
copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License,
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
perpetual (for the duration of the applicable copyright) license to
exercise the rights in the Work as stated below:
a. to Reproduce the Work, to incorporate the Work into one or more
Collections, and to Reproduce the Work as incorporated in the
Collections;
b. to create and Reproduce Adaptations provided that any such Adaptation,
including any translation in any medium, takes reasonable steps to
clearly label, demarcate or otherwise identify that changes were made
to the original Work. For example, a translation could be marked "The
original work was translated from English to Spanish," or a
modification could indicate "The original work has been modified.";
c. to Distribute and Publicly Perform the Work including as incorporated
in Collections; and,
d. to Distribute and Publicly Perform Adaptations.
The above rights may be exercised in all media and formats whether now
known or hereafter devised. The above rights include the right to make
such modifications as are technically necessary to exercise the rights in
other media and formats. Subject to Section 8(f), all rights not expressly
granted by Licensor are hereby reserved, including but not limited to the
rights described in Section 4(e).
4. Restrictions. The license granted in Section 3 above is expressly made
subject to and limited by the following restrictions:
a. You may Distribute or Publicly Perform the Work only under the terms
of this License. You must include a copy of, or the Uniform Resource
Identifier (URI) for, this License with every copy of the Work You
Distribute or Publicly Perform. You may not offer or impose any terms
on the Work that restrict the terms of this License or the ability of
the recipient of the Work to exercise the rights granted to that
recipient under the terms of the License. You may not sublicense the
Work. You must keep intact all notices that refer to this License and
to the disclaimer of warranties with every copy of the Work You
Distribute or Publicly Perform. When You Distribute or Publicly
Perform the Work, You may not impose any effective technological
measures on the Work that restrict the ability of a recipient of the
Work from You to exercise the rights granted to that recipient under
the terms of the License. This Section 4(a) applies to the Work as
incorporated in a Collection, but this does not require the Collection
apart from the Work itself to be made subject to the terms of this
License. If You create a Collection, upon notice from any Licensor You
must, to the extent practicable, remove from the Collection any credit
as required by Section 4(d), as requested. If You create an
Adaptation, upon notice from any Licensor You must, to the extent
practicable, remove from the Adaptation any credit as required by
Section 4(d), as requested.
b. You may Distribute or Publicly Perform an Adaptation only under: (i)
the terms of this License; (ii) a later version of this License with
the same License Elements as this License; (iii) a Creative Commons
jurisdiction license (either this or a later license version) that
contains the same License Elements as this License (e.g.,
Attribution-NonCommercial-ShareAlike 3.0 US) ("Applicable License").
You must include a copy of, or the URI, for Applicable License with
every copy of each Adaptation You Distribute or Publicly Perform. You
may not offer or impose any terms on the Adaptation that restrict the
terms of the Applicable License or the ability of the recipient of the
Adaptation to exercise the rights granted to that recipient under the
terms of the Applicable License. You must keep intact all notices that
refer to the Applicable License and to the disclaimer of warranties
with every copy of the Work as included in the Adaptation You
Distribute or Publicly Perform. When You Distribute or Publicly
Perform the Adaptation, You may not impose any effective technological
measures on the Adaptation that restrict the ability of a recipient of
the Adaptation from You to exercise the rights granted to that
recipient under the terms of the Applicable License. This Section 4(b)
applies to the Adaptation as incorporated in a Collection, but this
does not require the Collection apart from the Adaptation itself to be
made subject to the terms of the Applicable License.
c. You may not exercise any of the rights granted to You in Section 3
above in any manner that is primarily intended for or directed toward
commercial advantage or private monetary compensation. The exchange of
the Work for other copyrighted works by means of digital file-sharing
or otherwise shall not be considered to be intended for or directed
toward commercial advantage or private monetary compensation, provided
there is no payment of any monetary compensation in con-nection with
the exchange of copyrighted works.
d. If You Distribute, or Publicly Perform the Work or any Adaptations or
Collections, You must, unless a request has been made pursuant to
Section 4(a), keep intact all copyright notices for the Work and
provide, reasonable to the medium or means You are utilizing: (i) the
name of the Original Author (or pseudonym, if applicable) if supplied,
and/or if the Original Author and/or Licensor designate another party
or parties (e.g., a sponsor institute, publishing entity, journal) for
attribution ("Attribution Parties") in Licensor's copyright notice,
terms of service or by other reasonable means, the name of such party
or parties; (ii) the title of the Work if supplied; (iii) to the
extent reasonably practicable, the URI, if any, that Licensor
specifies to be associated with the Work, unless such URI does not
refer to the copyright notice or licensing information for the Work;
and, (iv) consistent with Section 3(b), in the case of an Adaptation,
a credit identifying the use of the Work in the Adaptation (e.g.,
"French translation of the Work by Original Author," or "Screenplay
based on original Work by Original Author"). The credit required by
this Section 4(d) may be implemented in any reasonable manner;
provided, however, that in the case of a Adaptation or Collection, at
a minimum such credit will appear, if a credit for all contributing
authors of the Adaptation or Collection appears, then as part of these
credits and in a manner at least as prominent as the credits for the
other contributing authors. For the avoidance of doubt, You may only
use the credit required by this Section for the purpose of attribution
in the manner set out above and, by exercising Your rights under this
License, You may not implicitly or explicitly assert or imply any
connection with, sponsorship or endorsement by the Original Author,
Licensor and/or Attribution Parties, as appropriate, of You or Your
use of the Work, without the separate, express prior written
permission of the Original Author, Licensor and/or Attribution
Parties.
e. For the avoidance of doubt:
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme cannot be waived, the Licensor
reserves the exclusive right to collect such royalties for any
exercise by You of the rights granted under this License;
ii. Waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme can be waived, the Licensor reserves
the exclusive right to collect such royalties for any exercise by
You of the rights granted under this License if Your exercise of
such rights is for a purpose or use which is otherwise than
noncommercial as permitted under Section 4(c) and otherwise waives
the right to collect royalties through any statutory or compulsory
licensing scheme; and,
iii. Voluntary License Schemes. The Licensor reserves the right to
collect royalties, whether individually or, in the event that the
Licensor is a member of a collecting society that administers
voluntary licensing schemes, via that society, from any exercise
by You of the rights granted under this License that is for a
purpose or use which is otherwise than noncommercial as permitted
under Section 4(c).
f. Except as otherwise agreed in writing by the Licensor or as may be
otherwise permitted by applicable law, if You Reproduce, Distribute or
Publicly Perform the Work either by itself or as part of any
Adaptations or Collections, You must not distort, mutilate, modify or
take other derogatory action in relation to the Work which would be
prejudicial to the Original Author's honor or reputation. Licensor
agrees that in those jurisdictions (e.g. Japan), in which any exercise
of the right granted in Section 3(b) of this License (the right to
make Adaptations) would be deemed to be a distortion, mutilation,
modification or other derogatory action prejudicial to the Original
Author's honor and reputation, the Licensor will waive or not assert,
as appropriate, this Section, to the fullest extent permitted by the
applicable national law, to enable You to reasonably exercise Your
right under Section 3(b) of this License (right to make Adaptations)
but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING AND TO THE
FULLEST EXTENT PERMITTED BY APPLICABLE LAW, LICENSOR OFFERS THE WORK AS-IS
AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE
WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT
LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT
DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED
WARRANTIES, SO THIS EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
a. This License and the rights granted hereunder will terminate
automatically upon any breach by You of the terms of this License.
Individuals or entities who have received Adaptations or Collections
from You under this License, however, will not have their licenses
terminated provided such individuals or entities remain in full
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
survive any termination of this License.
b. Subject to the above terms and conditions, the license granted here is
perpetual (for the duration of the applicable copyright in the Work).
Notwithstanding the above, Licensor reserves the right to release the
Work under different license terms or to stop distributing the Work at
any time; provided, however that any such election will not serve to
withdraw this License (or any other license that has been, or is
required to be, granted under the terms of this License), and this
License will continue in full force and effect unless terminated as
stated above.
8. Miscellaneous
a. Each time You Distribute or Publicly Perform the Work or a Collection,
the Licensor offers to the recipient a license to the Work on the same
terms and conditions as the license granted to You under this License.
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
offers to the recipient a license to the original Work on the same
terms and conditions as the license granted to You under this License.
c. If any provision of this License is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of
the remainder of the terms of this License, and without further action
by the parties to this agreement, such provision shall be reformed to
the minimum extent necessary to make such provision valid and
enforceable.
d. No term or provision of this License shall be deemed waived and no
breach consented to unless such waiver or consent shall be in writing
and signed by the party to be charged with such waiver or consent.
e. This License constitutes the entire agreement between the parties with
respect to the Work licensed here. There are no understandings,
agreements or representations with respect to the Work not specified
here. Licensor shall not be bound by any additional provisions that
may appear in any communication from You. This License may not be
modified without the mutual written agreement of the Licensor and You.
f. The rights granted under, and the subject matter referenced, in this
License were drafted utilizing the terminology of the Berne Convention
for the Protection of Literary and Artistic Works (as amended on
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
and the Universal Copyright Convention (as revised on July 24, 1971).
These rights and subject matter take effect in the relevant
jurisdiction in which the License terms are sought to be enforced
according to the corresponding provisions of the implementation of
those treaty provisions in the applicable national law. If the
standard suite of rights granted under applicable copyright law
includes additional rights not granted under this License, such
additional rights are deemed to be included in the License; this
License is not intended to restrict the license of any rights under
applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty
whatsoever in connection with the Work. Creative Commons will not be
liable to You or any party on any legal theory for any damages
whatsoever, including without limitation any general, special,
incidental or consequential damages arising in connection to this
license. Notwithstanding the foregoing two (2) sentences, if Creative
Commons has expressly identified itself as the Licensor hereunder, it
shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the
Work is licensed under the CCPL, Creative Commons does not authorize
the use by either party of the trademark "Creative Commons" or any
related trademark or logo of Creative Commons without the prior
written consent of Creative Commons. Any permitted use will be in
compliance with Creative Commons' then-current trademark usage
guidelines, as may be published on its website or otherwise made
available upon request from time to time. For the avoidance of doubt,
this trademark restriction does not form part of this License.
Creative Commons may be contacted at https://creativecommons.org/.

BIN
docs/images/ad8232.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

BIN
docs/images/adxl335.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
docs/images/apds9002.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
docs/images/at42qt1070.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

BIN
docs/images/ecs1030.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 12 KiB

BIN
docs/images/grovebutton.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

BIN
docs/images/grovecircularled.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
docs/images/groveled.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

BIN
docs/images/grovelight.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
docs/images/groverelay.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
docs/images/grovescam.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

BIN
docs/images/grovetemp.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
docs/images/guvas12d.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
docs/images/hp20x.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 929 KiB

BIN
docs/images/ht9170.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
docs/images/l298.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

BIN
docs/images/lolshield.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

BIN
docs/images/m24lr64e.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
docs/images/maxsonarez.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
docs/images/rgbringcoder.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

BIN
docs/images/sm130.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

View File

@ -16,12 +16,16 @@ such sensors and known workarounds if they exist.
Intel Edison Arduino board but will work with the Mini-breakout.
* **Grove 3-Axis Digital Accelerometer** (ADXL345) only works with the Intel
Edison Arduino board when powered from the 3.3V line.
* **Grove 3-Axis Digital Compass (HMC5883L) reports inaccurate values at 5V
on the Intel Edison Arduino board and newer revisions might not work at all.
Use 3.3V or the Mini-breakout.
* **Grove 96x96 OLED Display** will not work on the Intel Edison with Arduino
breakout.
* **Grove 128x64 OLED Display** will not work on the Intel Edison with Arduino
breakout.
* **Grove Barometer** (BMP085) has an unstable connection on the Intel Edison
using the Arduino breakout and does not run properly.
using the Arduino breakout and may drop read data. The Xadow version of this
sensor (BMP180) is also dropping data packets occasionally.
* **Grove 6-Axis Accelerometer & Compass** (LSM303) fails to write to the
configuration register properly and returns invalid data.
* **Grove I2C ADC Converter** does not show up on the I2C bus on the Intel
@ -39,7 +43,9 @@ such sensors and known workarounds if they exist.
#### Other Sensors
* **MPU9150** might return inaccurate data.
* **SM130** driver might not be fully functional.
* **NRF24L01** might not handle data packets as expected.
* **NRF8001** based devices do not initialize properly with provided examples.
#### General

View File

@ -80,7 +80,7 @@ useful to us and converting it to a double.
Our final example, very easy to use API!
@snippet examples/max31855.cxx Interesting
@snippet examples/c++/max31855.cxx Interesting
### Building

View File

@ -236,6 +236,7 @@ ALIASES = library="@ingroup " \
sensor="@li **ID:** " \
comname="@li **Name:** " \
altname="@li **Other Names:** " \
altid="@li **Other Chips:** " \
type="@li **Category:** " \
man="@li **Manufacturer:** " \
web="@li **Link:** " \

View File

@ -3,7 +3,7 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
**Welcome to UPM Python documentation!**
**Welcome to UPM Python Documentation!**
=========================================
.. include:: ../../README.md
@ -14,7 +14,15 @@
################
For building UPM, please follow this `link <https://github.com/intel-iot-devkit/upm/blob/master/docs/building.md>`_.
``Examples``
############
Multi-sensor samples for the starter and specialized kits can be found in the `iot-devkit-samples <https://github.com/intel-iot-devkit/iot-devkit-samples>`_
repository.
Individual sensor usage examples for python are available `here <https://github.com/intel-iot-devkit/upm/tree/master/examples/python>`_.
``Making your own UPM Module``
##############################
@ -22,7 +30,7 @@ This `link <https://github.com/intel-iot-devkit/upm/blob/master/docs/porting.md
There is also an example available for max31855 `sensor <https://github.com/intel-iot-devkit/upm/blob/master/docs/max31855.md>`_.
``Naming Conventions and rules for new UPM Contributions``
``Naming Conventions and Rules for New UPM Contributions``
##########################################################
Before you begin development, please take a look at our naming `conventions <https://github.com/intel-iot-devkit/upm/blob/master/docs/naming.md>`_.
@ -33,11 +41,11 @@ Don't forget to check the documentation `section <https://github.com/intel-iot-d
.. note::
* Make sure you add yourself as an author on every new code file submitted.
* If you are providing a fix with significant changes, feel free to add yourself as a contributor.
* Make sure you add yourself as an author on every new code file submitted.
* If you are providing a fix with significant changes, feel free to add yourself as a contributor.
* Signing-off your commits is mandatory.
``List of available sensors drivers``
``List of Available Sensors Drivers``
######################################
.. toctree::
@ -45,20 +53,25 @@ Don't forget to check the documentation `section <https://github.com/intel-iot-d
modules
``C/C++ API Documentation``
``Other API Documentation``
###########################
The C/C++ API documentation is available `here <http://iotdk.intel.com/docs/master/upm/>`_.
.. image:: ../docs/icons/c++.png
:target: http://iotdk.intel.com/docs/master/upm/modules.html
.. image:: ../docs/icons/python.png
:target: http://iotdk.intel.com/docs/master/upm/python
.. image:: ../docs/icons/node.png
:target: http://iotdk.intel.com/docs/master/upm/node
``Version``
###########
``Version Changelog``
#####################
For Version Changelog, please see `here <https://github.com/intel-iot-devkit/upm/blob/master/docs/changelog.md>`_.
For our Version Changelog, please see `here <https://github.com/intel-iot-devkit/upm/blob/master/docs/changelog.md>`_.
``Limitations and List of Changes``
``Known Limitations``
###################################
For List of Known Limitations, please see `here <https://github.com/intel-iot-devkit/upm/blob/master/docs/knownlimitations.md>`_.
For the List of Known Limitations, please see `here <https://github.com/intel-iot-devkit/upm/blob/master/docs/knownlimitations.md>`_.
``Indices and tables``
######################

View File

@ -43,20 +43,17 @@ opts
// use promise-style programming rather than spaghetti callbacks
Promise.promisifyAll(fs);
// TODO: create directory structure if doesn't exist
var formats = opts.formats.split(',');
formats.forEach(function(format){
mkdirp('jsdoc/' + format + '/' + opts.module);
});
Promise.promisifyAll(mkdirp);
// main
xml2js.parse().then(function(specjs) {
var formats = opts.formats.split(',');
Promise.all(_.map(formats, function(format) {
var generateDocs = require(__dirname + '/generators/' + format + '/generator');
var outFile = opts.outdir + '/' + format + '/' + specjs.MODULE + '/doc.js';
return fs.writeFileAsync(outFile, generateDocs(specjs));
var dir = opts.outdir + '/' + format + '/' + specjs.MODULE;
return mkdirp.mkdirpAsync(dir).then(function() {
return fs.writeFileAsync(dir + '/doc.js', generateDocs(specjs));
});
}));
});

View File

@ -58,6 +58,7 @@ function GENERATE_MODULE(module) {
// generate method spec with parent module/class
function GENERATE_METHOD(name, spec, parent) {
name = name.replace(/!+$/, '');
return GENERATE_DOC(spec.description + '\n'
+ '@method ' + name + '\n'
+ '@instance\n'

View File

@ -28,44 +28,66 @@ var _ = require('lodash');
// generate json for ternjs input
function generateDocs(specjs) {
var docs = GENERATE_MODULE(specjs.MODULE);
GENERATE_TYPE = (function(enums) {
return function(type) {
return (_.contains(enums, type) ? ('Enum ' + type) : type);
}
})(_.keys(specjs.ENUMS_BY_GROUP));
var docs = { '!name': specjs.MODULE + 'library' };
_.extend(docs, GENERATE_MODULE(specjs.MODULE));
_.each(specjs.ENUMS, function(enumSpec, enumName) {
_.extend(docs[specjs.MODULE], GENERATE_ENUM(enumName, enumSpec));
});
_.each(specjs.METHODS, function(methodSpec, methodName) {
_.extend(docs[specjs.MODULE], GENERATE_METHOD(methodName, methodSpec));
});
_.each(specjs.CLASSES, function(classSpec, parentClass) {
var constructor = classSpec.methods[parentClass];
_.extend(docs[specjs.MODULE], GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
_.each(classSpec.enums, function(enumSpec, enumName) {
_.extend(docs[specjs.MODULE][parentClass], GENERATE_ENUM(enumName, enumSpec));
if (_.isEmpty(specjs.CLASSGROUPS)) {
_.extend(docs[specjs.MODULE], GENERATE_CLASSES(specjs.CLASSES));
} else {
var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
_.extend(docs[specjs.MODULE], GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped)));
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
_.extend(docs, GENERATE_MODULE(groupName));
_.extend(docs[groupName], GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName));
});
docs[specjs.MODULE][parentClass].prototype = {};
_.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
_.extend(docs[specjs.MODULE][parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
});
_.each(classSpec.variables, function(variableSpec, variableName) {
_.extend(docs[specjs.MODULE][parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
});
});
}
return JSON.stringify(docs, null, 2);
}
// generate module spec
function GENERATE_MODULE(module) {
var docs = { '!name': module + 'library' };
var docs = {};
docs[module] = {};
return docs;
}
// generate the spec for the given list of classes
function GENERATE_CLASSES(classes) {
var docs = {};
_.each(classes, function(classSpec, parentClass) {
var constructor = classSpec.methods[parentClass];
_.extend(docs, GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
if (_.has(docs, parentClass)) {
_.each(classSpec.enums, function(enumSpec, enumName) {
_.extend(docs[parentClass], GENERATE_ENUM(enumName, enumSpec));
});
docs[parentClass].prototype = {};
_.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
_.extend(docs[parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
});
_.each(classSpec.variables, function(variableSpec, variableName) {
_.extend(docs[parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
});
}
});
return docs;
}
// generate method spec
function GENERATE_METHOD(name, spec) {
var doc = {};

View File

@ -46,7 +46,7 @@ function generateDocs(specjs) {
docs += GENERATE_MODULE('common', '');
var grouped = _.flatten(_.pluck(_.values(specjs.CLASSGROUPS), 'classes'));
var ungrouped = _.difference(_.keys(specjs.CLASSES), grouped);
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped), 'common');
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, ungrouped), 'common');
_.each(specjs.CLASSGROUPS, function(groupSpec, groupName) {
docs += GENERATE_CLASSES(_.pick(specjs.CLASSES, groupSpec.classes), groupName);
});
@ -76,7 +76,7 @@ function GENERATE_MODULE(name, description) {
function GENERATE_CLASSES(classes, parent) {
return _.reduce(classes, function(memo, classSpec, className) {
return memo
+ GENERATE_CLASS(className, classSpec.description, parent)
+ GENERATE_CLASS(className, classSpec.description, parent, classSpec.parent)
+ _.reduce(classSpec.methods, function(memo, methodSpec, methodName) {
return memo += GENERATE_METHOD(methodName, methodSpec, className);
}, '')
@ -91,15 +91,21 @@ function GENERATE_CLASSES(classes, parent) {
// generate class spec
function GENERATE_CLASS(name, description, parent) {
function GENERATE_CLASS(name, description, namespace, parent) {
return GENERATE_DOC(description + '\n'
+ '@class ' + name + '\n'
+ (parent ? ('@module ' + parent + '\n') : ''));
+ (namespace ? ('@module ' + namespace + '\n') : '')
/*
TODO: leave out until figure out what swig does with inheritance
+ (parent ? ('@extends ' + parent + '\n') : '')
*/
);
}
// generate method spec with parent module/class
function GENERATE_METHOD(name, spec, parent) {
name = name.replace(/!+$/, '');
return GENERATE_DOC(spec.description + '\n'
+ '@method ' + name + '\n'
+ (parent ? ('@for ' + parent + '\n') : '@for common\n')

View File

@ -77,17 +77,15 @@ function listByGroup(modules, classes, field, projectRoot) {
var groups = Object.keys(modulesByGroup).sort();
var html = '';
var pfx = projectRoot + 'modules/';
var first = true;
for (i = 0; i < groups.length; i++) {
var group = groups[i];
html += (first ? '' : '</span>');
html += '<div class="upmGroup"><div class="right-arrow"></div>' + group + '</div><span class="upmModules" style="display:none">';
var moduleNames = modulesByGroup[group];
for (j = 0; j < moduleNames.length; j++) {
var moduleName = moduleNames[j];
html += '<a href="' + pfx + moduleName + '.html">' + moduleName + '</a>';
}
first = false;
html += '</span>';
}
return html;
}
@ -117,7 +115,7 @@ var insertStyles = "Y.one(document.head).append('<style> \
font-size: 0; \
margin-right: 5px; \
vertical-align: 5px; \
display: inline; \
float: left; \
} \
div.down-arrow { \
width: 0; \
@ -127,7 +125,7 @@ var insertStyles = "Y.one(document.head).append('<style> \
border-top: 5px solid #356de4; \
font-size: 0; \
margin-right: 5px; \
display: inline; \
float: left; \
} \
div.upmGroup { \
font-weight: bold; \
@ -137,7 +135,7 @@ var insertStyles = "Y.one(document.head).append('<style> \
var scripts = "YUI().use('node', 'event', function (Y) {"
+ onClickHandler
+ insertStyles
// + insertStyles
+ "});";

View File

@ -311,13 +311,13 @@ abbr {
cursor: help;
}
.prettyprint li.L0,
.prettyprint li.L1,
.prettyprint li.L2,
.prettyprint li.L3,
.prettyprint li.L5,
.prettyprint li.L6,
.prettyprint li.L7,
.prettyprint li.L0,
.prettyprint li.L1,
.prettyprint li.L2,
.prettyprint li.L3,
.prettyprint li.L5,
.prettyprint li.L6,
.prettyprint li.L7,
.prettyprint li.L8 {
list-style: decimal;
}
@ -357,7 +357,7 @@ ul li p {
#hd img {
margin-right: 10px;
vertical-align: middle;
}
@ -787,3 +787,28 @@ kbd .cmd { font-family: Monaco, Helvetica; }
font-weight: bold;
}
div.right-arrow {
width: 0;
height: 0;
border-bottom: 5px solid transparent;
border-top: 5px solid transparent;
border-left: 5px solid #356de4;
font-size: 0;
margin-right: 5px;
float: left;
}
div.down-arrow {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #356de4;
font-size: 0;
margin-right: 5px;
float: left;
}
div.upmGroup {
font-weight: bold;
}

View File

@ -17,6 +17,8 @@
<h1>UPM</h1>
<p>
The UPM API is a high level sensor library for IoT devices using MRAA. See examples <a href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here</a>.
Back to <a href="http://iotdk.intel.com/docs/master/upm/node/"> index </a> page.
<br><em>SparkFun sensor images provided under <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>CC BY-NC-SA-3.0</a>.</em>
</p>
</div>
</div>

View File

@ -0,0 +1,166 @@
<div class="apidocs">
<div class="content" id="docs-main">
<h1><strong>Welcome to UPM Node.JS Documentation!</strong><a class="headerlink"
href="#welcome-to-upm-python-documentation"></a></h1>
<p>Browse to a module or class using the sidebar to view its API
documentation.</p>
<p>UPM is a high level repository for sensors that use libmraa. Each
sensor links to libmraa and are not meant to be interlinked although
some groups of sensors may be. Each sensor contains a header which
allows to interface with it. Typically a sensor is represented as a
class and instantiated.</p>
<p>The constructor is expected to initialise the sensor and parameters
may be used to provide identification/pin location on the board.</p>
<p>Typically an update() function will be called in order to get new
data from the sensor in order to reduce load when doing multiple reads
to sensor data.</p>
<div class="section" id="examples">
<h3><code class="docutils literal"><span class="pre">Examples</span></code><a class="headerlink"
href="#examples"
title="Permalink to this headline">*</a></h3>
<p>Multi-sensor samples for the starter and specialized kits can be
found in the
<a class="reference external"
href="https://github.com/intel-iot-devkit/iot-devkit-samples">iot-devkit-samples</a>
repository.</p>
<p>Individual sensor usage examples for node.js are available
<a class="reference external"
href="https://github.com/intel-iot-devkit/upm/tree/master/examples/javascript">here</a>.</p>
</div>
<div class="section" id="building-upm">
<h3><tt class="docutils literal"><span class="pre">Building</span>
<span class="pre">UPM</span></tt><a class="headerlink"
href="#building-upm"
title="Permalink to this headline">*</a></h3>
<p>For building UPM, please follow this
<a class="reference external"
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/building.md">link</a>.</p>
</div>
<div class="section" id="making-your-own-upm-module">
<h3><tt class="docutils literal"><span class="pre">Making</span>
<span class="pre">your</span> <span class="pre">own</span>
<span class="pre">UPM</span> <span class="pre">Module</span></tt><a class="headerlink"
href="#making-your-own-upm-module"
title="Permalink to this headline">*</a></h3>
<p>This
<a class="reference external"
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/porting.md">link</a>
has more information on making a new UPM module.</p>
<p>There is also an example available for max31855
<a class="reference external"
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/max31855.md">sensor</a>.</p>
</div>
<div class="section"
id="naming-conventions-and-rules-for-new-upm-contributions">
<h3><tt class="docutils literal"><span class="pre">Naming</span>
<span class="pre">Conventions</span> <span class="pre">and</span>
<span class="pre">Rules</span> <span class="pre">for</span>
<span class="pre">New</span> <span class="pre">UPM</span>
<span class="pre">Contributions</span></tt><a class="headerlink"
href="#naming-conventions-and-rules-for-new-upm-contributions"
title="Permalink to this headline">*</a></h3>
<p>Before you begin development, please take a look at our naming
<a class="reference external"
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/naming.md">conventions</a>.</p>
<p>Also, please read the guidelines for contributions to
<a class="reference external"
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/contributions.md">UPM</a>.</p>
<p>Don&rsquo;t forget to check the documentation
<a class="reference external"
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/documentation.md">section</a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<ul class="last simple">
<li>Make sure you add yourself as an author on every new code
file submitted.</li>
<li>If you are providing a fix with significant changes, feel
free to add yourself as a contributor.</li>
<li>Signing-off your commits is mandatory.</li>
</ul>
</div>
</div>
<div class="section" id="api-documentation">
<h1><strong>Other API Documentation</strong><a class="headerlink"
href="#api-documentation"
title="Permalink to this headline"></a></h1>
<p><a href="http://iotdk.intel.com/docs/master/upm/modules.html"><img src="../docs/icons/c++.png" /></a>
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="../docs/icons/python.png" /></a>
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="../docs/icons/node.png" /></a>
</p>
</div>
<div class="section" id="version-changelog">
<h3><tt class="docutils literal"><span class="pre">Version</span>
<span class="pre">Changelog</span></tt><a class="headerlink"
href="#version-changelog"
title="Permalink to this headline">*</a></h3>
<p>For our Version Changelog, please see
<a class="reference external"
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/changelog.md">here</a>.</p>
</div>
<div class="section" id="known-limitations">
<h3><tt class="docutils literal"><span class="pre">Known</span>
<span class="pre">Limitations</span></tt><a class="headerlink"
href="#known-limitations"
title="Permalink to this headline">*</a></h3>
<p>For the List of Known Limitations, please see
<a class="reference external"
href="https://github.com/intel-iot-devkit/upm/blob/master/docs/knownlimitations.md">here</a>.</p>
</div>
<div class="section" id="keyboard-shortcuts">
<h3><tt class="docutils literal"><span class="pre">Keyboard</span>
<span class="pre">Shortcuts</span></tt><a class="headerlink"
href="#keyboard-shortcuts"
title="Permalink to this headline">*</a></h3>
<ul>
<li>
<p>Press <kbd>s</kbd> to focus the API search box.</p> </li>
<li>
<p>Use <kbd>Up</kbd> and <kbd>Down</kbd> to select classes,
modules, and search results.</p> </li>
<li class="mac-only">
<p>With the API search box or sidebar focused, use <kbd><span class="cmd">&#8984;</span>-Left</kbd>
or <kbd><span class="cmd">&#8984;</span>-Right</kbd> to switch
sidebar tabs.</p> </li>
<li class="pc-only">
<p>With the API search box or sidebar focused, use <kbd>Ctrl+Left</kbd>
and <kbd>Ctrl+Right</kbd> to switch sidebar tabs.</p> </li>
</ul>
</div>
</div>

View File

@ -69,6 +69,8 @@ var xml2js = {
// CLASSES: {
// <class name>: {
// description: <class description>,
// parent: <parent class name>,
// group: <group name>,
// methods: { ... },
// variables: {
// <variable name>: {
@ -83,7 +85,9 @@ var xml2js = {
// CLASSGROUPS: {
// <group name>: {
// description: <group description>,
// classes: [ <class name>, ... ]
// classes: [ <class name>, ... ],
// enums: { ... },
// enums_by_group: { ... }
// }, ...
// }
MODULE: '',
@ -98,7 +102,8 @@ var xml2js = {
TYPEMAPS: {
'^(const)?\\s*(unsigned|signed)?\\s*(int|short|long|float|double|size_t|u?int\\d{1,2}_t)?$': 'Number',
'^bool$': 'Boolean',
'^(const)?\\s*(unsigned|signed)?\\s*(char|char\\s*\\*|std::string)$': 'String' // TODO: verify that swig does this mapping
'^(const)?\\s*(unsigned|signed)?\\s*(char|char\\s*\\*|std::string)$': 'String', // TODO: verify that swig does this mapping
'^void\\s*\\(\\s*\\*\\s*\\)\\s*\\(\\s*void\\s*\\*\\)\\s*$': 'Function'
},
@ -157,13 +162,14 @@ var xml2js = {
try {
var spec_c = xmlparser.parse(xml)[0];
var className = getName(spec_c);
xml2js.CLASSES[className] = {
_.extend(xml2js.CLASSES[className], {
description: getDescription(spec_c),
parent: getParent(spec_c, className),
enums: getEnums(spec_c, false, className),
enums_by_group: getEnums(spec_c, true, className),
variables: getVariables(spec_c, className),
methods: getMethods(spec_c, className)
};
});
} catch(e) {
console.log(e.toString() + ': class ' + className + ' was not parsed correctly.');
}
@ -177,15 +183,48 @@ var xml2js = {
return fs.readFileAsync(xml2js.opts.inputdir + '/' + fn, 'utf8').then(function(xml) {
var spec_c = xmlparser.parse(xml)[0];
if (_.isEmpty(getSubmodules(spec_c))) {
xml2js.CLASSGROUPS[getName(spec_c)] = {
var group = getName(spec_c);
var classes = getSubclassNames(spec_c);
xml2js.CLASSGROUPS[group] = {
description: getDescription(spec_c),
classes: getSubclassNames(spec_c)
}
classes: classes
};
_.each(classes, function(c) {
if (_.has(xml2js.CLASSES, c)) {
xml2js.CLASSES[c].group = group;
} else {
console.log('Warning: Group ' + group + ' has unknown class ' + c);
}
});
}
});
}));
});
return Promise.all(parseClasses.concat(parseGroups));
}).then(function() {
if (!_.isEmpty(xml2js.CLASSGROUPS)) {
// try to categorize ungrouped classes, if any
var grouped = _.flatten(_.pluck(_.values(xml2js.CLASSGROUPS), 'classes'));
var ungrouped = _.difference(_.keys(xml2js.CLASSES), grouped);
_.each(ungrouped, function(c) {
_.each(findUsage(c), function(group) {
xml2js.CLASSGROUPS[group].classes.push(c);
});
});
grouped = _.flatten(_.pluck(_.values(xml2js.CLASSGROUPS), 'classes'));
ungrouped = _.difference(_.keys(xml2js.CLASSES), grouped);
// try to categorize ungrouped enums, if any
_.each(xml2js.ENUMS_BY_GROUP, function(enumGroupSpec, enumGroupName) {
_.each(findUsage(enumGroupName, true), function(c) {
xml2js.CLASSES[c].enums_by_group[enumGroupName] = enumGroupSpec;
_.each(enumGroupSpec.members, function(enumName) {
xml2js.CLASSES[c].enums[enumName] = xml2js.ENUMS[enumName];
delete xml2js.ENUMS[enumName];
});
delete xml2js.ENUMS_BY_GROUP[enumGroupName];
});
});
}
}).then(function() {
if (xml2js.opts.custom && fs.existsSync(xml2js.opts.custom)) {
return fs.readFileAsync(xml2js.opts.custom, 'utf8').then(function(custom) {
@ -199,9 +238,9 @@ var xml2js = {
console.log(xml2js.opts.custom ? ('Error: No such customization file exists: ' + xml2js.opts.custom) : 'No customizations given.');
}
}).then(function() {
generateCustomPointerClasses();
validateMethods();
validateVars();
generateCustomPointerClasses();
return _.pick(xml2js, 'MODULE', 'ENUMS', 'ENUMS_BY_GROUP', 'METHODS', 'CLASSES', 'CLASSGROUPS');
});
}
@ -391,7 +430,30 @@ function generateCustomPointerClasses() {
}
// override autogenerated methods with custom configuration
// search for usage of a type
function findUsage(type, classOnly) {
var filterClasses = function(fn) { return _.without(_.map(xml2js.CLASSES, fn), undefined); };
var usesType = function(classSpec, className) {
var methodsOfType = (_.find(classSpec.methods, function(methodSpec, methodName) {
return ((!_.isEmpty(methodSpec.return) && methodSpec.return.type == type) ||
(_.contains(_.pluck(methodSpec.params, 'type'), type)));
}) != undefined);
var variablesOfType = _.contains(_.pluck(classSpec.variable, 'type'), type);
return ((methodsOfType || variablesOfType) ? className : undefined);
};
var extendsType = function(classSpec, className) {
return ((classSpec.parent == type) ? className : undefined);
};
var classes = _.union(filterClasses(usesType), filterClasses(extendsType));
if (classOnly) {
return classes;
} else {
return _.without(_.uniq(_.pluck(_.pick(xml2js.CLASSES, classes), 'group')), undefined);
}
}
// override autogenerated methods with custom configuration
function customizeMethods(custom) {
_.each(custom, function(classMethods, className) {
_.extend(xml2js.CLASSES[className].methods, _.pick(classMethods, function(methodSpec, methodName) {
@ -527,6 +589,19 @@ function getSubmodules(spec_c) {
}
// get parent class, if any
function getParent(spec_c, className) {
var parent = getChild(spec_c, 'basecompoundref');
if (parent) {
parent = getText(parent);
if (!_.has(xml2js.CLASSES, parent)) {
console.log('WARNING: Class ' + className + ' has unknown parent class ' + parent);
}
}
return parent;
}
function hasParams(paramsSpec) {
return !(_.isEmpty(paramsSpec) ||
((_.size(paramsSpec) == 1) && getText(getChild(paramsSpec[0], 'type')) == 'void'));
@ -559,6 +634,7 @@ function getMethods(spec_c, parent) {
if (!_.isEmpty(returnSpec)) {
retval = getReturn(returnSpec, getReturnDetails(description), methodName, parent);
}
methodName = getUniqueMethodName(methodName, spec_js, parent);
spec_js[methodName] = {
description: methodDescription,
params: params,
@ -575,6 +651,17 @@ function getMethods(spec_c, parent) {
}
// get a unique string to represent the name of an overloaded method
function getUniqueMethodName(methodName, module, parent) {
if (methodName in module) {
do {
methodName += '!';
} while (methodName in module);
}
return methodName;
}
// get variable specifications for a class
function getVariables(spec_c, parent) {
var spec_js = {};

View File

@ -122,6 +122,17 @@ add_executable (ht9170-example ht9170.cxx)
add_executable (h3lis331dl-example h3lis331dl.cxx)
add_executable (ad8232-example ad8232.cxx)
add_executable (grovescam-example grovescam.cxx)
add_executable (m24lr64e-example m24lr64e.cxx)
add_executable (grovecircularled-example grovecircularled.cxx)
add_executable (rgbringcoder-example rgbringcoder.cxx)
add_executable (hp20x-example hp20x.cxx)
add_executable (pn532-example pn532.cxx)
add_executable (pn532-writeurl-example pn532-writeurl.cxx)
add_executable (sainsmartks-example sainsmartks.cxx)
add_executable (mpu60x0-example mpu60x0.cxx)
add_executable (ak8975-example ak8975.cxx)
add_executable (lsm9ds0-example lsm9ds0.cxx)
add_executable (eboled-example eboled.cxx)
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
include_directories (${PROJECT_SOURCE_DIR}/src/grove)
@ -222,6 +233,12 @@ include_directories (${PROJECT_SOURCE_DIR}/src/ht9170)
include_directories (${PROJECT_SOURCE_DIR}/src/h3lis331dl)
include_directories (${PROJECT_SOURCE_DIR}/src/ad8232)
include_directories (${PROJECT_SOURCE_DIR}/src/grovescam)
include_directories (${PROJECT_SOURCE_DIR}/src/m24lr64e)
include_directories (${PROJECT_SOURCE_DIR}/src/grovecircularled)
include_directories (${PROJECT_SOURCE_DIR}/src/rgbringcoder)
include_directories (${PROJECT_SOURCE_DIR}/src/hp20x)
include_directories (${PROJECT_SOURCE_DIR}/src/pn532)
include_directories (${PROJECT_SOURCE_DIR}/src/lsm9ds0)
target_link_libraries (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT})
@ -345,3 +362,14 @@ target_link_libraries (ht9170-example ht9170 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (h3lis331dl-example h3lis331dl ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ad8232-example ad8232 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovescam-example grovescam ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (m24lr64e-example m24lr64e ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovecircularled-example grovecircularled ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (rgbringcoder-example rgbringcoder ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (hp20x-example hp20x ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (pn532-example pn532 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (pn532-writeurl-example pn532 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (sainsmartks-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mpu60x0-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ak8975-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (lsm9ds0-example lsm9ds0 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (eboled-example i2clcd ${CMAKE_THREAD_LIBS_INIT})

72
examples/c++/ak8975.cxx Normal file
View File

@ -0,0 +1,72 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "mpu9150.h"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
upm::AK8975 *sensor = new upm::AK8975();
sensor->init();
while (shouldRun)
{
sensor->update();
float x, y, z;
sensor->getMagnetometer(&x, &y, &z);
cout << "Magnetometer: ";
cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl;
cout << endl;
usleep(500000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

48
examples/c++/eboled.cxx Normal file
View File

@ -0,0 +1,48 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
#include <iostream>
#include "eboled.h"
using namespace std;
int main(int argc, char **argv)
{
//! [Interesting]
// Instantiate an Edison Block OLED using default values
upm::EBOLED *lcd = new upm::EBOLED();
lcd->clear();
lcd->setCursor(2, 0);
lcd->write("Hello");
lcd->setCursor(3, 5);
lcd->write("World!");
cout << "Sleeping for 5 seconds..." << endl;
sleep(5);
delete lcd;
//! [Interesting]
return 0;
}

View File

@ -0,0 +1,63 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "grovecircularled.h"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a Grove Circular LED on gpio pins 5 and 4
upm::GroveCircularLED *circle = new upm::GroveCircularLED(5, 4);
int level = 0;
while (shouldRun)
{
circle->setSpinner(level);
level = (level + 1) % 24;
usleep(100000);
}
//! [Interesting]
cout << "Exiting" << endl;
delete circle;
return 0;
}

View File

@ -58,7 +58,7 @@ void sendCommand(upm::HM11* ble, char *cmd)
{
memset(buffer, 0, BUFSIZ);
ble->readData(buffer, BUFSIZ);
ble->readData(buffer, BUFSIZ - 1);
cout << "Returned: " << buffer << endl;
}
else

View File

@ -23,6 +23,7 @@
*/
#include <unistd.h>
#include <string.h>
#include <iostream>
#include <signal.h>
#include "hmtrp.h"
@ -128,7 +129,8 @@ int main (int argc, char **argv)
// check to see if data is available first.
if (radio->dataAvailable())
{
int rv = radio->readData(radioBuffer, bufferLength);
memset(radioBuffer, 0, bufferLength);
int rv = radio->readData(radioBuffer, bufferLength - 1);
if (rv > 0)
cout << "Received: " << radioBuffer << endl;

70
examples/c++/hp20x.cxx Normal file
View File

@ -0,0 +1,70 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
#include <unistd.h>
#include <signal.h>
#include <iostream>
#include "hp20x.h"
using namespace std;
using namespace upm;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an HP20X on default I2C bus and address
upm::HP20X *bar = new upm::HP20X();
// Initialize the device with default values
bar->init();
// Output data every second until interrupted
while (shouldRun)
{
printf("Temperature: %f Celcius\n", bar->getTemperature());
printf("Pressure: %f Millibars\n", bar->getPressure());
printf("Altitude: %f Meters\n", bar->getAltitude());
printf("\n");
sleep(1);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete bar;
return 0;
}

View File

@ -34,6 +34,10 @@ main(int argc, char **argv)
lcd->write("Hello World");
lcd->setCursor(1,2);
lcd->write("Hello World");
printf("Sleeping for 5 seconds\n");
sleep(5);
delete lcd;
//! [Interesting]
return 0;
}

View File

@ -39,4 +39,6 @@ main(int argc, char **argv)
lcd->setCursor(3,6);
lcd->write("Hello World");
delete lcd;
return 0;
}

83
examples/c++/lsm9ds0.cxx Normal file
View File

@ -0,0 +1,83 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "lsm9ds0.h"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an LSM9DS0 using default parameters (bus 1, gyro addr 6b,
// xm addr 1d)
upm::LSM9DS0 *sensor = new upm::LSM9DS0();
sensor->init();
while (shouldRun)
{
sensor->update();
float x, y, z;
sensor->getAccelerometer(&x, &y, &z);
cout << "Accelerometer: ";
cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl;
sensor->getGyroscope(&x, &y, &z);
cout << "Gryoscope: ";
cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl;
sensor->getMagnetometer(&x, &y, &z);
cout << "Magnetometer: ";
cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl;
cout << "Temperature: " << sensor->getTemperature() << endl;
cout << endl;
usleep(500000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

65
examples/c++/m24lr64e.cxx Normal file
View File

@ -0,0 +1,65 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include "m24lr64e.h"
using namespace std;
using namespace upm;
int main(int argc, char **argv)
{
//! [Interesting]
// Instantiate an M24LR64E on I2C bus 0
upm::M24LR64E *nfcTag = new upm::M24LR64E(M24LR64E_I2C_BUS);
// This example accesses the device in the 'user' (default) mode,
// reads the last byte of data in the EEPROM, inverts it, writes
// it back, and then re-reads it.
// Read the last byte of the EEPROM area
int addr = M24LR64E::EEPROM_I2C_LENGTH - 1;
printf("Address: %d\n", addr);
uint8_t byte = nfcTag->readByte(addr);
printf("Read byte: %02x\n", byte);
// Now change it to it's opposite and write it
byte = ~byte;
nfcTag->writeByte(addr, byte);
printf("Wrote inverted byte: %02x\n", byte);
// Now read it back.
byte = nfcTag->readByte(addr);
printf("Read byte: %02x\n", byte);
//! [Interesting]
cout << "Exiting..." << endl;
delete nfcTag;
return 0;
}

77
examples/c++/mpu60x0.cxx Normal file
View File

@ -0,0 +1,77 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "mpu9150.h"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
upm::MPU60X0 *sensor = new upm::MPU60X0();
sensor->init();
while (shouldRun)
{
sensor->update();
float x, y, z;
sensor->getAccelerometer(&x, &y, &z);
cout << "Accelerometer: ";
cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl;
sensor->getGyroscope(&x, &y, &z);
cout << "Gryoscope: ";
cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl;
cout << "Temperature: " << sensor->getTemperature() << endl;
cout << endl;
usleep(500000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -1,6 +1,6 @@
/*
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
* Copyright (c) 2014 Intel Corporation.
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -24,36 +24,58 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "mpu9150.h"
int
main(int argc, char **argv)
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
//! [Interesting]
upm::Vector3D data;
upm::MPU9150 *sensor = new upm::MPU9150(0, ADDR);
sensor->getData ();
sensor->getAcceleromter (&data);
std::cout << "*************************************************" << std::endl;
std::cout << "DEVICE ID (" << (int) sensor->getDeviceID () << ")" << std::endl;
std::cout << "*************************************************" << std::endl;
std::cout << "ACCELEROMETER :: X (" << data.axisX << ")" << " Y (" << data.axisY << ")"
<< " Z (" << data.axisZ << ")" << std::endl;
sensor->getGyro (&data);
std::cout << "GYRO :: X (" << data.axisX << ")" << " Y (" << data.axisY << ")"
<< " Z (" << data.axisZ << ")" << std::endl;
sensor->getMagnometer (&data);
std::cout << "MAGNOMETER :: X (" << data.axisX << ")" << " Y (" << data.axisY << ")"
<< " Z (" << data.axisZ << ")" << std::endl;
std::cout << "TEMPERATURE (" << sensor->getTemperature () << ")" << std::endl;
std::cout << "*************************************************" << std::endl;
//! [Interesting]
std::cout << "exiting application" << std::endl;
delete sensor;
return 0;
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
upm::MPU9150 *sensor = new upm::MPU9150();
sensor->init();
while (shouldRun)
{
sensor->update();
float x, y, z;
sensor->getAccelerometer(&x, &y, &z);
cout << "Accelerometer: ";
cout << "AX: " << x << " AY: " << y << " AZ: " << z << endl;
sensor->getGyroscope(&x, &y, &z);
cout << "Gryoscope: ";
cout << "GX: " << x << " GY: " << y << " GZ: " << z << endl;
sensor->getMagnetometer(&x, &y, &z);
cout << "Magnetometer: ";
cout << "MX = " << x << " MY = " << y << " MZ = " << z << endl;
cout << "Temperature: " << sensor->getTemperature() << endl;
cout << endl;
usleep(500000);
}
//! [Interesting]
cout << "Exiting..." << endl;
delete sensor;
return 0;
}

View File

@ -0,0 +1,115 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include "pn532.h"
using namespace std;
// the URL we want to add as an NDEF record
// NOTE: this cannot exceed 34 characters.
static char url[] = "iotdk.intel.com";
int main(int argc, char **argv)
{
//! [Interesting]
// Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the
// IRQ, and gpio 2 for the reset pin.
upm::PN532 *nfc = new upm::PN532(3, 2);
if (!nfc->init())
cerr << "init() failed" << endl;
uint32_t vers = nfc->getFirmwareVersion();
if (vers)
printf("Got firmware version: 0x%08x\n", vers);
else
{
printf("Could not identify PN532\n");
return 1;
}
// Now scan and identify any cards that come in range (1 for now)
// Retry forever
nfc->setPassiveActivationRetries(0xff);
nfc->SAMConfig();
uint8_t uidSize;
uint8_t uid[7];
bool foundCard = false;
while (!foundCard)
{
memset(uid, 0, 7);
if (nfc->readPassiveTargetID(nfc->BAUD_MIFARE_ISO14443A,
uid, &uidSize, 2000))
{
// found a card
printf("Found a card: UID len %d\n", uidSize);
printf("UID: ");
for (int i = 0; i < uidSize; i++)
printf("%02x ", uid[i]);
printf("\n");
printf("SAK: 0x%02x\n", nfc->getSAK());
printf("ATQA: 0x%04x\n\n", nfc->getATQA());
foundCard = true;
}
else
{
printf("Waiting for a card...\n");
}
}
if (uidSize != 7)
{
printf("This example will only write an NDEF URI to preformatted\n");
printf("Mifare Ultralight or NTAG2XX tags\n");
return 1;
}
// 48 bytes is maximum data area on ultralight cards, so we use that
// as the maximum datasize here. Obviously if you have a bigger
// card, you can write more data.
if (!nfc->ntag2xx_WriteNDEFURI(nfc->NDEF_URIPREFIX_HTTP, url, 48))
{
// failure
printf("Failed to write NDEF record tag.\n");
return 1;
}
printf("Success, URL record written to tag.\n");
//! [Interesting]
delete nfc;
return 0;
}

101
examples/c++/pn532.cxx Normal file
View File

@ -0,0 +1,101 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
#include <unistd.h>
#include <signal.h>
#include <iostream>
#include "pn532.h"
using namespace std;
bool shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the
// IRQ, and gpio 2 for the reset pin.
upm::PN532 *nfc = new upm::PN532(3, 2);
if (!nfc->init())
cerr << "init() failed" << endl;
uint32_t vers = nfc->getFirmwareVersion();
if (vers)
printf("Got firmware version: 0x%08x\n", vers);
else
{
printf("Could not identify PN532\n");
return 1;
}
// Now scan and identify any cards that come in range (1 for now)
// Retry forever
nfc->setPassiveActivationRetries(0xff);
nfc->SAMConfig();
uint8_t uidSize;
uint8_t uid[7];
while (shouldRun)
{
memset(uid, 0, 7);
if (nfc->readPassiveTargetID(nfc->BAUD_MIFARE_ISO14443A,
uid, &uidSize, 2000))
{
// found a card
printf("Found a card: UID len %d\n", uidSize);
printf("UID: ");
for (int i = 0; i < uidSize; i++)
printf("%02x ", uid[i]);
printf("\n");
printf("SAK: 0x%02x\n", nfc->getSAK());
printf("ATQA: 0x%04x\n\n", nfc->getATQA());
sleep(1);
}
else
{
printf("Waiting for a card...\n");
}
}
//! [Interesting]
delete nfc;
return 0;
}

View File

@ -0,0 +1,110 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
#include <unistd.h>
#include <iostream>
#include "rgbringcoder.h"
#include <signal.h>
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// There are a lot of pins to hook up. These pins are valid for the
// Edison board, but may need to be adjusted for other platforms.
// In order:
// enable - 4
// latch - 10
// clear - 11
// clock - 2
// data - 9
// switch - 7
// red pwm - 3
// green pwm - 5
// blue pwm - 6
// encA - 12
// encB - 13
upm::RGBRingCoder *ringCoder =
new upm::RGBRingCoder(4, 10, 11, 2, 9, 7, 12, 13, 3, 5, 6);
uint16_t spin = 0x0001;
bool oldState = false;
int oldPos = 0;
// Lets go green
ringCoder->setRGBLED(0.99, 0.01, 0.99);
while (shouldRun)
{
// you spin me round...
if (spin == 0)
spin = 0x0001;
ringCoder->setRingLEDS(spin);
spin <<= 1;
// check button state
bool bstate = ringCoder->getButtonState();
if (bstate != oldState)
{
cout << "Button state changed from " << oldState << " to "
<< bstate << endl;
oldState = bstate;
}
// check encoder position
int epos = ringCoder->getEncoderPosition();
if (epos != oldPos)
{
cout << "Encoder position changed from " << oldPos << " to "
<< epos << endl;
oldPos = epos;
}
usleep(100000);
}
//! [Interesting]
delete ringCoder;
return 0;
}

View File

@ -0,0 +1,66 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
#include <unistd.h>
#include <signal.h>
#include <iostream>
#include "sainsmartks.h"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main(int argc, char **argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// use default pins
upm::SAINSMARTKS* lcd = new upm::SAINSMARTKS();
lcd->setCursor(0,0);
lcd->write("Sainsmart KS");
lcd->setCursor(1,2);
lcd->write("Hello World");
// output current key value every second.
while (shouldRun)
{
cout << "Button value: " << lcd->getRawKeyValue() << endl;
sleep(1);
}
//! [Interesting]
delete lcd;
return 0;
}

View File

@ -95,4 +95,5 @@ main(int argc, char **argv)
delete lcd;
//! [Interesting]
return 0;
}

View File

@ -123,4 +123,5 @@ main(int argc, char **argv)
delete lcd;
//! [Interesting]
return 0;
}

View File

@ -47,7 +47,7 @@ main(int argc, char** argv)
int timezone = -7; // Your UTC offset
time_t rawtime;
struct tm * gmt;
char myTime[4];
char myTime[5];
fprintf(stdout, "TM1637 Display Example\n");
signal(SIGINT, sig_handler);
@ -62,8 +62,10 @@ main(int argc, char** argv)
time(&rawtime); // Update raw time
gmt = gmtime(&rawtime); // Get current time
int hour = (gmt) ? gmt->tm_hour : 0;
int min = (gmt) ? gmt->tm_min : 0;
// Format and store the time in 24 hour format
sprintf(myTime, "%2d%02d", (gmt->tm_hour + timezone + 24) % 24, gmt->tm_min);
snprintf(myTime, 5, "%2d%02d", (hour + timezone + 24) % 24, min);
myDisplay.write(myTime); // Write to display as string
myDisplay.setColon(point ^= true); // Toggle the dots on the display

View File

@ -0,0 +1,64 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
var sensorObj = require('jsupm_mpu9150');
// Instantiate an AK8975 on default I2C bus and address
var sensor = new sensorObj.AK8975();
// Initialize the device with default values
sensor.init();
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// Output data every half second until interrupted
setInterval(function()
{
sensor.update();
sensor.getMagnetometer(x, y, z);
console.log("Magnetometer: MX: " + sensorObj.floatp_value(x) +
" MY: " + sensorObj.floatp_value(y) +
" MZ: " + sensorObj.floatp_value(z));
console.log();
}, 500);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,51 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
function exit()
{
lcd = null;
lcdObj.cleanUp();
lcdObj = null;
process.exit(0);
}
// Load i2clcd module
var lcdObj = require('jsupm_i2clcd');
var lcd = new lcdObj.EBOLED();
lcd.clear();
lcd.setCursor(2, 0);
lcd.write("Hello");
lcd.setCursor(3, 5);
lcd.write("World!");
console.log("Sleeping for 5 seconds...");
setTimeout(exit, 5000);

View File

@ -0,0 +1,49 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jun Kato
* Contributions: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
// Instantiate a Grove Circular LED on gpio pins 5 and 4
var GCL = require("jsupm_grovecircularled");
var circle = new GCL.GroveCircularLED(5, 4);
var level = 0;
// Show a spinner.
var myInterval = setInterval(function()
{
circle.setSpinner(level);
level = (level + 1) % 24;
}, 100);
// When exiting, clear interval and print message.
process.on('SIGINT', function()
{
clearInterval(myInterval);
circle.setLevel(0);
circle = null;
GCL.cleanUp();
console.log("Exiting...");
process.exit(0);
});

View File

@ -0,0 +1,55 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
var barometerObj = require('jsupm_hp20x');
// Instantiate an HP20X on default I2C bus and address
var bar = new barometerObj.HP20X();
// Initialize the device with default values
bar.init();
// Output data every second until interrupted
setInterval(function()
{
console.log("Temperature: " + bar.getTemperature() + " Celcius");
console.log("Pressure: " + bar.getPressure() + " Millibars");
console.log("Altitude: " + bar.getAltitude() + " Meters");
console.log("");
}, 1000);
// exit on ^C
process.on('SIGINT', function()
{
bar = null;
barometerObj.cleanUp();
barometerObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,77 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
var sensorObj = require('jsupm_lsm9ds0');
// Instantiate an LSM9DS0 using default parameters (bus 1, gyro addr 6b,
// xm addr 1d)
var sensor = new sensorObj.LSM9DS0();
// Initialize the device with default values
sensor.init();
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// Output data every half second until interrupted
setInterval(function()
{
sensor.update();
sensor.getAccelerometer(x, y, z);
console.log("Accelerometer: AX: " + sensorObj.floatp_value(x) +
" AY: " + sensorObj.floatp_value(y) +
" AZ: " + sensorObj.floatp_value(z));
sensor.getGyroscope(x, y, z);
console.log("Gyroscope: GX: " + sensorObj.floatp_value(x) +
" AY: " + sensorObj.floatp_value(y) +
" AZ: " + sensorObj.floatp_value(z));
sensor.getMagnetometer(x, y, z);
console.log("Magnetometer: MX: " + sensorObj.floatp_value(x) +
" MY: " + sensorObj.floatp_value(y) +
" MZ: " + sensorObj.floatp_value(z));
console.log("Temperature: " + sensor.getTemperature());
console.log();
}, 500);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,59 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
var nfcTagObj = require('jsupm_m24lr64e');
// Instantiate a M24LR64E Grove NFC Tag Module on UART 0
var nfcTag = new nfcTagObj.M24LR64E(nfcTagObj.M24LR64E_I2C_BUS);
// This example accesses the device in the 'user' (default) mode,
// reads the last byte of data in the EEPROM, inverts it, writes
// it back, and then re-reads it.
// Read the last byte of the EEPROM area
var addr = (nfcTagObj.M24LR64E.EEPROM_I2C_LENGTH - 1);
console.log("Address: " + addr);
var byte = nfcTag.readByte(addr);
console.log("Read byte: " + byte.toString(16));
// Now change it to it's opposite and write it
byte = (~byte & 0xff);
nfcTag.writeByte(addr, byte);
console.log("Wrote inverted byte: " + byte.toString(16));
// Now read it back.
byte = nfcTag.readByte(addr);
console.log("Read byte: " + byte.toString(16));
// clean up
nfcTag = null;
nfcTagObj.cleanUp();
nfcTagObj = null;
console.log("Exiting...");
process.exit(0);

View File

@ -0,0 +1,71 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
var sensorObj = require('jsupm_mpu9150');
// Instantiate an MPU60X0 on default I2C bus and address
var sensor = new sensorObj.MPU60X0();
// Initialize the device with default values
sensor.init();
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// Output data every half second until interrupted
setInterval(function()
{
sensor.update();
sensor.getAccelerometer(x, y, z);
console.log("Accelerometer: AX: " + sensorObj.floatp_value(x) +
" AY: " + sensorObj.floatp_value(y) +
" AZ: " + sensorObj.floatp_value(z));
sensor.getGyroscope(x, y, z);
console.log("Gyroscope: GX: " + sensorObj.floatp_value(x) +
" AY: " + sensorObj.floatp_value(y) +
" AZ: " + sensorObj.floatp_value(z));
console.log("Temperature: " + sensor.getTemperature());
console.log();
}, 500);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,76 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
var sensorObj = require('jsupm_mpu9150');
// Instantiate an MPU9105 on default I2C bus and address
var sensor = new sensorObj.MPU9150();
// Initialize the device with default values
sensor.init();
var x = new sensorObj.new_floatp();
var y = new sensorObj.new_floatp();
var z = new sensorObj.new_floatp();
// Output data every half second until interrupted
setInterval(function()
{
sensor.update();
sensor.getAccelerometer(x, y, z);
console.log("Accelerometer: AX: " + sensorObj.floatp_value(x) +
" AY: " + sensorObj.floatp_value(y) +
" AZ: " + sensorObj.floatp_value(z));
sensor.getGyroscope(x, y, z);
console.log("Gyroscope: GX: " + sensorObj.floatp_value(x) +
" AY: " + sensorObj.floatp_value(y) +
" AZ: " + sensorObj.floatp_value(z));
sensor.getMagnetometer(x, y, z);
console.log("Magnetometer: MX: " + sensorObj.floatp_value(x) +
" MY: " + sensorObj.floatp_value(y) +
" MZ: " + sensorObj.floatp_value(z));
console.log("Temperature: " + sensor.getTemperature());
console.log();
}, 500);
// exit on ^C
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,136 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
// Load PN532 module
var pn532 = require('jsupm_pn532');
// Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the
// IRQ, and gpio 2 for the reset pin.
var myNFCObj = new pn532.PN532(3, 2);
function writeUrl()
{
if (uidSize.getitem(0) != 7)
{
console.log("This example will only write an NDEF URI to preformatted");
console.log("Mifare Ultralight or NTAG2XX tags");
exit();
}
// 48 bytes is maximum data area on ultralight cards, so we use that
// as the maximum datasize here. Obviously if you have a bigger
// card, you can write more data.
if (!myNFCObj.ntag2xx_WriteNDEFURI(pn532.PN532.NDEF_URIPREFIX_HTTP,
url, 48))
{
// failure
console.log("Failed to write NDEF record tag.");
exit(1);
}
console.log("Success, URL record written to tag.");
}
function toHex(d, pad)
{
// pad should be between 1 and 8
return ("00000000"+(Number(d).toString(16))).slice(-pad)
}
function exit()
{
clearInterval(myInterval);
myNFCObj = null;
pn532.cleanUp();
pn532 = null;
console.log("Exiting");
process.exit(0);
}
// When exiting: clear interval, and print message
process.on('SIGINT', function()
{
exit();
});
// "main"
if (!myNFCObj.init())
console.log("init() failed");
var vers = myNFCObj.getFirmwareVersion();
if (vers)
console.log("Got firmware version: " + toHex(vers, 8));
else
{
console.log("Could not identify PN532");
exit();
}
// Now scan and identify any cards that come in range (1 for now)
// Retry forever
myNFCObj.setPassiveActivationRetries(0xff);
myNFCObj.SAMConfig();
var uidSize = new pn532.uint8Array(0);
var uid = new pn532.uint8Array(7);
// the URL we want to add as an NDEF record
// NOTE: this cannot exceed 34 characters.
url = "iotdk.intel.com";
var myInterval = setInterval(function()
{
for (var x = 0; x < 7; x++)
uid.setitem(x, 0);
if (myNFCObj.readPassiveTargetID(pn532.PN532.BAUD_MIFARE_ISO14443A,
uid, uidSize, 2000))
{
// found a card
console.log("Found a card: UID len " + uidSize.getitem(0));
process.stdout.write("UID: ");
for (var i = 0; i < uidSize.getitem(0); i++)
{
var byteVal = uid.getitem(i);
process.stdout.write(toHex(byteVal, 2) + " ");
}
process.stdout.write("\n");
console.log("SAK: " + toHex(myNFCObj.getSAK(), 2));
console.log("ATQA: " + toHex(myNFCObj.getATQA(), 4));
console.log(" ");
// write the URL
writeUrl();
clearInterval(myInterval);
return;
}
else
console.log("Waiting for a card...");
}, 1000);

View File

@ -0,0 +1,102 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
// Load PN532 module
var pn532 = require('jsupm_pn532');
// Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the
// IRQ, and gpio 2 for the reset pin.
var myNFCObj = new pn532.PN532(3, 2);
if (!myNFCObj.init())
console.log("init() failed");
var vers = myNFCObj.getFirmwareVersion();
if (vers)
console.log("Got firmware version: " + toHex(vers, 8));
else
{
console.log("Could not identify PN532");
exit();
}
// Now scan and identify any cards that come in range (1 for now)
// Retry forever
myNFCObj.setPassiveActivationRetries(0xff);
myNFCObj.SAMConfig();
var uidSize = new pn532.uint8Array(0);
var uid = new pn532.uint8Array(7);
var myInterval = setInterval(function()
{
for (var x = 0; x < 7; x++)
uid.setitem(x, 0);
if (myNFCObj.readPassiveTargetID(pn532.PN532.BAUD_MIFARE_ISO14443A,
uid, uidSize, 2000))
{
// found a card
console.log("Found a card: UID len " + uidSize.getitem(0));
process.stdout.write("UID: ");
for (var i = 0; i < uidSize.getitem(0); i++)
{
var byteVal = uid.getitem(i);
process.stdout.write(toHex(byteVal, 2) + " ");
}
process.stdout.write("\n");
console.log("SAK: " + toHex(myNFCObj.getSAK(), 2));
console.log("ATQA: " + toHex(myNFCObj.getATQA(), 4));
console.log(" ");
}
else
console.log("Waiting for a card...");
}, 1000);
function toHex(d, pad)
{
// pad should be between 1 and 8
return ("00000000"+(Number(d).toString(16))).slice(-pad)
}
function exit()
{
clearInterval(myInterval);
myNFCObj = null;
pn532.cleanUp();
pn532 = null;
console.log("Exiting");
process.exit(0);
}
// When exiting: clear interval, and print message
process.on('SIGINT', function()
{
exit();
});

View File

@ -0,0 +1,98 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
var ringcoderObj = require('jsupm_rgbringcoder');
// There are a lot of pins to hook up. These pins are valid for the
// Edison board, but may need to be adjusted for other platforms.
// In order:
// enable - 4
// latch - 10
// clear - 11
// clock - 2
// data - 9
// switch - 7
// red pwm - 3
// green pwm - 5
// blue pwm - 6
// encA - 12
// encB - 13
var ringCoder = new ringcoderObj.RGBRingCoder(4, 10, 11, 2, 9, 7, 12, 13, 3,
5, 6);
var spin = 0x0001;
var oldState = false;
var oldPos = 0;
// Lets go green
ringCoder.setRGBLED(0.99, 0.01, 0.99);
setInterval(function()
{
// you spin me round...
if ((spin & 0xffff) == 0)
spin = 0x0001;
ringCoder.setRingLEDS(spin);
spin <<= 1;
// check button state
var bstate = ringCoder.getButtonState();
if (bstate != oldState)
{
console.log("Button state changed from " + oldState + " to "
+ bstate);
oldState = bstate;
}
// check encoder position
var epos = ringCoder.getEncoderPosition();
if (epos != oldPos)
{
console.log("Encoder position changed from " + oldPos + " to "
+ epos);
oldPos = epos;
}
}, 100);
// exit on ^C
process.on('SIGINT', function()
{
ringCoder = null;
ringcoderObj.cleanUp();
ringcoderObj = null;
console.log("Exiting.");
process.exit(0);
});

View File

@ -0,0 +1,53 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* 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.
*/
var sainsmartObj = require('jsupm_i2clcd');
// Instantiate a Sainsmart LCD Keypad Shield using default pins
var lcd = new sainsmartObj.SAINSMARTKS();
lcd.setCursor(0,0);
lcd.write("Sainsmart KS");
lcd.setCursor(1,2);
lcd.write("Hello World");
// output current key value every second.
setInterval(function()
{
console.log("Button value: " + lcd.getRawKeyValue());
}, 1000);
// exit on ^C
process.on('SIGINT', function()
{
lcd = null;
sainsmartObj.cleanUp();
sainsmartObj = null;
console.log("Exiting.");
process.exit(0);
});

59
examples/python/ak8975.py Normal file
View File

@ -0,0 +1,59 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# 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.
import time, sys, signal, atexit
import pyupm_mpu9150 as sensorObj
# Instantiate an AK8975 on I2C bus 0
sensor = sensorObj.AK8975()
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
sensor.init()
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
while (1):
sensor.update()
sensor.getMagnetometer(x, y, z)
print "Magnetometer: MX: ", sensorObj.floatp_value(x),
print " MY: ", sensorObj.floatp_value(y),
print " MZ: ", sensorObj.floatp_value(z)
print
time.sleep(.5)

40
examples/python/eboled.py Normal file
View File

@ -0,0 +1,40 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# 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.
import time, sys
import pyupm_i2clcd as lcdObj
# setup with default values
lcd = lcdObj.EBOLED();
lcd.clear();
lcd.setCursor(2, 0);
lcd.write("Hello");
lcd.setCursor(3, 5);
lcd.write("World!");
print "Sleeping for 5 seconds..."
time.sleep(5)

View File

@ -0,0 +1,50 @@
#!/usr/bin/python
#
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# 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.
import time, sys, signal, atexit
import pyupm_grovecircularled as upmGroveCircularLED
# Exit handlers
def SIGINTHandler(signum, frame):
raise SystemExit
def exitHandler():
circle.setLevel(0, True)
print "Exiting"
sys.exit(0)
# This function lets you run code on exit
atexit.register(exitHandler)
# This function stops python from printing a stacktrace when you hit control-C
signal.signal(signal.SIGINT, SIGINTHandler)
# Instantiate a Grove Circular LED on gpio pins 5 and 4
circle = upmGroveCircularLED.GroveCircularLED(5, 4)
level = 0
while(1):
circle.setSpinner(level)
level = (level + 1) % 24
time.sleep(.1)

54
examples/python/hp20x.py Normal file
View File

@ -0,0 +1,54 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# 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.
import time, sys, signal, atexit
import pyupm_hp20x as barometerObj
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit,
# including functions from ringCoder
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
# Instantiate an HP20X on default I2C bus and address
bar = barometerObj.HP20X()
# Initialize the device with default values
bar.init()
while(1):
print "Temperature:", bar.getTemperature(), "Celcius"
print "Pressure: ", bar.getPressure(), "Millibars"
print "Altitude: ", bar.getAltitude(), "Meters"
print
time.sleep(1)

View File

@ -0,0 +1,71 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# 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.
import time, sys, signal, atexit
import pyupm_lsm9ds0 as sensorObj
# Instantiate an LSM9DS0 using default parameters (bus 1, gyro addr 6b,
# xm addr 1d)
sensor = sensorObj.LSM9DS0()
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
sensor.init()
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
while (1):
sensor.update()
sensor.getAccelerometer(x, y, z)
print "Accelerometer: AX: ", sensorObj.floatp_value(x),
print " AY: ", sensorObj.floatp_value(y),
print " AZ: ", sensorObj.floatp_value(z)
sensor.getGyroscope(x, y, z)
print "Gyroscope: GX: ", sensorObj.floatp_value(x),
print " GY: ", sensorObj.floatp_value(y),
print " GZ: ", sensorObj.floatp_value(z)
sensor.getMagnetometer(x, y, z)
print "Magnetometer: MX: ", sensorObj.floatp_value(x),
print " MY: ", sensorObj.floatp_value(y),
print " MZ: ", sensorObj.floatp_value(z)
print "Temperature: ", sensor.getTemperature()
print
time.sleep(.5)

View File

@ -0,0 +1,49 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# 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.
import sys
import pyupm_m24lr64e as nfcTagObj
# Instantiate a M24LR64E Grove NFC Tag Module on UART 0
nfcTag = nfcTagObj.M24LR64E(nfcTagObj.M24LR64E_I2C_BUS)
# This example accesses the device in the 'user' (default) mode,
# reads the last byte of data in the EEPROM, inverts it, writes
# it back, and then re-reads it.
# Read the last byte of the EEPROM area
addr = (nfcTagObj.M24LR64E.EEPROM_I2C_LENGTH - 1)
print "Address: ", addr
byte = nfcTag.readByte(addr)
print "Read byte: ", format(byte, '02x')
# Now change it to it's opposite and write it
byte = (~byte & 0xff)
nfcTag.writeByte(addr, byte)
print "Wrote inverted byte: ", format(byte, '02x')
# Now read it back.
byte = nfcTag.readByte(addr)
print "Read byte: ", format(byte, '02x')

View File

@ -0,0 +1,65 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# 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.
import time, sys, signal, atexit
import pyupm_mpu9150 as sensorObj
# Instantiate an MPU60X0 on I2C bus 0
sensor = sensorObj.MPU60X0()
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
sensor.init()
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
while (1):
sensor.update()
sensor.getAccelerometer(x, y, z)
print "Accelerometer: AX: ", sensorObj.floatp_value(x),
print " AY: ", sensorObj.floatp_value(y),
print " AZ: ", sensorObj.floatp_value(z)
sensor.getGyroscope(x, y, z)
print "Gyroscope: GX: ", sensorObj.floatp_value(x),
print " GY: ", sensorObj.floatp_value(y),
print " GZ: ", sensorObj.floatp_value(z)
print "Temperature: ", sensor.getTemperature()
print
time.sleep(.5)

View File

@ -0,0 +1,70 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# 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.
import time, sys, signal, atexit
import pyupm_mpu9150 as sensorObj
# Instantiate an MPU9150 on I2C bus 0
sensor = sensorObj.MPU9150()
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
sensor.init()
x = sensorObj.new_floatp()
y = sensorObj.new_floatp()
z = sensorObj.new_floatp()
while (1):
sensor.update()
sensor.getAccelerometer(x, y, z)
print "Accelerometer: AX: ", sensorObj.floatp_value(x),
print " AY: ", sensorObj.floatp_value(y),
print " AZ: ", sensorObj.floatp_value(z)
sensor.getGyroscope(x, y, z)
print "Gyroscope: GX: ", sensorObj.floatp_value(x),
print " GY: ", sensorObj.floatp_value(y),
print " GZ: ", sensorObj.floatp_value(z)
sensor.getMagnetometer(x, y, z)
print "Magnetometer: MX: ", sensorObj.floatp_value(x),
print " MY: ", sensorObj.floatp_value(y),
print " MZ: ", sensorObj.floatp_value(z)
print "Temperature: ", sensor.getTemperature()
print
time.sleep(.5)

View File

@ -0,0 +1,105 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# 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.
import time, sys, signal, atexit
import pyupm_pn532 as upmPn532
# Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the
# IRQ, and gpio 2 for the reset pin.
myNFC = upmPn532.PN532(3, 2)
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
if (not myNFC.init()):
print "init() failed"
sys.exit(0)
vers = myNFC.getFirmwareVersion()
if (vers):
print "Got firmware version: %08x" % vers
else:
print "Could not identify PN532"
sys.exit(0)
# Now scan and identify any cards that come in range (1 for now)
# Retry forever
myNFC.setPassiveActivationRetries(0xff)
myNFC.SAMConfig()
uidSize = upmPn532.uint8Array(0)
uid = upmPn532.uint8Array(7)
# the URL we want to add as an NDEF record
# NOTE: this cannot exceed 34 characters.
url = "iotdk.intel.com"
foundCard = False
while (not foundCard):
for i in range(7):
uid.__setitem__(i, 0)
if (myNFC.readPassiveTargetID(upmPn532.PN532.BAUD_MIFARE_ISO14443A,
uid, uidSize, 2000)):
# found a card
print "Found a card: UID len", uidSize.__getitem__(0)
print "UID: ",
for i in range(uidSize.__getitem__(0)):
print "%02x" % uid.__getitem__(i),
print
print "SAK: %02x" % myNFC.getSAK()
print "ATQA: %04x" % myNFC.getATQA()
print
foundCard = True
else:
print "Waiting for a card...\n"
if (uidSize.__getitem__(0) != 7):
print "This example will only write an NDEF URI to preformatted"
print "Mifare Ultralight or NTAG2XX tags"
sys.exit(1)
# 48 bytes is maximum data area on ultralight cards, so we use that
# as the maximum datasize here. Obviously if you have a bigger
# card, you can write more data.
if (not myNFC.ntag2xx_WriteNDEFURI(upmPn532.PN532.NDEF_URIPREFIX_HTTP, url, 48)):
# failure
print "Failed to write NDEF record tag."
sys.exit(1)
print "Success, URL record written to tag."

85
examples/python/pn532.py Normal file
View File

@ -0,0 +1,85 @@
#!/usr/bin/python
# Author: Zion Orent <zorent@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# 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.
import time, sys, signal, atexit
import pyupm_pn532 as upmPn532
# Instantiate an PN532 on I2C bus 0 (default) using gpio 3 for the
# IRQ, and gpio 2 for the reset pin.
myNFC = upmPn532.PN532(3, 2)
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This lets you run code on exit
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
if (not myNFC.init()):
print "init() failed"
sys.exit(0)
vers = myNFC.getFirmwareVersion()
if (vers):
print "Got firmware version: %08x" % vers
else:
print "Could not identify PN532"
sys.exit(0)
# Now scan and identify any cards that come in range (1 for now)
# Retry forever
myNFC.setPassiveActivationRetries(0xff)
myNFC.SAMConfig()
uidSize = upmPn532.uint8Array(0)
uid = upmPn532.uint8Array(7)
while (1):
for i in range(7):
uid.__setitem__(i, 0)
if (myNFC.readPassiveTargetID(upmPn532.PN532.BAUD_MIFARE_ISO14443A,
uid, uidSize, 2000)):
# found a card
print "Found a card: UID len", uidSize.__getitem__(0)
print "UID: ",
for i in range(uidSize.__getitem__(0)):
print "%02x" % uid.__getitem__(i),
print
print "SAK: %02x" % myNFC.getSAK()
print "ATQA: %04x" % myNFC.getATQA()
print
time.sleep(1)
else:
print "Waiting for a card...\n"

View File

@ -0,0 +1,90 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# 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.
import time, sys, signal, atexit
import pyupm_rgbringcoder as upmRGBRingCoder
# There are a lot of pins to hook up. These pins are valid for the
# Edison board, but may need to be adjusted for other platforms.
# In order:
# enable - 4
# latch - 10
# clear - 11
# clock - 2
# data - 9
# switch - 7
# red pwm - 3
# green pwm - 5
# blue pwm - 6
# encA - 12
# encB - 13
ringCoder = upmRGBRingCoder.RGBRingCoder(4, 10, 11, 2, 9, 7, 12, 13, 3,
5, 6)
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit,
# including functions from ringCoder
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
spin = 0x0001;
oldState = False;
oldPos = 0;
# Lets go green
ringCoder.setRGBLED(0.99, 0.01, 0.99);
while(1):
# you spin me round...
if ((spin & 0xffff) == 0):
spin = 0x0001
ringCoder.setRingLEDS(spin)
spin <<= 1
# check button state
bstate = ringCoder.getButtonState()
if (bstate != oldState):
print "Button state changed from", oldState, " to ", bstate
oldState = bstate
# check encoder position
epos = ringCoder.getEncoderPosition()
if (epos != oldPos):
print "Encoder position changed from", oldPos, "to", epos
oldPos = epos
time.sleep(0.1)

View File

@ -0,0 +1,54 @@
#!/usr/bin/python
# Author: Jon Trulson <jtrulson@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# 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.
import time, sys, signal, atexit
import pyupm_i2clcd as sainsmartObj
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit,
# including functions from ringCoder
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
# Instantiate a Sainsmart LCD Keypad Shield using default pins
lcd = sainsmartObj.SAINSMARTKS()
lcd.setCursor(0,0)
lcd.write("Sainsmart KS")
lcd.setCursor(1,2)
lcd.write("Hello World")
# output current key value every second.
while(1):
print "Button value: ", lcd.getRawKeyValue()
time.sleep(1)

View File

@ -55,18 +55,21 @@ endmacro()
macro(upm_doxygen)
if (DOXYGEN_FOUND)
if(NOT DEFINED classname)
set (classname ${libname})
endif()
set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../doxy2swig.py -n
${CMAKE_BINARY_DIR}/xml/${libname}_8h.xml
${CMAKE_BINARY_DIR}/xml/${classname}_8h.xml
${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i
DEPENDS ${CMAKE_BINARY_DIR}/xml/${libname}_8h.xml
DEPENDS ${CMAKE_BINARY_DIR}/xml/${classname}_8h.xml
)
add_custom_target (${libname}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i)
add_dependencies (${libname}doc_i doc)
if (BUILDSWIG)
add_dependencies (_pyupm_${libname} ${libname}doc_i)
add_dependencies (pydoc _pyupm_${libname})
add_dependencies (pydoc _pyupm_${libname})
else ()
add_dependencies (${libname} doc)
endif ()

View File

@ -30,19 +30,20 @@ namespace upm {
/**
* @brief A110X Hall Effect library
* @defgroup a110x libupm-a110x
* @ingroup seeed gpio electric
* @ingroup seeed gpio electric robok
*/
/**
* @library a110x
* @sensor a110x
* @comname A110X Hall Effect Sensor
* @altname A1101, A1102, A1103, A1004, A1106
* @altname Grove Hall Sensor
* @altid A1101, A1102, A1103, A1004, A1106
* @type electric
* @man seeed
* @web http://www.allegromicro.com/en/Products/Magnetic-Digital-Position-Sensor-ICs/Hall-Effect-Unipolar-Switches/A1101-2-3-4-6.aspx
* @con gpio
* @kit robok
*
* @brief API for the A110X Hall Effect sensors
*
@ -62,32 +63,32 @@ namespace upm {
/**
* A110x digital sensor constructor
*
* @param pin digital pin to use
* @param pin Digital pin to use
*/
A110X(int pin);
/**
* A110X Destructor
* A110X destructor
*/
~A110X();
/**
* Determine whether a magnetic field of south polarity has been detected
* Determines whether a magnetic field of south polarity has been detected
*
* @return True if magnetic field detected
*/
bool magnetDetected();
/**
* Install an Interrupt Service Routine (ISR) to be called when
* the appropriate magnetic field is detected.
* Installs an interrupt service routine (ISR) to be called when
* the appropriate magnetic field is detected
*
* @param fptr function pointer to function to be called on interrupt
* @param arg pointer to an object that will be supplied as an
* arguement to the ISR.
* @param fptr Pointer to a function to be called on interrupt
* @param arg Pointer to an object to be supplied as an
* argument to the ISR.
*/
void installISR(void (*isr)(void *), void *arg);
/**
* Uninstall the previously installed Interrupt Service Routine (ISR)
* Uninstalls the previously installed ISR
*
*/
void uninstallISR();

View File

@ -34,7 +34,7 @@
namespace upm {
/**
* @brief AD8232 heart rate monitor library
* @brief AD8232 Heart Rate Monitor library
* @defgroup ad8232 libupm-ad8232
* @ingroup sparkfun gpio medical
*/
@ -50,41 +50,46 @@ namespace upm {
*
* @brief UPM module for the AD8232 Heart Rate Monitor
*
* Note, this sensor must be driven at 3.3v only.
* Note: this sensor must be driven at 3.3V only.
*
* This module will simply spit out the ADC values reported by the
* sensor, with the intent being to send that data somewhere (via
* serial or network port) to another piece of software running on a
* computer that will plot the data for you, like an EKG.
* This module simply spits out the ADC values reported by the sensor, with
* the intent to send that data, via serial or network port, somewhere to
* another piece of software running on a computer that plots the data for
* you, like an EKG.
*
* Processing (https://www.processing.org/), is a piece of software
* that should work, using information from the Sparkfun website.
* Processing (https://www.processing.org/) is software
* that should work, using information from the SparkFun* website.
*
* This example just dumps the raw data:
*
* @image html ad8232.jpg
* <br><em>AD8232 Heart Rate Monitor image provided by SparkFun under
* <a href=https://creativecommons.org/licenses/by-nc-sa/3.0/>
* CC BY-NC-SA-3.0</a>.</em>
*
* This example just dumps the raw data.
* @snippet ad8232.cxx Interesting
*/
class AD8232 {
public:
/**
* AD8232 constructor
*
* @param loPlus digital pin to use for LO+
* @param loMinus digital pin to use LO-
* @param output analog pin to use for reading the data
* @param loPlus Digital pin to use for LO+
* @param loMinus Digital pin to use for LO-
* @param output Analog pin to read the data
*/
AD8232(int loPlus, int loMinus, int output, float aref=AD8232_DEFAULT_AREF);
/**
* AD8232 Destructor
* AD8232 destructor
*/
~AD8232();
/**
* return the current ADC value for the device output pin. If an
* LO (Leads Off) event is detected, 0 will be returned.
* Returns the current ADC value for the device output pin. If an
* LO (leads off) event is detected, 0 is returned.
*
* @return ADC value
*/

View File

@ -52,16 +52,16 @@ namespace upm {
* @web http://www.adafruit.com/products/1438
* @con i2c
*
* @brief API for the ADAFRUITMS1438 motor shield
* @brief API for the AdafruitMS1438 Motor Shield
*
* This class implements support for the stepper and DC motors that
* can be connected to this Motor Shield.
* NOTE: The two servo connections are not actually controlled by
* the pca9685 controller (or this class), rather they are connected
* directly to digital PWM pins 9 and 10 on the arduino breakout.
* Note: the two servo connections are not controlled by the PCA9685
* controller (or this class). They are connected directly to digital
* PWM pins 9 and 10 on the Arduino* breakout board.
*
* @image html adafruitms1438.jpg
* An example using a DC motor conected to M3
* An example using a DC motor connected to M3
* @snippet adafruitms1438.cxx Interesting
* An example using a stepper motor connected to M1 & M2
* @snippet adafruitms1438-stepper.cxx Interesting
@ -89,7 +89,7 @@ namespace upm {
} DCMOTORS_T;
/**
* Enum to specify a Stepper motor
* Enum to specify a stepper motor
*/
typedef enum {
STEPMOTOR_M12 = 0,
@ -99,62 +99,62 @@ namespace upm {
/**
* AdafruitMS1438 constructor
*
* @param bus i2c bus to use
* @param address the address for this sensor
* @param bus I2C bus to use
* @param address Address for this sensor
*/
AdafruitMS1438(int bus, uint8_t address = ADAFRUITMS1438_DEFAULT_I2C_ADDR);
/**
* AdafruitMS1438 Destructor
* AdafruitMS1438 destructor
*/
~AdafruitMS1438();
/**
* Return the number of milliseconds elapsed since initClock(...)
* Returns the number of milliseconds elapsed since initClock(...)
* was last called.
*
* @return elapsed milliseconds
* @return Elapsed milliseconds
*/
uint32_t getMillis(STEPMOTORS_T motor);
/**
* Reset the Clock
* Resets the clock
*
*/
void initClock(STEPMOTORS_T motor);
/**
* Set the PWM period. Note this applies to all PWM channels.
* Sets the PWM period. Note: this applies to all PWM channels.
*
* @param hz set the PWM period
* @param hz Sets the PWM period
*/
void setPWMPeriod(float hz);
/**
* enable PWM output for a motor
* Enables PWM output for a motor
*
* @param motor the DC motor to enable
* @param motor DC motor to enable
*/
void enableMotor(DCMOTORS_T motor);
/**
* disable PWM output for a motor
* Disables PWM output for a motor
*
* @param motor the DC motor to disable
* @param motor DC motor to disable
*/
void disableMotor(DCMOTORS_T motor);
/**
* enable output for a stepper motor
* Enables output for a stepper motor
*
* @param motor the stepper motor to enable
* @param motor Stepper motor to enable
*/
void enableStepper(STEPMOTORS_T motor);
/**
* disable output for a stepper motor
* Disable output for a stepper motor
*
* @param motor the stepper motor to disable
* @param motor Stepper motor to disable
*/
void disableStepper(STEPMOTORS_T motor);
@ -168,57 +168,57 @@ namespace upm {
void setMotorSpeed(DCMOTORS_T motor, int speed);
/**
* set the speed of a stepper in revolution per minute (RPM)
* Sets the speed of a stepper in revolutions per minute (RPM)
*
* @param motor the DC motor to configure
* @param speed speed to set the motor to
* @param motor DC motor to configure
* @param speed Speed to set the motor to
*/
void setStepperSpeed(STEPMOTORS_T motor, int speed);
/**
* set the direction of a DC motor, clockwise or counter clockwise
* Sets the direction of a DC motor, clockwise or counterclockwise
*
* @param motor the DC motor to configure
* @param dir direction to set the motor to
* @param motor DC motor to configure
* @param dir Direction to set the motor in
*/
void setMotorDirection(DCMOTORS_T motor, DIRECTION_T dir);
/**
* set the direction of a stepper motor, clockwise or counter clockwise
* Sets the direction of a stepper motor, clockwise or counterclockwise
*
* @param motor the stepper motor to configure
* @param dir direction to set the motor to
* @param motor Stepper motor to configure
* @param dir Direction to set the motor in
*/
void setStepperDirection(STEPMOTORS_T motor, DIRECTION_T dir);
/**
* set a stepper motor configuration
* Sets a stepper motor configuration
*
* @param motor the stepper motor to configure
* @param stepsPerRev the number of step to complete a full revolution
* @param motor Stepper motor to configure
* @param stepsPerRev Number of steps to complete a full revolution
*/
void stepConfig(STEPMOTORS_T motor, unsigned int stepsPerRev);
/**
* step a stepper motor a specified number of steps
* Steps a stepper motor a specified number of steps
*
* @param motor the stepper motor to step
* @param steps number of steps to move the stepper motor
* @param motor Stepper motor to step
* @param steps Number of steps to move the stepper motor
*/
void stepperSteps(STEPMOTORS_T motor, unsigned int steps);
private:
// SWIG will generate warning for these 'nested structs', however
// those can be ignored as these structs are never exposed.
// SWIG will generate a warning for these 'nested structs'; however,
// it can be ignored as these structs are never exposed.
// struct to hold mappings of the dc motors
// struct to hold mappings of DC motors
typedef struct {
int pwm;
int in1;
int in2;
} DC_PINMAP_T;
// struct to hold mappings of the stepper motors
// struct to hold mappings of stepper motors
typedef struct {
int pwmA;
int in1A;
@ -228,7 +228,7 @@ namespace upm {
int in2B;
} STEPPER_PINMAP_T;
// struct to hold some information about each stepper
// struct to hold information about each stepper
typedef struct {
int stepsPerRev; // steps per revolution
int currentStep; // current step number

View File

@ -30,75 +30,69 @@ using namespace upm;
adafruitss::adafruitss(int bus,int i2c_address)
{
int n;
int result;
mraa_init();
m_i2c = mraa_i2c_init(bus);
pca9685_addr = i2c_address;
result=mraa_i2c_address(m_i2c, pca9685_addr);
mraa_i2c_address(m_i2c, pca9685_addr);
m_rx_tx_buf[0]=PCA9685_MODE1;
m_rx_tx_buf[1]=0;
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
adafruitss::setPWMFreq(60);
adafruitss::update();
}
void adafruitss::setPWMFreq(float freq) {
int result;
freq *= 0.88; // Correct for overshoot in the frequency setting (see issue #11).
float afreq= freq * 0.899683334F; // Correct for overshoot in the frequency setting (see issue #11). (Tested at 60hz with Logic 4 for 50hz and 60hz)
float prescaleval = 25000000;
prescaleval /= 4096;
prescaleval /= freq;
prescaleval /= afreq;
prescaleval -= 1;
_pwm_frequency = 60.18; // FInal achieved frequency measured with Logic 8!
float pwm_frequency = freq; // Use actual requested frequency gives the correct pulse width
_duration_1ms = ((4096*_pwm_frequency)/1000); // This is 1ms duration
_duration_1ms = ((4096*pwm_frequency)/1000); // This is 1ms duration
uint8_t prescale = floor(prescaleval + 0.5);
uint8_t prescale = roundf(prescaleval);
result=mraa_i2c_address(m_i2c, pca9685_addr);
uint8_t oldmode=0;
oldmode = mraa_i2c_read_byte_data(m_i2c,PCA9685_MODE1);
mraa_i2c_address(m_i2c, pca9685_addr);
mraa_i2c_read_byte_data(m_i2c,PCA9685_MODE1);
m_rx_tx_buf[0]=PCA9685_MODE1;
m_rx_tx_buf[1]=0x10; // sleep
result=mraa_i2c_address(m_i2c, pca9685_addr);
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
mraa_i2c_address(m_i2c, pca9685_addr);
mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
m_rx_tx_buf[0]=PCA9685_PRESCALE;
m_rx_tx_buf[1]=prescale;
result=mraa_i2c_address(m_i2c, pca9685_addr);
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
mraa_i2c_address(m_i2c, pca9685_addr);
mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
m_rx_tx_buf[0]=PCA9685_MODE1;
m_rx_tx_buf[1]=0x00;
result=mraa_i2c_address(m_i2c, pca9685_addr);
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
mraa_i2c_address(m_i2c, pca9685_addr);
mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
// result=mraa_i2c_write_byte_data(m_i2c,0x00,PCA9685_MODE1);
// mraa_i2c_write_byte_data(m_i2c,0x00,PCA9685_MODE1);
usleep(5000);
m_rx_tx_buf[0]=PCA9685_MODE1;
m_rx_tx_buf[1]=0xa1;
result=mraa_i2c_address(m_i2c, pca9685_addr);
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
mraa_i2c_address(m_i2c, pca9685_addr);
mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
}
int adafruitss::update(void)
@ -106,21 +100,19 @@ int adafruitss::update(void)
return MRAA_SUCCESS;
}
void adafruitss::servo(uint8_t port, uint8_t servo_type, uint16_t degrees) {
void adafruitss::servo(uint8_t port, uint8_t servo_type, float degrees) {
// Set Servo values
// Degrees is from 0 to 180
// servo_type: 0 = standard 1ms to 2ms
// 1 = extended 0.6ms to 2.4ms
// 2 = extended 0.8ms to 2.2ms
uint16_t duration;
int result;
int r2;
float duration;
if(degrees>180) degrees=180; // Ensure within bounds
if (degrees<0) degrees=0;
switch (servo_type) {
default:
case 0: // Standard Servo 1ms to 2ms
duration = _duration_1ms + ((_duration_1ms*degrees)/180);
break;
@ -135,18 +127,19 @@ void adafruitss::servo(uint8_t port, uint8_t servo_type, uint16_t degrees) {
duration = (_duration_1ms*0.8) + ((_duration_1ms*degrees)/128);
break;
case 3: // Extended Servo 0.9ms to 2.1ms, - GWS Mini STD BB servo
//duration = (_duration_1ms*0.8) + ((_duration_1ms*1.4*degrees)/180); simplified to..
//duration = (_duration_1ms*0.9) + ((_duration_1ms*1.4*degrees)/180); simplified to..
duration = (_duration_1ms*0.9) + ((_duration_1ms*degrees)/120);
break;
}
result=mraa_i2c_address(m_i2c, pca9685_addr);
uint16_t d= roundf(duration);
mraa_i2c_address(m_i2c, pca9685_addr);
m_rx_tx_buf[0]=LED0_REG+4*port;
m_rx_tx_buf[1]=0;
m_rx_tx_buf[2]=0;
m_rx_tx_buf[3]=duration;
m_rx_tx_buf[4]=duration>>8;
m_rx_tx_buf[3]=d;
m_rx_tx_buf[4]=d>>8;
mraa_i2c_write(m_i2c,m_rx_tx_buf,5);
}
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,5);
r2=result;
}

View File

@ -52,15 +52,14 @@
#define PCA9685_PRESCALE_REG 0xFE
#define LED0_REG 0x06
namespace upm {
/**
* @brief Adafruit PCA9685 based servo controller library
* @brief Adafruit PCA9685-based Servo Shield library
* @defgroup adafruitss libupm-adafruitss
* @ingroup adafruit i2c servos
*/
/**
* @library adafruitss
* @sensor adafruitss
@ -70,47 +69,48 @@ namespace upm {
* @web http://www.adafruit.com/product/1411
* @con i2c
*
* @brief API for Adafruit Servo Shield
* @brief API for the Adafruit Servo Shield
*
* UPM library for the PCA9685 based Adafruit 16-channel servo shield. When 3
* or more GWS servos attached results unpredictable. Adafruit do recommend a
* capacitor be installed on the board which should alleviate the issue.
* Sizing depends on servos and count.
* UPM library for the PCA9685-based Adafruit 16-channel servo shield. If 3
* or more GWS servos are attached, results could be unpredictable. Adafruit
* Industries recommend installing a capacitor on the board, which should
* alleviate the issue. Sizing depends on servos and their number.
*
* @image html adafruitss.jpg
* @image html adafruitss.jpg
* @snippet adafruitss.cxx Interesting
*/
class adafruitss {
public:
/**
* Creates a adafruitss object
* Creates an adafruitss object
*
* @param bus number of used i2c bus
* @param i2c_address address of servo controller on i2c bus
* @param bus Number of the used I2C bus
* @param i2c_address Address of the servo shield on the I2C bus
*/
adafruitss(int bus, int i2c_address);
int update(void);
/**
* Sets the frequency for your servos
* Sets the frequency of the servos
*
* @param freq the frequency at which the servos operate
* @param freq Frequency at which the servos operate
*/
void setPWMFreq(float freq);
/**
* Moves the one of the servos to the specified angle
* Moves one of the servos to a specified angle
*
* @param port port of the servo on the controller (servo number)
* @param servo_type can be 0 = standard 1ms to 2ms, 1 = extended 0.6ms to 2.4ms, or 2 = extended 0.8ms to 2.2ms
* @param degrees angle to set the servo to
* @param port Port of the servo on the shield (servo number)
* @param servo_type Can be 0 = standard (1ms to 2ms), 1 = extended
* (0.6ms to 2.4ms), or 2 = extended (0.8ms to 2.2ms)
* @param degrees Angle to set the servo to
*/
void servo(uint8_t port, uint8_t servo_type, uint16_t degrees);
void servo(uint8_t port, uint8_t servo_type, float degrees);
private:
int pca9685_addr;
mraa_i2c_context m_i2c;
uint8_t m_rx_tx_buf[MAX_BUFFER_LENGTH];
float _pwm_frequency;
float _duration_1ms;
};

View File

@ -49,14 +49,14 @@
namespace upm {
/**
* @brief ADC121C021 I2C analog digital converter library
* @brief ADC121C021 I2C Analog-to-Digital Converter library
* @defgroup adc121c021 libupm-adc121c021
* @ingroup seeed i2c electric
*/
/**
* valid cycle times for automatic conversion mode
* Valid cycle times for the automatic conversion mode
*/
typedef enum { ADC121C021_CYCLE_NONE = 0, // disabled
@ -72,18 +72,18 @@ namespace upm {
/**
* @library adc121c021
* @sensor adc121c021
* @comname ADC121C021 Analog Digital Converter
* @comname ADC121C021 Analog-to-Digital Converter
* @altname Grove I2C ADC
* @type electric
* @man seeed
* @web http://www.seeedstudio.com/depot/Grove-I2C-ADC-p-1580.html
* @con i2c
*
* @brief API for the ADC121C021 I2C ADC
* @brief API for the ADC121C021 I2C Analog-to-Digital Converter
*
* UPM module for the ADC121C021 12 bit Analog to Digital (ADC) converter.
* By providing a constant reference voltage, this sensor helps
* to increase the accuracy of a value collected from an analog sensor.
* UPM module for the ADC121C021 12-bit analog-to-digital converter (ADC).
* By constantly providing a reference voltage, this sensor helps
* increase the accuracy of a value collected from an analog sensor.
*
* @image html adc121c021.jpg
* @snippet adc121c021.cxx Interesting
@ -91,208 +91,212 @@ namespace upm {
class ADC121C021 {
public:
/**
* adc121c021 ADC constructor
* ADC121C021 ADC constructor
*
* @param bus i2c bus to use
* @param address the address for this sensor; default is 0x55
* @param vref reference voltage for this sensor; default is 3.0
* @param bus I2C bus to use
* @param address Address for this sensor; default is 0x55
* @param vref Reference voltage for this sensor; default is 3.0v
*/
ADC121C021(int bus, uint8_t address = ADC121C021_DEFAULT_I2C_ADDR,
float vref = ADC121C021_DEFAULT_VREF);
/**
* ADC121C021 Destructor
* ADC121C021 destructor
*/
~ADC121C021();
/**
* Write byte value into register
* Writes a byte value into the register
*
* @param reg register location to write into
* @param byte byte to write
* @param reg Register location to write into
* @param byte Byte to write
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t writeByte(uint8_t reg, uint8_t byte);
/**
* Write word value into register
* Writes a word value into the register
*
* @param reg register location to write into
* @param word word to write
* @param reg Register location to write into
* @param word Word to write
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t writeWord(uint8_t reg, uint16_t word);
/**
* Read byte value from register
* Reads the byte value from the register
*
* @param reg register location to read from
* @return value at specified register
* @param reg Register location to read from
* @return Value in the specified register
*/
uint8_t readByte(uint8_t reg);
/**
* Read word value from register
* Reads the word value from the register
*
* @param reg register location to read from
* @return value at specified register
* @param reg Register location to read from
* @return Value in the specified register
*/
uint16_t readWord(uint8_t reg);
/**
* Read current value of conversion
* Reads the current value of conversion
*
* @return current conversion value
* @return Current value of conversion
*/
uint16_t value();
/**
* Convert a supplied value to voltage based on set VREF
* Converts a supplied value to voltage based on the set vref
*
* @param val value of conversion (from value())
* @return conversion value in volts
* @param val Value of conversion (from value())
* @return Value of conversion in volts
*/
float valueToVolts(uint16_t val);
/**
* Read current status of the alert flag. If the flag is set, the
* lower or upper alert indicators will be set as appropriate, and
* Reads the current status of the alert flag. If the flag is set, the
* low or high alert indicators are set as appropriate, and
* you can access these values with alertLowTriggered() or
* alertHighTriggered().
*
* @return true if the alert flag is set
* @return True if the alert flag is set
*/
bool getAlertStatus();
/**
* Return the current value of m_alertLow. You must call
* Returns the current value of m_alertLow. You must call
* getAlertStatus() to update this value.
*
* @return current alert low status
* @return Current status of the alert low flag
*/
bool alertLowTriggered() { return m_alertLow; };
/**
* Return the current value of m_alertHigh. You must call
* Returns the current value of m_alertHigh. You must call
* getAlertStatus() to update this value.
*
* @return current alert high status
* @return Current status of the alert high flag
*/
bool alertHighTriggered() { return m_alertHigh; };
/**
* Clear the alert low and high flags. This will also clear the
* Clears the alert low and alert high flags. This also clears the
* last stored alert values.
*/
void clearAlertStatus();
/**
* Enable or disable the Alert Flag functionality. If enabled,
* then when the measured value exceeds the low or high limits
* configured, the alert flag will be set. Use getAlertStatus()
* Enables or disables the alert flag functionality. If enabled,
* when the measured value exceeds the low or high limits
* configured, the alert flag is set. Use getAlertStatus()
* to access these values.
*
* @param enable if true, enables Alert Flag; otherwise, disables Alert Flag
* @param enable If true, enables the alert flag; otherwise, disables the
* alert flag
*/
void enableAlertFlag(bool enable);
/**
* Enable or disable the Alert Pin functionality.
* Enables or disables the alert pin functionality.
*
* @param enable if true, enables Alert Pin; otherwise, disables Alert Pin
* @param enable If true, enables the alert pin; otherwise, disables the
* alert pin
*/
void enableAlertPin(bool enable);
/**
* Enable or disable the Alert Hold functionality. When Alert
* Hold is enabled, the alert status remains until manually
* cleared via clearAlertStatus(). Otherwise, the alert will self
* clear when the value moves into the defined limits if alerts
* Enables or disables the alert hold functionality. When the alert
* hold is enabled, the alert status remains until manually
* cleared via clearAlertStatus(). Otherwise, the alert self-clears
* when the value moves into the defined limits if alerts
* are enabled via enableAlertFlag().
*
* @param enable if true, enables Alert Hold; otherwise, disables Alert Hold
* @param enable If true, enables the alert hold; otherwise, disables the
* alert hold
*/
void enableAlertHold(bool enable);
/**
* If the Alert Pin fnctionality is enabled, define the active
* polarity of the pin in an alert condition. Enabling this sets
* the pin to active high in an alert condition, otherwise an
* If the alert pin is enabled, defines the active
* polarity of the pin in an alert condition. Enabling this sets
* the pin to active high in an alert condition; otherwise,
* active low is used.
*
* @param enable if true, Alert Pin is active high, else active low
* @param enable If true, the alert pin is active high; otherwise, active
* low
*/
void enableAlertPinPolarityHigh(bool enable);
/**
* Enable or disable Automatic Conversion mode. When enabled, the
* ADC will sample and update the conversion value independently.
* This is disabled by default, and a conversion is only done by
* Enables or disables the automatic conversion mode. When enabled, the
* ADC samples and updates the conversion value independently.
* It is disabled by default, so conversion is only done by
* calling value().
*
* @param cycleTime set the Cycle Time for automatic conversion
* @param cycleTime Sets the cycle time for automatic conversion
*/
void setAutomaticConversion(ADC121C021_CYCLE_TIME_T cycleTime);
/**
* Set the Alert Low Limit. If Alerts are enabled and the
* measured conversion value is lower than this, an alert will be
* Sets the alert low limit. If alerts are enabled and the
* measured conversion value is lower than the low limit, an alert is
* triggered.
*
* @param limit the Low Alert Limit
* @param limit Alert low limit
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t setAlertLowLimit(uint16_t limit);
/**
* Set the Alert High Limit. If Alerts are enabled and the
* measured conversion value is higher than this, an alert will be
* Sets the alert high limit. If alerts are enabled and the
* measured conversion value is higher than the high limit, an alert is
* triggered.
*
* @param limit the High Alert Limit
* @param limit Alert high limit
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t setAlertHighLimit(uint16_t limit);
/**
* Set the Hysteresis value. If a high or low alert condition is
* Sets the hysteresis value. If a high or low alert condition is
* triggered, the conversion result must move within the high or
* low limit by more than this value to clear the alert condition.
* If the Alert Hold bit is set, then the alert will not self
* clear regardless of this value.
* If the alert hold is set, the alert doesn't self-clear
* regardless of this value.
*
* @param limit Hysteresis Limit
* @param limit Hysteresis limit
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t setHysteresis(uint16_t limit);
/**
* Return the Highest Conversion value sampled so far. This value
* is only updated by the converter when automatic conversion mode
* Returns the highest conversion value recorded so far. This value
* is only updated by the converter when the automatic conversion mode
* is enabled.
*
* @return the highest conversion value recorded
* @return Highest conversion value
*/
uint16_t getHighestConversion();
/**
* Return the Lowest Conversion value sampled so far. This value
* is only updated by the converter when automatic conversion mode
* Returns the lowest conversion value recorded so far. This value
* is only updated by the converter when the automatic conversion mode
* is enabled.
*
* @return the lowest conversion value recorded
* @return Lowest conversion value
*/
uint16_t getLowestConversion();
/**
* Clear the Highest Conversion value sampled so far.
* Clears the highest conversion value recorded so far.
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/
mraa_result_t clearHighestConversion();
/**
* Clear the Lowest Conversion value sampled so far.
* Clears the lowest conversion value recorded so far.
*
* @return 0 (MRAA_SUCCESS) if successful; non-zero otherwise
*/

View File

@ -11,7 +11,7 @@
//
// This library runs on an Intel Edison and uses mraa to acquire data
// from an ADIS16448. This data is then scaled and printed onto the terminal.
//
//
// This software has been tested to connect to an ADIS16448 through a level shifter
// such as the TI TXB0104. The SPI lines (DIN, DOUT, SCLK, /CS) are all wired through
// the level shifter and the ADIS16448 is also being powered by the Intel Edison.
@ -84,11 +84,11 @@
namespace upm {
/**
* @brief ADIS16448 accelerometer library
* @defgroup adis16448 libupm-adis16488
* @brief ADIS16448 Accelerometer library
* @defgroup adis16448 libupm-adis16448
* @ingroup generic spi accelerometer
*/
/**
* @library adis16448
* @sensor adis16448
@ -98,54 +98,76 @@ namespace upm {
* @web http://www.analog.com/en/products/sensors/isensor-mems-inertial-measurement-units/adis16448.html
* @con spi
*
* @brief API for Analog Devices ADIS16448
* @brief API for the Analog Devices ADIS16448 Accelerometer
*
* This is an industrial grade accelerometer by Analog Devices.
* This is an industrial-grade accelerometer by Analog Devices.
*
* @snippet adis16448.cxx Interesting
*/
class ADIS16448{
class ADIS16448{
public:
public:
// Constructor with configurable HW Reset
ADIS16448(int bus, int rst);
/**
* Constructor with configurable HW Reset
*/
ADIS16448(int bus, int rst);
//Destructor
~ADIS16448();
/**
* Destructor
*/
~ADIS16448();
//Performs hardware reset by sending the specified pin low for 2 seconds
void resetDUT();
/**
* Performs hardware reset by sending the specified pin low for 2 seconds
*/
void resetDUT();
//Sets SPI frequency, mode, and bits/word
void configSPI();
/**
* Sets SPI frequency, mode, and bits/word
*/
void configSPI();
//Read specified register and return data
int16_t regRead(uint8_t regAddr);
/**
* Reads a specified register and returns data
*/
int16_t regRead(uint8_t regAddr);
//Write to specified register
void regWrite(uint8_t regAddr, uint16_t regData);
/**
* Writes to a specified register
*/
void regWrite(uint8_t regAddr, uint16_t regData);
//Scale accelerometer data
float accelScale(int16_t sensorData);
/**
* Scales accelerometer data
*/
float accelScale(int16_t sensorData);
//Scale gyro data
float gyroScale(int16_t sensorData);
/**
* Scales gyro data
*/
float gyroScale(int16_t sensorData);
//Scale temperature data
float tempScale(int16_t sensorData);
/**
* Scales temperature data
*/
float tempScale(int16_t sensorData);
//Scale pressure data
float pressureScale(int16_t sensorData);
/**
* Scales pressure data
*/
float pressureScale(int16_t sensorData);
//Scale magnetometer data
float magnetometerScale(int16_t sensorData);
/**
* Scales magnetometer data
*/
float magnetometerScale(int16_t sensorData);
private:
private:
mraa_spi_context _spi;
mraa_gpio_context _rst;
mraa_spi_context _spi;
mraa_gpio_context _rst;
};
};
}

View File

@ -35,7 +35,7 @@
namespace upm {
/**
* @brief ADXL335 accelerometer library
* @brief ADXL335 Accelerometer library
* @defgroup adxl335 libupm-adxl335
* @ingroup seeed analog accelerometer
*/
@ -49,12 +49,13 @@ namespace upm {
* @man seeed
* @con analog
*
* @brief API for the ADXL335 3-axis Analog Accelerometer
* @brief API for the ADXL335 3-Axis Analog Accelerometer
*
* UPM module for the ADXL335 3-axis analog accelerometer. This
* was tested on a Grove 3-axis Analog Accelerometer. It uses 3
* analog pins, one each for X, Y, and Z axis.
* UPM module for the ADXL335 3-axis analog accelerometer. This
* was tested on a Grove 3-axis Analog Accelerometer. It uses 3
* analog pins, one for each axis: X, Y, and Z.
*
* @image html adxl335.jpg
* @snippet adxl335.cxx Interesting
*/
class ADXL335 {
@ -62,61 +63,60 @@ namespace upm {
/**
* ADXL335 constructor
*
* @param pinX analog pin to use for axis X
* @param pinY analog pin to use for axis Y
* @param pinZ analog pin to use for axis Z
* @param aref analog voltage reference, default 5.0
* @param pinX Analog pin to use for X-axis
* @param pinY Analog pin to use for Y-axis
* @param pinZ Analog pin to use for Z-axis
* @param aref Analog reference voltage; default is 5.0v
*/
ADXL335(int pinX, int pinY, int pinZ, float aref=ADXL335_DEFAULT_AREF);
/**
* ADXL335 Destructor
* ADXL335 destructor
*/
~ADXL335();
/**
* Set the "zero" value of the X axis, determined through calibration
* Sets the "zero" value of the X-axis, determined through calibration
*
* @param zeroX The "zero" value of the X axis
* @param zeroX "Zero" value of the X-axis
*/
void setZeroX(float zeroX) { m_zeroX = zeroX; };
/**
* Set the "zero" value of the Y axis, determined through calibration
* Sets the "zero" value of the Y-axis, determined through calibration
*
* @param zeroX The "zero" value of the Y axis
* @param zeroY "Zero" value of the Y-axis
*/
void setZeroY(float zeroY) { m_zeroY = zeroY; };
/**
* Set the "zero" value of the Z axis, determined through calibration
* Sets the "zero" value of the Z-axis, determined through calibration
*
* @param zeroX The "zero" value of the Z axis
* @param zeroZ "Zero" value of the Z-axis
*/
void setZeroZ(float zeroZ) { m_zeroZ = zeroZ; };
/**
* Get the analog values for the 3 axes
* Gets the analog values for the 3 axes
*
* @param xVal pointer to returned X value
* @param yVal pointer to returned Y value
* @param zVal pointer to returned Z value
* @param xVal Pointer to the returned X-axis value
* @param yVal Pointer to the returned Y-axis value
* @param zVal Pointer to the returned Z-axis value
*/
void values(int *xVal, int *yVal, int *zVal);
/**
* Get the acceleration along all 3 axes
* Gets the acceleration along all 3 axes
*
* @param xAccel pointer to returned X value
* @param yAccel pointer to returned Y value
* @param zAccel pointer to returned Z value
* @param xAccel Pointer to returned X-axis value
* @param yAccel Pointer to returned Y-axis value
* @param zAccel Pointer to returned Z-axis value
*/
void acceleration(float *xAccel, float *yAccel, float *zAccel);
/**
* While the sensor is still, measure the X, Y, and Z values and
* use those values as our zero values.
*
* While the sensor is still, measures the X-axis, Y-axis, and Z-axis
* values and uses those values as the zero values.
*/
void calibrate();

View File

@ -1,4 +1,4 @@
/*
/*
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
@ -30,7 +30,7 @@
namespace upm {
/**
* @brief ADXL345 accelerometer library
* @brief ADXL345 Accelerometer library
* @defgroup adxl345 libupm-adxl345
* @ingroup seeed i2c accelerometer
*/
@ -44,13 +44,14 @@ namespace upm {
* @man seeed
* @con i2c
*
* @brief API for Adxl345 (3-axis digital accelerometer)
* @brief API for the ADXL345 3-Axis Digital Accelerometer
*
* The Adxl345 is a 3-axis digital accelerometer.
* ADXL345 is a 3-axis digital accelerometer.
* (http://www.seeedstudio.com/wiki/images/2/2c/ADXL345_datasheet.pdf)
* The sensor has configurable resolutions for measuring ±2g, ±4g, ±8g or ±16g.
* Note that the sensor it is incompatible and will not be detected on the I2C bus
* by the Intel Edison using the Arduino breakout board at 5V (3V3 will work fine).
* The sensor has configurable resolutions to measure ±2g, ±4g, ±8g, or ±16g.
* Note: The Grove* version of the sensor is incompatible with and not detected
* on the I2C bus by the Intel(R) Edison using an Arduino* breakout board at 5V
* (3V works fine).
*
* @image html adxl345.jpeg
* @snippet adxl345.cxx Interesting
@ -58,14 +59,14 @@ namespace upm {
class Adxl345 {
public:
/**
* Creates an Adxl345 object
* Creates an ADXL345 object
*
* @param bus number of used i2c bus
* @param bus Number of the used I2C bus
*/
Adxl345(int bus);
/**
* Adxl345 object destructor
* ADXL345 object destructor
*/
~Adxl345();
@ -77,23 +78,25 @@ public:
float* getAcceleration();
/**
* Returns a pointer to an int[3] that contains the raw register values for X, Y and Z
* Returns a pointer to an int[3] that contains the raw register values
* for X, Y, and Z
*
* @return int* to an int[3]
*/
int16_t* getRawValues();
/**
* Returns the scale the accelerometer is currently set up to: 2, 4, 8 or 16
* Returns the scale the accelerometer is currently set up to: 2, 4, 8,
* or 16
*
* @return uint with current scale value
* @return uint with the current scale value
*/
uint8_t getScale();
/**
* Updates the acceleration values from i2c bus
* Updates the acceleration values from the I2C bus
*
* @return 0 for success
* @return 0 if successful
*/
mraa_result_t update();
private:

Some files were not shown because too many files have changed in this diff Show More