예제 #1
0
/**
 * check mode
 */
void trigger(void) {

    switch(mode){

        case MODE_START:
            if(isPushed(BREAK)){
                mode = MODE_OFF;
                OFF(ACC);
                OFF(IG);
                OFF(STARTER);
                // avoid falling to the MODE_OFF
                return;
            }
        break;

        // rotate key from IG to Starter or off
        case MODE_IG:
            if(isPushed(BREAK)){
                ON(ACC);
                ON(IG);
                ON(STARTER);
                while(pushed(BUTTON));
                OFF(STARTER);

                // TODO: check tachometer sensor the next mode
                mode = MODE_START;
            } else {
                mode = MODE_OFF;
                OFF(ACC);
                OFF(IG);
                OFF(STARTER);
                return;
            }

        break;

        // rotate key from ACC to IG
        case MODE_ACC:
            mode = MODE_IG;
            ON(ACC);
            ON(IG);
        break;

        // rotate key from off to ACC
        case MODE_OFF:
            mode = MODE_ACC;
            ON(ACC);
            OFF(IG);
        break;

    }
}
예제 #2
0
/*************************************************************************
	Handler for mouse button release events
*************************************************************************/
void PushButton::onMouseButtonUp(MouseEventArgs& e)
{
	if ((e.button == LeftButton) && isPushed())
	{
		Window* sheet = getGUIContext().getRootWindow();

		if (sheet)
		{
			// if mouse was released over this widget
            // (use position from mouse, as e.position has been unprojected)
			if (this == sheet->getTargetChildAtPosition(
                getGUIContext().getMouseCursor().getPosition()))
			{
				// fire event
				WindowEventArgs args(this);
				onClicked(args);
			}

		}

		++e.handled;
	}

	// default handling
	ButtonBase::onMouseButtonUp(e);
}
예제 #3
0
/**
 * point of entry
 */
int main(void) {

    // init IO and timers
    init();

    // turn on interrupts
    sei();

    // main loop
    while(1){

        // mode off and wake up timeout is empty
        if(mode == MODE_OFF && wakeup == 0){
            // sleep mcu
            sleep();
        }

        // check pushed button
        if(isPushed(BUTTON)){
            // trigger mode change
            trigger();
            // until button is not released
            while(pushed(BUTTON));
        }
    }

    return 0;
}
예제 #4
0
/*************************************************************************
	Handler for mouse button up events
*************************************************************************/
void Checkbox::onMouseButtonUp(MouseEventArgs& e)
{
	if ((e.button == LeftButton) && isPushed())
	{
		Window* sheet = System::getSingleton().getGUISheet();

		if (sheet)
		{
			// if mouse was released over this widget
            // (use mouse position, as e.position has been unprojected)
			if (this == sheet->getTargetChildAtPosition(
                                    MouseCursor::getSingleton().getPosition()))
			{
				// toggle selected state
				setSelected(d_selected ^ true);
			}

		}

		++e.handled;
	}

	// default handling
	ButtonBase::onMouseButtonUp(e);
}
예제 #5
0
void HTTPTransaction::sendHeadersWithOptionalEOM(
    const HTTPMessage& headers,
    bool eom) {
  CHECK(HTTPTransactionEgressSM::transit(
          egressState_, HTTPTransactionEgressSM::Event::sendHeaders));
  DCHECK(!isEgressComplete());
  if (isDownstream() && !isPushed()) {
    lastResponseStatus_ = headers.getStatusCode();
  }
  if (headers.isRequest()) {
    headRequest_ = (headers.getMethod() == HTTPMethod::HEAD);
  }
  HTTPHeaderSize size;
  transport_.sendHeaders(this, headers, &size, eom);
  if (transportCallback_) {
    transportCallback_->headerBytesGenerated(size);
  }
  if (eom) {
    CHECK(HTTPTransactionEgressSM::transit(
          egressState_, HTTPTransactionEgressSM::Event::sendEOM));
    // trailers are supported in this case:
    // trailers are for chunked encoding-transfer of a body
    if (transportCallback_) {
      transportCallback_->bodyBytesGenerated(0);
    }
    CHECK(HTTPTransactionEgressSM::transit(
          egressState_, HTTPTransactionEgressSM::Event::eomFlushed));
  }
  flushWindowUpdate();
}
예제 #6
0
/*************************************************************************
    Handler called when mouse button gets released
*************************************************************************/
void RadioButton::onMouseButtonUp(MouseEventArgs& e)
{
    if ((e.button == LeftButton) && isPushed())
    {
        Window* sheet = System::getSingleton().getGUISheet();

        if (sheet)
        {
            // if mouse was released over this widget
            // (use mouse position, since e.position has been unprojected)
            if (this == sheet->getTargetChildAtPosition(
                                    MouseCursor::getSingleton().getPosition()))
            {
                // select this button & deselect all others in the same group.
                setSelected(true);
            }

        }

        ++e.handled;
    }

    // default handling
    ButtonBase::onMouseButtonUp(e);
}
예제 #7
0
	void	FalagardAnimate::drawSelf(float z)
	{
		if( d_needsRedraw )
		{
			d_renderCache.clearCachedImagery();
			d_needsRedraw = false;
			// normal 状态是作为永远显示模式出现的
			drawNormal( z );
			if (isDisabled(true) )
			{
				drawDisabled(z);
			}
			else
			{
				//If pushed or checked draw "Pushed" Layer
				if (isPushed() ) 
				{
					drawPushed(z);
				}
				//Draw "Hover" Layer
				if (isHovering() )
				{
					drawHover(z);
				}
			}
		}
		Window::drawSelf(z);
	}
예제 #8
0
void TabButton::onCursorActivate(CursorInputEventArgs& e)
{
    if ((e.source == CIS_Left) && isPushed())
	{
		Window* sheet = getGUIContext().getRootWindow();

		if (sheet)
		{
            // if cursor was released over this widget
            // (use cursor position, as e.position has been unprojected)
			if (this == sheet->getTargetChildAtPosition(
                                    getGUIContext().getCursor().getPosition()))
			{
				// fire event
				WindowEventArgs args(this);
				onClicked(args);
			}
		}

		++e.handled;
    }
    else if (e.source == CIS_Middle)
    {
        d_dragging = false;
        releaseInput ();
        ++e.handled;
    }

	// default handling
    ButtonBase::onCursorActivate(e);
}
예제 #9
0
void FalagardActionButton::onMouseButtonUp(MouseEventArgs& e)
{
    //		FalagardButton::onMouseButtonUp(e);下面就是pushbutton中的部分
    if ((e.button == LeftButton) && isPushed())
    {
        Window* sheet = System::getSingleton().getGUISheet();

        if (sheet != NULL)
        {
            // if mouse was released over this widget
            if (this == sheet->getChildAtPosition(e.position))
            {
                // fire event
                WindowEventArgs args(this);
                onClicked(args);
            }

        }

        e.handled = true;
    }

    if(e.button == RightButton)
    {
        Window* sheet = System::getSingleton().getGUISheet();

        if (sheet != NULL)
        {
            // if mouse was released over this widget
            if (this == sheet->getChildAtPosition(e.position))
            {
                // fire event
                WindowEventArgs args(this);
                onRBClicked(args);
            }

        }

    }

    // default handling
    //		ButtonBase::onMouseButtonUp(e);下面就是buttonbase中的部分
    Window::onMouseButtonUp(e);

    if (e.button == LeftButton || e.button == RightButton)
    {
        releaseInput();

        // event was handled by us.
        e.handled = true;
    }

    d_leftMouseDown = false;
}
예제 #10
0
	void	FalagardCheckButton::drawSelf(float z)
	{
		if( d_needsRedraw )
		{
			if( isCheck() && !isPushed())
			{
				d_renderCache.clearCachedImagery();
            // signal that we'll no loger need a redraw.
				d_needsRedraw = false;
				drawPushed( z );
			}
			else
				return FalagardButton::drawSelf( z );
		}
		Window::drawSelf(z);
	}
예제 #11
0
/*************************************************************************
	Perform the rendering for this widget.	
*************************************************************************/
void ButtonBase::drawSelf(float z)
{
	if (isHovering())
	{
		drawHover(z);
	}
	else if (isPushed())
	{
		drawPushed(z);
	}
	else if (isDisabled())
	{
		drawDisabled(z);
	}
	else
	{
		drawNormal(z);
	}

}
예제 #12
0
void HTTPTransaction::onIngressHeadersComplete(
  std::unique_ptr<HTTPMessage> msg) {
  DestructorGuard g(this);
  msg->setSeqNo(seqNo_);
  if (isUpstream() && !isPushed() && msg->isResponse()) {
    lastResponseStatus_ = msg->getStatusCode();
  }
  if (!validateIngressStateTransition(
        HTTPTransactionIngressSM::Event::onHeaders)) {
    return;
  }
  if ((msg->isRequest() && msg->getMethod() != HTTPMethod::CONNECT) ||
       (msg->isResponse() &&
        !headRequest_ &&
        !RFC2616::responseBodyMustBeEmpty(msg->getStatusCode()))) {
    // CONNECT payload has no defined semantics
    const auto& clHeader =
      msg->getHeaders().getSingleOrEmpty(HTTP_HEADER_CONTENT_LENGTH);
    if (!clHeader.empty()) {
      try {
        expectedContentLengthRemaining_ = folly::to<uint64_t>(clHeader);
      } catch (const folly::ConversionError& ex) {
        // ignore this, at least for now
      }
    }
  }
  if (transportCallback_) {
    transportCallback_->headerBytesReceived(msg->getIngressHeaderSize());
  }
  if (mustQueueIngress()) {
    checkCreateDeferredIngress();
    deferredIngress_->emplace(id_, HTTPEvent::Type::HEADERS_COMPLETE,
                             std::move(msg));
    VLOG(4) << *this << " Queued ingress event of type " <<
      HTTPEvent::Type::HEADERS_COMPLETE;
  } else {
    processIngressHeadersComplete(std::move(msg));
  }
}
예제 #13
0
/*************************************************************************
	Handler for mouse button up events
*************************************************************************/
void Checkbox::onMouseButtonUp(MouseEventArgs& e)
{
	if ((e.button == LeftButton) && isPushed())
	{
		Window* sheet = System::getSingleton().getGUISheet();

		if (sheet != NULL)
		{
			// if mouse was released over this widget
			if (this == sheet->getChildAtPosition(e.position))
			{
				// toggle selected state
				setSelected(d_selected ^ true);
			}

		}

		e.handled = true;
	}

	// default handling
	ButtonBase::onMouseButtonUp(e);
}
예제 #14
0
/*************************************************************************
	Handler for mouse button release events
*************************************************************************/
void PushButton::onMouseButtonUp(MouseEventArgs& e)
{
	if ((e.button == LeftButton) && isPushed())
	{
		Window* sheet = System::getSingleton().getGUISheet();

		if (sheet != NULL)
		{
			// if mouse was released over this widget
			if (this == sheet->getChildAtPosition(e.position))
			{
				// fire event
				WindowEventArgs args(this);
				onClicked(args);
			}

		}

		e.handled = true;
	}

	// default handling
	ButtonBase::onMouseButtonUp(e);
}
예제 #15
0
void FalagardActionButton::drawSelf( float z )
{
    if (d_needsRedraw  )
    {
        d_renderCache.clearCachedImagery();
        d_needsRedraw = false;
        const StateImagery* imagery;
        // get WidgetLookFeel for the assigned look.
        const WidgetLookFeel& wlf = WidgetLookManager::getSingleton().getWidgetLook(d_lookName);
        if( wlf.isStateImageryPresent( "BackgroundImage" ) )
        {
            imagery = &wlf.getStateImagery( "BackgroundImage" );
            // peform the rendering operation.
            imagery->render(*this);
        }
        // 画背景

        d_BackImage.draw(d_renderCache);
        //Empty
        if(isEmpty())
        {
            if((isHovering() || isPushed()) && !isDisabled(true) )//&& !isGloom())
            {
                drawHover(z);
            }
        }
        else
        {
            //Draw normal image
            drawNormal(z);

            //Draw percentage Img
            if(isPercentagePresent())
            {
                drawPercentageImg(z);
            }

            //Notin Dragging
            if(d_dragging && !isGloom())
            {
                drawPushed(z);
            }
            else
            {
                //Draw disable mask only when disabled
                if (isDisabled(true) || isGloom() )
                {
                    drawDisabled(z);
                    if (isPushed() || isChecked())
                    {
                        drawPushed(z);
                    }
                    drawAnimate(z);
                }
                else
                {
                    //If pushed or checked draw "Pushed" Layer
                    if (isPushed() || isChecked())
                    {
                        drawPushed(z);
                    }

                    //Draw "Hover" Layer
                    if (isHovering() && !isChecked())
                    {
                        drawHover(z);
                    }

                    drawAnimate(z);
                    // If default
                    if(isDefault())
                    {
                        drawDefault(z);
                    }

                }

                //Draw corner character
                drawCorner(z);
                drawFlash( z );
            }
        }
    }

    Window::drawSelf(z);
}
예제 #16
0
	void FalagardActionButton::drawSelf( float z )
	{
		if (d_needsRedraw  )
		{
			d_renderCache.clearCachedImagery();
			d_needsRedraw = false;
			
			//Empty
			if(isEmpty())
			{
				if((isHovering() || isPushed()) && !isDisabled(true) )//&& !isGloom())
				{
					drawHover(z);
				}
			}
			else
			{
				//Draw normal image
				drawNormal(z);

				//Notin Dragging
				if(d_dragging && !isGloom())
				{
					drawPushed(z);
				}
				else
				{
					//Draw disable mask only when disabled
					if (isDisabled(true) || isGloom() )
					{
						drawDisabled(z);
						if (isPushed() || isChecked()) 
						{
							drawPushed(z);
						}
					}
					else
					{
						//If pushed or checked draw "Pushed" Layer
						if (isPushed() || isChecked()) 
						{
							drawPushed(z);
						}

						//Draw "Hover" Layer
						if (isHovering() && !isChecked())
						{
							drawHover(z);
						}

						drawAnimate(z);
						// If default
						if(isDefault())
						{
							drawDefault(z);
						}
						
					}

					//Draw corner character
					drawCorner(z);
				}
			}
		}

		Window::drawSelf(z);
	}