Stay organized with collections
Save and categorize content based on your preferences.
PwmDriver
public
interface
PwmDriver
implements
Pwm
com.google.android.things.userdriver.pio.PwmDriver
|
PWM user driver.
A PwmDriver must implement all Pwm functions, but additionally this class provides an open()
function that will be called whenever a process obtains ownership of the PWM, to match the
existing close() function.
Summary
Public methods |
abstract
void
|
close()
Closes the PWM.
|
default
String
|
getName()
Returns null.
|
abstract
void
|
open()
Opens the PWM.
|
Public methods
close
void close ()
Closes the PWM.
This will be called when the PWM is closed by its owner. Any resources that need to
be cleaned up should be done so here.
This method may throw IOException to indicate I/O failure, but will still be considered
closed and may attempt to be re-opened in the future.
Throws |
IOException |
on I/O failure; the driver will still be considered closed.
|
getName
String getName ()
Returns null.
I/O user drivers can be registered under any name so this returns null by default. Child
classes may override this if other behavior is desired.
open
void open ()
Opens the PWM.
This will be called when ownership of a PWM is obtained. The driver should do any
initialization needed to configure the PWM for use here.
Throws |
IOException |
on I/O failure; the driver will remain closed.
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# PwmDriver\n\nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \\| [\\[Expand All\\]](#) \n\nPwmDriver\n=========\n\n\n`\npublic\n\n\ninterface\nPwmDriver\n`\n\n\n`\n\n\nimplements\n\n`[Pwm](/reference/com/google/android/things/pio/Pwm)`\n\n\n`\n\n|----------------------------------------------------|\n| com.google.android.things.userdriver.pio.PwmDriver |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nPWM user driver.\n\nA PwmDriver must implement all Pwm functions, but additionally this class provides an open()\nfunction that will be called whenever a process obtains ownership of the PWM, to match the\nexisting close() function.\n\nSummary\n-------\n\n| ### Public methods ||\n|--------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[close](/reference/com/google/android/things/userdriver/pio/PwmDriver#close())`() ` Closes the PWM. |\n| ` default `[String](/reference/java/lang/String) | ` `[getName](/reference/com/google/android/things/userdriver/pio/PwmDriver#getName())`() ` Returns null. |\n| ` abstract void` | ` `[open](/reference/com/google/android/things/userdriver/pio/PwmDriver#open())`() ` Opens the PWM. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[com.google.android.things.pio.Pwm](/reference/com/google/android/things/pio/Pwm)` ` |--------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](/reference/com/google/android/things/pio/Pwm#close())`() ` Releases the PWM pin. | | ` default `[String](/reference/java/lang/String) | ` `[getName](/reference/com/google/android/things/pio/Pwm#getName())`() ` Returns the I/O name. | | ` abstract void` | ` `[setEnabled](/reference/com/google/android/things/pio/Pwm#setEnabled(boolean))`(boolean enabled) ` Enables the PWM pin. | | ` abstract void` | ` `[setPwmDutyCycle](/reference/com/google/android/things/pio/Pwm#setPwmDutyCycle(double))`(double duty_cycle) ` Sets the duty cycle. | | ` abstract void` | ` `[setPwmFrequencyHz](/reference/com/google/android/things/pio/Pwm#setPwmFrequencyHz(double))`(double freq_hz) ` Sets the frequency of the signal. | ||\n| From interface ` `[java.io.Closeable](/reference/java/io/Closeable)` ` |------------------|--------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](/reference/java/io/Closeable#close())`() ` Closes this stream and releases any system resources associated with it. | ||\n| From interface ` `[java.lang.AutoCloseable](/reference/java/lang/AutoCloseable)` ` |------------------|---------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](/reference/java/lang/AutoCloseable#close())`() ` Closes this resource, relinquishing any underlying resources. | ||\n\nPublic methods\n--------------\n\n### close\n\n```\nvoid close ()\n```\n\nCloses the PWM.\n\nThis will be called when the PWM is closed by its owner. Any resources that need to\nbe cleaned up should be done so here.\n\nThis method may throw IOException to indicate I/O failure, but will still be considered\nclosed and may attempt to be re-opened in the future.\n\n\u003cbr /\u003e\n\n| Throws ||\n|-----------------------------------------------|-------------------------------------------------------------|\n| [IOException](/reference/java/io/IOException) | on I/O failure; the driver will still be considered closed. |\n\n### getName\n\n```\nString getName ()\n```\n\nReturns null.\n\nI/O user drivers can be registered under any name so this returns null by default. Child\nclasses may override this if other behavior is desired.\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------------------------------|--------|\n| [String](/reference/java/lang/String) | \u003cbr /\u003e |\n\n### open\n\n```\nvoid open ()\n```\n\nOpens the PWM.\n\nThis will be called when ownership of a PWM is obtained. The driver should do any\ninitialization needed to configure the PWM for use here.\n\n\u003cbr /\u003e\n\n| Throws ||\n|-----------------------------------------------|------------------------------------------------|\n| [IOException](/reference/java/io/IOException) | on I/O failure; the driver will remain closed. |\n\n-\n\n Interfaces\n ----------\n\n - [GpioDriver](/reference/com/google/android/things/userdriver/pio/GpioDriver)\n - [I2cBusDriver](/reference/com/google/android/things/userdriver/pio/I2cBusDriver)\n - [PwmDriver](/reference/com/google/android/things/userdriver/pio/PwmDriver)\n - [SpiBusDriver](/reference/com/google/android/things/userdriver/pio/SpiBusDriver)\n - [UartDeviceDriver](/reference/com/google/android/things/userdriver/pio/UartDeviceDriver)\n-\n\n Classes\n -------\n\n - [PioDriverManager](/reference/com/google/android/things/userdriver/pio/PioDriverManager)"]]