void OLED::initOLED() { //unsigned char i; //make scl high setBit(OLED_scl_port,OLED_scl_pin); //make rst low clrBit(OLED_rst_port,OLED_rst_pin); //delay 50 ms _delay_ms(50); //make rst high setBit(OLED_rst_port,OLED_rst_pin); setDisplayOnOff(0x00); // Display Off (0x00/0x01) setDisplayClock(0x80); // Set Clock as 100 Frames/Sec setMultiplexRatio(0x3F); // 1/64 Duty (0x0F~0x3F) setDisplayOffset(0x00); // Shift Mapping RAM Counter (0x00~0x3F) setStartLine(0x00); // Set Mapping RAM Display Start Line (0x00~0x3F) setChargePump(0x04); // Enable Embedded DC/DC Converter (0x00/0x04) setAddressingMode(0x02); // Set Page Addressing Mode (0x00/0x01/0x02) setSegmentRemap(0x01); // Set SEG/Column Mapping setCommonRemap(0x08); // Set COM/Row Scan Direction setCommonConfig(0x10); // Set Sequential Configuration (0x00/0x10) setContrastControl(0xCF); // Set SEG Output Current setPrechargePeriod(0xF1); // Set Pre-Charge as 15 Clocks & Discharge as 1 Clock setVCOMH(0x40); // Set VCOM Deselect Level setEntireDisplay(0x00); // Disable Entire Display On (0x00/0x01) setInverseDisplay(0x00); // Disable Inverse Display On (0x00/0x01) setDisplayOnOff(0x01); // Display On (0x00/0x01) fill(0x00); //clear all setPos(0,0); }
void displayAccounts(accounts *acctList, unsigned char highlightLine) { char init_msg[16]; //initSPIHeader(); // LCD_INVERT=1; setPos(0,0); setStartLine(0); storeList=acctList; strcpy(init_msg,acctList->acctL[0]); drawString(init_msg,1); strcpy(init_msg,acctList->acctL[1]); drawString(init_msg,2); strcpy(init_msg,acctList->acctL[2]); drawString(init_msg,3); strcpy(init_msg,acctList->acctL[3]); drawString(init_msg,4); if(highlightLine>0 && highlightLine <=4) { LCD_INVERT=1; strcpy(init_msg,acctList->acctL[highlightLine-1]); drawString(init_msg,highlightLine); LCD_INVERT=0; } // CloseSPI1(); }
void displayDebug(void) { char printUser[]="User ", printOpt[]="Opt ", blank[]=" "; unsigned char buffer[3]={MSGT_USER_CHOICE,chosenName,chosenState}; ToMainHigh_sendmsg(3,MSGT_USER_CHOICE,(void *) buffer); setPos(0,0); setStartLine(0); printUser[5]=(char)chosenName+0x40; printOpt[5]=(char)chosenState+0x40; drawString(printUser,1); drawString(printOpt,2); drawString(blank,3); drawString(blank,4); }
void displayOptions(unsigned char highlightLine) { setPos(0,0); setStartLine(0); drawString(optL[0],1); drawString(optL[1],2); drawString(optL[2],3); drawString(optL[3],4); if(highlightLine>0 && highlightLine <=4) { LCD_INVERT=1; drawString(optL[highlightLine-1],highlightLine); LCD_INVERT=0; } }
int SearchDialog::find() { QRegExp searchTextRegExp; QDltMsg msg; QByteArray buf; QString text; int searchLine; int searchBorder; if(file->sizeFilter()==0) return 0; //setSearchColour(QColor(0,0,0),QColor(255,255,255)); if(getMatch() || getSearchFromBeginning()==false){ QModelIndexList list = table->selectionModel()->selection().indexes(); if(list.count()<=0) { QMessageBox::critical(0, QString("DLT Viewer"),QString("No message selected")); setMatch(false); //table->clearSelection(); //setSearchColour(QColor(255,255,255),QColor(255,102,102)); return 0; } QModelIndex index; for(int num=0; num < list.count();num++) { index = list[num]; if(index.column()==0) { break; } } setStartLine(index.row()); } searchLine = getStartLine(); searchBorder = getStartLine();; if(searchBorder < 0){ if(getNextClicked()){ searchBorder = file->sizeFilter()==0?0:file->sizeFilter()-1; }else{ searchBorder = 0; } } if(getRegExp()) { searchTextRegExp.setPattern(getText()); searchTextRegExp.setCaseSensitivity(getCaseSensitive()?Qt::CaseSensitive:Qt::CaseInsensitive); if (!searchTextRegExp.isValid()) { QMessageBox::warning(0, QString("Search"), QString("Invalid regular expression!")); //setSearchColour(QColor(255,255,255),QColor(255,102,102)); return 0; } } QProgressDialog fileprogress("Searching...", "Abort", 0, file->sizeFilter(), this); fileprogress.setWindowTitle("DLT Viewer"); fileprogress.setWindowModality(Qt::WindowModal); fileprogress.show(); do { if(getNextClicked()){ searchLine++; if(searchLine >= file->sizeFilter()){ searchLine = 0; //QMessageBox::information(0, QString("Search"),QString("End of file reached. Search start from top.")); } }else{ searchLine--; if(searchLine <= -1){ searchLine = file->sizeFilter()-1; //QMessageBox::information(0, QString("Search"),QString("Top of file reached. Search start from bottom.")); } } //qDebug()<<"startLine: "<<getStartLine(); //qDebug()<<"searchBorder: "<<searchBorder; //qDebug()<<"searchLine: "<<searchLine; if(getNextClicked()){ fileprogress.setValue(searchLine+1); }else{ fileprogress.setValue(file->sizeFilter()-searchLine); } /* get the message with the selected item id */ buf = file->getMsgFilter(searchLine); msg.setMsg(buf); for(int num2 = 0; num2 < plugin->topLevelItemCount (); num2++) { PluginItem *item = (PluginItem*)plugin->topLevelItem(num2); if(item->getMode() != item->ModeDisable && item->plugindecoderinterface && item->plugindecoderinterface->isMsg(msg,1)) { item->plugindecoderinterface->decodeMsg(msg,1); break; } } bool pluginFound = false; /* search header */ if(!pluginFound || text.isEmpty()) { text += msg.toStringHeader(); } if(getHeader()) { if (getRegExp()) { if(text.contains(searchTextRegExp)) { table->selectRow(searchLine); setStartLine(searchLine); setMatch(true); break; }else { setMatch(false); } } else { if(text.contains(getText(),getCaseSensitive()? Qt::CaseSensitive : Qt::CaseInsensitive )) { table->selectRow(searchLine); setStartLine(searchLine); setMatch(true); break; }else { setMatch(false); } } } /* search payload */ text.clear(); if(!pluginFound || text.isEmpty()) { text += msg.toStringPayload(); } if(getPayload()) { if (getRegExp()) { if(text.contains(searchTextRegExp)) { table->selectRow(searchLine); setMatch(true); setStartLine(searchLine); break; }else { setMatch(false); } } else { if(text.contains(getText(),getCaseSensitive()?Qt::CaseSensitive:Qt::CaseInsensitive)) { table->selectRow(searchLine); setMatch(true); setStartLine(searchLine); break; } else { setMatch(false); } } } }while(searchBorder != searchLine); if(getMatch()) { return 1; } //table->clearSelection(); //setSearchColour(QColor(255,255,255),QColor(255,102,102)); return 0; }
bool TimeSeriesMotion::load(const QString &fileName, bool defaults, double scale) { m_accel.clear(); setFileName(fileName); const QString ext = m_fileName.right(3).toUpper(); // Load the file QFile file(m_fileName); if (!file.open( QIODevice::ReadOnly | QIODevice::Text )) { qWarning() << "Unable to open the time series file:" << qPrintable(m_fileName); return false; } QTextStream stream(&file); if (defaults) { if (ext == "AT2") { // Set format setFormat(Rows); setStartLine(5); setStopLine(0); setScale(scale); // Read in the header information Q_UNUSED(stream.readLine()); setDescription(stream.readLine()); Q_UNUSED(stream.readLine()); QStringList parts = stream.readLine().split(QRegExp("\\s+")); bool b; const int count = parts.at(0).toInt(&b); if (b && count > 1) { // Greater than one condition to catch if an acceleration value is read setPointCount(count); } else { qCritical() << "Unable to parse the point count in AT2 file!"; return false; } const double timeStep = parts.at(1).toDouble(&b); if (b) { setTimeStep(timeStep); } else { qCritical() << "Unable to parse the time step in AT2 file!"; return false; } } else { // Unknown file format can't process with default settings return false; } } else { // Check the input if (m_timeStep <= 0) { qCritical("Time step must be greater than one"); return false; } if (m_startLine < 0) { qCritical("Number of header lines must be positive"); return false; } } // Move back to the start of the stream stream.seek(0); int lineNum = 1; // Skip the header lines while (lineNum < m_startLine) { Q_UNUSED(stream.readLine()); ++lineNum; } // Initialize the length of m_accel m_accel.resize(m_pointCount); // Process each of the lines int index = 0; // Read the first line QString line =stream.readLine(); bool finished = false; bool stopLineReached = false; // Modify the scale for unit conversion scale = unitConversionFactor() * m_scale; while (!finished && !line.isNull()) { // Stop if line exceeds number of lines. The line number has // to be increased by one because the user display starts at // line number 1 instead of 0 if (m_stopLine > 0 && m_stopLine <= lineNum+1) { stopLineReached = true; break; } // Read the line and split the line QRegExp rx("(-?\\d*\\.\\d+(?:[eE][+-]?\\d+)?)"); int pos = 0; QStringList row; while ((pos = rx.indexIn(line, pos)) != -1) { row << rx.cap(1); pos += rx.matchedLength(); } // Process the row based on the format bool ok; switch (m_format) { case Rows: // Use all parts of the data for(int i = 0; i < row.size(); ++i) { if ( index == m_pointCount ) { qWarning("Point count reached before end of data!"); finished = true; break; } // Apply the scale factor and read the acceleration m_accel[index] = scale * row.at(i).trimmed().toDouble(&ok); // Increment the index ++index; // Stop if there was an error in the conversion if (!ok) { continue; } } break; case Columns: // Use only the important column, however at the end of the // file that column may not exist -- this only happens when the // row format is applied, but it still causes the program to // crash. if ( m_dataColumn - 1 < row.size() ) { m_accel[index] = scale * row.at(m_dataColumn-1).trimmed().toDouble(&ok); } // Increment the index ++index; break; } // Throw an error if there was a problem if (!ok) { qCritical() << "Error converting string to double in line: \n\"" << qPrintable(line) << "\"\nCheck starting line."; return false; } // Read the next line ++lineNum; line = stream.readLine(); } if (m_pointCount != index) { if (stopLineReached) { qWarning() << "Number of points limited by stop line."; } else { qCritical() << "Number of points read does not equal specified point count!"; return false; } } // Compute motion properties calculate(); setIsLoaded(true); return true; }