コード例 #1
0
ファイル: plottericon.cpp プロジェクト: Voker57/qnetload
void PlotterIcon::inputData(quint64 value)
{
	log[cursor] = value;
	cursor += 1;
	if(cursor >= getLogSize())
		cursor -= getLogSize();
}
コード例 #2
0
ファイル: mavesp8266.cpp プロジェクト: baumandr/mavesp8266
//---------------------------------------------------------------------------------
String
MavESP8266Log::getLog(uint32_t position) {
    String buffer;
#if 0
    //-- TODO
    uint32_t len = getLogSize();
    if (position < _log_posistion) {
        position = 0;
    } else if (position >= _log_posistion + len) {
        position = len;
    } else {
        position = position - _log_posistion;
    }
    int r = (_log_read + position) % _buffer_size;
    while (r != _log_write) {
        uint8_t c = _buffer[r];
        if (c == '\\' || c == '"') {
            buffer += '\\';
            buffer += c;
        } else if (c < ' ') {
            char tmp[12];
            snprintf(tmp, 12, "\\u%04x", c);
            buffer += tmp;
        } else {
            buffer += c;
        }
        r = (r + 1) % _buffer_size;
    }
#endif
    return buffer;
}
コード例 #3
0
ファイル: mavesp8266.cpp プロジェクト: EATtomatoes/mavesp8266
//---------------------------------------------------------------------------------
String
MavESP8266Log::getLog(uint32_t* pStart, uint32_t* pLen) {
    String buffer;

    uint32_t position = *pStart, len = getLogSize();
    if (position < _log_position - len) { //-- Can't read data that was overriden
        position = _log_position - len;
    } else if (position > _log_position) { //-- Can't read data from the future
        position = _log_position;
    }
    len = _log_position - position;
    *pStart = position;
    *pLen = len;

    uint32_t r = (_log_offset + (_buffer_size - len)) % _buffer_size;
    while(len > 0) {
        char c = _buffer[r];
        //-- Copy as JSON encoded characters
        if (c == '\\' || c == '"') {
            buffer += '\\';
            buffer += c;
        } else if (c < ' ') {
            char tmp[12];
            snprintf(tmp, 12, "\\u%04x", c);
            buffer += tmp;
        } else {
            buffer += c;
        }
        r = (r + 1) % _buffer_size;
        len--;
    }
    return buffer;
}
コード例 #4
0
ファイル: plottericon.cpp プロジェクト: Voker57/qnetload
void PlotterIcon::redraw()
{
	QPixmap pm(22,22);
	pm.fill(config->getBackgroundColor());
	QPainter painter(&pm);

	// Grid
	painter.setPen(config->getGridColor());
	for (int i = 0; i < 22; i+= config->getGridDensity())
		painter.drawLine(0, 22 - i, 21, 22 - i);

	// Graph
	painter.setPen(config->getColor());
	int startPosition = cursor + 1;
	if (startPosition >= getLogSize())
		startPosition -= getLogSize();
	int i = startPosition;
	int graphPosition = 0;
	do
	{
		int barWidth = round((double)log[i] / (double)config->getScale() * 21 + 1);

		painter.drawLine(graphPosition, 22, graphPosition, 22 - barWidth);
		graphPosition++;
		i++;
		if (i >= getLogSize())
			i -= getLogSize();
	} while(i != startPosition);

	// Label
	painter.setPen(config->getTextColor());
	painter.setFont(QFont(config->getFontFamily(), config->getFontSize()));
	painter.drawText(QRect(0,0,22,22), config->getLabel(), QTextOption(Qt::AlignLeft | Qt::AlignTop));

	setIcon(QIcon(pm));
}