Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc. http://www.blynk.cc/

Dependents:   Blynk_RBL_BLE_Nano Blynk_MicroBit Blynk_Serial Blynk_RBL_BLE_Nano

WidgetLED.h

Committer:
Volodymyr Shymanskyy
Date:
2016-10-12
Revision:
7:8879692d4e6c
Parent:
0:58b20b438383
Child:
9:7369ec77a3ea

File content as of revision 7:8879692d4e6c:

/**
 * @file       WidgetLED.h
 * @author     Volodymyr Shymanskyy
 * @license    This project is released under the MIT License (MIT)
 * @copyright  Copyright (c) 2015 Volodymyr Shymanskyy
 * @date       Apr 2015
 * @brief
 */

#ifndef WidgetLED_h
#define WidgetLED_h

#include <Blynk/BlynkApi.h>

class WidgetLED
{
public:
	WidgetLED(uint8_t pin) : mPin(pin) {}
    void setVPin(int vPin) { mPin = vPin; }

    uint8_t getValue() const {
        return mValue;
    }

    void setValue(uint8_t value) {
    	mValue = value;
        Blynk.virtualWrite(mPin, value);
    }

    void on() {
    	setValue(255);
    }

    void off() {
    	setValue(0);
    }

private:
    uint8_t mPin;
    uint8_t mValue;
};

#endif