Module renamed
This commit is contained in:
parent
e46ef04631
commit
0e8b4acee6
|
@ -1,4 +1,4 @@
|
|||
# SimpleLed
|
||||
# SimpLedRGB
|
||||
|
||||
This Arduino IDE library is a simple way to control an RGB LED. It can also be used for other micro controllers that can be programmed via Arduino IDE.
|
||||
|
||||
|
@ -8,20 +8,20 @@ Put this folder into your `~/Arduino/libraries` folder.
|
|||
|
||||
## Usage
|
||||
|
||||
Include the header file `SimpleLed.h` and initialize the module with three PWM pins of your micro controller (in the case of the Arduino Uno 3, 5 and 6 for instance). Don't forget to call `begin()` in the setup() method. Now you can use both methods `setColor()` and `translateToColor()` to control your LED.
|
||||
Include the header file `SimpLedRGB.h` and initialize the module with three PWM pins of your micro controller (in the case of the Arduino Uno 3, 5 and 6 for instance). Don't forget to call `begin()` in the setup() method. Now you can use both methods `setColor()` and `translateToColor()` to control your LED.
|
||||
|
||||
The RGB Colors are specified with the `Color` type. Red, green and blue can have values between 0.0 (off) and 1.0 (completely on).
|
||||
|
||||
The following example defines three colors RED, GREEN and VIOLET and uses the two methods to control the led:
|
||||
|
||||
```cpp
|
||||
#include <SimpleLed.h>
|
||||
#include <SimpLedRGB.h>
|
||||
|
||||
const Color RED = {1.0, 0.0, 0.0};
|
||||
const Color GREEN = {0.0, 1.0, 0.0};
|
||||
const Color VIOLET = {1.0, 0.0, 1.0};
|
||||
|
||||
SimpleLed led(3, 5, 6);
|
||||
SimpLedRGB led(3, 5, 6);
|
||||
|
||||
void setup {
|
||||
led.begin();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include "SimpleLed.h"
|
||||
#include "SimpLedRGB.h"
|
||||
|
||||
SimpleLed::SimpleLed(int pinRed, int pinGreen, int pinBlue) {
|
||||
SimpLedRGB::SimpLedRGB(int pinRed, int pinGreen, int pinBlue) {
|
||||
this->pin_red = pinRed;
|
||||
this->pin_green = pinGreen;
|
||||
this->pin_blue = pinBlue;
|
||||
}
|
||||
|
||||
void SimpleLed::begin()
|
||||
void SimpLedRGB::begin()
|
||||
{
|
||||
pinMode(this->pin_red, OUTPUT);
|
||||
pinMode(this->pin_green, OUTPUT);
|
||||
|
@ -15,7 +15,7 @@ void SimpleLed::begin()
|
|||
this->setColor(color);
|
||||
}
|
||||
|
||||
void SimpleLed::setColor(const Color &color)
|
||||
void SimpLedRGB::setColor(const Color &color)
|
||||
{
|
||||
this->color.red = color.red;
|
||||
this->color.green = color.green;
|
||||
|
@ -26,7 +26,7 @@ void SimpleLed::setColor(const Color &color)
|
|||
analogWrite(this->pin_blue, 255 * color.blue);
|
||||
}
|
||||
|
||||
void SimpleLed::translateToColor(const Color &color, int duration_millis)
|
||||
void SimpLedRGB::translateToColor(const Color &color, int duration_millis)
|
||||
{
|
||||
const Color colorStart = {
|
||||
this->color.red,
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef SimpleLed_h
|
||||
#define SimpleLed_h
|
||||
#ifndef SimpLedRGB_h
|
||||
#define SimpLedRGB_h
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
|
@ -9,7 +9,7 @@ typedef struct {
|
|||
float blue;
|
||||
} Color;
|
||||
|
||||
class SimpleLed
|
||||
class SimpLedRGB
|
||||
{
|
||||
int pin_red = 0;
|
||||
int pin_green = 0;
|
||||
|
@ -18,7 +18,7 @@ class SimpleLed
|
|||
Color color = {0.0, 0.0, 0.0};
|
||||
|
||||
public:
|
||||
SimpleLed(int pinRed, int pinGreen, int pinBlue);
|
||||
SimpLedRGB(int pinRed, int pinGreen, int pinBlue);
|
||||
|
||||
void begin();
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
name=SimpleLed
|
||||
name=SimpLedRGB
|
||||
version=1.0.0
|
||||
author=Mal
|
||||
maintainer=Mal
|
||||
sentence=A simple Arduino library for RGB LED control
|
||||
paragraph=A simple Arduino library for RGB LED control. Just specify the three pins for red, green and blue and set colors or fade from one color to another.
|
||||
category=Signal Input/Output
|
||||
url=https://git.leinelab.org/Mal/SimpleLed
|
||||
url=https://git.leinelab.org/Mal/SimpLedRGB
|
||||
architectures=*
|
||||
|
|
Loading…
Reference in New Issue