worked at RGBclass

This commit is contained in:
Sebastian 2020-06-29 18:35:12 +02:00
parent ac9327179d
commit a0066f0811

View File

@ -1,9 +1,5 @@
#include <header.h>
#define RED_PIN 1
#define GREEN_PIN 2
#define BLUE_PIN 3
enum colorTypes {
purple,
blue,
@ -15,14 +11,36 @@ enum colorTypes {
};
int valueNM;
// Colors in Array: purple, blue, green, yellow, orange, red, white
int colorValueArray[][3] = {{125,0,125}, {0,0,255}, {0,255,0}, {255,255,0}, {255,140,0}, {255,0,0}, {255,255,255}};
int colorCounter = 6;
colorTypes color = white;
void readPreferableLight() {
//preferableLight = Read from database
//Setting PWM properties
const int freqRed = 5000;
const int freqGreen = 5000;
const int freqBlue = 5000;
const int ledChannelRed = 0;
const int ledChannelGreen = 1;
const int ledChannelBlue= 2;
const int resolutionRed = 8;
const int resolutionGreen = 8;
const int resolutionBlue = 8;
void setupPWM() {
ledcSetup(ledChannelRed, freqRed, resolutionRed);
ledcSetup(ledChannelGreen, freqGreen, resolutionGreen);
ledcSetup(ledChannelBlue, freqBlue, resolutionBlue);
ledcAttachPin()
}
void getColorBasedOnPreferableLight() {
void readValueNM() {
//valueNM = Read from database
}
void getColorBasedOnValueNM() {
if (valueNM <= 420) {
color = purple;
}
@ -38,11 +56,37 @@ void getColorBasedOnPreferableLight() {
else if (valueNM <= 650) {
color = orange;
}
else if (valueNM <= 750) {
else if (valueNM > 650) { //650 to 750 is red
color = red;
}
}
void activateLight(int duration) {
switch (color) {
case purple:
colorCounter = 0;
break;
case blue:
colorCounter = 1;
break;
case green:
colorCounter = 2;
break;
case yellow:
colorCounter = 3;
break;
case orange:
colorCounter = 4;
break;
case red:
colorCounter = 5;
break;
case white:
colorCounter = 6;
break;
}
void activateLight() {
}
}