void QSvgTinyDocument::draw(QPainter *p, const QRectF &bounds) { if (m_time.isNull()) { m_time.start(); } if (displayMode() == QSvgNode::NoneMode) return; p->save(); //sets default style on the painter //### not the most optimal way mapSourceToTarget(p, bounds); QPen pen(Qt::NoBrush, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); pen.setMiterLimit(4); p->setPen(pen); p->setBrush(Qt::black); p->setRenderHint(QPainter::Antialiasing); p->setRenderHint(QPainter::SmoothPixmapTransform); QList<QSvgNode*>::iterator itr = m_renderers.begin(); applyStyle(p, m_states); while (itr != m_renderers.end()) { QSvgNode *node = *itr; if ((node->isVisible()) && (node->displayMode() != QSvgNode::NoneMode)) node->draw(p, m_states); ++itr; } revertStyle(p, m_states); p->restore(); }
void QS60WindowSurface::beginPaint(const QRegion &rgn) { #ifdef Q_SYMBIAN_SUPPORTS_SURFACES S60->wsSession().Finish(); #endif QWidgetPrivate *windowPrivate = qt_widget_private(window()); if (!windowPrivate->isOpaque || blitWriteAlpha(windowPrivate)) { QSymbianRasterPixmapData *pixmapData = static_cast<QSymbianRasterPixmapData *>(d_ptr->device.data_ptr().data()); TDisplayMode mode = displayMode(false); if (pixmapData->cfbsBitmap->DisplayMode() != mode) pixmapData->convertToDisplayMode(mode); pixmapData->beginDataAccess(); if (!windowPrivate->isOpaque) { QPainter p(&pixmapData->image); p.setCompositionMode(QPainter::CompositionMode_Source); const QVector<QRect> rects = rgn.rects(); const QColor blank = Qt::transparent; for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) { p.fillRect(*it, blank); } } pixmapData->endDataAccess(); } }
status_t AudioHardwareBase::setMode(int mode) { #if LOG_ROUTING_CALLS LOGD("setMode(%s)", displayMode(mode)); #endif if ((mode < 0) || (mode >= AudioSystem::NUM_MODES)) return BAD_VALUE; if (mMode == mode) return NO_ERROR; #if LOG_ROUTING_CALLS LOGD("doRouting: old mode=%s, new mode=%s route=[%s]", displayMode(mMode), displayMode(mode), displayRoutes(mRoutes[mode])); #endif mMode = mode; return doRouting(); }
bool MoviesMainForm::handleKeyPress(const EventType& event) { if (showTheatres == displayMode_ || showMovies == displayMode_) { ExtendedList& list = (showTheatres==displayMode()?theatresList_:moviesList_); int option = ExtendedList::optionScrollPagesWithLeftRight; if (application().runningOnTreo600()) option = 0; if (list.handleKeyDownEvent(event, option | ExtendedList::optionFireListSelectOnCenter)) return true; if (isAlNum(event.data.keyDown.chr) && 256 > event.data.keyDown.chr) { if (showMovies == displayMode_) { Movie m; m.title.assign(1, event.data.keyDown.chr); int pos = std::lower_bound(movies.begin(), movies.end(), &m, MovieTitleFirstLetterLess()) - movies.begin(); if (pos == movies.size()) --pos; moviesList_.setSelection(pos, ExtendedList::redraw); } else scrollTheatresListToLetter(event.data.keyDown.chr); return true; } } return false; }
void MoviesMainForm::handleControlSelect(const EventType& event) { MoriartyApplication& app=application(); switch (event.data.ctlSelect.controlID) { case theatresButton: if (showTheatres==displayMode()) break; infoRenderer_.clear(); if (NULL != theatres) { setDisplayMode(showTheatres); update(); } break; case moviesButton: if (showMovies==displayMode()) break; infoRenderer_.clear(); if (NULL != theatres) { setDisplayMode(showMovies); update(); } break; case doneBackButton: if (showDetailedInfo == displayMode_ ) { if (showMovies == invisibleDisplayMode_) setDisplayMode(showMovies); else setDisplayMode(showTheatres); update(); } else application().runMainForm(); break; default: assert(false); } }
// generics for audio routing - the real work is done in doRouting status_t AudioHardwareBase::setRouting(int mode, uint32_t routes) { #if LOG_ROUTING_CALLS LOGD("setRouting: mode=%s, routes=[%s]", displayMode(mode), displayRoutes(routes)); #endif if (mode == AudioSystem::MODE_CURRENT) mode = mMode; if ((mode < 0) || (mode >= AudioSystem::NUM_MODES)) return BAD_VALUE; uint32_t old = mRoutes[mode]; mRoutes[mode] = routes; if ((mode != mMode) || (old == routes)) return NO_ERROR; #if LOG_ROUTING_CALLS const char* oldRouteStr = strdup(displayRoutes(old)); LOGD("doRouting: mode=%s, old route=[%s], new route=[%s]", displayMode(mode), oldRouteStr, displayRoutes(routes)); delete oldRouteStr; #endif return doRouting(); }
status_t AudioHardwareBase::setMode(int mode) { #if LOG_ROUTING_CALLS ALOGD("setMode(%s)", displayMode(mode)); #endif if ((mode < 0) || (mode >= AudioSystem::NUM_MODES)) return BAD_VALUE; if (mMode == mode) return ALREADY_EXISTS; mMode = mode; return NO_ERROR; }
status_t AudioHardwareBase::getRouting(int mode, uint32_t* routes) { if (mode == AudioSystem::MODE_CURRENT) mode = mMode; if ((mode < 0) || (mode >= AudioSystem::NUM_MODES)) return BAD_VALUE; *routes = mRoutes[mode]; #if LOG_ROUTING_CALLS LOGD("getRouting: mode=%s, routes=[%s]", displayMode(mode), displayRoutes(*routes)); #endif return NO_ERROR; }
/* main function in embree namespace */ int main( int argc, char** argv) { g_device = new Device(); g_renderer = g_device->rtNewRenderer("pathtracer"); g_renderer->rtSetInt1("maxDepth",10); g_renderer->rtSetInt1("sampler.spp",1); g_renderer->rtCommit(); g_frameBuffer = g_device->rtNewFrameBuffer("RGB_FLOAT32", g_width, g_height); parseCommandLine(new ParseStream(new CommandLineStream(argc,argv)),FileName()); /*! if we did no render yet but have loaded a scene, switch to display mode */ if (!g_rendered && g_scene->size()) displayMode(); return 0; }
// ============================ MEMBER FUNCTIONS =============================== // ----------------------------------------------------------------------------- // CMaskedBitmap::CopyBitmap // ----------------------------------------------------------------------------- TInt BitmapUtil::CopyBitmap( const CFbsBitmap& aSource, CFbsBitmap& aDestination ) { TSize size( aSource.SizeInPixels() ); TDisplayMode displayMode( aSource.DisplayMode() ); TInt err( aDestination.Create( size, displayMode ) ); if( !err ) { err = BitmapUtil::CopyBitmapData( aSource, aDestination, size, displayMode ); if( err ) { aDestination.Reset(); } } return err; }
void MoviesMainForm::handleListItemSelect(UInt16 listId, UInt16 itemId) { switch (displayMode()) { case showTheatres: sendEvent(MoriartyApplication::appSelectTheatreEvent, MoriartyApplication::SelectItemEventData(itemId)); break; case showMovies: sendEvent(MoriartyApplication::appSelectMovieEvent, MoriartyApplication::SelectItemEventData(itemId)); break; default: assert(false); } }
QS60WindowSurface::QS60WindowSurface(QWidget* widget) : QWindowSurface(widget), d_ptr(new QS60WindowSurfacePrivate) { QWidgetPrivate *widgetPrivate = qt_widget_private(widget); const bool opaque = widgetPrivate->isOpaque && !blitWriteAlpha(widgetPrivate); TDisplayMode mode = displayMode(opaque); // We create empty CFbsBitmap here -> it will be resized in setGeometry CFbsBitmap *bitmap = new CFbsBitmap; // CBase derived object needs check on new Q_CHECK_PTR(bitmap); qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) ); QSymbianRasterPixmapData *data = new QSymbianRasterPixmapData(QPixmapData::PixmapType); if (data) { data->fromSymbianBitmap(bitmap, true); d_ptr->device = QPixmap(data); } }
void RelationalCollection::setFilterFromRelationFilters() { // FIXME escape the id field for sql ? if (m_relation_filters.empty()) { if (displayMode() == CollectionDisplay::Filtered) setFilter("false"); else setFilter(""); } else { QString sql_filter_string = ""; QStringList sql_filters; foreach(RelationalObjectRef filter, m_relation_filters) { sql_filters << QString("%1 == %2").arg(getIdField(filter), QVariant(filter.id()).toString()); } foreach(QSqlField filter, m_filters) { sql_filters << QString("%1 == %2").arg(filter.name(), filter.value().toString()); }
static void parseCommandLine(Ref<ParseStream> cin, const FileName& path) { while (true) { std::string tag = cin->getString(); if (tag == "") return; /* parse command line parameters from a file */ if (tag == "-c") { FileName file = path + cin->getFileName(); parseCommandLine(new ParseStream(new LineCommentFilter(file,"#")),file.path()); } /* read model from file */ else if (tag == "-i") *g_scene += load(path+cin->getFileName()); /* triangulated sphere */ else if (tag == "-trisphere") { Ref<Device::RTShape> sphere = g_device->rtNewShape("sphere"); sphere->rtSetFloat3("P",cin->getVec3f()); sphere->rtSetFloat1("r",cin->getFloat()); sphere->rtSetInt1("numTheta",cin->getInt()); sphere->rtSetInt1("numPhi",cin->getInt()); sphere->rtCommit(); Ref<Device::RTMaterial> material = g_device->rtNewMaterial("matte"); material->rtSetFloat3("reflection",Col3f(1.0f,0.0f,0.0f)); material->rtCommit(); *g_scene += new ShapeNode(sphere,material); } /* ambient light source */ else if (tag == "-ambientlight") { Ref<Device::RTLight> light = g_device->rtNewLight("ambientlight"); light->rtSetFloat3("L",cin->getVec3f()); light->rtCommit(); *g_scene += new LightNode(light); } /* point light source */ else if (tag == "-pointlight") { Vec3f P = cin->getVec3f(); Vec3f I = cin->getVec3f(); std::cout << " P " << P.x << " : " << P.y << " : " << P.z << std::endl; std::cout << " I " << I.x << " : " << I.y << " : " << I.z << std::endl; Ref<Device::RTLight> light = g_device->rtNewLight("pointlight"); light->rtSetFloat3("P",P); light->rtSetFloat3("I",I); light->rtCommit(); *g_scene += new LightNode(light); } /* distant light source */ else if (tag == "-distantlight") { Ref<Device::RTLight> light = g_device->rtNewLight("distantlight"); light->rtSetFloat3("D",cin->getVec3f()); light->rtSetFloat3("L",cin->getVec3f()); light->rtSetFloat1("halfAngle",cin->getFloat()); light->rtCommit(); *g_scene += new LightNode(light); } /* triangular light source */ else if (tag == "-trianglelight") { Vec3f P = cin->getVec3f(); Vec3f U = cin->getVec3f(); Vec3f V = cin->getVec3f(); Vec3f L = cin->getVec3f(); Ref<Device::RTLight> light = g_device->rtNewLight("trianglelight"); light->rtSetFloat3("v0",P); light->rtSetFloat3("v1",P+U); light->rtSetFloat3("v2",P+V); light->rtSetFloat3("L" ,L); light->rtCommit(); *g_scene += new LightNode(light); } /* quad light source */ else if (tag == "-quadlight") { Vec3f P = cin->getVec3f(); Vec3f U = cin->getVec3f(); Vec3f V = cin->getVec3f(); Vec3f L = cin->getVec3f(); Ref<Device::RTLight> light0 = g_device->rtNewLight("trianglelight"); light0->rtSetFloat3("v0",P); light0->rtSetFloat3("v1",P+U); light0->rtSetFloat3("v2",P+U+V); light0->rtSetFloat3("L" ,L); light0->rtCommit(); *g_scene += new LightNode(light0); Ref<Device::RTLight> light1 = g_device->rtNewLight("trianglelight"); light1->rtSetFloat3("v0",P+U+V); light1->rtSetFloat3("v1",P+V); light1->rtSetFloat3("v2",P); light1->rtSetFloat3("L" ,L); light1->rtCommit(); *g_scene += new LightNode(light1); } /* HDRI light source */ else if (tag == "-hdrilight") { Ref<Device::RTLight> light = g_device->rtNewLight("hdrilight"); light->rtSetFloat3("L",cin->getVec3f()); light->rtSetImage("image",loadRTImage(path + cin->getFileName())); light->rtCommit(); *g_scene += new LightNode(light); } /* parse camera parameters */ else if (tag == "-vp") g_camPos = Vec3f(cin->getVec3f()); else if (tag == "-vi") g_camLookAt = Vec3f(cin->getVec3f()); else if (tag == "-vd") g_camLookAt = g_camPos+cin->getVec3f(); else if (tag == "-vu") g_camUp = cin->getVec3f(); else if (tag == "-angle") g_camAngle = cin->getFloat(); else if (tag == "-fov") g_camAngle = cin->getFloat(); else if (tag == "-radius") g_camRadius = cin->getFloat(); /* frame buffer size */ else if (tag == "-size") { g_width = cin->getInt(); g_height = cin->getInt(); g_frameBuffer = g_device->rtNewFrameBuffer("RGB_FLOAT32", g_width, g_height); } /* full screen mode */ else if (tag == "-fullscreen") { g_fullscreen = true; } /* refine rendering when not moving */ else if (tag == "-refine") g_refine = true; else if (tag == "-norefine") g_refine = false; /* acceleration structure to use */ else if (tag == "-accel") g_accel = cin->getString(); /* set renderer */ else if (tag == "-renderer") { std::string renderer = cin->getString(); if (renderer == "debug" ) g_renderer = parseDebugRenderer(cin,path); else if (renderer == "pt" ) g_renderer = parsePathTracer(cin,path); else if (renderer == "pathtracer") g_renderer = parsePathTracer(cin,path); else if (renderer == "material" ) g_renderer = parseMaterialRenderer(cin,path); else if (renderer == "opengl" ) g_renderer = parseOpenGLRenderer(cin); else throw std::runtime_error("unknown renderer: "+renderer); } /* set gamma */ else if (tag == "-gamma") { g_renderer->rtSetFloat1("gamma",g_gamma = cin->getFloat()); g_renderer->rtCommit(); } /* set recursion depth */ else if (tag == "-depth") { g_renderer->rtSetInt1("maxDepth",g_depth = cin->getInt()); g_renderer->rtCommit(); } /* set samples per pixel */ else if (tag == "-spp") { g_renderer->rtSetInt1("sampler.spp",g_spp = cin->getInt()); g_renderer->rtCommit(); } /* set the backplate */ else if (tag == "-backplate") { g_renderer->rtSetImage("backplate",g_backplate = loadRTImage(path + cin->getFileName())); g_renderer->rtCommit(); } /* render frame */ else if (tag == "-o") outputMode(path + cin->getFileName()); /* display image */ else if (tag == "-display") displayMode(); /* regression testing */ else if (tag == "-regression") { g_refine = false; g_regression = true; GLUTDisplay(OrthonormalSpace::lookAtPoint(g_camPos,g_camLookAt,g_camUp),0.01f); } else if (tag == "-version") { std::cout << "embree renderer version 1.0" << std::endl; exit(1); } else if (tag == "-h" || tag == "-?" || tag == "-help" || tag == "--help") { std::cout << std::endl; std::cout << "Embree Version 1.0" << std::endl; std::cout << std::endl; std::cout << " usage: embree -i model.obj -renderer debug -display" << std::endl; std::cout << " embree -i model.obj -renderer pathtracer -o out.tga" << std::endl; std::cout << " embree -c model.ecs -display" << std::endl; std::cout << std::endl; std::cout << "-renderer [debug,pathtracer]" << std::endl; std::cout << " Sets the renderer to use." << std::endl; std::cout << std::endl; std::cout << "-c file" << std::endl; std::cout << " Parses command line parameters from file." << std::endl; std::cout << std::endl; std::cout << "-i file" << std::endl; std::cout << " Loads a scene from file." << std::endl; std::cout << std::endl; std::cout << "-o file" << std::endl; std::cout << " Renders and outputs the image to the file." << std::endl; std::cout << std::endl; std::cout << "-display" << std::endl; std::cout << " Interactively displays the rendering into a window." << std::endl; std::cout << std::endl; std::cout << "-vp x y z" << std::endl; std::cout << " Sets camera position to the location (x,y,z)." << std::endl; std::cout << std::endl; std::cout << "-vi x y z" << std::endl; std::cout << " Sets camera lookat point to the location (x,y,z)." << std::endl; std::cout << std::endl; std::cout << "-vd x y z" << std::endl; std::cout << " Sets camera viewing direction to (x,y,z)." << std::endl; std::cout << std::endl; std::cout << "-vu x y z" << std::endl; std::cout << " Sets camera up direction to (x,y,z)." << std::endl; std::cout << std::endl; std::cout << "-fov angle" << std::endl; std::cout << " Sets camera field of view in y direction to angle." << std::endl; std::cout << std::endl; std::cout << "-size width height" << std::endl; std::cout << " Sets the width and height of image to render." << std::endl; std::cout << std::endl; std::cout << "-fullscreen" << std::endl; std::cout << " Enables full screen display mode." << std::endl; std::cout << std::endl; std::cout << "-accel [bvh2,bvh4,bvh4.spatial]" << std::endl; std::cout << " Sets the spatial index structure to use." << std::endl; std::cout << std::endl; std::cout << "-gamma v" << std::endl; std::cout << " Sets gamma correction to v (only pathtracer)." << std::endl; std::cout << std::endl; std::cout << "-depth i" << std::endl; std::cout << " Sets the recursion depth to i (default 16)" << std::endl; std::cout << std::endl; std::cout << "-spp i" << std::endl; std::cout << " Sets the number of samples per pixel to i (default 1) (only pathtracer)." << std::endl; std::cout << std::endl; std::cout << "-backplate" << std::endl; std::cout << " Sets a high resolution back ground image. (default none) (only pathtracer)." << std::endl; std::cout << std::endl; std::cout << "-ambientlight r g b" << std::endl; std::cout << " Creates an ambient light with intensity (r,g,b)." << std::endl; std::cout << std::endl; std::cout << "-pointlight px py pz r g b" << std::endl; std::cout << " Creates a point light with intensity (r,g,b) at position (px,py,pz)." << std::endl; std::cout << std::endl; std::cout << "-distantlight dx dy dz r g b halfAngle" << std::endl; std::cout << " Creates a distant sun light with intensity (r,g,b) shining into " << std::endl; std::cout << " direction (dx,dy,dz) from the cone spanned by halfAngle." << std::endl; std::cout << std::endl; std::cout << "-trianglelight px py pz ux uy uz vx vy vz r g b" << std::endl; std::cout << " Creates a triangle-light with intensity (r,g,b) spanned by the point " << std::endl; std::cout << " (px,py,pz) and the vectors (vx,vy,vz) and (ux,uy,uz)." << std::endl; std::cout << std::endl; std::cout << "-quadlight px py pz ux uy uz vx vy vz r g b" << std::endl; std::cout << " Creates a quad-light with intensity (r,g,b) spanned by the point " << std::endl; std::cout << " (px,py,pz) and the vectors (vx,vy,vz) and (ux,uy,uz)." << std::endl; std::cout << std::endl; std::cout << "-hdrilight r g b file" << std::endl; std::cout << " Creates a high dynamic range environment light from the image " << std::endl; std::cout << " file. The intensities are multiplies by (r,g,b)." << std::endl; std::cout << std::endl; std::cout << "-trisphere px py pz r theta phi" << std::endl; std::cout << " Creates a triangulated sphere with radius r at location (px,py,pz) " << std::endl; std::cout << " and triangulation rates theta and phi." << std::endl; std::cout << std::endl; std::cout << "-[no]refine" << std::endl; std::cout << " Enables (default) or disables the refinement display mode." << std::endl; std::cout << std::endl; std::cout << "-regression" << std::endl; std::cout << " Runs a stress test of the system." << std::endl; std::cout << std::endl; std::cout << "-version" << std::endl; std::cout << " Prints version number." << std::endl; std::cout << std::endl; std::cout << "-h, -?, -help, --help" << std::endl; std::cout << " Prints this help." << std::endl; exit(1); } /* skip unknown command line parameter */ else { std::cerr << "unknown command line parameter: " << tag << " "; while (cin->peek() != "" && cin->peek()[0] != '-') std::cerr << cin->getString() << " "; std::cerr << std::endl; } } }
/// This will create a new window only if the the window has not already /// been created. /// \returns whether a valid window is created bool create(){ return create(dimensions(), title(), fps(), displayMode()); }
void PediaMainForm::search(bool fullText) { const char* text = termInputField_.text(); uint_t textLen; if (0==text || 0==(textLen=StrLen(text))) return; LookupManager* lookupManager=app().getLookupManager(true); if (!lookupManager || lookupManager->lookupInProgress()) return; String term(text, textLen); if (!fullText) { if (!lookupManager->lookupIfDifferent(term, app().preferences().currentLang) && showArticle!=displayMode()) updateAfterLookup(); } else lookupManager->search(term); }
void MapBox::createOptionsDialog() { if (m_optionsWidget) delete m_optionsWidget; m_optionsWidget = new QWidget(this); QGridLayout * optionsLayout = new QGridLayout; QVector<QString> mapTypeNames; QVector<QGraphicsGeoMap::MapType> mapControlTypes; mapControlTypes.append(QGraphicsGeoMap::StreetMap); mapTypeNames.append(tr("Street")); mapControlTypes.append(QGraphicsGeoMap::SatelliteMapDay); mapTypeNames.append(tr("Satellite")); mapControlTypes.append(QGraphicsGeoMap::SatelliteMapNight); mapTypeNames.append(tr("Satellite - Night")); mapControlTypes.append(QGraphicsGeoMap::TerrainMap); mapTypeNames.append(tr("Terrain")); { // map types QSignalMapper * mapper = new QSignalMapper(m_optionsWidget); connect(mapper, SIGNAL(mapped(int)), this, SLOT(mapTypeToggled(int))); QLabel * mapTypesLabel = new QLabel(tr("Map types")); mapTypesLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); mapTypesLabel->setAlignment(Qt::AlignHCenter); optionsLayout->addWidget(mapTypesLabel, 0, 0); QList<QGraphicsGeoMap::MapType> types = m_mapWidget->supportedMapTypes(); for (int controlIndex = 0; controlIndex < mapControlTypes.size(); ++controlIndex) { QPushButton *button = new QPushButton(mapTypeNames[controlIndex], m_optionsWidget); button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QFont font = button->font(); font.setPointSize(24); button->setFont(font); optionsLayout->addWidget(button, controlIndex+1, 0); int supportedTypeIndex = types.indexOf(mapControlTypes[controlIndex]); if (supportedTypeIndex == -1) { button->setEnabled(false); } else { connect(button, SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(button, mapControlTypes[controlIndex]); button->setEnabled(true); //button->setChecked(mapControlTypes[controlIndex] == m_mapWidget->mapType()); } } } { // connectivity modes QVector<QString> connectivityModeNames; QVector<QGraphicsGeoMap::ConnectivityMode> connectivityModes; connectivityModes.append(QGraphicsGeoMap::NoConnectivity); connectivityModeNames.append(tr("No connectivity")); connectivityModes.append(QGraphicsGeoMap::OfflineMode); connectivityModeNames.append(tr("Offline")); connectivityModes.append(QGraphicsGeoMap::OnlineMode); connectivityModeNames.append(tr("Online")); connectivityModes.append(QGraphicsGeoMap::HybridMode); connectivityModeNames.append(tr("Hybrid")); // map types QSignalMapper * mapper = new QSignalMapper(m_optionsWidget); connect(mapper, SIGNAL(mapped(int)), this, SLOT(connectivityModeToggled(int))); QLabel * connectivityModesLabel = new QLabel(tr("Connectivity")); connectivityModesLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); connectivityModesLabel->setAlignment(Qt::AlignHCenter); optionsLayout->addWidget(connectivityModesLabel, 0, 1); QList<QGraphicsGeoMap::ConnectivityMode> modes = m_mapWidget->supportedConnectivityModes(); for (int controlIndex = 0; controlIndex < connectivityModes.size(); ++controlIndex) { QPushButton *button = new QPushButton(connectivityModeNames[controlIndex], m_optionsWidget); button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QFont font = button->font(); font.setPointSize(24); button->setFont(font); optionsLayout->addWidget(button, controlIndex+1, 1); int supportedTypeIndex = modes.indexOf(connectivityModes[controlIndex]); if (supportedTypeIndex == -1) { button->setEnabled(false); } else { connect(button, SIGNAL(clicked()), mapper, SLOT(map())); mapper->setMapping(button, connectivityModes[controlIndex]); button->setEnabled(true); //button->setChecked(connectivityModes[controlIndex] == m_mapWidget->connectivityMode()); } } } /* { // plugins, TODO QList<QString> providers = QGeoServiceProvider::availableServiceProviders(); for (int i = 0; i < providers.count(); ++i) { QAction *providerAction = new QAction(providers[i], this); providerAction->setCheckable(true); providerAction->setChecked(i == 0); m_pluginMenu->addAction(providerAction); } } */ m_optionsWidget->setLayout(optionsLayout); if (displayMode() == DisplayOptions) { setDisplayMode(DisplayNone); setDisplayMode(DisplayOptions); } }
void main() { Time *time; ADCON0 = 0; ADCON1 = 0x06; // All ports are digital I2C1_Init(100000); // initialize I2C PORTB = 0xFF; TRISB = 0; // Comment following line for debugging OPTION_REG = 0x40; // Assign prescaler to TMR0 (1/2) TMR0 = 12; // Timer0 initial value INTCON = 0xA0; // Enable TMRO interrupt ALARM_COLD_TRIS = 0; Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1, 1, "Started!"); PORTC = 0; turnOffFeeder(); loadFeederData(); getCustomAlarm(&minTemp, &maxTemp); displayEdited(2, 1); while(1) { TRISC = TRISC|BUTTONS_MASK; state = PORTC & BUTTONS_MASK; if(state != lastState) { lastState = state; if(state & (1<<BUTTON_PREVIOUS)) { if(mode == MODE_EDIT_FEED1_HH || mode == MODE_EDIT_FEED1_MN) previousEditFeed1(mode, 0, 2, 1); else if(mode == MODE_EDIT_FEED2_HH || mode == MODE_EDIT_FEED2_MN) previousEditFeed1(mode, 1, 2, 1); else if(mode == MODE_EDIT_MIN || mode == MODE_EDIT_MAX) previousEdited(2, 1); else { if(--mode < 0) mode = MODE_COUNT -1; displayMode(2, 1); } } else if(state & (1<<BUTTON_NEXT)) { if(mode == MODE_EDIT_FEED1_HH || mode == MODE_EDIT_FEED1_MN) nextEditFeed1(mode, 0, 2, 1); else if(mode == MODE_EDIT_FEED2_HH || mode == MODE_EDIT_FEED2_MN) nextEditFeed1(mode, 1, 2, 1); else if(mode == MODE_EDIT_MIN || mode == MODE_EDIT_MAX) nextEdited(2, 1); else { if(++mode >= MODE_COUNT) mode = 0; displayMode(2, 1); } } if(state & (1<<BUTTON_OK)) handleOKButton(state); } if (timerCounter >= 20000) handleCounterEvent(); } }
void loop() { // Process AI if (Settings[S_ENABLEADC]){ //temperature=(analogRead(temperaturePin)-102)/2.048; // Does someone use this ATM?? if (!Settings[S_MAINVOLTAGE_VBAT]){ static uint16_t ind = 0; static uint32_t voltageRawArray[8]; voltageRawArray[(ind++)%8] = analogRead(voltagePin); uint16_t voltageRaw = 0; for (uint16_t i=0;i<8;i++) voltageRaw += voltageRawArray[i]; voltage = float(voltageRaw) * Settings[S_DIVIDERRATIO] /1023; } if (!Settings[S_VIDVOLTAGE_VBAT]) { static uint16_t ind = 0; static uint32_t voltageRawArray[8]; voltageRawArray[(ind++)%8] = analogRead(vidvoltagePin); uint16_t voltageRaw = 0; for (uint16_t i=0;i<8;i++) voltageRaw += voltageRawArray[i]; vidvoltage = float(voltageRaw) * Settings[S_VIDDIVIDERRATIO] /1023; } if (!Settings[S_MWRSSI] && !Settings[S_PWMRSSI]) { rssiADC = analogRead(rssiPin)/4; // RSSI Readings, rssiADC=0 to 1023/4 (avoid a number > 255) } if (!Settings[S_MWAMPERAGE]) { int16_t currsensOffSet=(Settings[S_CURRSENSOFFSET_L] | (Settings[S_CURRSENSOFFSET_H] << 8)); // Read OffSetH/L amperageADC = analogRead(amperagePin); if (amperageADC > currsensOffSet) amperageADC=((amperageADC-currsensOffSet)*4.8828)/Settings[S_CURRSENSSENSITIVITY]; // [A] Positive Current flow (512...1023) or Unidir (0...1023) else amperageADC=((currsensOffSet-amperageADC)*4.8828)/Settings[S_CURRSENSSENSITIVITY]; // [A] Negative Current flow (0...512) } } if (Settings[S_MWAMPERAGE]) { amperagesum = MW_ANALOG.pMeterSum; amperage = MW_ANALOG.Amperage /100; } if (Settings[S_MWRSSI]) { rssiADC = MW_ANALOG.Rssi/4; // RSSI from MWii, rssiADC=0 to 1023/4 (avoid a number > 255) } if (Settings[S_PWMRSSI] && !Settings[S_MWRSSI]){ rssiADC = pulseIn(PWMrssiPin, HIGH,15000)/Settings[S_PWMRSSIDIVIDER]; // Reading W/time out (microseconds to wait for pulse to start: 15000=0.015sec) } // Blink Basic Sanity Test Led at 1hz - this stuff introduces strange behavior on my system if(tenthSec>10) digitalWrite(7,HIGH); else digitalWrite(7,LOW); //--------------- Start Timed Service Routines --------------------------------------- uint16_t currentMillis = millis(); if((currentMillis - previous_millis_low) >= lo_speed_cycle) // 10 Hz (Executed every 100ms) { previous_millis_low = currentMillis; tenthSec++; TempBlinkAlarm++; Blink10hz=!Blink10hz; if(!fontMode) blankserialRequest(MSP_ATTITUDE); if(Settings[L_RSSIPOSITIONDSPL]) calculateRssi(); } // End of slow Timed Service Routine (100ms loop) if((currentMillis - previous_millis_high) >= hi_speed_cycle) // 20 Hz (Executed every 50ms) { previous_millis_high = currentMillis; calculateTrip(); // Speed integration on 50msec if (!Settings[S_MWAMPERAGE]) calculateAmperage(); // Amperage and amperagesum integration on 50msec uint8_t MSPcmdsend; if(queuedMSPRequests == 0) queuedMSPRequests = modeMSPRequests; uint32_t req = queuedMSPRequests & -queuedMSPRequests; queuedMSPRequests &= ~req; switch(req) { case REQ_MSP_IDENT: MSPcmdsend = MSP_IDENT; break; case REQ_MSP_STATUS: MSPcmdsend = MSP_STATUS; break; case REQ_MSP_RAW_IMU: MSPcmdsend = MSP_RAW_IMU; break; case REQ_MSP_RC: MSPcmdsend = MSP_RC; break; case REQ_MSP_RAW_GPS: MSPcmdsend = MSP_RAW_GPS; break; case REQ_MSP_COMP_GPS: MSPcmdsend = MSP_COMP_GPS; break; case REQ_MSP_ATTITUDE: MSPcmdsend = MSP_ATTITUDE; break; case REQ_MSP_ALTITUDE: MSPcmdsend = MSP_ALTITUDE; break; case REQ_MSP_ANALOG: MSPcmdsend = MSP_ANALOG; break; case REQ_MSP_RC_TUNING: MSPcmdsend = MSP_RC_TUNING; break; case REQ_MSP_PID: MSPcmdsend = MSP_PID; break; case REQ_MSP_BOX: MSPcmdsend = MSP_BOXIDS; break; case REQ_MSP_FONT: MSPcmdsend = MSP_OSD; break; } if(!fontMode) blankserialRequest(MSPcmdsend); //MAX7456_DrawScreen(); if( allSec < 6 ){ displayIntro(KVTeamVersionPosition); lastCallSign = onTime; } else { if(armed){ previousarmedstatus=1; } if(previousarmedstatus && !armed){ configPage=9; ROW=10; COL=1; configMode=1; setMspRequests(); } if(fontMode) { displayFontScreen(); } else if(configMode) { displayConfigScreen(); } else { displayVoltage(); displayVidVoltage(); displayRSSI(); displayTime(); displaySensor(); displayGPSMode(); displayMode(); //if((temperature<Settings[S_TEMPERATUREMAX])||(BlinkAlarm)) displayTemperature(); displayAmperage(); displaypMeterSum(); displayArmed(); displayCurrentThrottle(); displayautoPilot(); if ( (onTime > (lastCallSign+300)) || (onTime < (lastCallSign+4))) { // Displays 4 sec every 5min (no blink during flight) if ( onTime > (lastCallSign+300))lastCallSign = onTime; displayCallsign(); } if(MW_STATUS.sensorPresent&ACCELEROMETER) displayHorizon(MW_ATT.Angle[0],MW_ATT.Angle[1]); if(MW_STATUS.sensorPresent&MAGNETOMETER) { displayHeadingGraph(); displayHeading(); } if(MW_STATUS.sensorPresent&BAROMETER) { displayAltitude(); displayClimbRate(); } if(MW_STATUS.sensorPresent&GPSSENSOR) if(Settings[S_DISPLAYGPS]){ displayNumberOfSat(); displayDirectionToHome(); displayDistanceToHome(); displayAngleToHome(); displayGPS_speed(); displayGPSPosition(); //displayGPS_altitude(); // Do not remove yet } } } MAX7456_DrawScreen(); } // End of fast Timed Service Routine (50ms loop) //--------------------- End of Timed Service Routine --------------------------------------- if(TempBlinkAlarm >= Settings[S_BLINKINGHZ]) { // selectable alarm blink freq TempBlinkAlarm = 0; BlinkAlarm =!BlinkAlarm; // 10=1Hz, 9=1.1Hz, 8=1.25Hz, 7=1.4Hz, 6=1.6Hz, 5=2Hz, 4=2.5Hz, 3=3.3Hz, 2=5Hz, 1=10Hz } if(tenthSec >= 10) // this execute 1 time a second { onTime++; tenthSec=0; if(!armed) { flyTime=0; } else { flyTime++; flyingTime++; configMode=0; setMspRequests(); } allSec++; if((accCalibrationTimer==1)&&(configMode)) { blankserialRequest(MSP_ACC_CALIBRATION); accCalibrationTimer=0; } if((magCalibrationTimer==1)&&(configMode)) { blankserialRequest(MSP_MAG_CALIBRATION); magCalibrationTimer=0; } if((eepromWriteTimer==1)&&(configMode)) { blankserialRequest(MSP_EEPROM_WRITE); eepromWriteTimer=0; } if(accCalibrationTimer>0) accCalibrationTimer--; if(magCalibrationTimer>0) magCalibrationTimer--; if(eepromWriteTimer>0) eepromWriteTimer--; if((rssiTimer==1)&&(configMode)) { Settings[S_RSSIMIN]=rssiADC; // set MIN RSSI signal received (tx off?) rssiTimer=0; } if(rssiTimer>0) rssiTimer--; } serialMSPreceive(); } // End of main loop