// -------------------------------------------------------------------------------------------------------------------- /// \file wordmap.cpp /// \brief Description // -------------------------------------------------------------------------------------------------------------------- // // vbchaos software design // // -------------------------------------------------------------------------------------------------------------------- /// $Revision: $ /// $Author: $ /// $Date: $ // (c) 2023 vbchaos // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // Include files // -------------------------------------------------------------------------------------------------------------------- #include #include // -------------------------------------------------------------------------------------------------------------------- // Constant and macro definitions // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // Type definitions // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // File-scope variables // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // Function declarations // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // Function definitions // -------------------------------------------------------------------------------------------------------------------- wordmap::wordmap(ledmatrix* matrix) { wordmap::matrix = matrix; wordmap::language = NL; wordmap::red = 0xFF; wordmap::green = 0xFF; wordmap::blue = 0xFF; } bool wordmap::setWord(Language_t lang, std::string& identifier, bool value) { bool returnValue; auto _compare = [&](struct word currentword) { if (identifier.compare(currentword.identifier) == 0) { return true; } else { return false; } }; // Create a list Iterator std::list::iterator it; // Fetch the iterator of element with value 'the' it = find_if(wordlist[lang].begin(), wordlist[lang].end(), _compare); // Check if iterator points to end or not if(it != wordlist[lang].end()) { returnValue = true; } else { returnValue = false; } if (returnValue) { std::list::iterator pixel; for (pixel = it->pixels.begin(); pixel != it->pixels.end(); pixel++) { if (value) { matrix->setPixel(pixel->y, pixel->x, wordmap::red, wordmap::green, wordmap::blue); } else { matrix->setPixel(pixel->y, pixel->x, 0, 0, 0); } } } return returnValue; } bool wordmap::setColour(uint8_t red, uint8_t green, uint8_t blue) { bool returnValue = true; wordmap::red = red; wordmap::green = green; wordmap::blue = blue; return returnValue; } void wordmap::createList_NL(void) { // First, clear the list wordlist[NL].clear(); } void wordmap::createList_EN(void) { // First, clear the list wordlist[EN].clear(); }