示例#1
0
void calibrateI(bool charging, uint8_t point, AnalogInputs::ValueType current)
{
    AnalogInputs::ValueType maxValue;
    AnalogInputs::Name name1;
    AnalogInputs::Name name2;
    AnalogInputs::CalibrationPoint pName1;
    AnalogInputs::CalibrationPoint pName2;

    Program::dischargeOutputCapacitor();
    AnalogInputs::powerOn();
    if(testVout(false)) {

        if(charging) {
            maxValue = SMPS_UPPERBOUND_VALUE;
            name1 = AnalogInputs::IsmpsSet;
            name2 = AnalogInputs::Ismps;
            SMPS::powerOn();
            hardware::setVoutCutoff(MAX_CHARGE_V);

        } else {
            name1 = AnalogInputs::IdischargeSet;
            name2 = AnalogInputs::Idischarge;
            maxValue = DISCHARGER_UPPERBOUND_VALUE;
            Discharger::powerOn();
        }

        getCalibrationPoint(pName1, name1, point);
        getCalibrationPoint(pName2, name2, point);

        CurrentMenu menu(name1, name2, point, maxValue);
        int8_t index;
        do {
            menu.refreshValue(pName1);
            index = menu.runSimple(true);
            if(index < 0) break;
            if(index == 0) {
                setCurrentValue(name1, menu.value_);
                if(menu.runEdit()) {
                    AnalogInputs::doFullMeasurement();
                    pName1.y = current;
                    pName1.x = menu.value_;
                    pName2.y = current;
                    pName2.x = AnalogInputs::getAvrADCValue(name2);
                }
                setCurrentValue(name1, 0);
            }
        } while(true);

        if(charging)   SMPS::powerOff();
        else           Discharger::powerOff();

        //Info: we save eeprom data only when no current is flowing
        AnalogInputs::setCalibrationPoint(name1, point, pName1);
        AnalogInputs::setCalibrationPoint(name2, point, pName2);
        eeprom::restoreCalibrationCRC();
    }
    AnalogInputs::powerOff();
}
示例#2
0
void CGridDlg::calculate() {
  if (!validate()) return;

  setNotifyEnabled(false);
  windowToValue();
  const GridParameters v = getCurrentValue();
  GridParameters v1 = v;
  v1.m_colorCount++;
  setCurrentValue(v1);
  setNotifyEnabled(true);
  setCurrentValue(v);
}
示例#3
0
void AutomationUI::newMessage(const ContainerAsyncEvent & e)
{
	if (e.type == ContainerAsyncEvent::EventType::ControllableFeedbackUpdate)
	{
		if (e.targetControllable == manager->position)
		{
			setCurrentPosition(manager->position->floatValue());
			repaint();
		} else if (e.targetControllable == manager->value)
		{
			setCurrentValue(manager->value->floatValue());
			repaint();
		}else if (e.targetControllable != nullptr)
		{
			AutomationKey * k = dynamic_cast<AutomationKey *>(e.targetControllable->parentContainer);
			if (k != nullptr)
			{
				if (e.targetControllable == k->easingType)
				{
					//repaint();
				}
				else if (e.targetControllable == k->position || e.targetControllable == k->value)
				{
					placeKeyUI(getUIForItem(k));
					//repaint();
				}
			}
		}
		
	}
	
}
示例#4
0
    void Spinner::initialise(void)
    {
        Window::initialise();

        // create all the component widgets
        d_increaseButton = createIncreaseButton(getName() + "__auto_incbtn__");
        addChildWindow(d_increaseButton);
        d_decreaseButton = createDecreaseButton(getName() + "__auto_decbtn__");
        addChildWindow(d_decreaseButton);
        d_editbox = createEditbox(getName() + "__auto_editbox__");
        addChildWindow(d_editbox);

        // setup component controls
        d_increaseButton->setWantsMultiClickEvents(false);
        d_increaseButton->setMouseAutoRepeatEnabled(true);
        d_decreaseButton->setWantsMultiClickEvents(false);
        d_decreaseButton->setMouseAutoRepeatEnabled(true);

        // perform event subscriptions.
        d_increaseButton->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(&Spinner::handleIncreaseButton, this));
        d_decreaseButton->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(&Spinner::handleDecreaseButton, this));
        d_editbox->subscribeEvent(Window::EventTextChanged, Event::Subscriber(&Spinner::handleEditTextChange, this));

        // final initialisation
        setTextInputMode(Integer);
        setCurrentValue(0.0f);
        performChildWindowLayout();
    }
示例#5
0
    virtual void editItem(uint8_t index, uint8_t key) {
        int dir = -1;
        if(key == BUTTON_INC) dir = 1;
//        dir *= Keyboard::getSpeedFactor();
        change0ToMaxSmart(value_, dir, maxValue_, 1);
        setCurrentValue(cName_, value_);
    }
static void currentCalibration(uint8_t point)
{
    AnalogInputs::CalibrationPoint pSet;
    AnalogInputs::CalibrationPoint p;
    bool save = false;

    Program::dischargeOutputCapacitor();
    AnalogInputs::powerOn();
    if(testVout(false)) {

        getCalibrationPoint(pSet, gNameSet_, point);
        getCalibrationPoint(p, gName_, point);

        EditMenu::initialize(currentData, editCallback);
        gIexpected_ = pSet.y;
        int8_t index;
        do {
            gValue_ = pSet.x;
            index = EditMenu::run(true);
            if(index < 0) break;
            else if(index == 0) {
                powerOnCurrent();
                setCurrentValue(gValue_);
                if(EditMenu::runEdit()) {
                    AnalogInputs::doFullMeasurement();
                    pSet.y = gIexpected_;
                    pSet.x = gValue_;
                    p.y = gIexpected_;
                    p.x = AnalogInputs::getAvrADCValue(gName_);
                    save = true;
                }
                setCurrentValue(0);
                powerOffCurrent();
            } else if(index == 2 && !EditMenu::runEdit()) {
                gIexpected_ = pSet.y;
            }
        } while(true);

        //Info: we save eeprom data only when no current is flowing
        if(save) {
            AnalogInputs::setCalibrationPoint(gNameSet_, point, pSet);
            AnalogInputs::setCalibrationPoint(gName_, point, p);
            eeprom::restoreCalibrationCRC();
        }
    }
    AnalogInputs::powerOff();
}
示例#7
0
void CGridDlg::resetControls() {
  setNotifyEnabled(false);
  const GridParameters &v = getStartValue();
  setCurrentValue(v);
  valueToWindow(v);

  setNotifyEnabled(true);
}
示例#8
0
 bool Spinner::handleEditTextChange(const EventArgs& e)
 {
     // set this windows text to match
     setText(d_editbox->getText());
     // update value
     setCurrentValue(getValueFromText());
     return true;
 }
示例#9
0
void calibrateI(bool charging, uint8_t point, AnalogInputs::ValueType current)
{
    AnalogInputs::ValueType maxValue;
    AnalogInputs::Name name1;
    AnalogInputs::Name name2;

    if(testVout()) {

        if(charging) {
            maxValue = SMPS_UPPERBOUND_VALUE;
            name1 = AnalogInputs::IsmpsValue;
            name2 = AnalogInputs::Ismps;
            SMPS::powerOn();
        } else {
            name1 = AnalogInputs::IdischargeValue;
            name2 = AnalogInputs::Idischarge;
            maxValue = DISCHARGER_UPPERBOUND_VALUE;
            Discharger::powerOn();
        }

        CurrentMenu menu(name1, point, maxValue);
        int8_t index;
        do {
            menu.refreshValue();
            index = menu.runSimple(true);
            if(index < 0) break;
            if(index == 0) {
                setCurrentValue(name1, menu.value_);
                if(menu.runEdit(index)) {
                    AnalogInputs::doFullMeasurement();
                    AnalogInputs::CalibrationPoint p;
                    p.y = current;
                    p.x = menu.value_;
                    AnalogInputs::setCalibrationPoint(name1, point, p);
                    p.x = AnalogInputs::getAvrADCValue(name2);
                    AnalogInputs::setCalibrationPoint(name2, point, p);
                }
                setCurrentValue(name1, 0);
            }
        } while(true);

        if(charging)   SMPS::powerOff();
        else           Discharger::powerOff();
    }
}
示例#10
0
int resetPositionMine(int group, int current){
    println_I("Resetting PID Local ");p_int_I(group);print_I(" to ");p_int_I(current);print_I(" from ");p_fl_I(getPositionMine(group));
    if(group<numPidMotors){
        setCurrentValue(group, current);
    }else{
        resetHeater(group, current);
    }
    return getPositionMine(group);
}
示例#11
0
    void Spinner::onMinimumValueChanged(WindowEventArgs& e)
    {
        fireEvent(EventMinimumValueChanged, e, EventNamespace);

        if (d_currentValue < d_minValue)
        {
            setCurrentValue(d_minValue);
        }
    }
示例#12
0
    bool Spinner::handleDecreaseButton(const EventArgs& e)
    {
        if (((const MouseEventArgs&)e).button == LeftButton)
        {
            setCurrentValue(d_currentValue - d_stepSize);
            return true;
        }

        return false;
    }
示例#13
0
/*************************************************************************
	Handler for scroll wheel changes
*************************************************************************/
void Slider::onMouseWheel(MouseEventArgs& e)
{
	// base class processing
	Window::onMouseWheel(e);

	// scroll by e.wheelChange * stepSize
	setCurrentValue(d_value + d_step * -e.wheelChange);

	// ensure the message does not go to our parent.
	e.handled = true;
}
示例#14
0
void CGridDlg::windowToValue() {
  GridParameters param;
  param.m_cellSize      = m_cellSize;
  param.m_cellCount.cx  = m_horizontalCount;
  param.m_cellCount.cy  = m_verticalCount;
  param.m_colorCount    = m_colorCount;
  param.m_cellSizeMM    = m_cellSizeMM;
  const bool wasEnabled = isNotifyEnabled();
  if(!IsDlgButtonChecked(IDC_CHECKAUTOCALCULATE)) {
    setNotifyEnabled(false);
  }
  setCurrentValue(param);
  setNotifyEnabled(wasEnabled);
}
示例#15
0
AlkQuoteItem::AlkQuoteItem(const AlkQuoteItem& item, QObject* parent):
    QObject(parent),
    d(new Private)
{
  setSymbol(item.symbol());
  setDateTime(item.dateTime());
  setCurrentValue(item.currentValue());
  setOpeningValue(item.openingValue());
  setHighValue(item.highValue());
  setLowValue(item.lowValue());
  setClosingValue(item.closingValue());
  setVolume(item.volume());
  setMarketCap(item.marketCap());
  setEarningsPerShare(item.earningsPerShare());
  setChangeToday(item.changeToday());
  setEbitda(item.ebitda());
  setRecordId(item.recordId());
}
示例#16
0
/*************************************************************************
	Handler for when a mouse button is pressed
*************************************************************************/
void Slider::onMouseButtonDown(MouseEventArgs& e)
{
	// base class processing
	Window::onMouseButtonDown(e);

	if (e.button == LeftButton)
	{
		float adj = getAdjustDirectionFromPoint(e.position);

		// adjust slider position in whichever direction as required.
		if (adj != 0)
		{
			setCurrentValue(d_value + (adj * d_step));
		}

		e.handled = true;
	}

}
static void editCallback(uint16_t * value) {
    //make sure we don't go too high
    if(gName_ == AnalogInputs::Ismps) {
        if(gValue_ > SMPS_UPPERBOUND_VALUE)         gValue_ = SMPS_UPPERBOUND_VALUE;
        if(gIexpected_ > MAX_CHARGE_I)              gIexpected_ = MAX_CHARGE_I;
    } else {
        if(gValue_ > DISCHARGER_UPPERBOUND_VALUE)   gValue_ = DISCHARGER_UPPERBOUND_VALUE;
        if(gIexpected_ > MAX_DISCHARGE_I)           gIexpected_ = MAX_DISCHARGE_I;
    }
    //set current
    if(value == &gValue_) {
        setCurrentValue(gValue_);
    }
    //TODO: hack, should be improved ... Gyuri: R138 burned.
    if(!AnalogInputs::isConnected(AnalogInputs::Vout)) {
        Screen::displayStrings(string_connect, string_battery);
        if(gName_ == AnalogInputs::Idischarge) {
            Discharger::powerOff();
        }
    }
}
示例#18
0
    void Spinner::initialiseComponents(void)
    {
        // get all the component widgets
        PushButton* increaseButton = getIncreaseButton();
        PushButton* decreaseButton = getDecreaseButton();
        Editbox* editbox = getEditbox();

        // setup component controls
        increaseButton->setWantsMultiClickEvents(false);
        increaseButton->setMouseAutoRepeatEnabled(true);
        decreaseButton->setWantsMultiClickEvents(false);
        decreaseButton->setMouseAutoRepeatEnabled(true);

        // perform event subscriptions.
        increaseButton->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(&Spinner::handleIncreaseButton, this));
        decreaseButton->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(&Spinner::handleDecreaseButton, this));
        editbox->subscribeEvent(Window::EventTextChanged, Event::Subscriber(&Spinner::handleEditTextChange, this));

        // final initialisation
        setTextInputMode(Integer);
        setCurrentValue(0.0f);
        performChildWindowLayout();
    }
示例#19
0
void SelectBuddyComboBox::setCurrentBuddy(Buddy buddy)
{
	setCurrentValue(buddy);
}
示例#20
0
void AccountsComboBox::setCurrentAccount(Account account)
{
	setCurrentValue(account);
}
示例#21
0
/*************************************************************************
	handler function for when thumb moves.	
*************************************************************************/
bool Slider::handleThumbMoved(const EventArgs& e)
{
	setCurrentValue(getValueFromThumb());

	return true;
}
示例#22
0
void ProxyComboBox::setCurrentProxy(const NetworkProxy &networkProxy)
{
    setCurrentValue(networkProxy);
}
示例#23
0
void CGridDlg::OnCancel() {
  const GridParameters &v = getStartValue();
  valueToWindow(v);
  setCurrentValue(v);
  OnHideWindow();
}
示例#24
0
 virtual void editItem(uint8_t index, uint8_t key) {
     int dir = -1;
     if(key == BUTTON_INC) dir = 1;
     changeMinToMaxStep(&value_, dir, 1, maxValue_, 1);
     setCurrentValue(cName1_, value_);
 }