xtLcd.cpp (2276B)
1 #include "xtLcd.h" 2 3 #include "xtController.h" 4 5 #include "jucePluginLib/pluginVersion.h" 6 7 #include "hardwareLib/lcdfonts.h" 8 9 namespace 10 { 11 constexpr char g_defaultTextSingle[] = 12 " Play Sound EEEEE | Mode |Main Vol. " 13 " 0123456789012345 | Sound | VVV "; 14 15 constexpr char g_defaultTextMulti[] = 16 " Play Multi 001 | Mode |Main Vol. " 17 " 0123456789012345 | Multi | VVV Z"; 18 19 static_assert(std::size(g_defaultTextSingle) == 80 + 1); 20 static_assert(std::size(g_defaultTextMulti) == 80 + 1); 21 } 22 23 namespace xtJucePlugin 24 { 25 // 40*2 LCD simulation 26 27 XtLcd::XtLcd(Component& _parent, Controller& _controller) : Lcd(_parent, 40, 2), m_controller(_controller) 28 { 29 postConstruct(); 30 31 m_currentText.fill(' '); 32 } 33 34 XtLcd::~XtLcd() = default; 35 36 void XtLcd::refresh() 37 { 38 setText(m_currentText); 39 } 40 41 void XtLcd::setText(const std::array<uint8_t, 80>& _text) 42 { 43 m_currentText = _text; 44 45 std::vector<uint8_t> text{_text.begin(), _text.end()}; 46 47 if(m_controller.isMultiMode()) 48 text.back() = '1' + m_controller.getCurrentPart(); 49 50 if(!m_paramName.empty() && !m_paramValue.empty()) 51 { 52 const auto param = '[' + m_paramName + " = " + m_paramValue + ']'; 53 if(param.size() <= 40) 54 { 55 memcpy(text.data() + 40 - param.size(), param.c_str(), param.size()); 56 } 57 } 58 59 Lcd::setText(text); 60 } 61 62 bool XtLcd::getOverrideText(std::vector<std::vector<uint8_t>>& _lines) 63 { 64 std::string lineA(std::string("Xenia v") + pluginLib::Version::getVersionString()); 65 std::string lineB = pluginLib::Version::getVersionDateTime(); 66 67 constexpr char lineAright[] = "From TUS"; 68 constexpr char lineBright[] = "with <3"; 69 70 while(lineA.size() < 40 - std::size(lineAright) + 1) 71 lineA.push_back(' '); 72 lineA += lineAright; 73 74 while(lineB.size() < 40 - std::size(lineBright) + 1) 75 lineB.push_back(' '); 76 lineB += lineBright; 77 78 _lines = 79 { 80 std::vector<uint8_t>(lineA.begin(), lineA.end()), 81 std::vector<uint8_t>(lineB.begin(), lineB.end()) 82 }; 83 84 return true; 85 } 86 87 const uint8_t* XtLcd::getCharacterData(const uint8_t _character) const 88 { 89 return hwLib::getCharacterData(_character); 90 } 91 92 void XtLcd::setCurrentParameter(const std::string& _name, const std::string& _value) 93 { 94 m_paramName = _name; 95 m_paramValue = _value; 96 97 setText(m_currentText); 98 } 99 }