modified games

This commit is contained in:
willem oldemans
2020-12-08 18:38:35 +01:00
parent 43fcb87efc
commit 32ae7afe35
9 changed files with 489 additions and 139 deletions

View File

@@ -14,10 +14,51 @@ c_leds *getledlist(void)
return &ledlist;
}
void initLeds(void)
{
ledlist.init();
ledlist.AddLed(LED1, DETECT1, 1, 844, YELLOW, false);
ledlist.AddLed(LED2, DETECT2, 2, 512, RED, false);
ledlist.AddLed(LED3, DETECT3, 2, 92, GREEN, false);
ledlist.begin();
}
void turnOnLed(e_ledcolor color)
{
ledlist.turnOnLed(color);
}
void turnOffLed(uint16_t index)
{
ledlist.turnOffLed(index);
}
void turnOnLed(uint16_t index)
{
ledlist.turnOnLed(index);
}
void turnOffLed(e_ledcolor color)
{
ledlist.turnOffLed(color);
}
void turnOffAllLed()
{
ledlist.turnAllOff();
}
//#############################################
//# leds functions #
//#############################################
void c_leds::init(void)
{
v_ledports.clear();
v_leds.clear();
}
void c_leds::AddLed(uint32_t pin, uint32_t analogpin, uint16_t index, uint16_t value, e_ledcolor color, bool invert)
{
c_ledport port(pin, analogpin, index, invert);
@@ -37,16 +78,45 @@ void c_leds::begin(void)
void c_leds::turnOnLed(e_ledcolor color)
{
getLed(color)->turnOn();
if (verifyLed(color))
{
getLed(color)->turnOn();
}
}
void c_leds::turnOnLed(uint16_t index)
{
if (verifyLed(index))
{
getLed(index)->turnOn();
}
}
void c_leds::turnOffLed(e_ledcolor color)
{
getLed(color)->turnOff();
if (verifyLed(color))
{
getLed(color)->turnOff();
}
}
void c_leds::turnOffLed(uint16_t index)
{
if (verifyLed(index))
{
getLed(index)->turnOff();
}
}
c_ledport* c_leds::getLed( e_ledcolor color )
void c_leds::turnAllOff(void)
{
for (auto &&port : v_ledports)
{
port.turnOff();
}
}
c_ledport *c_leds::getLed(e_ledcolor color)
{
for (auto &&port : v_ledports)
{
@@ -59,18 +129,43 @@ c_ledport* c_leds::getLed( e_ledcolor color )
}
}
}
return NULL;
}
void c_leds::turnOnLed(uint16_t index)
{
}
void c_leds::turnAllOff(void)
c_ledport *c_leds::getLed(uint16_t index)
{
for (auto &&port : v_ledports)
{
port.turnOff();
if (port.getIndex() == index)
{
return &port;
}
}
return NULL;
}
bool c_leds::verifyLed(e_ledcolor color)
{
for (auto &&thisled : v_leds)
{
if (thisled.checkcolor(color))
{
return true;
}
}
return false;
}
bool c_leds::verifyLed(uint16_t index)
{
for (auto &&thisled : v_leds)
{
if (thisled.checkIndex(index))
{
return true;
}
}
return false;
}
//#############################################
@@ -109,7 +204,6 @@ uint16_t c_ledport::ledRead(void)
return analogRead(_analogPin);
}
//#############################################
//# c_led functions #
//#############################################
@@ -128,9 +222,18 @@ bool c_led::checkThreshold(uint16_t value)
bool c_led::checkcolor(e_ledcolor color)
{
if(_color == color)
if (_color == color)
{
return true;
}
return false;
}
}
bool c_led::checkIndex(uint16_t index)
{
if (_index == index)
{
return true;
}
return false;
}