Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extremely slow speed when updating the display #137

Open
OmerFlame opened this issue Jul 11, 2020 · 1 comment
Open

Extremely slow speed when updating the display #137

OmerFlame opened this issue Jul 11, 2020 · 1 comment

Comments

@OmerFlame
Copy link

OmerFlame commented Jul 11, 2020

Hi, olikraus! I am having issues with the ST7735 using Ucglib. I am using my display to show values calculated from a lot of potentiometers and the values are very widely spread over the display (I am using the 160x128 display from Adafruit). For some reason, I am having very slow update speeds. I can give you my code and show you what I have been doing.

CODE ON THE MAIN LOOP:

for (int i = 0; i < 4; i++) {
    filters[i].setTextFrequency(String(map(filters[i].frequencyReading(), 0, 1023, 40, 800)));
    filters[i].setTextDB(String(mapFloat(filters[i].dbReading(), 0.0, 1023.0, -10.0, 10.0)));
    filters[i].setTextQ(String(map(filters[i].qReading(), 0, 1023, 0, 100)));
            
    filters[i].updateDigitpots(); // This function does not work on the hardware SPI bus, but on a separate software SPI bus and is completely unrelated to normal Ucglib operations.
}

CODE FOR setTextFrequency, setTextDB and setTextQ:

void Filter::setTextFrequency(String replacementText) {
    String modifiedReplacementText = replacementText;
    _displayHandler.setPrintPos(freqCursorX, freqCursorY);
    _displayHandler.setColor(0, _textColorR, _textColorG, _textColorB);
    
    switch (modifiedReplacementText.length()) {
        case 1:
            modifiedReplacementText = "00" + modifiedReplacementText;
            break;
    
        case 2:
            modifiedReplacementText = "0" + modifiedReplacementText;
            break;
    
        default:
            modifiedReplacementText = modifiedReplacementText;
            break;
    }
    
    if (shouldReadFromMemory) {
        setMemFrequency(atol(replacementText.c_str()));
    } else {
        setFrequency(atol(replacementText.c_str()));
    }
    
    _displayHandler.print(modifiedReplacementText);
}
void Filter::setTextDB(String replacementText) {
    String modifiedReplacementText = replacementText;
    _displayHandler.setPrintPos(dbCursorX, dbCursorY);
    _displayHandler.setColor(0, _textColorR, _textColorG, _textColorB);
    
    modifiedReplacementText.remove(replacementText.length() - 1);
    
    if (atof(modifiedReplacementText.c_str()) > 0) {
        modifiedReplacementText = "+" + modifiedReplacementText;
    }
    
    if (modifiedReplacementText == "+10.0") {
        modifiedReplacementText = "+10";
    }
    if (modifiedReplacementText == "-10.0") {
        modifiedReplacementText = "-10";
    }
    if (modifiedReplacementText == "+0.0" || modifiedReplacementText == "-0.0") {
        modifiedReplacementText = "+0.0";
    }
    
    if (shouldReadFromMemory) {
        setMemDB(atof(replacementText.c_str()));
    } else {
        setDB(atof(replacementText.c_str()));
    }
    
    _displayHandler.print(modifiedReplacementText);
    
    if (modifiedReplacementText.length() == 1) {
        _displayHandler.print("   ");
    }
    if (modifiedReplacementText.length() == 2) {
        _displayHandler.print("  ");
    }
    if (modifiedReplacementText.length() == 3) {
        _displayHandler.print(" ");
    }
}
void Filter::setTextQ(String replacementText) {
    String modifiedReplacementText = replacementText;
    _displayHandler.setPrintPos(qCursorX, qCursorY);
    _displayHandler.setColor(0, _textColorR, _textColorG, _textColorB);
    
    switch (modifiedReplacementText.length()) {
        case 1:
            modifiedReplacementText = "00" + modifiedReplacementText;
            break;
            
        case 2:
            modifiedReplacementText = "0" + modifiedReplacementText;
            break;
            
        default:
            break;
    }
    
    if (shouldReadFromMemory) {
        setMemQ(atoi(replacementText.c_str()));
    } else {
        setQ(atoi(replacementText.c_str()));
    }
    
    _displayHandler.print(modifiedReplacementText);
}

Note: _displayHandler is the UCG display controller.
Thank your for your time and your great library!

@EBTEAM3
Copy link

EBTEAM3 commented May 13, 2022

I am having the same issue, it was quite fast for a while, then suddenly slowed down. Did you end up finding a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants