Exemple #1
0
      //! Initialize resources.
      void
      onResourceInitialization(void)
      {
        if (!getConstantParameters())
          throw RestartNeeded(DTR("failed to get constant parameters"), c_restart_delay);

        setConfig();

        std::map<std::string, LED*>::iterator itr = m_led_by_name.begin();
        for (unsigned i = 0; i < c_led_count; ++i)
          setBrightness(itr->second, 0);

        if (!m_args.led_patterns.empty())
        {
          uint8_t count = m_args.led_patterns.size();

          UCTK::Frame frame;
          frame.setId(PKT_ID_LED_PATTERN);
          frame.setPayloadSize(1 + (count * 2));
          frame.set(count, 0);
          for (size_t i = 0; i < count; ++i)
            frame.set<uint16_t>(m_args.led_patterns[i], 1 + i * 2);
          if (!m_ctl->sendFrame(frame))
            throw RestartNeeded(DTR("failed to set LED patterns"), c_restart_delay);
        }

        m_wdog.reset();
        setEntityState(IMC::EntityState::ESTA_NORMAL, Status::CODE_ACTIVE);
      }
Exemple #2
0
      void
      setBrightness(LED* led, uint8_t value)
      {
        uint8_t id = led->id;
        uint16_t ticks = ((value * m_dif_dur) / 255) + m_min_dur;

        UCTK::Frame frame;
        frame.setId(PKT_ID_LED_PW);
        frame.setPayloadSize(3);
        frame.set(id, 0);
        frame.set(ticks, 1);

        if (m_ctl->sendFrame(frame))
        {
          led->brightness.value = value;
          m_wdog.reset();
        }
      }
Exemple #3
0
 bool
 setPatternPulseWidth(uint16_t pwidth)
 {
   UCTK::Frame frame;
   frame.setId(PKT_ID_LED_PATTERN_PW);
   frame.setPayloadSize(2);
   frame.set(pwidth, 0);
   return m_ctl->sendFrame(frame);
 }
Exemple #4
0
 bool
 setExternalTrigger(bool enabled)
 {
   uint8_t v = enabled ? 1 : 0;
   UCTK::Frame frame;
   frame.setId(PKT_ID_LED_EXT_TRG);
   frame.setPayloadSize(1);
   frame.set(v, 0);
   return m_ctl->sendFrame(frame);
 }