![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
confidential
Dependencies: Chainable_RGB_LED mbed mbedConnectorInterface mbedEndpointNetwork
mbedEndpointResources/Touch.h
- Committer:
- cjwu15
- Date:
- 2015-05-09
- Revision:
- 0:02b8d440ded3
- Child:
- 1:73f962479f1a
File content as of revision 0:02b8d440ded3:
/** * @file LightResource.h * @brief mbed CoAP Endpoint Light resource supporting CoAP GET and PUT * @author Doug Anson, Michael Koster * @version 1.0 * @see * * Copyright (c) 2014 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __TOUCH_RESOURCE_H__ #define __TOUCH_RESOURCE_H__ #include <stdio.h> // Base class #include "DynamicResource.h" #include "mbed.h" DigitalIn button(D2); int count = 0; void touch_thread(void const *args) { while(1) { if (button) { printf("touch detected\n"); count++; LED_set_color("0000FF00"); wait(1.0); LED_set_color("00000000"); while(button); } Thread::wait(500); } } /** LightResource class */ class TouchResource : public DynamicResource { public: /** Default constructor @param logger input logger instance for this resource @param name input the Light resource name @param observable input the resource is Observable (default: FALSE) */ TouchResource(const Logger *logger,const char *name,const bool observable = false) : DynamicResource(logger,name,"Touch",SN_GRS_GET_ALLOWED,observable) { } /** Get the value of the LED @returns string containing the last setting */ virtual string get() { char result[10]; sprintf(result, "%d", count); count = 0; return(result); } }; #endif // __TOUCH_RESOURCE_H__