1765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang/* 2765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * Author: Sarah Knepper <sarah.knepper@intel.com> 3765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * Copyright (c) 2014 Intel Corporation. 4765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * 5765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * Permission is hereby granted, free of charge, to any person obtaining 6765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * a copy of this software and associated documentation files (the 7765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * "Software"), to deal in the Software without restriction, including 8765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * without limitation the rights to use, copy, modify, merge, publish, 9765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * distribute, sublicense, and/or sell copies of the Software, and to 10765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * permit persons to whom the Software is furnished to do so, subject to 11765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * the following conditions: 12765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * 13765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * The above copyright notice and this permission notice shall be 14765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * included in all copies or substantial portions of the Software. 15765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * 16765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang */ 24765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang#pragma once 25765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang 26765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang#include <string> 27765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang#include <mraa/aio.h> 28765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang 29765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhangnamespace upm { 30765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang 31765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang/** 32765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @brief LDT0-028 Piezo Vibration Sensor library 33765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @defgroup ldt0028 libupm-ldt0028 34765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @ingroup seeed analog flexfor 35765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang */ 36765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang 37765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang/** 38765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @library ldt0028 39765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @sensor ldt0028 40765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @comname LDT0-028 Piezo Vibration Sensor 41765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @altname Grove Piezo Vibration Sensor 42765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @type flexfor 43765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @man seeed 44765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @con analog 45765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * 46765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @brief API for LDT0-028 PZT film-based sensors, 47765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * such as a Grove Piezo Vibration sensor 48765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * 49765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * This module defines the LDT0-028 interface for libupm-ldt0028 50765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * 51765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @image html ldt0028.jpg 52765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @snippet ldt0028.cxx Interesting 53765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang */ 54765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhangclass LDT0028 { 55765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang public: 56765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang /** 57765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * LDT0028 constructor 58765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * 59765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @param pin AIO pin where the sensor is connected 60765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang */ 61765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang LDT0028(unsigned int pin); 62765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang 63765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang /** 64765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * LDT0028 destructor 65765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang */ 66765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang ~LDT0028(); 67765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang 68765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang /** 69765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * Returns the name of this sensor 70765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * 71765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @return Name of this sensor 72765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang */ 73765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang std::string name(); 74765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang 75765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang /** 76765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * Returns one sample from this sensor 77765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * 78765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang * @return One value from this sensor 79765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang */ 80765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang int getSample(); 81765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang 82765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang protected: 83765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang std::string m_name; //!< name of this sensor 84765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang mraa_aio_context m_pin; //!< AIO pin 85765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang}; 86765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang 87765adb95dc941c32690d6c43bc08b9d07d197fcbJianxun Zhang} 88