本文整理汇总了Java中com.google.android.things.contrib.driver.pwmspeaker.Speaker类的典型用法代码示例。如果您正苦于以下问题:Java Speaker类的具体用法?Java Speaker怎么用?Java Speaker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Speaker类属于com.google.android.things.contrib.driver.pwmspeaker包,在下文中一共展示了Speaker类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import com.google.android.things.contrib.driver.pwmspeaker.Speaker; //导入依赖的package包/类
public void init(String gpioPin) throws IOException {
buzzer = new Speaker(gpioPin);
buzzer.stop(); // in case the PWM pin was enabled already
handlerThread.start();
handler = new Handler(handlerThread.getLooper()) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
try {
buzzer.stop();
if (msg.what == HANDLER_MSG_PLAY) {
buzzer.play(msg.arg1);
handler.sendEmptyMessageDelayed(HANDLER_MSG_STOP, 800);
}
} catch (IOException e) {
Log.e(TAG, "Buzzer error", e);
}
}
};
}
开发者ID:Nilhcem,项目名称:mpr121-androidthings,代码行数:22,代码来源:PassiveBuzzerHelper.java
示例2: onCreate
import com.google.android.things.contrib.driver.pwmspeaker.Speaker; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
mSpeaker = new Speaker(BoardDefaults.getPwmPin());
mSpeaker.stop(); // in case the PWM pin was enabled already
} catch (IOException e) {
Log.e(TAG, "Error initializing speaker");
return; // don't initilize the handler
}
mHandlerThread = new HandlerThread("pwm-playback");
mHandlerThread.start();
mHandler = new Handler(mHandlerThread.getLooper());
mHandler.post(mPlaybackRunnable);
}
开发者ID:androidthings,项目名称:drivers-samples,代码行数:18,代码来源:SpeakerActivity.java
示例3: Buzzer
import com.google.android.things.contrib.driver.pwmspeaker.Speaker; //导入依赖的package包/类
public Buzzer(Speaker speaker, Handler stopHandler) throws IOException {
this.speaker = speaker;
this.stopHandler = stopHandler;
stopRunnable = new Runnable() {
@Override
public void run() {
try {
stop();
} catch (IOException e) {
e.printStackTrace();
}
}
};
}
开发者ID:JeppeLeth,项目名称:android-things-rainbow-hat-sample,代码行数:15,代码来源:Buzzer.java
示例4: onCreate
import com.google.android.things.contrib.driver.pwmspeaker.Speaker; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
speaker = new Speaker(BoardDefaults.getPwmPin());
presenter = new PianoPresenter(this, (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE),
getString(R.string.service_id), getPackageName());
} catch (IOException e) {
throw new IllegalArgumentException("Piezo can't be opened, lets end this here.");
}
}
开发者ID:riggaroo,项目名称:android-things-distributed-piano,代码行数:13,代码来源:PianoActivity.java
示例5: onCreate
import com.google.android.things.contrib.driver.pwmspeaker.Speaker; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PeripheralManagerService service = new PeripheralManagerService();
Log.d(TAG, "Available GPIO: " + service.getGpioList());
Log.d(TAG, "Available I2C: " + service.getI2cBusList());
Log.d(TAG, "Available SPI: " + service.getSpiBusList());
Log.d(TAG, "Available PWM: " + service.getPwmList());
Log.d(TAG, "Available UART: " + service.getUartDeviceList());
startTime = System.currentTimeMillis();
try {
mLedGpio = service.openGpio(GPIO_LED_PIN_NAME);
// Step 2. Configure as an output.
mLedGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
// Step 1. Create GPIO connection.
mButtonGpio = service.openGpio(GPIO__BUTTON_PIN_NAME);
// Step 2. Configure as an input.
mButtonGpio.setDirection(Gpio.DIRECTION_IN);
// Step 3. Enable edge trigger events.
mButtonGpio.setEdgeTriggerType(Gpio.EDGE_FALLING);
// Step 4. Register an event callback.
mButtonGpio.registerGpioCallback(mCallback);
mSpeaker = new Speaker(BUZZER_PIN_NAME);
mSpeaker.stop(); // in case the PWM pin was enabled already
//mLedMatrix = new LEDMatrix(LED_MATRIX_RCLK_PIN_NAME, LED_MATRIX_SRCLK_PIN_NAME, LED_MATRIX_DI_PIN_NAME);
//mLedMatrix.setFlipVertical(true);
//mSegDisplay = new TM1838Driver(LED_SEG7_CLK_PIN_NAME, LED_SEG7_STB_PIN_NAME
// , LED_SEG7_DIO_PIN_NAME, TM1838Driver.BRIGHTNESS_LOW);
mSegDisplay = new TM1838Driver("SPI0.0", TM1838Driver.BRIGHTNESS_MED);
/*mLedBar = new LEDBar(LED_BAR_DI_PIN_NAME, LED_BAR_DCLK_PIN_NAME, 10);
mLedBar.clear();*/
/*mDisplay = new NumericDisplay(DISPLAY7_DATA_PIN_NAME, DISPLAY7_CLK_PIN_NAME);
mDisplaySelect = service.openGpio(DISPLAY7_SELECT_PIN_NAME);
mDisplaySelect .setDirection(Gpio.DIRECTION_OUT_INITIALLY_HIGH);*/
} catch (IOException e) {
Log.e(TAG, "Error on PeripheralIO API", e);
}
THEME = MusicNotes.DRAMATIC_THEME;
}
开发者ID:dglabs,项目名称:androidthings-drivers,代码行数:51,代码来源:MainActivity.java
示例6: openPiezo
import com.google.android.things.contrib.driver.pwmspeaker.Speaker; //导入依赖的package包/类
public static Speaker openPiezo() throws IOException {
return new Speaker(BOARD.getPiezoPwm());
}
开发者ID:androidthings,项目名称:contrib-drivers,代码行数:4,代码来源:RainbowHat.java
注:本文中的com.google.android.things.contrib.driver.pwmspeaker.Speaker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论