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: Chainable_RGB_LED DHT LED_Bar mbed mbedConnectorInterface mbedEndpointNetwork_mjk_regfix
IlluminanceResource.h
00001 /** 00002 * @file IlluminanceResource.h 00003 * @brief mbed CoAP Endpoint 00004 * @author Michael Koster 00005 * @version 1.0 00006 * @see 00007 * 00008 * Copyright (c) 2015 00009 * 00010 * Licensed under the Apache License, Version 2.0 (the "License"); 00011 * you may not use this file except in compliance with the License. 00012 * You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, software 00017 * distributed under the License is distributed on an "AS IS" BASIS, 00018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 * See the License for the specific language governing permissions and 00020 * limitations under the License. 00021 */ 00022 00023 #ifndef __ILLUMI_RESOURCE_H__ 00024 #define __ILLUMI_RESOURCE_H__ 00025 00026 // Base class 00027 #include "DynamicResource.h" 00028 00029 // Luminance Sensor connected to A0 00030 AnalogIn illumi_in(A0); 00031 00032 /** LuminanceResource class 00033 */ 00034 class IlluminanceResource : public DynamicResource 00035 { 00036 public: 00037 /** 00038 Default constructor 00039 @param logger input logger instance for this resource 00040 @param name input the resource name 00041 @param observable input the resource is Observable (default: FALSE) 00042 */ 00043 IlluminanceResource(const Logger *logger,const char *name,const bool observable = false) : 00044 DynamicResource(logger,name,"urn:X-ipso:illuminance", SN_GRS_GET_ALLOWED,observable) { 00045 } 00046 00047 /** 00048 Get the value of the illuminance Sensor 00049 @returns string containing the illuminance value 00050 */ 00051 virtual string get() { 00052 char illumi_str[6]; 00053 memset(illumi_str,0,6); 00054 float illumi_read = illumi_in.read(); 00055 sprintf(illumi_str,"%6.1f", (illumi_read * 100) ); 00056 return string(illumi_str); 00057 } 00058 }; 00059 00060 #endif // __ILLUMI_RESOURCE_H__
Generated on Wed Jul 13 2022 19:30:15 by
1.7.2