當前位置: 首頁>>代碼示例>>Java>>正文


Java Pwm類代碼示例

本文整理匯總了Java中com.google.android.things.pio.Pwm的典型用法代碼示例。如果您正苦於以下問題:Java Pwm類的具體用法?Java Pwm怎麽用?Java Pwm使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Pwm類屬於com.google.android.things.pio包,在下文中一共展示了Pwm類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setPwmThrottle

import com.google.android.things.pio.Pwm; //導入依賴的package包/類
private void setPwmThrottle(Pwm pwm, int throttle) throws IOException {
    if (throttle < POWER_MIN || throttle > POWER_MAX) {
        throw new IllegalArgumentException("Throttle must be between 0 and 100. Throttle: " + throttle);
    }
    if (pwm == null) {
        throw new IllegalStateException("PWM Device not open");
    }
    pwm.setPwmDutyCycle(throttle);
    pwm.setEnabled(throttle != 0);
}
 
開發者ID:leinardi,項目名稱:androidthings-kuman-sm9,代碼行數:11,代碼來源:PwrA53A.java

示例2: Speaker

import com.google.android.things.pio.Pwm; //導入依賴的package包/類
/**
 * Create a Speaker connected to the given PWM pin name
 */
public Speaker(String pin) throws IOException {
    PeripheralManagerService pioService = new PeripheralManagerService();
    Pwm device = pioService.openPwm(pin);
    try {
        connect(device);
    } catch (IOException|RuntimeException e) {
        try {
            close();
        } catch (IOException|RuntimeException ignored) {
        }
        throw e;
    }
}
 
開發者ID:androidthings,項目名稱:contrib-drivers,代碼行數:17,代碼來源:Speaker.java

示例3: Servo

import com.google.android.things.pio.Pwm; //導入依賴的package包/類
/**
 * Create a new Servo that connects to the named pin and uses the specified frequency
 *
 * @param pin the PWM pin name
 * @param frequencyHz the frequency in Hertz
 * @throws IOException
 */
public Servo(String pin, double frequencyHz) throws IOException {
    PeripheralManagerService pioService = new PeripheralManagerService();
    Pwm device = pioService.openPwm(pin);
    try {
        connect(device, frequencyHz);
    } catch (IOException | RuntimeException e) {
        try {
            close();
        } catch (IOException | RuntimeException ignored) {
        }
        throw e;
    }
}
 
開發者ID:androidthings,項目名稱:contrib-drivers,代碼行數:21,代碼來源:Servo.java

示例4: connect

import com.google.android.things.pio.Pwm; //導入依賴的package包/類
/**
 * Create a new Servo that connects to the given PWM device and uses the specified frequency
 *
 * @param device the PWM device
 * @param frequencyHz the frequency in Hertz
 * @throws IOException
 */
@VisibleForTesting
/*package*/ Servo(Pwm device, double frequencyHz) throws IOException {
    try {
        connect(device, frequencyHz);
    } catch (IOException | RuntimeException e) {
        try {
            close();
        } catch (IOException | RuntimeException ignored) {
        }
        throw e;
    }
}
 
開發者ID:androidthings,項目名稱:contrib-drivers,代碼行數:20,代碼來源:Servo.java

示例5: connect

import com.google.android.things.pio.Pwm; //導入依賴的package包/類
/**
 * Create a Speaker from a {@link Pwm} device
 */
@VisibleForTesting
/*package*/ Speaker(Pwm device) throws IOException {
    connect(device);
}
 
開發者ID:androidthings,項目名稱:contrib-drivers,代碼行數:8,代碼來源:Speaker.java

示例6: this

import com.google.android.things.pio.Pwm; //導入依賴的package包/類
/**
 * Create a new Servo that connects to the given PWM device
 *
 * @param device the PWM device
 * @throws IOException
 */
@VisibleForTesting
/*package*/ Servo(Pwm device) throws IOException {
    this(device, DEFAULT_FREQUENCY_HZ);
}
 
開發者ID:androidthings,項目名稱:contrib-drivers,代碼行數:11,代碼來源:Servo.java


注:本文中的com.google.android.things.pio.Pwm類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。