Пример #1
0
void PluginLCD::SendData(int row, int col, 
    int layer, string val) {
    QByteArray data = val.toAscii();
    if(type_ == LCD_TEXT) {
        LCDText *lcd = (LCDText *)visitor_->GetLCD();
        if(layer >= lcd->LAYERS) {
            LCDError("PluginLCD::SendData: Invalid layer");
            return;
        }
        unsigned char *FB = lcd->LayoutFB[layer];
        int cols = lcd->LCOLS;
        int rows = lcd->LROWS;
        if( row >= rows )
            return;
        for(int i = 0; i < (int)data.size() && 
            i + col < cols; i++) {
            FB[row * cols + col + i] = data[i];
        }
        lcd->TextBlit(row, col, 1, data.size());
    } else if(type_ == LCD_GRAPHIC) {
	LCDGraphic *lcd = (LCDGraphic *)visitor_->GetLCD();
	RGBA fg_(0, 0, 0);
	RGBA bg_(255, 255, 255);
	row*=lcd->YRES;
	col*=lcd->XRES;
	if(layer >= lcd->LAYERS) {
		LCDError("PluginLCD::SendData: Invalid layer");
		return;
	}
	lcd->GraphicRender(layer, row, col, fg_, bg_, val.c_str(), 0, 0, GetCurrentLayout().c_str());
	lcd->GraphicBlit(0, 0, lcd->LROWS, lcd->LCOLS); 
    }
}
Пример #2
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);
    }
}
Пример #3
0
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]);
    }
}
Пример #4
0
void LCDCore::ChangeLayout() {
    if(is_transitioning_) {
        //timer_->start(100);
        return;
    }
    LCDError("ChangeLayout");
    Json::Value *t = CFG_Fetch_Raw(CFG_Get_Root(), 
        current_layout_ + ".transition");
    if(!t or transitions_off_) {
        StopLayout(current_layout_);
        StartLayout();
    } else {
        StartTransition(t->asString());
        delete t;
        if(type_ & LCD_TEXT) {
            LCDText *text = ((LCDText *)lcd_);
            text->CleanBuffer(text->LayoutFB);
        }
    }
}
Пример #5
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());
    }
}