bool WalkCameraManipulatorHIDSync::updateFrame( float dt ) { if (!m_hid) { return false; } dp::math::Vec2i pos = m_hid->getValue<dp::math::Vec2i>( PID_Pos ); if( getReverseMouse() && getRenderTarget() ) { pos[1] = getRenderTarget()->getHeight() - pos[1] - 1; } setCursorPosition( pos ); setWheelTicks( m_hid->getValue<int>( PID_Wheel ) ); // set height above terrain if( m_hid->getValue<bool>( PID_KeyUp ) ) { setCameraHeightAboveTerrain( getCameraHeightAboveTerrain() + m_sensitivity[1] ); } else if( m_hid->getValue<bool>( PID_KeyDown ) ) { float hat = getCameraHeightAboveTerrain() - m_sensitivity[1]; if( hat < 0.f ) { hat = 0.f; } setCameraHeightAboveTerrain( hat ); } bool forward = m_hid->getValue<bool>( PID_ButtonForward ) || m_hid->getValue<bool>( PID_KeyForward ); bool reverse = m_hid->getValue<bool>( PID_ButtonReverse ) || m_hid->getValue<bool>( PID_KeyReverse ); bool strafeLeft = m_hid->getValue<bool>( PID_KeyStrafeLeft ); bool strafeRight = m_hid->getValue<bool>( PID_KeyStrafeRight ); float run = m_hid->getValue<bool>( PID_KeyRun ) ? 2.0f : 1.0f; unsigned int mode = MODE_FREELOOK; // update speed based on wheel m_speed += getWheelTicksDelta() * 0.1f; if( m_speed < 0.f ) { m_speed = 0.f; } if( forward || reverse ) { // set forward, reverse here float speed = forward ? m_speed : -m_speed; WalkCameraManipulator::setSpeed( speed * run ); mode |= MODE_WALK; } if( strafeLeft ) { WalkCameraManipulator::setSpeed( m_speed * run ); mode |= MODE_STRAFE_LEFT; } else if( strafeRight ) { WalkCameraManipulator::setSpeed( m_speed * run ); mode |= MODE_STRAFE_RIGHT; } // if not moving, set speed to 0 if( mode == MODE_FREELOOK ) { // stopped WalkCameraManipulator::setSpeed( 0.f ); } setMode( mode ); return WalkCameraManipulator::updateFrame( dt ); }
void QLCDNumber::setDecMode() { setMode(Dec); }
void StatusNotifierItem::onDBusError(const QDBusError &error) { qWarning() << "StatusNotifierItem encountered a D-Bus error:" << error; setMode(Mode::Legacy); }
//put transceiver in sleep mode to save battery - to wake or resume receiving just call receiveDone() void RFM69::sleep() { setMode(RF69_MODE_SLEEP); }
void PiperGL11::setMatrix(const MATRIX &matrix, Piper::Mode mode) { if (setMode(mode)) glLoadMatrixf(matrix.f); }
void PiperGL11::popMatrix(Piper::Mode mode) { if (setMode(mode)) glPopMatrix(); }
void FV_VisualDragText::_mouseDrag(UT_sint32 x, UT_sint32 y) { // // Don't try to drag the entire document. // if(!m_bDoingCopy && (m_pView->isSelectAll() && !m_pView->isHdrFtrEdit())&&(m_iVisualDragMode != FV_VisualDrag_DRAGGING)) { setMode(FV_VisualDrag_NOT_ACTIVE); return; } if(m_iVisualDragMode == FV_VisualDrag_NOT_ACTIVE) { m_iInitialOffX = x; m_iInitialOffY = y; m_iVisualDragMode = FV_VisualDrag_WAIT_FOR_MOUSE_DRAG; UT_DEBUGMSG(("Initial call for drag -1\n")); return; } if((m_iInitialOffX == 0) && (m_iInitialOffY == 0)) { m_iInitialOffX = x; m_iInitialOffY = y; m_iVisualDragMode = FV_VisualDrag_WAIT_FOR_MOUSE_DRAG; UT_DEBUGMSG(("Initial call for drag -2 \n")); } if(m_iVisualDragMode == FV_VisualDrag_WAIT_FOR_MOUSE_DRAG) { double diff = sqrt((static_cast<double>(x) - static_cast<double>(m_iInitialOffX))*(static_cast<double>(x) - static_cast<double>(m_iInitialOffX)) + (static_cast<double>(y) - static_cast<double>(m_iInitialOffY))*(static_cast<double>(y) - static_cast<double>(m_iInitialOffY))); if(diff < static_cast<double>(getGraphics()->tlu(MIN_DRAG_PIXELS))) { UT_DEBUGMSG(("Not yet dragged enough.%f \n", diff)); // // Have to drag 4 pixels before initiating the drag // return; } else { m_iVisualDragMode = FV_VisualDrag_START_DRAGGING; XAP_Frame * pFrame = static_cast<XAP_Frame*>(m_pView->getParentData()); if (pFrame) pFrame->dragText(); } } if((m_iVisualDragMode != FV_VisualDrag_DRAGGING) && (m_iVisualDragMode != FV_VisualDrag_WAIT_FOR_MOUSE_DRAG) && !m_bDoingCopy) { // // Haven't started the drag yet so create our image and cut the text. // m_pView->getDocument()->beginUserAtomicGlob(); mouseCut(m_iInitialOffX,m_iInitialOffY); m_bTextCut = true; } clearCursor(); if(m_iVisualDragMode == FV_VisualDrag_START_DRAGGING) { reposOffsets(x,y); } m_iVisualDragMode = FV_VisualDrag_DRAGGING; xxx_UT_DEBUGMSG(("x = %d y = %d width \n",x,y)); bool bScrollDown = false; bool bScrollUp = false; bool bScrollLeft = false; bool bScrollRight = false; m_xLastMouse = x; m_yLastMouse = y; if(y<=0) { bScrollUp = true; } else if( y >= m_pView->getWindowHeight()) { bScrollDown = true; } if(x <= 0) { bScrollLeft = true; } else if(x >= m_pView->getWindowWidth()) { bScrollRight = true; } if(bScrollDown || bScrollUp || bScrollLeft || bScrollRight) { if(m_pAutoScrollTimer != NULL) { return; } m_pAutoScrollTimer = UT_Timer::static_constructor(_autoScroll, this); m_pAutoScrollTimer->set(AUTO_SCROLL_MSECS); m_pAutoScrollTimer->start(); return; } UT_sint32 dx = 0; UT_sint32 dy = 0; UT_Rect expX(0,m_recCurFrame.top,0,m_recCurFrame.height); UT_Rect expY(m_recCurFrame.left,0,m_recCurFrame.width,0); UT_sint32 iext = getGraphics()->tlu(3); dx = x - m_iLastX; dy = y - m_iLastY; m_recCurFrame.left += dx; m_recCurFrame.top += dy; m_recOrigLeft.left += dx; m_recOrigLeft.top += dy; m_recOrigRight.left += dx; m_recOrigRight.top += dy; if(dx < 0) { expX.left = m_recCurFrame.left+m_recCurFrame.width -iext; expX.width = -dx + 2*iext; if(dy > 0) { expX.top -= iext; expX.height += dy + 2*iext; } else { expX.top -= iext; expX.height += (-dy + 2*iext); } } else { expX.left = m_recCurFrame.left - dx - iext; expX.width = dx + 2*iext; if(dy > 0) { expX.top -= iext; expX.height += dy + 2*iext; } else { expX.top -= iext; expX.height += (-dy + 2*iext); } } expY.left -= iext; expY.width += 2*iext; if(dy < 0) { expY.top = m_recCurFrame.top + m_recCurFrame.height -iext; expY.height = -dy + 2*iext; } else { expY.top = m_recCurFrame.top - dy - iext; expY.height = dy + 2*iext; } if(!m_bNotDraggingImage && (expX.width > 0)) { getGraphics()->setClipRect(&expX); if(m_bSelectedRow) { m_pView->setSelectionMode(FV_SelectionMode_NONE); } m_pView->updateScreen(false); if(m_bSelectedRow) { m_pView->setSelectionMode(FV_SelectionMode_TableRow); } } if(!m_bNotDraggingImage && (expY.height > 0)) { xxx_UT_DEBUGMSG(("expY left %d top %d width %d height %d \n",expY.left,expY.top,expY.width,expY.height)); getGraphics()->setClipRect(&expY); if(m_bSelectedRow) { m_pView->setSelectionMode(FV_SelectionMode_NONE); } m_pView->updateScreen(false); if(m_bSelectedRow) { m_pView->setSelectionMode(FV_SelectionMode_TableRow); } } if(!m_bNotDraggingImage && (expX.height > 0)) { xxx_UT_DEBUGMSG(("expY left %d top %d width %d height %d \n",expX.left,expX.top,expX.width,expX.height)); getGraphics()->setClipRect(&expX); if(m_bSelectedRow) { m_pView->setSelectionMode(FV_SelectionMode_NONE); } m_pView->updateScreen(false); if(m_bSelectedRow) { m_pView->setSelectionMode(FV_SelectionMode_TableRow); } } if(!m_bNotDraggingImage) { getGraphics()->setClipRect(NULL); drawImage(); if(m_recOrigLeft.width > 0) { getGraphics()->setClipRect(&m_recOrigLeft); m_pView->updateScreen(false); } if(m_recOrigRight.width > 0) { getGraphics()->setClipRect(&m_recOrigRight); m_pView->updateScreen(false); } } m_iLastX = x; m_iLastY = y; getGraphics()->setClipRect(NULL); PT_DocPosition posAtXY = getPosFromXY(x,y); m_pView->_setPoint(posAtXY); xxx_UT_DEBUGMSG(("Point at visual drag set to %d \n",m_pView->getPoint())); // m_pView->_fixInsertionPointCoords(); drawCursor(posAtXY); }
CustInfo::CustInfo(QWidget *pParent, const char *name) : QWidget(pParent, name) { // Create and place the component Widgets QHBoxLayout *layoutMain = new QHBoxLayout(this, 0, 6, "layoutMain"); QHBoxLayout *layoutNumber = new QHBoxLayout(0, 0, 6, "layoutNumber"); QHBoxLayout *layoutButtons = new QHBoxLayout(0, 0, -1, "layoutButtons"); _customerNumberLit = new QLabel(tr("Customer #:"), this, "_customerNumberLit"); _customerNumberLit->setAlignment(Qt::AlignVCenter | Qt::AlignRight); layoutNumber->addWidget(_customerNumberLit); _customerNumber = new CLineEdit(this, "_customerNumber"); _customerNumber->setMinimumWidth(100); layoutNumber->addWidget(_customerNumber); _customerNumberEdit = new XLineEdit(this, "_customerNumberEdit"); _customerNumberEdit->setMinimumWidth(100); _customerNumberEdit->setMaximumWidth(100); layoutNumber->addWidget(_customerNumberEdit); _customerNumberEdit->hide(); layoutMain->addLayout(layoutNumber); _list = new QPushButton(tr("..."), this, "_list"); _list->setFocusPolicy(Qt::NoFocus); if(_x_preferences) { if(_x_preferences->value("DefaultEllipsesAction") == "search") _list->setToolTip(tr("Search")); else _list->setToolTip(tr("List")); } layoutButtons->addWidget(_list); _info = new QPushButton(tr("?"), this, "_info"); _info->setFocusPolicy(Qt::NoFocus); _info->setToolTip(tr("Open")); _info->setEnabled(false); layoutButtons->addWidget(_info); connect(this, SIGNAL(valid(bool)), _info, SLOT(setEnabled(bool))); _delete = new QPushButton(tr("x"), this, "_delete"); _delete->setFocusPolicy(Qt::NoFocus); _delete->setToolTip(tr("Delete")); layoutButtons->addWidget(_delete); _new = new QPushButton(tr("+"), this, "_new"); _new->setFocusPolicy(Qt::NoFocus); _new->setToolTip(tr("New")); layoutButtons->addWidget(_new); _edit = new QPushButton(tr("!"), this, "_edit"); _edit->setFocusPolicy(Qt::NoFocus); _edit->setCheckable(true); _edit->setToolTip(tr("Edit Mode")); layoutButtons->addWidget(_edit); #ifndef Q_WS_MAC _list->setMaximumWidth(25); _info->setMaximumWidth(25); _new->setMaximumWidth(25); _edit->setMaximumWidth(25); _delete->setMaximumWidth(25); #else _list->setMinimumWidth(60); _list->setMinimumHeight(32); _info->setMinimumWidth(60); _info->setMinimumHeight(32); _new->setMinimumWidth(60); _new->setMinimumHeight(32); _edit->setMinimumWidth(60); _edit->setMinimumHeight(32); _delete->setMinimumWidth(60); _delete->setMinimumHeight(32); layoutNumber->setContentsMargins(2,0,0,0); layoutButtons->setContentsMargins(0,8,0,0); layoutButtons->setSpacing(6); #endif layoutMain->addLayout(layoutButtons); // Make some internal connections connect(_list, SIGNAL(clicked()), _customerNumber, SLOT(sEllipses())); connect(_info, SIGNAL(clicked()), this, SLOT(sInfo())); connect(_customerNumber, SIGNAL(newId(int)), this, SIGNAL(newId(int))); connect(_customerNumber, SIGNAL(custNameChanged(const QString &)), this, SIGNAL(nameChanged(const QString &))); connect(_customerNumber, SIGNAL(custAddr1Changed(const QString &)), this, SIGNAL(address1Changed(const QString &))); connect(_customerNumber, SIGNAL(custAddr2Changed(const QString &)), this, SIGNAL(address2Changed(const QString &))); connect(_customerNumber, SIGNAL(custAddr3Changed(const QString &)), this, SIGNAL(address3Changed(const QString &))); connect(_customerNumber, SIGNAL(custCityChanged(const QString &)), this, SIGNAL(cityChanged(const QString &))); connect(_customerNumber, SIGNAL(custStateChanged(const QString &)), this, SIGNAL(stateChanged(const QString &))); connect(_customerNumber, SIGNAL(custZipCodeChanged(const QString &)), this, SIGNAL(zipCodeChanged(const QString &))); connect(_customerNumber, SIGNAL(custCountryChanged(const QString &)), this, SIGNAL(countryChanged(const QString &))); connect(_customerNumber, SIGNAL(custAddressChanged(const int)), this, SIGNAL(addressChanged(const int))); connect(_customerNumber, SIGNAL(custContactChanged(const int)), this, SIGNAL(contactChanged(const int))); connect(_customerNumber, SIGNAL(valid(bool)), this, SIGNAL(valid(bool))); connect(_customerNumber, SIGNAL(creditStatusChanged(const QString &)), this, SLOT(sHandleCreditStatus(const QString &))); connect(_customerNumber, SIGNAL(textChanged(const QString &)), _customerNumberEdit, SLOT(setText(const QString &))); connect(_customerNumberEdit, SIGNAL(editingFinished()), this, SIGNAL(editingFinished())); connect(_edit, SIGNAL(clicked()), this, SLOT(setMode())); connect(_new, SIGNAL(clicked()), this, SLOT(sNewClicked())); connect(_delete, SIGNAL(clicked()), this, SIGNAL(deleteClicked())); connect(_customerNumber, SIGNAL(newId(int)), this, SLOT(setMode())); if(_x_privileges && (!_x_privileges->check("MaintainCustomerMasters") && !_x_privileges->check("ViewCustomerMasters"))) { _info->setEnabled(false); _delete->setEnabled(false); _edit->setEnabled(false); _new->setEnabled(false); } else { connect(_customerNumber, SIGNAL(valid(bool)), _info, SLOT(setEnabled(bool))); connect(_customerNumber, SIGNAL(requestInfo()), this, SLOT(sInfo())); } if(_x_privileges && (!_x_privileges->check("MaintainCustomerMasters") )) { _delete->setEnabled(false); _edit->setEnabled(false); _new->setEnabled(false); } setFocusProxy(_customerNumber); _mapper = new XDataWidgetMapper(this); _labelVisible = true; _canEdit=true; setCanEdit(false); }
void MatchReplayController::pause() { setMode(Mode::REPLAY_PAUSE); }
void Lcars::begin() { _width = (*_tft).width(); _height = (*_tft).height() / 3 * 2; _width3 = _width / 3; _width32 = _width3 * 2; _geo.setTft(_tft); _geo.setColor(Lcars_Color_GREEN); _geo.setX(0); _geo.setY(_height); _geo.setPin(0); _geo.setWidth(30); _geo.setHeight(30); _bio.setTft(_tft); _bio.setColor(Lcars_Color_GREEN); _bio.setX(60); _bio.setY(_height); _bio.setPin(0); _bio.setWidth(30); _bio.setHeight(30); _met.setTft(_tft); _met.setColor(Lcars_Color_GREEN); _met.setX(30); _met.setY(_height); _met.setPin(0); _met.setWidth(30); _met.setHeight(30); uint16_t chaserX = _width - 20; uint16_t chaserY = (*_tft).height() - 60; _ch1.setTft(_tft); _ch1.setColor(Lcars_Color_RED); _ch1.setX(chaserX); _ch1.setY(chaserY); _ch1.setPin(0); _ch1.setWidth(20); _ch1.setHeight(15); _ch2.setTft(_tft); _ch2.setColor(Lcars_Color_GREEN); _ch2.setX(chaserX); _ch2.setY(chaserY + 15); _ch2.setPin(0); _ch2.setWidth(20); _ch2.setHeight(15); _ch3.setTft(_tft); _ch3.setColor(Lcars_Color_GREEN); _ch3.setX(chaserX); _ch3.setY(chaserY + 30); _ch3.setPin(0); _ch3.setWidth(20); _ch3.setHeight(15); _ch4.setTft(_tft); _ch4.setColor(Lcars_Color_GREEN); _ch4.setX(chaserX); _ch4.setY(chaserY + 45); _ch4.setPin(0); _ch4.setWidth(20); _ch4.setHeight(15); setMode(Lcars_Mode_Medical); }
void MatchReplayController::play() { setMode(Mode::REPLAY_PLAY); }
void LogLineBox::setEvent(int line,RDLogLine::TransType next_type, RDLogLine *logline) { QString cutname; QPalette p; line_logline=logline; line_next_type=next_type; RDCart *cart; RDCut *cut; log_id=logline->id(); log_line=line; line_type=logline->type(); switch(line_logline->transType()) { case RDLogLine::Stop: line_trans_label->setText(tr("STOP")); line_trans_label->setPalette(palette()); break; case RDLogLine::Play: line_trans_label->setText(tr("PLAY")); line_trans_label->setPalette(palette()); break; case RDLogLine::Segue: line_trans_label->setText(tr("SEGUE")); if(logline->hasCustomTransition()) { line_trans_label->setPalette(line_transition_palette); } else { line_trans_label->setPalette(palette()); } break; default: break; } switch(line_type) { case RDLogLine::Cart: line_comment_label->hide(); cart=new RDCart(logline->cartNumber()); cut=new RDCut(logline->cartNumber(),logline->cutNumber()); if(!cart->exists()) { line_cart_label-> setText(QString().sprintf("%06u",logline->cartNumber())); line_description_label->clear(); line_artist_label->clear(); line_cut_label->clear(); line_group_label->clear(); line_outcue_label->clear(); line_length_label->setText("00:00"); line_talktime_label->setText(":00"); line_up_label->setText("0:00:00"); line_down_label->setText("0:00:00"); line_comment_label->clear(); line_title_label->setText(tr("[CART NOT FOUND]")); switch(cart->type()) { case RDCart::Audio: case RDCart::Macro: case RDCart::All: line_icon_label->setPixmap(*line_playout_map); break; } SetColor(QColor(LOGLINEBOX_MISSING_COLOR)); delete cart; delete cut; } else { if(((cart->forcedLength()==0)&&(cart->type()==RDCart::Audio))|| (line_logline->state()==RDLogLine::NoCut)) { line_cart_label-> setText(QString().sprintf("%06u",logline->cartNumber())); line_description_label->setText(cut->description()); line_artist_label->setText(tr("[NO AUDIO AVAILABLE]")); line_cut_label->clear(); line_group_label->clear(); line_outcue_label->clear(); line_length_label->setText("00:00"); line_talktime_label->setText(":00"); line_up_label->setText("0:00:00"); line_down_label->setText("0:00:00"); line_comment_label->clear(); line_icon_label->setPixmap(*line_playout_map); line_title_label->setText(logline->title()); SetColor(QColor(LOGLINEBOX_MISSING_COLOR)); delete cart; delete cut; } else { line_cart_label-> setText(QString().sprintf("%06u",logline->cartNumber())); if(line_logline->evergreen()) { SetColor(QColor(LOGLINEBOX_EVERGREEN_COLOR)); } else { SetColor(QColor(LOGLINEBOX_BACKGROUND_COLOR)); } if(line_logline->source()==RDLogLine::Tracker) { line_icon_label->setPixmap(*line_track_cart_map); } else { switch(cart->type()) { case RDCart::Audio: case RDCart::All: line_icon_label->setPixmap(*line_playout_map); break; case RDCart::Macro: line_icon_label->setPixmap(*line_macro_map); break; } } line_group_label->setText(cart->groupName()); p=line_group_label->palette(); p.setColor(QColorGroup::Foreground,line_logline->groupColor()); line_group_label->setPalette(p); if(line_logline->talkLength()<=0) { line_talktime_label->setText(":00"); } else { line_talktime_label-> setText(RDGetTimeLength(line_logline->talkLength(), false,false)); } line_length_label-> setText(RDGetTimeLength(line_logline->effectiveLength(), false,false)); if(line_logline->timescalingActive()) { line_length_label->setPalette(line_hard_palette); } else { line_length_label->setPalette(line_time_palette); } if((line_logline->source()!=RDLogLine::Tracker)|| line_logline->originUser().isEmpty()|| (!line_logline->originDateTime().isValid())) { line_title_label-> setText(RDResolveNowNext(line_title_template,line_logline)); } else { line_title_label->setText(QString(). sprintf("%s -- %s %s", (const char *)line_logline->title(), (const char *)line_logline->originUser(), (const char *)line_logline->originDateTime(). toString("M/d hh:mm"))); } line_description_label-> setText(RDResolveNowNext(line_description_template,line_logline)); line_artist_label-> setText(RDResolveNowNext(line_artist_template,line_logline)); line_up_label-> setText(RDGetTimeLength(line_logline->playPosition(),true,true)); line_down_label-> setText(RDGetTimeLength(line_logline->effectiveLength()- line_logline->playPosition(),true,true)); line_position_bar->setTotalSteps(line_logline->effectiveLength()); line_position_bar->setProgress(line_logline->playPosition()); if(logline->cutNumber()>=0) { line_cut_label-> setText(QString().sprintf("%03u",logline->cutNumber())); line_outcue_label-> setText(RDResolveNowNext(line_outcue_template,line_logline)); } else { SetColor(QColor(LOGLINEBOX_MISSING_COLOR)); line_cut_label->clear(); line_outcue_label->setText(tr("[NO VALID CUT AVAILABLE]")); } delete cart; delete cut; setMode(line_mode); line_title_label->show(); line_artist_label->show(); } } break; case RDLogLine::Marker: line_icon_label->setPixmap(*line_notemarker_map); SetColor(QColor(LOGLINEBOX_MARKER_COLOR)); line_title_label->hide(); line_description_label->hide(); line_artist_label->hide(); line_cart_label->setText(tr("MARKER")); line_group_label->setText(logline->markerLabel()); line_length_label->setText(":00"); line_transition=logline->transType(); line_comment_label->setText(logline->markerComment()); setMode(line_mode); line_comment_label->show(); break; case RDLogLine::Track: line_icon_label->setPixmap(*line_mic16_map); SetColor(QColor(LOGLINEBOX_MARKER_COLOR)); line_title_label->hide(); line_description_label->hide(); line_artist_label->hide(); line_cart_label->setText(tr("TRACK")); line_group_label->setText(""); line_length_label->setText(":00"); line_transition=logline->transType(); line_comment_label->setText(logline->markerComment()); setMode(line_mode); line_comment_label->show(); break; case RDLogLine::MusicLink: line_icon_label->setPixmap(*line_music_map); SetColor(QColor(LOGLINEBOX_MARKER_COLOR)); line_title_label->hide(); line_description_label->hide(); line_artist_label->hide(); line_cart_label->setText(tr("LINK")); line_group_label->setText(""); line_length_label->setText(":00"); line_transition=logline->transType(); line_comment_label-> setText(logline->linkEventName()+" - "+ logline->linkStartTime().toString("hh:mm:ss")+" / "+ RDGetTimeLength(logline->linkLength())); setMode(line_mode); line_comment_label->show(); break; case RDLogLine::TrafficLink: line_icon_label->setPixmap(*line_traffic_map); SetColor(QColor(LOGLINEBOX_MARKER_COLOR)); line_title_label->hide(); line_description_label->hide(); line_artist_label->hide(); line_cart_label->setText(tr("LINK")); line_group_label->setText(""); line_length_label->setText(":00"); line_transition=logline->transType(); line_comment_label-> setText(logline->linkEventName()+" - "+ logline->linkStartTime().toString("hh:mm:ss")+" / "+ RDGetTimeLength(logline->linkLength())); setMode(line_mode); line_comment_label->show(); break; case RDLogLine::Chain: line_icon_label->setPixmap(*line_chain_map); SetColor(QColor(LOGLINEBOX_CHAIN_COLOR)); line_title_label->setText(logline->markerLabel()); line_description_label->setText(""); line_artist_label->setText(logline->markerComment()); line_cart_label->setText(tr("CHAIN")); line_group_label->setText(""); line_length_label->setText(":00"); line_transition=logline->transType(); line_comment_label->hide(); setMode(line_mode); line_title_label->show(); line_artist_label->show(); break; case RDLogLine::Macro: line_icon_label->setPixmap(*line_macro_map); line_comment_label->hide(); cart=new RDCart(logline->cartNumber()); cut=new RDCut(QString().sprintf("%06u_%03u",logline->cartNumber(), logline->cutNumber())); if(!cart->exists()) { SetColor(QColor(LOGLINEBOX_MISSING_COLOR)); } else { SetColor(QColor(LOGLINEBOX_BACKGROUND_COLOR)); } line_cart_label->setText(QString().sprintf("%06u",cart->number())); line_cut_label->setText(""); line_group_label->setText(cart->groupName()); p=line_group_label->palette(); p.setColor(QColorGroup::Foreground,line_logline->groupColor()); line_group_label->setPalette(p); line_length_label-> setText(RDGetTimeLength(line_logline->effectiveLength(), false,false)); line_title_label-> setText(RDResolveNowNext(line_title_template,line_logline)); line_description_label-> setText(RDResolveNowNext(line_description_template,line_logline)); line_artist_label-> setText(RDResolveNowNext(line_artist_template,line_logline)); line_outcue_label-> setText(RDResolveNowNext(line_outcue_template,line_logline)); delete cart; delete cut; setMode(line_mode); line_title_label->show(); line_artist_label->show(); break; default: break; } PrintTime(); }
void StitcherView::mouseReleaseEvent( QMouseEvent * event){ ImageView::mouseReleaseEvent(event); if(mode == Line && event->button() & Qt::LeftButton){ setMode(Default); QGraphicsLineItem * line = new QGraphicsLineItem(QLineF(mapToScene(lineOrigin),mapToScene(lineEnd))); line->setData(0,QString("Helper")); line->setZValue(11); QPen pen = line->pen(); pen.setColor(Qt::white); pen.setStyle(Qt::SolidLine); line->setPen(pen); graphicsScene->addItem(line); }else if(mode == Circle && event->button() & Qt::LeftButton){ setMode(Default); QPointF lineOriginF = mapToScene(lineOrigin); QPointF lineEndF = mapToScene(lineEnd); QPointF circleCenter = (lineOriginF+lineEndF)/2; qreal circleRadius = sqrt((lineOriginF-lineEndF).x()* (lineOriginF-lineEndF).x()+ (lineOriginF-lineEndF).y()* (lineOriginF-lineEndF).y())/2; if(QApplication::keyboardModifiers() & Qt::ShiftModifier){ circleCenter = mapFromScene(QPointF(0,0)); circleRadius = sqrt((circleCenter-lineEnd).x()* (circleCenter-lineEnd).x()+ (circleCenter-lineEnd).y()* (circleCenter-lineEnd).y()); circleCenter = QPointF(0,0); } QGraphicsEllipseItem * circle = new QGraphicsEllipseItem(QRect(circleCenter.x()-circleRadius,circleCenter.y()-circleRadius,circleRadius*2,circleRadius*2)); circle->setData(0,QString("Helper")); circle->setZValue(11); QPen pen = circle->pen(); pen.setColor(Qt::white); pen.setStyle(Qt::SolidLine); circle->setPen(pen); graphicsScene->addItem(circle); }else if(mode == AddPoint && event->button() & Qt::LeftButton){ QList<QGraphicsItem *> it = items(event->pos()); for(int i = 0; i < it.size(); i++){ if(ImageItem * item = qgraphicsitem_cast<ImageItem *>(it.at(i))){ item->addControlPoint(item->mapFromScene(mapToScene(event->pos()))); } } }else if(mode == DeletePoint && event->button() & Qt::LeftButton){ QList<QGraphicsItem *> it = items(event->pos()); for(int i = 0; i < it.size(); i++){ if(ImageItem * item = qgraphicsitem_cast<ImageItem *>(it.at(i))){ item->deleteControlPoint(item->mapFromScene(mapToScene(event->pos()))); } } }else if(mode == DeleteGuide && event->button() & Qt::LeftButton){ QList<QGraphicsItem *> it = items(event->pos()); QPointF pos = mapToScene(event->pos()); /* 10 px tolerance radius, delete the closest */ for(int i = 0; i < it.size(); i++){ if(QString("Helper") == it[i]->data(0)){ QGraphicsEllipseItem * elipse = qgraphicsitem_cast<QGraphicsEllipseItem *>(it[i]); if(elipse){ // Check if click position close to the line QPointF origin = elipse->rect().center(); qreal radius = elipse->rect().height()/2; QPointF d = origin-pos; if(abs(sqrt(d.x()*d.x()+d.y()*d.y())-radius) < 10){ delete elipse; } } QGraphicsLineItem * line = qgraphicsitem_cast<QGraphicsLineItem *>(it[i]); if(line){ delete line; } } } } }
void QLCDNumber::setOctMode() { setMode(Oct); }
/** Configure a feature for the currently open device. * * @pre feature_set_ initialized * * @param feature desired feature number * @param control [in,out] pointer to control parameter (may change) * @param value [in,out] pointer to requested parameter value (may * change depending on device restrictions) * @param value2 [in,out] optional pointer to second parameter value * for white balance (may change depending on device * restrictions). No second value if NULL pointer. * * The parameter values are represented as double despite the fact * that most features on most cameras only allow unsigned 12-bit * values. The exception is the rare feature that supports * "absolute" values in 32-bit IEEE float format. Double can * represent all possible option values accurately. */ void Features::configure(dc1394feature_t feature, int *control, double *value, double *value2) { // device-relevant information for this feature dc1394feature_info_t *finfo = &feature_set_.feature[feature - DC1394_FEATURE_MIN]; if (!finfo->available) // feature not available? { *control = camera1394::Camera1394_None; return; } switch (*control) { case camera1394::Camera1394_Off: setOff(finfo); break; case camera1394::Camera1394_Query: getValues(finfo, value, value2); break; case camera1394::Camera1394_Auto: if (!setMode(finfo, DC1394_FEATURE_MODE_AUTO)) { setOff(finfo); } break; case camera1394::Camera1394_Manual: if (!setMode(finfo, DC1394_FEATURE_MODE_MANUAL)) { setOff(finfo); break; } // TODO: break this into some internal methods if (finfo->absolute_capable && finfo->abs_control) { // supports reading and setting float value float fmin, fmax; if (DC1394_SUCCESS == dc1394_feature_get_absolute_boundaries(camera_, feature, &fmin, &fmax)) { // clamp *value between minimum and maximum if (*value < fmin) *value = (double) fmin; else if (*value > fmax) *value = (double) fmax; } else { ROS_WARN_STREAM("failed to get feature " << featureName(feature) << " boundaries "); } // @todo handle absolute White Balance values float fval = *value; if (DC1394_SUCCESS != dc1394_feature_set_absolute_value(camera_, feature, fval)) { ROS_WARN_STREAM("failed to set feature " << featureName(feature) << " to " << fval); } } else // no float representation { // round requested value to nearest integer *value = rint(*value); // clamp *value between minimum and maximum if (*value < finfo->min) *value = (double) finfo->min; else if (*value > finfo->max) *value = (double) finfo->max; dc1394error_t rc; uint32_t ival = (uint32_t) *value; // handle White Balance, which has two components if (feature == DC1394_FEATURE_WHITE_BALANCE) { *value2 = rint(*value2); // clamp *value2 between same minimum and maximum if (*value2 < finfo->min) *value2 = (double) finfo->min; else if (*value2 > finfo->max) *value2 = (double) finfo->max; uint32_t ival2 = (uint32_t) *value2; rc = dc1394_feature_whitebalance_set_value(camera_, ival, ival2); } else { // other features only have one component rc = dc1394_feature_set_value(camera_, feature, ival); } if (rc != DC1394_SUCCESS) { ROS_WARN_STREAM("failed to set feature " << featureName(feature) << " to " << ival); } } break; case camera1394::Camera1394_OnePush: // Try to set OnePush mode setMode(finfo, DC1394_FEATURE_MODE_ONE_PUSH_AUTO); // Now turn the control off, so camera does not continue adjusting setOff(finfo); break; case camera1394::Camera1394_None: // Invalid user input, because this feature actually does exist. ROS_INFO_STREAM("feature " << featureName(feature) << " exists, cannot set to None"); break; default: ROS_WARN_STREAM("unknown state (" << *control <<") for feature " << featureName(feature)); } // return actual state reported by the device *control = getState(finfo); ROS_DEBUG_STREAM("feature " << featureName(feature) << " now in state " << *control); }
void QLCDNumber::setBinMode() { setMode(Bin); }
OSG_USING_NAMESPACE /***************************************************************************\ * Description * \***************************************************************************/ /*! \class OSG::Navigator \ingroup GrpSystemWindowNavigators The general Navigator helper class, see \ref PageSystemWindowNavigatorsNavigator for a description. */ /*! \enum OSG::NavigatorBase::Mode The navigation mode, i.e. the actual active low-level navigator. The NONE case is also used for the purpose of matrix consistency. */ /*! \enum OSG::NavigatorBase::State The navigation state, mainly needed for correct interpretation of mouse motions, which have to be interpreted differently for different states. Interpretation also depends on the currently active Navigator::Mode. */ /*! \var Navigator::State Navigator::IDLE Inactive state. */ /*! \var Navigator::State Navigator::ROTATING State for in-place rotation. */ /*! \var Navigator::State Navigator::TRANSLATING_XY State for x/y translation, used by the Trackball case. */ /*! \var Navigator::State Navigator::TRANSLATING_Z State for z translation, used by the Trackball case. */ /*! \var Navigator::State Navigator::TRANSLATING_ZPLUS State for rotation with automatic forward motion. The standard fly forward state. */ /*! \var Navigator::State Navigator::TRANSLATING_ZMINUS State for rotation with automatic backwards motion. The standard fly backwards state. */ /*! \enum OSG::NavigatorBase::MouseButton Abstraction enumeration for mouse buttons, to keep the Navigator independent of the actual Window System. */ /*! \var Navigator::MouseButton Navigator::UP_MOUSE Mouse wheel up button. */ /*! \var Navigator::MouseButton Navigator::DOWN_MOUSE Mouse wheel down button. */ /*! \enum OSG::NavigatorBase::Key Abstraction enumeration for keys, to keep the Navigator independent of the actual Window System. */ /*! \var Navigator::_rMotionFactor The motion factor, roughly equivalent to speed. */ /*------------------------- constructors ----------------------------------*/ Navigator::Navigator() : _engine(NULL), // pointer to current engine _trackballEngine(TrackballEngine::create()), _flyEngine (FlyEngine ::create()), _walkEngine (WalkEngine ::create()), _noneEngine (NoneEngine ::create()), _userEngine (TrackballEngine::create()), _rRotationAngle(0.04908739f), _rMotionFactor(1.f), _absolute(true), _vp(NULL), _cartN(NULL), _moved(false), _clickCenter(true), _clickNoIntersect(false), _lastX(0), _lastY(0) { setMode(TRACKBALL); // use trackball as default }
void CustInfo::setEditMode(bool p) { _edit->setChecked(p); setMode(); }
bool Adafruit_BNO055::init(adafruit_bno055_opmode_t mode) { // BNO055 clock stretches for 500us or more! #ifdef ESP8266 _wire -> setClockStretchLimit(1000); // Allow for 1000us of clock stretching #endif /* Make sure we have the right device */ uint8_t id = read8(BNO055_CHIP_ID_ADDR); if(id != BNO055_ID) { delay(1000); // hold on for boot id = read8(BNO055_CHIP_ID_ADDR); if(id != BNO055_ID) { return false; // still not? ok bail } } /* Switch to config mode (just in case since this is the default) */ setMode(OPERATION_MODE_CONFIG); /* Reset */ write8(BNO055_SYS_TRIGGER_ADDR, 0x20); while (read8(BNO055_CHIP_ID_ADDR) != BNO055_ID) { delay(10); } delay(50); /* Set to normal power mode */ write8(BNO055_PWR_MODE_ADDR, POWER_MODE_NORMAL); delay(10); write8(BNO055_PAGE_ID_ADDR, 0); /* Set the output units */ /* uint8_t unitsel = (0 << 7) | // Orientation = Android (0 << 4) | // Temperature = Celsius (0 << 2) | // Euler = Degrees (1 << 1) | // Gyro = Rads (0 << 0); // Accelerometer = m/s^2 write8(BNO055_UNIT_SEL_ADDR, unitsel); */ /* Configure axis mapping (see section 3.4) */ write8(BNO055_AXIS_MAP_CONFIG_ADDR, REMAP_CONFIG_P3); // P0-P7, Default is P1 delay(10); write8(BNO055_AXIS_MAP_SIGN_ADDR, REMAP_SIGN_P3); // P0-P7, Default is P1 delay(10); write8(BNO055_SYS_TRIGGER_ADDR, 0x0); delay(10); /* Set the requested operating mode (see section 3.3) */ setMode(mode); delay(20); return true; }
void PiperGL11::pushMatrix(Piper::Mode mode) { if (setMode(mode)) glPushMatrix(); }
//////////////////////////////////// // MODE CONTROL // //////////////////////////////////// static void SETMODE(GtkWidget *widget, GTKwrapper *state){ char* MODE = (char*)gtk_combo_box_text_get_active_text((GtkComboBoxText*)state->MOD[0]); setMode(gpibHANDLE, MODE); }
void PiperGL11::multMatrix(const MATRIX &matrix, Mode mode) { if (setMode(mode)) glMultMatrixf(matrix.f); }
eFbLCD::eFbLCD(const char *fb) { m_manual_blit = -1; instance = this; locked = 0; _buffer = 0; m_available = 0; m_cmap.start = 0; m_cmap.len = 256; m_cmap.red = m_red; m_cmap.green = m_green; m_cmap.blue = m_blue; m_cmap.transp = m_trans; m_alpha = 255; m_gamma = 128; m_brightness = 128; lcdfd = open(fb, O_RDWR); if (lcdfd < 0) { eDebug("[eFbLCD] %s: %m", fb); goto nolfb; } if (ioctl(lcdfd, FBIOGET_VSCREENINFO, &m_screeninfo) < 0) { eDebug("[eFbLCD] FBIOGET_VSCREENINFO: %m"); goto nolfb; } fb_fix_screeninfo fix; if (ioctl(lcdfd, FBIOGET_FSCREENINFO, &fix) < 0) { eDebug("[eFbLCD] FBIOGET_FSCREENINFO: %m"); goto nolfb; } m_available = fix.smem_len; m_phys_mem = fix.smem_start; eDebug("[eFbLCD] %s %dk video mem", fb, m_available / 1024); _buffer=(unsigned char*)mmap(0, m_available, PROT_WRITE|PROT_READ, MAP_SHARED, lcdfd, 0); if (!_buffer) { eDebug("[eFbLCD] mmap: %m"); goto nolfb; } lcd_type = 4; calcRamp(); getMode(); setMode(m_xRes, m_yRes, m_bpp); enableManualBlit(); return; nolfb: if (lcdfd >= 0) { ::close(lcdfd); lcdfd = -1; } eDebug("[eFbLCD] framebuffer %s not available", fb); return; }
StatusNotifierItem::StatusNotifierItem(QWidget *parent) : StatusNotifierItemParent(parent) #if QT_VERSION >= 0x050000 , _iconThemeDir{QDir::tempPath() + QLatin1String{"/quassel-sni-XXXXXX"}} #endif { static bool registered = []() -> bool { qDBusRegisterMetaType<DBusImageStruct>(); qDBusRegisterMetaType<DBusImageVector>(); qDBusRegisterMetaType<DBusToolTipStruct>(); return true; }(); Q_UNUSED(registered) setMode(Mode::StatusNotifier); connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(onVisibilityChanged(bool))); connect(this, SIGNAL(modeChanged(Mode)), this, SLOT(onModeChanged(Mode))); connect(this, SIGNAL(stateChanged(State)), this, SLOT(onStateChanged(State))); trayMenu()->installEventFilter(this); // Create a temporary directory that holds copies of the tray icons. That way, visualizers can find our icons. // For Qt4 the relevant icons are installed in hicolor already, so nothing to be done. #if QT_VERSION >= 0x050000 if (_iconThemeDir.isValid()) { _iconThemePath = _iconThemeDir.path(); } else { qWarning() << "Could not create temporary directory for themed tray icons!"; } #endif connect(this, SIGNAL(iconsChanged()), this, SLOT(refreshIcons())); refreshIcons(); // Our own SNI service _statusNotifierItemDBus = new StatusNotifierItemDBus(this); connect(this, SIGNAL(currentIconNameChanged()), _statusNotifierItemDBus, SIGNAL(NewIcon())); connect(this, SIGNAL(currentIconNameChanged()), _statusNotifierItemDBus, SIGNAL(NewAttentionIcon())); connect(this, SIGNAL(toolTipChanged(QString, QString)), _statusNotifierItemDBus, SIGNAL(NewToolTip())); // Service watcher to keep track of the StatusNotifierWatcher service QDBusServiceWatcher *watcher = new QDBusServiceWatcher(kSniWatcherService, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this); connect(watcher, SIGNAL(serviceOwnerChanged(QString, QString, QString)), SLOT(serviceChange(QString, QString, QString))); // Client instance for StatusNotifierWatcher _statusNotifierWatcher = new org::kde::StatusNotifierWatcher(kSniWatcherService, kSniWatcherPath, QDBusConnection::sessionBus(), this); connect(_statusNotifierWatcher, SIGNAL(StatusNotifierHostRegistered()), SLOT(checkForRegisteredHosts())); connect(_statusNotifierWatcher, SIGNAL(StatusNotifierHostUnregistered()), SLOT(checkForRegisteredHosts())); // Client instance for notifications _notificationsClient = new org::freedesktop::Notifications(kXdgNotificationsService, kXdgNotificationsPath, QDBusConnection::sessionBus(), this); connect(_notificationsClient, SIGNAL(NotificationClosed(uint, uint)), SLOT(notificationClosed(uint, uint))); connect(_notificationsClient, SIGNAL(ActionInvoked(uint, QString)), SLOT(notificationInvoked(uint, QString))); if (_notificationsClient->isValid()) { QStringList desktopCapabilities = _notificationsClient->GetCapabilities(); _notificationsClientSupportsMarkup = desktopCapabilities.contains("body-markup"); _notificationsClientSupportsActions = desktopCapabilities.contains("actions"); } #ifdef HAVE_DBUSMENU new QuasselDBusMenuExporter(menuObjectPath(), trayMenu(), _statusNotifierItemDBus->dbusConnection()); // will be added as menu child #endif }
void QLCDNumber::setHexMode() { setMode(Hex); }
bool RFM69::initialize(uint8_t freqBand, uint8_t nodeID, uint8_t networkID) { const uint8_t CONFIG[][2] = { /* 0x01 */ { REG_OPMODE, RF_OPMODE_SEQUENCER_ON | RF_OPMODE_LISTEN_OFF | RF_OPMODE_STANDBY }, /* 0x02 */ { REG_DATAMODUL, RF_DATAMODUL_DATAMODE_PACKET | RF_DATAMODUL_MODULATIONTYPE_FSK | RF_DATAMODUL_MODULATIONSHAPING_00 }, // no shaping /* 0x03 */ { REG_BITRATEMSB, RF_BITRATEMSB_1200}, // default: 4.8 KBPS and changed to 1.2 kbps /* 0x04 */ { REG_BITRATELSB, RF_BITRATELSB_1200}, /* 0x05 */ { REG_FDEVMSB, RF_FDEVMSB_50000}, // default: 5KHz, (FDEV + BitRate / 2 <= 500KHz) /* 0x06 */ { REG_FDEVLSB, RF_FDEVLSB_50000}, /* 0x07 */ { REG_FRFMSB, (uint8_t) (freqBand==RF69_315MHZ ? RF_FRFMSB_315 : (freqBand==RF69_433MHZ ? RF_FRFMSB_433 : (freqBand==RF69_868MHZ ? RF_FRFMSB_868 : RF_FRFMSB_915))) }, /* 0x08 */ { REG_FRFMID, (uint8_t) (freqBand==RF69_315MHZ ? RF_FRFMID_315 : (freqBand==RF69_433MHZ ? RF_FRFMID_433 : (freqBand==RF69_868MHZ ? RF_FRFMID_868 : RF_FRFMID_915))) }, /* 0x09 */ { REG_FRFLSB, (uint8_t) (freqBand==RF69_315MHZ ? RF_FRFLSB_315 : (freqBand==RF69_433MHZ ? RF_FRFLSB_433 : (freqBand==RF69_868MHZ ? RF_FRFLSB_868 : RF_FRFLSB_915))) }, // looks like PA1 and PA2 are not implemented on RFM69W, hence the max output power is 13dBm // +17dBm and +20dBm are possible on RFM69HW // +13dBm formula: Pout = -18 + OutputPower (with PA0 or PA1**) // +17dBm formula: Pout = -14 + OutputPower (with PA1 and PA2)** // +20dBm formula: Pout = -11 + OutputPower (with PA1 and PA2)** and high power PA settings (section 3.3.7 in datasheet) ///* 0x11 */ { REG_PALEVEL, RF_PALEVEL_PA0_ON | RF_PALEVEL_PA1_OFF | RF_PALEVEL_PA2_OFF | RF_PALEVEL_OUTPUTPOWER_11111}, ///* 0x13 */ { REG_OCP, RF_OCP_ON | RF_OCP_TRIM_95 }, // over current protection (default is 95mA) // RXBW defaults are { REG_RXBW, RF_RXBW_DCCFREQ_010 | RF_RXBW_MANT_24 | RF_RXBW_EXP_5} (RxBw: 10.4KHz) /* 0x19 */ { REG_RXBW, RF_RXBW_DCCFREQ_010 | RF_RXBW_MANT_16 | RF_RXBW_EXP_2 }, // (BitRate < 2 * RxBw) //for BR-19200: /* 0x19 */ { REG_RXBW, RF_RXBW_DCCFREQ_010 | RF_RXBW_MANT_24 | RF_RXBW_EXP_3 }, /* 0x25 */ { REG_DIOMAPPING1, RF_DIOMAPPING1_DIO0_01 }, // DIO0 is the only IRQ we're using /* 0x26 */ { REG_DIOMAPPING2, RF_DIOMAPPING2_CLKOUT_OFF }, // DIO5 ClkOut disable for power saving /* 0x28 */ { REG_IRQFLAGS2, RF_IRQFLAGS2_FIFOOVERRUN }, // writing to this bit ensures that the FIFO & status flags are reset /* 0x29 */ { REG_RSSITHRESH, 220 }, // must be set to dBm = (-Sensitivity / 2), default is 0xE4 = 228 so -114dBm ///* 0x2D */ { REG_PREAMBLELSB, RF_PREAMBLESIZE_LSB_VALUE } // default 3 preamble bytes 0xAAAAAA /* 0x2E */ { REG_SYNCCONFIG, RF_SYNC_ON | RF_SYNC_FIFOFILL_AUTO | RF_SYNC_SIZE_2 | RF_SYNC_TOL_0 }, /* 0x2F */ { REG_SYNCVALUE1, 0x2D }, // attempt to make this compatible with sync1 byte of RFM12B lib /* 0x30 */ { REG_SYNCVALUE2, networkID }, // NETWORK ID /* 0x37 */ { REG_PACKETCONFIG1, RF_PACKET1_FORMAT_VARIABLE | RF_PACKET1_DCFREE_OFF | RF_PACKET1_CRC_ON | RF_PACKET1_CRCAUTOCLEAR_ON | RF_PACKET1_ADRSFILTERING_OFF }, /* 0x38 */ { REG_PAYLOADLENGTH, 66 }, // in variable length mode: the max frame size, not used in TX ///* 0x39 */ { REG_NODEADRS, nodeID }, // turned off because we're not using address filtering /* 0x3C */ { REG_FIFOTHRESH, RF_FIFOTHRESH_TXSTART_FIFONOTEMPTY | RF_FIFOTHRESH_VALUE }, // TX on FIFO not empty /* 0x3D */ { REG_PACKETCONFIG2, RF_PACKET2_RXRESTARTDELAY_2BITS | RF_PACKET2_AUTORXRESTART_ON | RF_PACKET2_AES_OFF }, // RXRESTARTDELAY must match transmitter PA ramp-down time (bitrate dependent) //for BR-19200: /* 0x3D */ { REG_PACKETCONFIG2, RF_PACKET2_RXRESTARTDELAY_NONE | RF_PACKET2_AUTORXRESTART_ON | RF_PACKET2_AES_OFF }, // RXRESTARTDELAY must match transmitter PA ramp-down time (bitrate dependent) /* 0x6F */ { REG_TESTDAGC, RF_DAGC_IMPROVED_LOWBETA0 }, // run DAGC continuously in RX mode for Fading Margin Improvement, recommended default for AfcLowBetaOn=0 {255, 0} }; digitalWrite(_slaveSelectPin, HIGH); pinMode(_slaveSelectPin, OUTPUT); SPI.begin(); do writeReg(REG_SYNCVALUE1, 0xAA); while (readReg(REG_SYNCVALUE1) != 0xAA); do writeReg(REG_SYNCVALUE1, 0x55); while (readReg(REG_SYNCVALUE1) != 0x55); for (uint8_t i = 0; CONFIG[i][0] != 255; i++) writeReg(CONFIG[i][0], CONFIG[i][1]); // Encryption is persistent between resets and can trip you up during debugging. // Disable it during initialization so we always start from a known state. encrypt(0); setHighPower(_isRFM69HW); // called regardless if it's a RFM69W or RFM69HW setMode(RF69_MODE_STANDBY); while ((readReg(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00); // wait for ModeReady attachInterrupt(_interruptNum, RFM69::isr0, RISING); selfPointer = this; _address = nodeID; return true; }
/*! \brief Calibrate using the self test operation. Average the values using bias mode to obtain the scale factors. \param gain [in] Gain setting for the sensor. See data sheet. \param n_samples [in] Number of samples to average together while applying the positive and negative bias. \return Returns false if any of the following occurs: # Invalid input parameters. (gain>7 or n_samples=0). # Id registers are wrong for the compiled device. Unfortunately, we can't distinguish between HMC5843 and HMC5883L. # Calibration saturates during the positive or negative bias on any of the readings. # Readings are outside of the expected range for bias current. */ bool HMC58X3::calibrate(unsigned char gain,unsigned int n_samples) { int xyz[3]; // 16 bit integer values for each axis. long int xyz_total[3]={0,0,0}; // 32 bit totals so they won't overflow. bool bret=true; // Function return value. Will return false if the wrong identifier is returned, saturation is detected or response is out of range to self test bias. char id[3]; // Three identification registers should return 'H43'. long int low_limit, high_limit; /* Make sure we are talking to the correct device. Hard to believe Honeywell didn't change the identifier. */ if ((8>gain) && (0<n_samples)) // Notice this allows gain setting of 7 which the data sheet warns against. { getID(id); if (('H' == id[0]) && ('4' == id[1]) && ('3' == id[2])) { /* Use the positive bias current to impose a known field on each axis. This field depends on the device and the axis. */ writeReg(HMC58X3_R_CONFA, 0x010 + HMC_POS_BIAS); // Reg A DOR=0x010 + MS1,MS0 set to pos bias /* Note that the very first measurement after a gain change maintains the same gain as the previous setting. The new gain setting is effective from the second measurement and on. */ setGain(gain); setMode(1); // Change to single measurement mode. getRaw(&xyz[0],&xyz[1],&xyz[2]); // Get the raw values and ignore since this reading may use previous gain. for (unsigned int i=0; i<n_samples; i++) { setMode(1); getRaw(&xyz[0],&xyz[1],&xyz[2]); // Get the raw values in case the scales have already been changed. /* Since the measurements are noisy, they should be averaged rather than taking the max. */ xyz_total[0]+=xyz[0]; xyz_total[1]+=xyz[1]; xyz_total[2]+=xyz[2]; /* Detect saturation. */ if (-(1<<12) >= min(xyz[0],min(xyz[1],xyz[2]))) { DEBUG_PRINT("HMC58x3 Self test saturated. Increase range."); bret=false; break; // Breaks out of the for loop. No sense in continuing if we saturated. } } /* Apply the negative bias. (Same gain) */ writeReg(HMC58X3_R_CONFA, 0x010 + HMC_NEG_BIAS); // Reg A DOR=0x010 + MS1,MS0 set to negative bias. for (unsigned int i=0; i<n_samples; i++) { setMode(1); getRaw(&xyz[0],&xyz[1],&xyz[2]); // Get the raw values in case the scales have already been changed. /* Since the measurements are noisy, they should be averaged. */ xyz_total[0]-=xyz[0]; xyz_total[1]-=xyz[1]; xyz_total[2]-=xyz[2]; /* Detect saturation. */ if (-(1<<12) >= min(xyz[0],min(xyz[1],xyz[2]))) { DEBUG_PRINT("HMC58x3 Self test saturated. Increase range."); bret=false; break; // Breaks out of the for loop. No sense in continuing if we saturated. } } /* Compare the values against the expected self test bias gauss. Notice, the same limits are applied to all axis. */ low_limit =SELF_TEST_LOW_LIMIT *counts_per_milligauss[gain]*2*n_samples; high_limit=SELF_TEST_HIGH_LIMIT*counts_per_milligauss[gain]*2*n_samples; if ((true==bret) && (low_limit <= xyz_total[0]) && (high_limit >= xyz_total[0]) && (low_limit <= xyz_total[1]) && (high_limit >= xyz_total[1]) && (low_limit <= xyz_total[2]) && (high_limit >= xyz_total[2]) ) { /* Successful calibration. Normalize the scale factors so all axis return the same range of values for the bias field. Factor of 2 is from summation of total of n_samples from both positive and negative bias. */ x_scale=(counts_per_milligauss[gain]*(HMC58X3_X_SELF_TEST_GAUSS*2))/(xyz_total[0]/n_samples); y_scale=(counts_per_milligauss[gain]*(HMC58X3_Y_SELF_TEST_GAUSS*2))/(xyz_total[1]/n_samples); z_scale=(counts_per_milligauss[gain]*(HMC58X3_Z_SELF_TEST_GAUSS*2))/(xyz_total[2]/n_samples); }else { DEBUG_PRINT("HMC58x3 Self test out of range."); bret=false; } writeReg(HMC58X3_R_CONFA, 0x010); // set RegA/DOR back to default. }else { #if defined(ISHMC5843) DEBUG_PRINT("HMC5843 failed id check."); #else DEBUG_PRINT("HMC5883L failed id check."); #endif bret=false; } }else { /* Bad input parameters. */ DEBUG_PRINT("HMC58x3 Bad parameters."); bret=false; } return(bret); } // calibrate().