Esempio n. 1
0
bool SpektrumRX::initOkay(void){
	// check if all sticks are centered and land selected all is okay
	if (getThrottle() == 0){
		if (getRoll() == 0){
			if (getPitch() == 0){
				if (getYaw() == 0){
					if (getAuto() == 0)
						return true;
					else
						return false;
				}
				else
					return false;
			}
			else
				return false;
		}
		else
			return false;
	}
	else
		return false;
}
Esempio n. 2
0
  cl::Context createContext (std::string arg, const Core::OStream& out) {
    DevicePattern pattern = DevicePattern::parse (arg);
    PlatformList list = PlatformList::getPlatformList ();

    std::vector<DeviceEntry> devices;
    if (pattern.hasPlatform ()) {
      if (pattern.platform () >= list.platforms ().size ())
        ABORT_MSG ("Invalid platform id " + boost::lexical_cast<std::string> (pattern.platform ()));
      devices = list.platforms ()[pattern.platform ()]->getDevices (pattern.typeOrAll ());
    } else {
      devices = list.getDevices (pattern.typeOrAll ());
    }

    if (pattern.devices ().size () > 0) {
      std::vector<DeviceEntry> devices2;
      size_t platform = pattern.platform ();
      for (size_t i = 0; i < pattern.devices ().size (); i++) {
        size_t devid = pattern.devices ()[i];
        bool found = false;
        for (size_t j = 0; j < devices.size () && !found; j++) {
          ASSERT (devices[j].platform ().id () == platform);
          if (devices[j].id () == devid) {
            found = true;
            devices2.push_back (devices[j]);
          }
        }
        if (!found)
          ABORT_MSG ("Invalid device id " + boost::lexical_cast<std::string> (devid) + " for platform id " + boost::lexical_cast<std::string> (platform));
      }
      devices = devices2;
    } else if (pattern.type () == 0) {
      devices = getAuto (devices);
    } else {
    }

    if (pattern.list ()) {
      std::stringstream str;
      size_t lastPl = (size_t) (ssize_t) -1;
      for (size_t i = 0; i < devices.size (); i++) {
        const DeviceEntry& dev = devices[i];
        if (dev.platform ().id () != lastPl) {
          lastPl = dev.platform ().id ();
          str << dev.platform ().toString () << std::endl;
        }
        str << " " << dev.toString () << std::endl;
      }
      throw Core::HelpResultException (str.str ());
    }

    if (pattern.devices ().size () == 0 && devices.size () > 0) {
      devices.erase (devices.begin () + 1, devices.end ());
    }

    if (devices.size () == 0)
      ABORT_MSG ("No matching device found");

    if (devices.size () == 1) {
      out << "Using device " << devices[0].toString () << std::endl;
    } else {
      out << "Using devices:" << std::endl;
      for (size_t i = 0; i < devices.size (); i++)
        out << " " << devices[i].toString () << std::endl;
    }

    std::vector<cl::Device> clDevs;
    for (size_t i = 0; i < devices.size (); i++)
      clDevs.push_back (devices[i].device ());

    cl::Context context (clDevs);
    return context;
  }