mirror of
				https://github.com/eclipse/upm.git
				synced 2025-10-29 22:24:48 +03:00 
			
		
		
		
	Initial implementation of Grove PIR motion sensor with BISS0001 chip
jrvandr: removed unnecessary mraa_init() Signed-off-by: Zion Orent <zorent@ics.com> Signed-off-by: Jon Trulson <jtrulson@ics.com> Signed-off-by: John Van Drasek <john.r.van.drasek@intel.com>
This commit is contained in:
		 Zion Orent
					Zion Orent
				
			
				
					committed by
					
						 John Van Drasek
						John Van Drasek
					
				
			
			
				
	
			
			
			 John Van Drasek
						John Van Drasek
					
				
			
						parent
						
							9cda72b077
						
					
				
				
					commit
					5448e72975
				
			
							
								
								
									
										5
									
								
								src/biss0001/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/biss0001/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| set (libname "biss0001") | ||||
| set (libdescription "upm biss0001 motion module") | ||||
| set (module_src ${libname}.cxx) | ||||
| set (module_h ${libname}.h) | ||||
| upm_module_init() | ||||
							
								
								
									
										45
									
								
								src/biss0001/biss0001.cxx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								src/biss0001/biss0001.cxx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| /* | ||||
|  * Author: Zion Orent <sorent@ics.com> | ||||
|  * Copyright (c) 2014 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 "biss0001.h" | ||||
|  | ||||
| using namespace upm; | ||||
|  | ||||
| BISS0001::BISS0001(int pin) | ||||
| { | ||||
|     m_gpio = mraa_gpio_init(pin); | ||||
|     mraa_gpio_dir(m_gpio, MRAA_GPIO_IN); | ||||
| } | ||||
|  | ||||
| BISS0001::~BISS0001() | ||||
| { | ||||
|     mraa_gpio_close(m_gpio); | ||||
| } | ||||
|  | ||||
| bool BISS0001::value() | ||||
| { | ||||
|     return (mraa_gpio_read(m_gpio) ? true : false); | ||||
| } | ||||
							
								
								
									
										63
									
								
								src/biss0001/biss0001.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								src/biss0001/biss0001.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,63 @@ | ||||
| /* | ||||
|  * Author: Zion Orent <sorent@ics.com> | ||||
|  * Copyright (c) 2014 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. | ||||
|  */ | ||||
| #pragma once | ||||
|  | ||||
| #include <string> | ||||
| #include <mraa/aio.h> | ||||
|  | ||||
| namespace upm { | ||||
|  | ||||
|   /** | ||||
|    * @brief C++ API for the BISS0001 Motion Sensor | ||||
|    * | ||||
|    * UPM module for the BISS0001 Motion Sensor | ||||
|    * | ||||
|    * @ingroup gpio | ||||
|    * @snippet biss0001.cxx Interesting | ||||
|    */ | ||||
|   class BISS0001 { | ||||
|   public: | ||||
|     /** | ||||
|      * BISS0001 motion sensor constructor | ||||
|      * | ||||
|      * @param pin digital pin to use | ||||
|      */ | ||||
|     BISS0001(int pin); | ||||
|     /** | ||||
|      * BISS0001 Destructor | ||||
|      */ | ||||
|     ~BISS0001(); | ||||
|     /** | ||||
|      * Get the motion value from the sensor | ||||
|      * | ||||
|      * @return the motion reading | ||||
|      */ | ||||
|     bool value(); | ||||
|  | ||||
|   private: | ||||
|         mraa_gpio_context m_gpio; | ||||
|   }; | ||||
| } | ||||
|  | ||||
|  | ||||
							
								
								
									
										8
									
								
								src/biss0001/jsupm_biss0001.i
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/biss0001/jsupm_biss0001.i
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| %module jsupm_biss0001 | ||||
| %include "../upm.i" | ||||
|  | ||||
| %{ | ||||
|     #include "biss0001.h" | ||||
| %} | ||||
|  | ||||
| %include "biss0001.h" | ||||
							
								
								
									
										9
									
								
								src/biss0001/pyupm_biss0001.i
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/biss0001/pyupm_biss0001.i
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| %module pyupm_biss0001 | ||||
| %include "../upm.i" | ||||
|  | ||||
| %feature("autodoc", "3"); | ||||
|  | ||||
| %include "biss0001.h" | ||||
| %{ | ||||
|     #include "biss0001.h" | ||||
| %} | ||||
		Reference in New Issue
	
	Block a user