Example #1
0
uint16_t Buzzer::getError(uint16_t time)
{
    uint16_t val = time/10;
    uint16_t v = val%40;
    uint16_t t = val/40;

    if(t > 10)
        return setOff();
    return wave(v, 20);
}
Example #2
0
uint16_t Buzzer::getProgramComplete(uint16_t time)
{
    uint16_t val = time/10;
    uint16_t v = val%40;
    uint16_t t = val/40;

    if(t > 10)
        return setOff();
    return wave(v, 20);
}
void HueOutputLightRGB::setColorReal(const ColorValue &c, bool s)
{
    if (!s)
    {
        cDebugDom("hue") << "State OFF ";
        setOff();
    }
    else
    {
        cDebugDom("hue") << "Hue color: " << c.toString();
        setColor(c);
    }
}
Example #4
0
void glowButton::toggle( )
{
	if( state )
	{
		state = FALSE;
		setOff();
	}
	else
	{
		state = TRUE;
		setOn();
	}
}
Example #5
0
status_t BnLedService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case CONNECT: {
            CHECK_INTERFACE(ILedService, data, reply);
            return NO_ERROR;
        } break;
	case LED_ON:
            CHECK_INTERFACE(ILedService, data, reply);
            int n = data.readInt32();//
            status_t result = setOn(n);//
            reply->writeInt32(result);//
	    return NO_ERROR;//
	case LED_OFF://
            CHECK_INTERFACE(ILedService, data, reply);//
            int n = data.readInt32();//
            status_t result = setOff(n);//
            reply->writeInt32(result);//
	    return NO_ERROR;//
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Example #6
0
void LED::toggle()
{
    isOn() ? setOff() : setOn();
}
Example #7
0
		// @todo industrialize with Button::onTouch()
		bool Toggle::onTouch( TouchEvent event )
		{
			// if the Toggle is disabled
			// we ignore this touch event
			if( _state == State::DISABLED )
			{
				return false;
			}
			
			// if the touch event is a CANCEL event
			// we just release the Toggle and return
			// without consuming the touch event
			if (event.getType() == TouchEvent::Type::CANCEL)
			{
				release();
				return false;
			}
			
			bool result = false;
			
			// get event data
			const TouchEvent::Type eventType = event.getType();
			const float eventX = event.getX();
			const float eventY = event.getY();
			
			// get this Toggle's bounding box
			px::tools::Rect bb = getBoundingBox();
			
			// add the GUI touch margin to the bounding box
            
			bb.setX(bb.getX() - guiButtonTouchMargin);
			bb.setY(bb.getY() - guiButtonTouchMargin);
			bb.setWidth(bb.getWidth() + 2*guiButtonTouchMargin);
			bb.setHeight(bb.getHeight() + 2*guiButtonTouchMargin);
			
			// test if touch event is on the Toggle
			if(eventX > bb.getX() && eventX < bb.getX()+bb.getWidth() &&
			   eventY > bb.getY() && eventY < bb.getY()+bb.getHeight())
			{
				// event is on the Toggle
				// in this case we test only touch DOWN and UP
				if( eventType == TouchEvent::Type::DOWN )
				{
					// we push the Toggle
					press();
					// we consume the touch event
					result = true;
				}
				else if( eventType == TouchEvent::Type::UP )
				{
					// Toggle receives a touch up event on it
					// but it may be not pushed at this time
					// if it was pushed, it's a click action
					// if it wasn't it does nothing
					if( _state == State::PRESSED )
					{
						if(_on)
							setOff();
						else
							setOn();
						// this is a click action
						clickCallback();
						// we consume the touch event
						result = true;
					}
					// in both cases, Toggle isn't pushed anymore
					release();
				}
			}
			else
			{
				// event is not on this Toggle object
				if( eventType == TouchEvent::Type::UP )
				{
					// Toggle is no more down, it's a click cancel action
					// PXLLOG("Toggle touch UP cancel");
					release();
					// we do not consume this event because it wasn't on the Toggle
				}
			}
			return result;
		}
Example #8
0
void ElidedLabel::setHasOffMode(bool v)
{
  _hasOffMode = v;
  setOff(false);
}
Example #9
0
LockController::LockController(const char *name, int flags):Controller(name,flags)
{
  setOff();
  kind = LOCK_TAG;
}
Example #10
0
 void Led::toggle()
 {
   ledIsOn ? setOff() : setOn();
 }
Example #11
0
Relay::Relay(int mypin) {
	pin = mypin;
	pinMode(pin, OUTPUT);
	setOff();
}
Example #12
0
/** Configure a feature for the currently open device.
 *
 *  @pre feature_set_ initialized
 *
 *  @param feature desired feature number
 *  @param control [in,out] pointer to control parameter (may change)
 *  @param value [in,out] pointer to requested parameter value (may
 *               change depending on device restrictions)
 *  @param value2 [in,out] optional pointer to second parameter value
 *               for white balance (may change depending on device
 *               restrictions).  No second value if NULL pointer.
 *
 *  The parameter values are represented as double despite the fact
 *  that most features on most cameras only allow unsigned 12-bit
 *  values.  The exception is the rare feature that supports
 *  "absolute" values in 32-bit IEEE float format.  Double can
 *  represent all possible option values accurately.
 */
void Features::configure(dc1394feature_t feature, int *control,
                         double *value, double *value2)
{
  // device-relevant information for this feature
  dc1394feature_info_t *finfo =
    &feature_set_.feature[feature - DC1394_FEATURE_MIN];

  if (!finfo->available)                // feature not available?
    {
      *control = camera1394::Camera1394_None;
      return;
    }

  switch (*control)
    {
    case camera1394::Camera1394_Off:
      setOff(finfo);
      break;

    case camera1394::Camera1394_Query:
      getValues(finfo, value, value2);
      break;

    case camera1394::Camera1394_Auto:
      if (!setMode(finfo, DC1394_FEATURE_MODE_AUTO))
        {
          setOff(finfo);
        }
      break;

    case camera1394::Camera1394_Manual:
      if (!setMode(finfo, DC1394_FEATURE_MODE_MANUAL))
        {
          setOff(finfo);
          break;
        }

      // TODO: break this into some internal methods
      if (finfo->absolute_capable && finfo->abs_control)
        {
          // supports reading and setting float value
          float fmin, fmax;
          if (DC1394_SUCCESS ==
              dc1394_feature_get_absolute_boundaries(camera_, feature,
                                                     &fmin, &fmax))
            {
              // clamp *value between minimum and maximum
              if (*value < fmin)
                *value = (double) fmin;
              else if (*value > fmax)
                *value = (double) fmax;
            }
          else
            {
              ROS_WARN_STREAM("failed to get feature "
                              << featureName(feature) << " boundaries ");
            }

          // @todo handle absolute White Balance values
          float fval = *value;
          if (DC1394_SUCCESS !=
              dc1394_feature_set_absolute_value(camera_, feature, fval))
            {
              ROS_WARN_STREAM("failed to set feature "
                              << featureName(feature) << " to " << fval);
            }
        }
      else // no float representation
        {
          // round requested value to nearest integer
          *value = rint(*value);

          // clamp *value between minimum and maximum
          if (*value < finfo->min)
            *value = (double) finfo->min;
          else if (*value > finfo->max)
            *value = (double) finfo->max;

          dc1394error_t rc;
          uint32_t ival = (uint32_t) *value;

          // handle White Balance, which has two components
          if (feature == DC1394_FEATURE_WHITE_BALANCE)
            {
              *value2 = rint(*value2);

              // clamp *value2 between same minimum and maximum
              if (*value2 < finfo->min)
                *value2 = (double) finfo->min;
              else if (*value2 > finfo->max)
                *value2 = (double) finfo->max;

              uint32_t ival2 = (uint32_t) *value2;
              rc = dc1394_feature_whitebalance_set_value(camera_, ival, ival2);
            }
          else
            {
              // other features only have one component
              rc = dc1394_feature_set_value(camera_, feature, ival);
            }
          if (rc != DC1394_SUCCESS)
            {
              ROS_WARN_STREAM("failed to set feature "
                              << featureName(feature) << " to " << ival);
            }
        }
      break;

    case camera1394::Camera1394_OnePush:
      // Try to set OnePush mode
      setMode(finfo, DC1394_FEATURE_MODE_ONE_PUSH_AUTO);

      // Now turn the control off, so camera does not continue adjusting
      setOff(finfo);
      break;

    case camera1394::Camera1394_None:
      // Invalid user input, because this feature actually does exist.
      ROS_INFO_STREAM("feature " << featureName(feature)
                      << " exists, cannot set to None");
      break;

    default:
      ROS_WARN_STREAM("unknown state (" << *control
                      <<") for feature " << featureName(feature));
    }

  // return actual state reported by the device
  *control = getState(finfo);
  ROS_DEBUG_STREAM("feature " << featureName(feature)
                   << " now in state " << *control);
}