Exemplo n.º 1
0
 /**
  * Free the PWM channel.
  *
  * <p>Free the resource associated with the PWM channel and set the value to 0.
  */
 public void free() {
   if (m_port == 0) return;
   PWMJNI.setPWM(m_port, (short) 0);
   PWMJNI.freePWMChannel(m_port);
   PWMJNI.freeDIO(m_port);
   DIOJNI.freeDigitalPort(m_port);
   m_port = 0;
 }
Exemplo n.º 2
0
  /**
   * Initialize PWMs given a channel.
   *
   * <p>This method is private and is the common path for all the constructors for creating PWM
   * instances. Checks channel value ranges and allocates the appropriate channel. The allocation is
   * only done to help users ensure that they don't double assign channels. $
   *
   * @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the MXP port
   */
  private void initPWM(final int channel) {
    checkPWMChannel(channel);
    m_channel = channel;

    m_port = DIOJNI.initializeDigitalPort(DIOJNI.getPort((byte) m_channel));

    if (!PWMJNI.allocatePWMChannel(m_port)) {
      throw new AllocationException("PWM channel " + channel + " is already allocated");
    }

    PWMJNI.setPWM(m_port, (short) 0);

    m_eliminateDeadband = false;

    UsageReporting.report(tResourceType.kResourceType_PWM, channel);
  }
Exemplo n.º 3
0
 /**
  * Set the PWM value directly to the hardware.
  *
  * <p>Write a raw value to a PWM channel.
  *
  * @param value Raw PWM value. Range 0 - 255.
  */
 public void setRaw(int value) {
   PWMJNI.setPWM(m_port, (short) value);
 }