QString WeatherPlugin::replace(const QString &text) { QString res = text; QString sun_set, sun_raise, updated; #if COMPAT_QT_VERSION >= 0x030000 QTime tmp_time; QDateTime dt; int h,m; parseTime(getSun_set(),h,m); tmp_time.setHMS(h,m,0,0); sun_set = tmp_time.toString(Qt::LocalDate); sun_set = sun_set.left(sun_set.length() - 3); parseTime(getSun_raise(),h,m); tmp_time.setHMS(h,m,0,0); sun_raise = tmp_time.toString(Qt::LocalDate); sun_raise = sun_raise.left(sun_raise.length() - 3); parseDateTime(getUpdated(),dt); updated = dt.toString(Qt::LocalDate); updated = updated.left(updated.length() - 3); #else sun_set = getSun_set(); sun_raise = getSun_raise(); updated = getUpdated(); #endif /* double Expressions *before* single or better RegExp ! */ res = res.replace(QRegExp("\\%mp"), i18n("moonphase", getMoonPhase())); res = res.replace(QRegExp("\\%mi"), number(getMoonIcon())); res = res.replace(QRegExp("\\%pp"), number(getPrecipitation())); res = res.replace(QRegExp("\\%ut"), i18n("weather", getUV_Description())); res = res.replace(QRegExp("\\%ui"), number(getUV_Intensity())); res = res.replace(QRegExp("\\%t"), QString::number((int)getTemperature()) + QChar((unsigned short)176) + getUT()); res = res.replace(QRegExp("\\%f"), QString::number((int)getFeelsLike()) + QChar((unsigned short)176) + getUT()); res = res.replace(QRegExp("\\%d"), QString::number((int)getDewPoint()) + QChar((unsigned short)176) + getUT()); res = res.replace(QRegExp("\\%h"), number(getHumidity()) + "%"); res = res.replace(QRegExp("\\%w"), number(getWind_speed()) + " " + i18n(getUS())); res = res.replace(QRegExp("\\%x"), QString::number(getWind_speed() * 10 / 36) + " " + i18n("m/s")); res = res.replace(QRegExp("\\%g"), getWindGust() ? QString("(") + i18n("gust ") + number(getWindGust()) + i18n(getUS()) + QString(")") : QString("")); res = res.replace(QRegExp("\\%y"), getWindGust() ? QString("(") + i18n("gust ") + number(getWindGust() * 10 / 36) + QString(" ") + i18n("m/s") + QString(")") : QString("")); res = res.replace(QRegExp("\\%p"), number(getPressure()) + " " + i18n(getUP())); res = res.replace(QRegExp("\\%a"), number(getPressure() * 75 / 100)); res = res.replace(QRegExp("\\%q"), i18n("weather", getPressureD())); res = res.replace(QRegExp("\\%l"), getLocation()); res = res.replace(QRegExp("\\%b"), i18n("weather", getWind())); res = res.replace(QRegExp("\\%u"), updated); res = res.replace(QRegExp("\\%r"), sun_raise); res = res.replace(QRegExp("\\%s"), sun_set); res = res.replace(QRegExp("\\%c"), i18n_conditions(getConditions())); res = res.replace(QRegExp("\\%v"), i18n("weather", getVisibility()) + (atol(getVisibility()) ? QString(" ") + i18n(getUD()) : QString(""))); res = res.replace(QRegExp("\\%i"), number(getIcon())); return res; }
void BezierCurve::addPoint(int position, const QPointF point) { if ( position > -1 && position < getVertexSize() ) { QPointF v1 = getVertex(position-1); QPointF v2 = getVertex(position); QPointF c1o = getC1(position); QPointF c2o = getC2(position); c1[position] = point + 0.2*(v2-v1); c2[position] = v2 + (c2o-v2)*(0.5); c1.insert(position, v1 + (c1o-v1)*(0.5) ); c2.insert(position, point - 0.2*(v2-v1)); vertex.insert(position, point); pressure.insert(position, getPressure(position)); selected.insert(position, isSelected(position) && isSelected(position-1)); //smoothCurve(); } else { qDebug() << "Error BezierCurve::addPoint(int, QPointF)"; } }
// Mean sampling interpolation operation QList<QPointF> StrokeManager::meanInpolOp(QList<QPointF> points, qreal x, qreal y, qreal pressure) { for (int i = 0; i < strokeQueue.size(); i++) { x += strokeQueue[i].x(); y += strokeQueue[i].y(); pressure += getPressure(); } // get arichmic mean of x, y and pressure x /= strokeQueue.size(); y /= strokeQueue.size(); pressure /= strokeQueue.size(); // Use our interpolated points QPointF mNewInterpolated = mLastInterpolated; mNewInterpolated = QPointF(x,y); //save our new pressure value setPressure(pressure); points << mLastPixel << mLastInterpolated << mNewInterpolated << mCurrentPixel; // Set lastPixel non interpolated pixel to our // new interpolated pixel mLastPixel = mNewInterpolated; return points; }
void BezierCurve::addPoint(int position, const qreal t) // t is the fraction where to split the bezier curve (ex: t=0.5) { // de Casteljau's method is used // http://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm // http://www.damtp.cam.ac.uk/user/na/PartIII/cagd2002/halve.ps if ( position > -1 && position < getVertexSize() ) { QPointF vA = getVertex(position-1); QPointF vB = getVertex(position); QPointF c1o = getC1(position); QPointF c2o = getC2(position); QPointF c12 = (1-t)*c1o + t*c2o; QPointF cA1 = (1-t)*vA + t*c1o; QPointF cB2 = (1-t)*c2o + t*vB; QPointF cA2 = (1-t)*cA1 + t*c12; QPointF cB1 = (1-t)*c12 + t*cB2; QPointF vM = (1-t)*cA2 + t*cB1; setC1(position, cB1); setC2(position, cB2); c1.insert(position, cA1); c2.insert(position, cA2); vertex.insert(position, vM); pressure.insert(position, getPressure(position)); selected.insert(position, isSelected(position) && isSelected(position-1)); //smoothCurve(); } else { qDebug() << "Error BezierCurve::addPoint(int, qreal)"; } }
mir::EventUPtr mia::Lexicon::translate(droidinput::InputEvent const* android_event) { switch(android_event->getType()) { case AINPUT_EVENT_TYPE_KEY: { auto kev = static_cast<const droidinput::KeyEvent*>(android_event); return mev::make_event(MirInputDeviceId(android_event->getDeviceId()), kev->getEventTime(), kev->getMac(), mia::mir_keyboard_action_from_android(kev->getAction(), kev->getRepeatCount()), kev->getKeyCode(), kev->getScanCode(), mia::mir_modifiers_from_android(kev->getMetaState())); } case AINPUT_EVENT_TYPE_MOTION: { if (mia::android_source_id_is_pointer_device(android_event->getSource())) { auto mev = static_cast<const droidinput::MotionEvent*>(android_event); return mev::make_event(MirInputDeviceId(android_event->getDeviceId()), mev->getEventTime(), mev->getMac(), mia::mir_modifiers_from_android(mev->getMetaState()), mia::mir_pointer_action_from_masked_android(mev->getAction() & AMOTION_EVENT_ACTION_MASK), mia::mir_pointer_buttons_from_android(mev->getButtonState()), mev->getX(0), mev->getY(0), mev->getRawAxisValue(AMOTION_EVENT_AXIS_HSCROLL, 0), mev->getRawAxisValue(AMOTION_EVENT_AXIS_VSCROLL, 0), mev->getRawAxisValue(AMOTION_EVENT_AXIS_RX, 0), mev->getRawAxisValue(AMOTION_EVENT_AXIS_RY, 0)); } else { auto mev = static_cast<const droidinput::MotionEvent*>(android_event); auto ev = mev::make_event(MirInputDeviceId(android_event->getDeviceId()), mev->getEventTime(), mev->getMac(), mia::mir_modifiers_from_android(mev->getMetaState())); auto action = mev->getAction(); size_t index_with_action = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; auto masked_action = action & AMOTION_EVENT_ACTION_MASK; for (unsigned i = 0; i < mev->getPointerCount(); i++) { auto action = (i == index_with_action) ? mia::mir_touch_action_from_masked_android(masked_action) : mir_touch_action_change; mev::add_touch(*ev, mev->getPointerId(i), action, mia::mir_tool_type_from_android(mev->getToolType(i)), mev->getX(i), mev->getY(i), mev->getPressure(i), mev->getTouchMajor(i), mev->getTouchMinor(i), mev->getSize(i)); } return ev; } } default: BOOST_THROW_EXCEPTION(std::logic_error("Invalid android event")); } }
float Barometer::getAltitudeAboveGround() { float pressure = getPressure(); if(pressure == NO_DATA) { return NO_DATA; } return getPressureAltitude(SENSORS_PRESSURE_SEALEVELHPA, pressure, thermometer.getTemperature()) - groundLevel; }
float Barometer::getAltitudeAboveSeaLevel() { float pressure = getPressure(); if(pressure == NO_DATA) { return NO_DATA; } return getPressureAltitude(pressureSetting * MERCURY_TO_HPA_CONVERSION, pressure, thermometer.getTemperature()); }
void ForecastDisplay::notify() { auto weather_data = weather_data_.lock(); if (weather_data) { last_pressure_ = current_pressure_; current_pressure_ = weather_data->getPressure(); display(); } }
void FlowField::getPressureAndVelocity(FLOAT &pressure, FLOAT* const velocity, int i, int j){ FLOAT * v_here = getVelocity().getVector(i, j); FLOAT * v_left = getVelocity().getVector(i-1, j); FLOAT * v_down = getVelocity().getVector(i, j-1); velocity[0] = ( v_here[0] + v_left[0] ) / 2; velocity[1] = ( v_here[1] + v_down[1] ) / 2; pressure = getPressure().getScalar(i,j); }
/*Only use this method after calling the gettemperature method max 1 second ago*/ long getCurrentPressure() { long temp = 0; CoEnterMutexSection(I2CMutex); temp = getPressure(); CoLeaveMutexSection(I2CMutex); CoEnterMutexSection(currentPressureMutex); currentPressure = temp; CoLeaveMutexSection(currentPressureMutex); return temp; }
void LogEntry::print() { Serial.print("P: "); Serial.print(getPressure()); Serial.print(" T: "); Serial.print(getTemperature()); Serial.print(" B: "); Serial.print(getBattery()); Serial.print(" S: "); Serial.println(getServo(), DEC); }
QString WeatherPlugin::replace(const QString &text) { QString res = text; res = res.replace(QRegExp("\\%t"), number(getTemperature()) + QChar((unsigned short)176) + getUT()); res = res.replace(QRegExp("\\%f"), number(getFeelsLike()) + QChar((unsigned short)176) + getUT()); res = res.replace(QRegExp("\\%d"), number(getDewPoint()) + QChar((unsigned short)176) + getUT()); res = res.replace(QRegExp("\\%h"), number(getHumidity()) + "%"); res = res.replace(QRegExp("\\%w"), number(getWind_speed()) + " " + getUS()); res = res.replace(QRegExp("\\%g"), getWindGust() ? QString("<") + i18n("gust ") + number(getWindGust()) + ")" : ""); res = res.replace(QRegExp("\\%p"), number(getPressure()) + " " + getUP() + " (" + i18n("weather", getPressureD()) + ")"); res = res.replace(QRegExp("\\%a"), number(getPressure() * 75 / 100)); res = res.replace(QRegExp("\\%l"), getLocation()); res = res.replace(QRegExp("\\%b"), getWind()); res = res.replace(QRegExp("\\%u"), getUpdated()); res = res.replace(QRegExp("\\%r"), getSun_raise()); res = res.replace(QRegExp("\\%s"), getSun_set()); res = res.replace(QRegExp("\\%c"), i18n_conditions(getConditions())); res = res.replace(QRegExp("\\%v"), i18n("weather", getVisibility())); return res; }
QList<QPointF> StrokeManager::noInpolOp(QList<QPointF> points) { setPressure(getPressure()); points << mLastPixel << mLastPixel << mCurrentPixel << mCurrentPixel; // Set lastPixel non CurrentPixel // new interpolated pixel mLastPixel = mCurrentPixel; return points; }
QString WeatherPlugin::replace(const QString &text) { QString res = text; res = res.replace(QRegExp("\\%t"), number(getTemperature()) + QChar((unsigned short)176) + getUT()); res = res.replace(QRegExp("\\%h"), number(getHumidity()) + "%"); res = res.replace(QRegExp("\\%w"), number(getWind_speed()) + " " + getUS()); res = res.replace(QRegExp("\\%i"), number(getPressure()) + " " + getUP()); res = res.replace(QRegExp("\\%l"), getLocation()); res = res.replace(QRegExp("\\%r"), getWind()); res = res.replace(QRegExp("\\%u"), getUpdated()); res = res.replace(QRegExp("\\%p"), getSun_raise()); res = res.replace(QRegExp("\\%q"), getSun_set()); res = res.replace(QRegExp("\\%c"), i18n("weather", getConditions())); return res; }
JNIEXPORT void JNICALL Java_com_myprogressbar_MainActivity_startp (JNIEnv * env, jobject obj) { flag = 1; while(flag) { //获取锅炉压力 int pressure = getPressure(); //jclass (*FindClass)(JNIEnv*, const char*); jclass clazz = (*env)->FindClass(env, "com/myprogressbar/MainActivity"); //jmethodID (*GetMethodID)(JNIEnv*, jclass, const char*, const char*); jmethodID methodId = (*env)->GetMethodID(env, clazz, "setMyProgressBarData", "(I)V"); //void (*CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...); (*env)->CallVoidMethod(env, obj, methodId, pressure); sleep(1); } }
/* * Class: com_xiaozhe_showpressure_MainActivity * Method: startMonitor * Signature: ()V */ JNIEXPORT void JNICALL Java_com_xiaozhe_showpressure_MainActivity_startMonitor (JNIEnv *env, jobject obj){ monitor=1; while(monitor){ //获取压力值 int prossure = getPressure(); //调用java显示的方法 //jclass (*FindClass)(JNIEnv*, const char*); jclass clazz = (*env)->FindClass(env ,"com/xiaozhe/showpressure/MainActivity"); // jmethodID (*GetMethodID)(JNIEnv*, jclass, const char*, const char*); jmethodID methodID = (*env)->GetMethodID(env, clazz, "showProgress","(I)V"); //void (*CallVoidMethod)(JNIEnv*, jobject, jmethodID, ...); (*env)->CallVoidMethod(env, obj,methodID,prossure); //刷新周期 sleep(1); } }
void elFlowPort::updateValues() { // checkInTimeCount(); if( _emitFlow ) { getFlow(); } if( _emitPressure ) { getPressure(); } if( _emitTemperature ) { getTemperature(); } // updateNumInTimeValues(); if( _setValueType != setValueType::setTypeNone && _autoAdjust ) { // adjustValues(); } }
// used when lim=PARAFLAT void parapl(int realisinterp, int dir, FTYPE **yrealpl, FTYPE **ypl, FTYPE *loutpl, FTYPE *routpl) { FTYPE dq0[NPR2INTERP][8]; FTYPE *dq[NPR2INTERP]; FTYPE *y,*yreal; void parasteep(int dir, int pl, FTYPE *V, FTYPE *P, FTYPE *y, FTYPE *dq, FTYPE *l, FTYPE *r); void paraflatten(int dir, int pl, FTYPE *y, FTYPE Fi, FTYPE *l, FTYPE *r); void getPressure(FTYPE **yrealpl, FTYPE *P); FTYPE a_P[10]; FTYPE *V,*P; FTYPE Ficalc(int dir, FTYPE *V, FTYPE *P, FTYPE **ypl); int pl; FTYPE Fi; int dqrange; FTYPE a_ddq[7]; FTYPE *ddq; int mm; // consistent with PARAFLAT using 7 points dqrange = 5; // dq's will exist from -2,-1,0,1,2 and ddq computed from -2,-1,0,1 // shift P P=a_P + 4; // P accessed from -3..3 ( shifted sufficiently) // shift dq PLOOPINTERP(pl){ dq[pl]=dq0[pl]+4; // shifted sufficiently } ddq=a_ddq+3; // shifted sufficiently // assume velocity is istelf V = yrealpl[U1+dir-1]; // get pressures for all points since needed for reduction or steepening #if( DOPPMREDUCE || DOPPMCONTACTSTEEP) getPressure(yrealpl, P); #endif // computed only once for all variables #if( DOPPMREDUCE ) Fi = Ficalc(dir,V,P,ypl); #else Fi = 0.0; #endif /////////////// // // Loop over variables and get interpolated left/right values within cell // ////////////// PLOOPINTERP(pl){ y=ypl[pl]; yreal=yrealpl[pl]; // get continuous solution para4gen(dqrange,pl,y,&loutpl[pl],&routpl[pl],dq[pl]); #if(DOPPMCONTACTSTEEP) parasteep(dir,pl,V,P,ypl[pl],dq[pl],&loutpl[pl],&routpl[pl]); #endif #if( DOPPMREDUCE ) paraflatten(dir,pl,ypl[pl],Fi,&loutpl[pl],&routpl[pl]); #endif // finally check monotonicity of the parabola and create discontinuities if non-monotonic // FLASH equations 51 -> 53 for points or averages for(mm=-dqrange/2+1;mm<=dqrange/2;mm++){ ddq[mm] = dq[pl][mm] - dq[pl][mm-1]; } checkparamonotonicity(dqrange, pl, ypl[pl], ddq, dq[pl], &loutpl[pl], &routpl[pl], &loutpl[pl], &routpl[pl]); #if(NONMONOLIM>0 && DOPPMREDUCE) // then flatten again paraflatten(dir,pl,ypl[pl],Fi,&loutpl[pl],&routpl[pl]); #endif } }
/** * Return latest calculated pressure value in Pascals. See * IPressureSensor. * * @return The current pressure in Pascals. */ int getPressurePa() { update(); return getPressure(); }
JNIEXPORT jint JNICALL Java_com_czt_ndk_monitor_DemoActivity_getCurrentPressure (JNIEnv * env, jobject obj){ return getPressure(); }
float Barometer::getAltitude(float baselinePressure) { float pressure = getPressure(); float altitude = 44330 * (1.0 - pow(pressure / baselinePressure, 1 / 5.255)); return altitude; }
/** * Return latest calculated pressure value in Pascals * See IPressureSensor */ int getPressurePa() { return getPressure(); };
float Barometer::getSealevelPressure(float altitude) { float pressure = getPressure(); return pressure / pow(1.0 - altitude / 44330, 5.255); }
uint_least8_t ADS7846::doCalibration(MI0283QT9 *lcd, uint16_t eeprom_addr, uint_least8_t check_eeprom) //touch panel calibration routine { uint_least8_t i; CAL_POINT lcd_points[3] = {CAL_POINT1, CAL_POINT2, CAL_POINT3}; //calibration point postions CAL_POINT tp_points[3]; //calibration data in EEPROM? if(readCalibration(eeprom_addr) && check_eeprom) { return 0; } //clear screen and wait for touch release lcd->fillScreen(RGB(255,255,255)); #if defined(__AVR__) lcd->drawTextPGM((lcd->getWidth()/2)-50, (lcd->getHeight()/2)-10, PSTR("Calibration"), RGB(0,0,0), RGB(255,255,255), 1); #else lcd->drawText((lcd->getWidth()/2)-50, (lcd->getHeight()/2)-10, "Calibration", RGB(0,0,0), RGB(255,255,255), 1); #endif while(getPressure() > MIN_PRESSURE){ service(); }; //show calibration points for(i=0; i<3; ) { //draw points lcd->drawCircle(lcd_points[i].x, lcd_points[i].y, 2, RGB( 0, 0, 0)); lcd->drawCircle(lcd_points[i].x, lcd_points[i].y, 5, RGB( 0, 0, 0)); lcd->drawCircle(lcd_points[i].x, lcd_points[i].y, 10, RGB(255, 0, 0)); //run service routine service(); //press dectected? -> save point if(getPressure() > MIN_PRESSURE) { lcd->fillCircle(lcd_points[i].x, lcd_points[i].y, 2, RGB(255,0,0)); tp_points[i].x = getXraw(); tp_points[i].y = getYraw(); i++; //wait and redraw screen delay(100); lcd->fillScreen(RGB(255,255,255)); #if defined(__AVR__) lcd->drawTextPGM((lcd->getWidth()/2)-50, (lcd->getHeight()/2)-10, PSTR("Calibration"), RGB(0,0,0), RGB(255,255,255), 1); #else lcd->drawText((lcd->getWidth()/2)-50, (lcd->getHeight()/2)-10, "Calibration", RGB(0,0,0), RGB(255,255,255), 1); #endif } } //calulate calibration matrix setCalibration(lcd_points, tp_points); //save calibration matrix writeCalibration(eeprom_addr); //wait for touch release while(getPressure() > MIN_PRESSURE){ service(); }; return 1; }
double TSoundTrack::getPressure(double second, TSound::Channel chan) const { return getPressure(secondsToSamples(second), chan); }
void Barometer::setGroundLevel() { groundLevel = getPressureAltitude(SENSORS_PRESSURE_SEALEVELHPA, getPressure(), thermometer.getTemperature()); }