Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: LSM303AGR
LSM303AGR_JS.h
00001 /** 00002 ****************************************************************************** 00003 * @file LSM303AGR_JS.h 00004 * @author ST 00005 * @version V1.0.0 00006 * @date 9 October 2017 00007 * @brief Implementation of an LSM303AGR Accelerometer and Magnetometer sensor for 00008 * use with Javascript. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00013 * 00014 * Redistribution and use in source and binary forms, with or without modification, 00015 * are permitted provided that the following conditions are met: 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00022 * may be used to endorse or promote products derived from this software 00023 * without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00028 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00029 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00031 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00033 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00034 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************** 00037 */ 00038 00039 00040 /* Prevent recursive inclusion -----------------------------------------------*/ 00041 00042 #ifndef __LSM303AGR_JS_H__ 00043 #define __LSM303AGR_JS_H__ 00044 00045 /* Includes ------------------------------------------------------------------*/ 00046 00047 #include <stdint.h> 00048 #include "mbed.h" 00049 #include "LSM303AGRMagSensor.h" 00050 #include "LSM303AGRAccSensor.h" 00051 00052 /* Class Declaration ---------------------------------------------------------*/ 00053 00054 /** 00055 * Abstract class of an LSM303AGR Humidity and Temperature sensor for Javascript. 00056 */ 00057 class LSM303AGR_JS { 00058 private: 00059 /* Helper classes. */ 00060 LSM303AGRMagSensor *magnetometer = NULL; 00061 LSM303AGRAccSensor *accelerometer = NULL; 00062 00063 public: 00064 /* Constructors */ 00065 LSM303AGR_JS(){} 00066 00067 //LSM303AGRAccSensor(SPI *spi, PinName cs_pin, PinName int1_pin=NC, PinName int2_pin=NC); // SPI3W ONLY 00068 void init_acc(SPI &spi, PinName cs_pin); 00069 void init_acc(SPI &spi, PinName cs_pin, PinName int1_pin, PinName int2_pin); 00070 00071 //LSM303AGRAccSensor(DevI2C *i2c, uint8_t address=LSM303AGR_ACC_I2C_ADDRESS, PinName int1_pin=NC, PinName int2_pin=NC); 00072 void init_acc(DevI2C &devI2c); 00073 void init_acc(DevI2C &devI2c, PinName int1_pin, PinName int2_pin); 00074 void init_acc(DevI2C &devI2c, PinName int1_pin, PinName int2_pin, uint8_t address); 00075 00076 //LSM303AGRMagSensor(SPI *spi, PinName cs_pin, PinName intmag_pin=NC); // SPI3W ONLY 00077 void init_mag(SPI &spi, PinName cs_pin); 00078 void init_mag(SPI &spi, PinName cs_pin, PinName int_pin); 00079 00080 //LSM303AGRMagSensor(DevI2C *i2c, uint8_t address=LSM303AGR_MAG_I2C_ADDRESS, PinName int_pin=NC); 00081 void init_mag(DevI2C &devI2c); 00082 void init_mag(DevI2C &devI2c, PinName int_pin); 00083 void init_mag(DevI2C &devI2c, PinName int_pin, uint8_t address); 00084 00085 00086 /* Destructor */ 00087 ~LSM303AGR_JS(); 00088 00089 /* Declarations */ 00090 char *make_json(char* str, int32_t *data, char *axes, int data_count); 00091 uint8_t read_magnetometer_id(); 00092 uint8_t read_accelerometer_id(); 00093 int32_t *get_accelerometer_axes(int32_t *); 00094 char *get_accelerometer_axes_json(char *); 00095 int32_t *get_magnetometer_axes(int32_t *); 00096 char *get_magnetometer_axes_json(char *); 00097 00098 }; 00099 00100 #endif
Generated on Thu Jul 14 2022 02:47:33 by
