Modified to run on Renesas GR Peach board

Dependencies:   EthernetInterface HTTP-Server Webpage mbed-rpc mbed-src

Fork of HTTPServer_echoback by Takuya Urakawa

Committer:
webOnBoard
Date:
Wed Oct 07 20:42:51 2015 +0000
Revision:
16:5d102be2566c
web based AHRS demo Renesas GR Peach board; Using HTTP Server/RPC Adafruit 10DOF

Who changed what in which revision?

UserRevisionLine numberNew contents of line
webOnBoard 16:5d102be2566c 1 /*
webOnBoard 16:5d102be2566c 2 * Copyright (C) 2008 The Android Open Source Project
webOnBoard 16:5d102be2566c 3 *
webOnBoard 16:5d102be2566c 4 * Licensed under the Apache License, Version 2.0 (the "License");
webOnBoard 16:5d102be2566c 5 * you may not use this file except in compliance with the License.
webOnBoard 16:5d102be2566c 6 * You may obtain a copy of the License at
webOnBoard 16:5d102be2566c 7 *
webOnBoard 16:5d102be2566c 8 * http://www.apache.org/licenses/LICENSE-2.0
webOnBoard 16:5d102be2566c 9 *
webOnBoard 16:5d102be2566c 10 * Unless required by applicable law or agreed to in writing, software< /span>
webOnBoard 16:5d102be2566c 11 * distributed under the License is distributed on an "AS IS" BASIS,
webOnBoard 16:5d102be2566c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
webOnBoard 16:5d102be2566c 13 * See the License for the specific language governing permissions and
webOnBoard 16:5d102be2566c 14 * limitations under the License.
webOnBoard 16:5d102be2566c 15 */
webOnBoard 16:5d102be2566c 16
webOnBoard 16:5d102be2566c 17 /* Update by K. Townsend (Adafruit Industries) for lighter typedefs, and
webOnBoard 16:5d102be2566c 18 * extended sensor support to include color, voltage and current */
webOnBoard 16:5d102be2566c 19
webOnBoard 16:5d102be2566c 20 #ifndef _ADAFRUIT_SENSOR_H
webOnBoard 16:5d102be2566c 21 #define _ADAFRUIT_SENSOR_H
webOnBoard 16:5d102be2566c 22 #include <stdint.h>
webOnBoard 16:5d102be2566c 23 #include "mbed.h"
webOnBoard 16:5d102be2566c 24
webOnBoard 16:5d102be2566c 25 #include "Timer.h"
webOnBoard 16:5d102be2566c 26
webOnBoard 16:5d102be2566c 27
webOnBoard 16:5d102be2566c 28 /* Intentionally modeled after sensors.h in the Android API:
webOnBoard 16:5d102be2566c 29 * https://github.com/android/platform_hardware_libhardware/blob/master/include/hardware/sensors.h */
webOnBoard 16:5d102be2566c 30
webOnBoard 16:5d102be2566c 31 /* Constants */
webOnBoard 16:5d102be2566c 32 #define SENSORS_GRAVITY_EARTH (9.80665F) /**< Earth's gravity in m/s^2 */
webOnBoard 16:5d102be2566c 33 #define SENSORS_GRAVITY_MOON (1.6F) /**< The moon's gravity in m/s^2 */
webOnBoard 16:5d102be2566c 34 #define SENSORS_GRAVITY_SUN (275.0F) /**< The sun's gravity in m/s^2 */
webOnBoard 16:5d102be2566c 35 #define SENSORS_GRAVITY_STANDARD (SENSORS_GRAVITY_EARTH)
webOnBoard 16:5d102be2566c 36 #define SENSORS_MAGFIELD_EARTH_MAX (60.0F) /**< Maximum magnetic field on Earth's surface */
webOnBoard 16:5d102be2566c 37 #define SENSORS_MAGFIELD_EARTH_MIN (30.0F) /**< Minimum magnetic field on Earth's surface */
webOnBoard 16:5d102be2566c 38 #define SENSORS_PRESSURE_SEALEVELHPA (1013.25F) /**< Average sea level pressure is 1013.25 hPa */
webOnBoard 16:5d102be2566c 39 #define SENSORS_DPS_TO_RADS (0.017453293F) /**< Degrees/s to rad/s multiplier */
webOnBoard 16:5d102be2566c 40 #define SENSORS_GAUSS_TO_MICROTESLA (100) /**< Gauss to micro-Tesla multiplier */
webOnBoard 16:5d102be2566c 41
webOnBoard 16:5d102be2566c 42 extern mbed::I2C* i2c;
webOnBoard 16:5d102be2566c 43 extern Timer timer;
webOnBoard 16:5d102be2566c 44
webOnBoard 16:5d102be2566c 45 typedef uint8_t byte;
webOnBoard 16:5d102be2566c 46
webOnBoard 16:5d102be2566c 47 /** Sensor types */
webOnBoard 16:5d102be2566c 48 typedef enum
webOnBoard 16:5d102be2566c 49 {
webOnBoard 16:5d102be2566c 50 SENSOR_TYPE_ACCELEROMETER = (1), /**< Gravity + linear acceleration */
webOnBoard 16:5d102be2566c 51 SENSOR_TYPE_MAGNETIC_FIELD = (2),
webOnBoard 16:5d102be2566c 52 SENSOR_TYPE_ORIENTATION = (3),
webOnBoard 16:5d102be2566c 53 SENSOR_TYPE_GYROSCOPE = (4),
webOnBoard 16:5d102be2566c 54 SENSOR_TYPE_LIGHT = (5),
webOnBoard 16:5d102be2566c 55 SENSOR_TYPE_PRESSURE = (6),
webOnBoard 16:5d102be2566c 56 SENSOR_TYPE_PROXIMITY = (8),
webOnBoard 16:5d102be2566c 57 SENSOR_TYPE_GRAVITY = (9),
webOnBoard 16:5d102be2566c 58 SENSOR_TYPE_LINEAR_ACCELERATION = (10), /**< Acceleration not including gravity */
webOnBoard 16:5d102be2566c 59 SENSOR_TYPE_ROTATION_VECTOR = (11),
webOnBoard 16:5d102be2566c 60 SENSOR_TYPE_RELATIVE_HUMIDITY = (12),
webOnBoard 16:5d102be2566c 61 SENSOR_TYPE_AMBIENT_TEMPERATURE = (13),
webOnBoard 16:5d102be2566c 62 SENSOR_TYPE_VOLTAGE = (15),
webOnBoard 16:5d102be2566c 63 SENSOR_TYPE_CURRENT = (16),
webOnBoard 16:5d102be2566c 64 SENSOR_TYPE_COLOR = (17)
webOnBoard 16:5d102be2566c 65 } sensors_type_t;
webOnBoard 16:5d102be2566c 66
webOnBoard 16:5d102be2566c 67 /** struct sensors_vec_s is used to return a vector in a common format. */
webOnBoard 16:5d102be2566c 68 typedef struct {
webOnBoard 16:5d102be2566c 69 union {
webOnBoard 16:5d102be2566c 70 float v[3];
webOnBoard 16:5d102be2566c 71 struct {
webOnBoard 16:5d102be2566c 72 float x;
webOnBoard 16:5d102be2566c 73 float y;
webOnBoard 16:5d102be2566c 74 float z;
webOnBoard 16:5d102be2566c 75 };
webOnBoard 16:5d102be2566c 76 /* Orientation sensors */
webOnBoard 16:5d102be2566c 77 struct {
webOnBoard 16:5d102be2566c 78 float roll; /**< Rotation around the longitudinal axis (the plane body, 'X axis'). Roll is positive and increasing when moving downward. -90�<=roll<=90� */
webOnBoard 16:5d102be2566c 79 float pitch; /**< Rotation around the lateral axis (the wing span, 'Y axis'). Pitch is positive and increasing when moving upwards. -180�<=pitch<=180�) */
webOnBoard 16:5d102be2566c 80 float heading; /**< Angle between the longitudinal axis (the plane body) and magnetic north, measured clockwise when viewing from the top of the device. 0-359� */
webOnBoard 16:5d102be2566c 81 };
webOnBoard 16:5d102be2566c 82 };
webOnBoard 16:5d102be2566c 83 int8_t status;
webOnBoard 16:5d102be2566c 84 uint8_t reserved[3];
webOnBoard 16:5d102be2566c 85 } sensors_vec_t;
webOnBoard 16:5d102be2566c 86
webOnBoard 16:5d102be2566c 87 /** struct sensors_color_s is used to return color data in a common format. */
webOnBoard 16:5d102be2566c 88 typedef struct {
webOnBoard 16:5d102be2566c 89 union {
webOnBoard 16:5d102be2566c 90 float c[3];
webOnBoard 16:5d102be2566c 91 /* RGB color space */
webOnBoard 16:5d102be2566c 92 struct {
webOnBoard 16:5d102be2566c 93 float r; /**< Red component */
webOnBoard 16:5d102be2566c 94 float g; /**< Green component */
webOnBoard 16:5d102be2566c 95 float b; /**< Blue component */
webOnBoard 16:5d102be2566c 96 };
webOnBoard 16:5d102be2566c 97 };
webOnBoard 16:5d102be2566c 98 uint32_t rgba; /**< 24-bit RGBA value */
webOnBoard 16:5d102be2566c 99 } sensors_color_t;
webOnBoard 16:5d102be2566c 100
webOnBoard 16:5d102be2566c 101 /* Sensor event (36 bytes) */
webOnBoard 16:5d102be2566c 102 /** struct sensor_event_s is used to provide a single sensor event in a common format. */
webOnBoard 16:5d102be2566c 103 typedef struct
webOnBoard 16:5d102be2566c 104 {
webOnBoard 16:5d102be2566c 105 int32_t version; /**< must be sizeof(struct sensors_event_t) */
webOnBoard 16:5d102be2566c 106 int32_t sensor_id; /**< unique sensor identifier */
webOnBoard 16:5d102be2566c 107 int32_t type; /**< sensor type */
webOnBoard 16:5d102be2566c 108 int32_t reserved0; /**< reserved */
webOnBoard 16:5d102be2566c 109 int32_t timestamp; /**< time is in milliseconds */
webOnBoard 16:5d102be2566c 110 union
webOnBoard 16:5d102be2566c 111 {
webOnBoard 16:5d102be2566c 112 float data[4];
webOnBoard 16:5d102be2566c 113 sensors_vec_t acceleration; /**< acceleration values are in meter per second per second (m/s^2) */
webOnBoard 16:5d102be2566c 114 sensors_vec_t magnetic; /**< magnetic vector values are in micro-Tesla (uT) */
webOnBoard 16:5d102be2566c 115 sensors_vec_t orientation; /**< orientation values are in degrees */
webOnBoard 16:5d102be2566c 116 sensors_vec_t gyro; /**< gyroscope values are in rad/s */
webOnBoard 16:5d102be2566c 117 float temperature; /**< temperature is in degrees centigrade (Celsius) */
webOnBoard 16:5d102be2566c 118 float distance; /**< distance in centimeters */
webOnBoard 16:5d102be2566c 119 float light; /**< light in SI lux units */
webOnBoard 16:5d102be2566c 120 float pressure; /**< pressure in hectopascal (hPa) */
webOnBoard 16:5d102be2566c 121 float relative_humidity; /**< relative humidity in percent */
webOnBoard 16:5d102be2566c 122 float current; /**< current in milliamps (mA) */
webOnBoard 16:5d102be2566c 123 float voltage; /**< voltage in volts (V) */
webOnBoard 16:5d102be2566c 124 sensors_color_t color; /**< color in RGB component values */
webOnBoard 16:5d102be2566c 125 };
webOnBoard 16:5d102be2566c 126 } sensors_event_t;
webOnBoard 16:5d102be2566c 127
webOnBoard 16:5d102be2566c 128 /* Sensor details (40 bytes) */
webOnBoard 16:5d102be2566c 129 /** struct sensor_s is used to describe basic information about a specific sensor. */
webOnBoard 16:5d102be2566c 130 typedef struct
webOnBoard 16:5d102be2566c 131 {
webOnBoard 16:5d102be2566c 132 char name[12]; /**< sensor name */
webOnBoard 16:5d102be2566c 133 int32_t version; /**< version of the hardware + driver */
webOnBoard 16:5d102be2566c 134 int32_t sensor_id; /**< unique sensor identifier */
webOnBoard 16:5d102be2566c 135 int32_t type; /**< this sensor's type (ex. SENSOR_TYPE_LIGHT) */
webOnBoard 16:5d102be2566c 136 float max_value; /**< maximum value of this sensor's value in SI units */
webOnBoard 16:5d102be2566c 137 float min_value; /**< minimum value of this sensor's value in SI units */
webOnBoard 16:5d102be2566c 138 float resolution; /**< smallest difference between two values reported by this sensor */
webOnBoard 16:5d102be2566c 139 int32_t min_delay; /**< min delay in microseconds between events. zero = not a constant rate */
webOnBoard 16:5d102be2566c 140 } sensor_t;
webOnBoard 16:5d102be2566c 141
webOnBoard 16:5d102be2566c 142 //class Adafruit_Sensor {
webOnBoard 16:5d102be2566c 143 // public:
webOnBoard 16:5d102be2566c 144 // // Constructor(s)
webOnBoard 16:5d102be2566c 145 // void constructor();
webOnBoard 16:5d102be2566c 146 //
webOnBoard 16:5d102be2566c 147 // // These must be defined by the subclass
webOnBoard 16:5d102be2566c 148 // virtual void enableAutoRange(bool enabled) {};
webOnBoard 16:5d102be2566c 149 // virtual void getEvent(sensors_event_t*);
webOnBoard 16:5d102be2566c 150 // virtual void getSensor(sensor_t*);
webOnBoard 16:5d102be2566c 151 //
webOnBoard 16:5d102be2566c 152 // private:
webOnBoard 16:5d102be2566c 153 // bool _autoRange;
webOnBoard 16:5d102be2566c 154 //};
webOnBoard 16:5d102be2566c 155 class Adafruit_Sensor {
webOnBoard 16:5d102be2566c 156 public:
webOnBoard 16:5d102be2566c 157 // Constructor(s)
webOnBoard 16:5d102be2566c 158 Adafruit_Sensor() {}
webOnBoard 16:5d102be2566c 159 virtual ~Adafruit_Sensor() {}
webOnBoard 16:5d102be2566c 160
webOnBoard 16:5d102be2566c 161 // These must be defined by the subclass
webOnBoard 16:5d102be2566c 162 virtual void enableAutoRange(bool enabled) {};
webOnBoard 16:5d102be2566c 163 virtual bool getEvent(sensors_event_t*) = 0;
webOnBoard 16:5d102be2566c 164 virtual void getSensor(sensor_t*) = 0;
webOnBoard 16:5d102be2566c 165
webOnBoard 16:5d102be2566c 166 private:
webOnBoard 16:5d102be2566c 167 bool _autoRange;
webOnBoard 16:5d102be2566c 168 };
webOnBoard 16:5d102be2566c 169 #endif
webOnBoard 16:5d102be2566c 170