示例#1
0
void PluginLCD::SetSpecialChar(int ch, SpecialChar matrix) {
    if(type_ == LCD_TEXT) {
        LCDText *lcd = (LCDText *)visitor_->GetLCD();
        lcd->special_chars[ch] = matrix;
        lcd->TextSpecialCharChanged(ch);
    }
}
void WidgetHistogram::SetupChars() {
    ch_.clear();
    LCDText *lcd = (LCDText *)visitor_->GetLCD();
    for(int c = 0; c < (int)lcd->YRES; c++ ) {
        SpecialChar buffer(lcd->YRES);;
        for(int i = lcd->YRES - 1; i >= 0; i-- ) {
            buffer[lcd->YRES - i - 1] = (i < c ? pow(2.0, (double)lcd->XRES)-1-gap_ : 0);
        }

        bool reused = false;

        for(unsigned int i = 0; i < lcd->special_chars.size(); i++ ) {
            if( buffer == lcd->special_chars[i] ) {
                ch_[c] = i;
                reused = true;
                break;
            }
        }

        if( lcd->CHARS < (int)lcd->special_chars.size() ) {
            update_ = -1;
            LCDError("Widget %s - unable to allocate special chars", 
                name_.c_str());
            return;
        }

        if( reused ) continue;
        lcd->special_chars.push_back(buffer);
        ch_[c] = lcd->special_chars.size() - 1;
        lcd->TextSpecialCharChanged(ch_[c]);
    }
}
示例#3
0
void WidgetBar::SetupChars() {
    LCDText *lcd = (LCDText *)visitor_->GetLCD();
    ch_.clear();
    if( style_ == STYLE_HOLLOW and not expression2_->Valid()) {
        for( int i = 0; i < 4; i++ ) {
            for( int j = 0; j < (int)lcd->special_chars.size(); j++ ) {
                SpecialChar c(SCHARS[i], 8);
                if( lcd->special_chars[j] == c ) {
                    ch_[i] = j;
                }
            }

        }
        for(int i = 0; i < 6; i++ ) {
            std::map<const int, char>::iterator it = ch_.find(i);
            if(it != ch_.end()) {
                if((int)lcd->special_chars.size() >= lcd->CHARS ) {
                    LCDError("Can not allot char for widget: %s",name_.c_str());
                    update_ = -1;
                    return;
                }
                lcd->special_chars.push_back(SpecialChar(SCHARS[i], 8));
                ch_[i] = lcd->special_chars.size() - 1;
                lcd->TextSpecialCharChanged(ch_[i]);
            }
        }
    } else if (style_ == STYLE_NORMAL ) {
        for(unsigned int j = 0; j < lcd->special_chars.size(); j++ ) {
            if( lcd->special_chars[j] == SpecialChar(SCHARS[0], 8)) {
                ch_[0] = j;
            }
            if( lcd->special_chars[j] == SpecialChar(SCHARS[4], 8)) {
                ch_[1] = j;
            }
            if( lcd->special_chars[j] == SpecialChar(SCHARS[5], 8)) {
                ch_[2] = j;
            }
        }
        std::map<const int, char>::iterator it;

        it = ch_.find(0);
        if(it == ch_.end()) {
            if((int)lcd->special_chars.size() >= lcd->CHARS ) {
                LCDError("Can not allot char for bar widget: %s",name_.c_str());
                update_ = -1;
                return;
            }
            lcd->special_chars.push_back(SpecialChar(SCHARS[0], 8));
            ch_[0] = lcd->special_chars.size() - 1;
            lcd->TextSpecialCharChanged(ch_[0]);
        }

        it = ch_.find(1);
        if(it == ch_.end() && expression2_->Valid()) {
            if( (int)lcd->special_chars.size() >= lcd->CHARS ) {
                LCDError("Can not allot char for bar widget: %s",name_.c_str());
                update_ = -1;
                return;
            }
            lcd->special_chars.push_back(SpecialChar(SCHARS[4], 8));
            ch_[1] = lcd->special_chars.size() - 1;
            lcd->TextSpecialCharChanged(ch_[1]);
        }

        it = ch_.find(2);
        if(it == ch_.end() && expression2_->Valid()) {
            if( (int)lcd->special_chars.size() >= lcd->CHARS ) {
                LCDError("Can not allot char for bar widget: %s",name_.c_str());
                update_ = -1;
                return;
            }
            lcd->special_chars.push_back(SpecialChar(SCHARS[5], 8));
            ch_[2] = lcd->special_chars.size() - 1;
            lcd->TextSpecialCharChanged(ch_[2]);
        }

    } else {
        LCDError("%s: Either choose style (H)ollow or have a 2nd expression.",
                 widget_base_.c_str());
    }
}