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 mbed mbedConnectorInterface mbedEndpointNetwork
Fork of IoT_LED_demo by
SliderResource.h
00001 /** 00002 * @file SliderResource.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 __SLIDER_RESOURCE_H__ 00024 #define __SLIDER_RESOURCE_H__ 00025 00026 // Base class 00027 #include "DynamicResource.h" 00028 00029 // Slide Potentiometer connected to A0 00030 AnalogIn slider_in(A0); 00031 00032 /** TemperatureResource class 00033 */ 00034 class SliderResource : 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 SliderResource(const Logger *logger,const char *name,const bool observable = false) : DynamicResource(logger,name,"Slider", SN_GRS_GET_ALLOWED,observable) { 00044 } 00045 00046 /** 00047 Get the value of the slide potentiometer 00048 @returns string containing the slider value from 0-1.00 00049 */ 00050 virtual string get() { 00051 char slider_pos[7]; 00052 memset(slider_pos,0,7); 00053 sprintf(slider_pos,"%3.2f", slider_in.read()); 00054 return string(slider_pos); 00055 } 00056 }; 00057 00058 #endif // __SLIDER_RESOURCE_H__
Generated on Tue Jul 12 2022 20:37:45 by
1.7.2
