#include <colorObj.h>
#include <neoPixel.h>
#include <autoPOT.h>
#include <mechButton.h>
neoPixel theRing(12,2);
autoPOT redPot(A0);
autoPOT greenPot(A1);
autoPOT bluePot(A2);
mapper POT2BYTE(0,1023,0,255);
colorObj ourColor;
mechButton colorBtn(3);
void setup() {
Serial.begin(115200);
theRing.begin();
theRing.setAll(&white);
theRing.show();
redPot.setCallback(changeRed);
greenPot.setCallback(changeGreen);
bluePot.setCallback(changeBlue);
colorBtn.setCallback(clkButton);
Serial.println("Click button to see RGB values.");
}
void changeRed(int newValue) {
int redVal;
int greenVal;
int blueVal;
redVal = round(POT2BYTE.map(newValue));
greenVal = ourColor.getGreen();
blueVal = ourColor.getBlue();
ourColor.setColor(redVal,greenVal,blueVal);
theRing.setAll(&ourColor);
theRing.show();
}
void changeGreen(int newValue) {
int redVal;
int greenVal;
int blueVal;
redVal = ourColor.getRed();
greenVal = round(POT2BYTE.map(newValue));
blueVal = ourColor.getBlue();
ourColor.setColor(redVal,greenVal,blueVal);
theRing.setAll(&ourColor);
theRing.show();
}
void changeBlue(int newValue) {
int redVal;
int greenVal;
int blueVal;
redVal = ourColor.getRed();
greenVal = ourColor.getGreen();
blueVal = round(POT2BYTE.map(newValue));
ourColor.setColor(redVal,greenVal,blueVal);
theRing.setAll(&ourColor);
theRing.show();
}
void clkButton(void) {
if (!colorBtn.getState()) {
Serial.print("Color values Red ");
Serial.print(ourColor.getRed());
Serial.print("\t Green ");
Serial.print(ourColor.getGreen());
Serial.print("\t Blue ");
Serial.println(ourColor.getBlue());
}
}
void loop() { idle(); }