smart-fursuit-tail-esp32/embedded/src/led.cpp

57 lines
1.3 KiB
C++

#include "led.hpp"
LED::LED(int r, int g, int b){
this->r = new GPIOOutputPin(r, false);
this->g = new GPIOOutputPin(g, false);
this->b = new GPIOOutputPin(b, false);
this->r->bind();
this->g->bind();
this->b->bind();
}
void LED::color(char c){
switch (c) {
case 'w':
this->r->write(true);
this->g->write(true);
this->b->write(true);
break;
case 'c':
this->r->write(false);
this->g->write(true);
this->b->write(true);
break;
case 'm':
this->r->write(true);
this->g->write(false);
this->b->write(true);
break;
case 'y':
this->r->write(true);
this->g->write(true);
this->b->write(false);
break;
case 'r':
this->r->write(true);
this->g->write(false);
this->b->write(false);
break;
case 'g':
this->r->write(false);
this->g->write(true);
this->b->write(false);
break;
case 'b':
this->r->write(false);
this->g->write(false);
this->b->write(true);
break;
case 'k':
default:
this->r->write(false);
this->g->write(false);
this->b->write(false);
break;
}
}