GPIOServoFunction::GPIOServoFunction() : GPIOFunction(), _portA(0), _portB(0), _CurrentEmotion(GPIOServoFunctionEmotionNone), _CurrentDegree(0), _FutureDegree(0), _CurrentCalibrationSets{0}, VoltageSpeed(0) { // TODO Auto-generated constructor stub _CurrentCalibrationSets[GPIOServoFunctionServoLeft] = new GPIOServoFunctionCalibrationData(GPIOServoFunctionServoLeft); _CurrentCalibrationSets[GPIOServoFunctionServoRight] = new GPIOServoFunctionCalibrationData(GPIOServoFunctionServoRight); _FutureDegree = new GPIOServoFunctionContainer(); _CurrentDegree = new GPIOServoFunctionContainer(); RegisterEventFunc(this, &GPIOServoFunction::ReceiveServoEvent); RegisterEventFunc(this, &GPIOServoFunction::ReceiveServoEmotionEvent); // Servo Speed Function float VoltageSpeedReferences[2][2] = {{6.0, 0.08}, {4.8, 0.1}}; /* formula * y2 -y1 * m = ------- * (x - x1) + y1 * x2 - x1 */ float m = (VoltageSpeedReferences[1][1] - VoltageSpeedReferences[0][1]) / (VoltageSpeedReferences[0][0] - VoltageSpeedReferences[1][0]); VoltageSpeed = (fabs(SERVO_VOLTAGE - VoltageSpeedReferences[0][0]) * m) + VoltageSpeedReferences[0][1]; // --------------- }
void NumericUpDown::InitializeButtons() { //mDown = (Button*)AddChild(0.0, 0.0, 0.33333f, 1.0f, ComponentType::Button); assert(mDown.expired()); auto down = std::static_pointer_cast<Button>(AddChild(ComponentType::Button)); mDown = down; down->SetName("down"); down->SetRuntimeChild(true); //mUp = (Button*)AddChild(1.0, 0.0, 0.33333f, 1.0f, ComponentType::Button); auto up = std::static_pointer_cast<Button>(AddChild(ComponentType::Button)); mUp = up; up->SetName("up"); up->SetRuntimeChild(true); down->ChangeSize(Vec2I(20, 20)); down->ChangeNPos(Vec2(0, 0)); down->SetUseAbsPos(false); down->SetProperty(UIProperty::REGION, "DownTriangle"); down->SetProperty(UIProperty::IMAGE_COLOR_OVERLAY, "1, 1, 0, 1"); down->SetProperty(UIProperty::NO_BACKGROUND, "true"); down->RegisterEventFunc(UIEvents::EVENT_MOUSE_LEFT_CLICK, std::bind(&NumericUpDown::OnDown, this, std::placeholders::_1)); down->SetEnable(mValue > mMin && mEnable); up->ChangeSize(Vec2I(20, 20)); up->ChangeNPos(Vec2(1, 0)); up->SetUseAbsPos(false); up->SetProperty(UIProperty::REGION, "UpTriangle"); up->SetProperty(UIProperty::IMAGE_COLOR_OVERLAY, "1, 1, 0, 1"); up->SetProperty(UIProperty::ALIGNH, "right"); up->SetProperty(UIProperty::NO_BACKGROUND, "true"); up->RegisterEventFunc(UIEvents::EVENT_MOUSE_LEFT_CLICK, std::bind(&NumericUpDown::OnUp, this, std::placeholders::_1)); up->SetEnable(mValue < mMax && mEnable); SetProperty(UIProperty::TEXT_ALIGN, "center"); WCHAR buffer[100]; swprintf_s(buffer, L"%d", mValue); SetText(buffer); if (up && down){ mValue = std::min(mValue, mMax); mValue = std::max(mValue, mMin); SetNumber(mValue); } }
TextField::TextField() : WinBase() , mPasswd(false) , mCursorOffset(0) { mUIObject = UIObject::Create(GetRenderTargetSize()); mUIObject->SetMaterial("EssentialEngineData/materials/UITextField.material"); mUIObject->mOwnerUI = this; mUIObject->mTypeString = ComponentType::ConvertToString(GetType()); mUIObject->SetTextSize(mTextSize); mUIObject->SetTextColor(mTextColor); RegisterEventFunc(UIEvents::EVENT_MOUSE_LEFT_CLICK, std::bind(&TextField::OnClicked, this, std::placeholders::_1)); RegisterEventFunc(UIEvents::EVENT_MOUSE_LEFT_DOUBLE_CLICK, std::bind(&TextField::OnDoubleClicked, this, std::placeholders::_1)); }
bool SIPController::InitializeSIP (ApplicationSettings &Settings) { if (_SIP_EndPoint == 0) { if (_SIP_Status == SIPStatusNone || _SIP_Status == SIPStatusStop) { _SIP_Status = SIPStatusStarting; SendEvent(new SIPEvent(SIPStatusStarting)); _EndPoint_Config = Settings._SIP_Config_Endpoint; _Transport_Config = Settings._SIP_Config_Transport; _Account_Config = Settings._SIP_Config_Account; _CurrentCodecType = (SIPCodecType)Settings._SIP_Config_Codec_Type; _Ringtone = (bool)Settings._SIP_Config_Ringtone; _RingtoneFilename = Settings._SIP_Config_Ringtone_File; if (InitCPlusPlus() == false) { _SIP_Status = SIPStatusNone; SendEvent(new SIPEvent(SIPStatusError)); return false; } const CodecInfoVector &Codecs = _SIP_EndPoint->codecEnum(); CodecInfoVector::const_iterator it = Codecs.begin(); if (_CurrentCodecType != SIPCodecTypeNone) { while (it != Codecs.end()) { if ((*it)->codecId == _Codecs[_CurrentCodecType]) { _SIP_EndPoint->codecSetPriority((*it)->codecId, 255); } else { _SIP_EndPoint->codecSetPriority((*it)->codecId, 0); } string description = (*it)->codecId; it++; } } RegisterEventFunc(this, &SIPController::ReceiveCallAnswerEvent); RegisterEventFunc(this, &SIPController::ReceiveCallInternalStateEvent); return true; } } return false; }