• 検索結果がありません。

Android Thingsであそぼう

N/A
N/A
Protected

Academic year: 2018

シェア "Android Thingsであそぼう"

Copied!
21
0
0

読み込み中.... (全文を見る)

全文

(1)

あそ う

(2)

ード ア

=

(3)

ード アの ービス

pio = new PeripheralManagerService();

(4)

LED ける

Gpio led = pio.openGpio("GPIO_34");

led.setDirection(DIRECTION_OUT_INITIALLY_LOW);

led.setValue(true);

(5)

LED 消す

led.setValue(false);

(6)

ボタンの値 む

Gpio button = pio.openGpio("GPIO_174");

button.setDirection(DIRECTION_IN);

boolean val = button.getValue();

(7)

ボタン ッスンする

button.setEdgeTriggerType(EDGE_BOTH);

button.registerGpioCallback((gpio)->{

//...

led.setValue(!gpio.getValue());

});

(8)

ド イ 使う

compile 'com.google.android.things.contrib:driver-button:+'

(9)

Android

button = new Button("GPIO_174", PRESSED_WHEN_HIGH); button.setOnButtonEventListener((button, pressed)->{

//... });

(10)

ユー ード イ 使う

inputDriver = new ButtonInputDriver("GPIO_174",

PRESSED_WHEN_HIGH, KEYCODE_A);

inputDriver.register();

(11)

Android しく

boolean onKeyDown(int keyCode, KeyEvent event){ //...

}

(12)

14 セグのド

compile 'com.google.android.things.contrib:driver-ht16k33:+'

display = new AlphanumericDisplay("I2C1"); display.setEnabled(true);

display.display("OREO");

(13)

BMP280 のド

compile 'com.google.android.things.contrib:driver-bmx280:+'

bmp280 = new Bmx280("I2C1");

float temp = bmp280.readTemperature();

(14)

BMP280 のユー ード

compile 'com.google.android.things.contrib:driver-bmx280:+'

sensorDriver = new Bmx280SensorDriver("I2C1"); sensorDriver.registerTemperatureSensor();

//...

void onSensorChanged(SensorEvent event) { }

(15)

ブ ーのド イ

compile 'com.google.android.things.contrib:driver-pwmspeaker:+'

buzzer = new Speaker("PWM2"); double NOTE_A = 440.0;

buzzer.play(NOTE_A);

(16)

LED のド イ

compile 'com.google.android.things.contrib:driver-apa102:+'

leds = new Apa102("SPI3", Apa102.Mode.RGB); int[] colors = new int[] {

Color.RED, Color.GREEN, Color.BLUE };

leds.write(colors);

(17)

UI 使える

button.setOnCheckedChangeListener((button, isChecked)->{ //…

led.setValue(isChecked); }

Android !

(18)

Firebase 使う

compile 'com.google.firebase:firebase-database:11.4.0'

FirebaseDatabase.getInstance()

.getReference("hello") .setValue("firebase");

Android !

(19)

GCP 使う

compile 'com.google.firebase:firebase-database:11.4.0'

pubsubService.projects() .topics()

.publish(topic, request) .execute();

Android !

(20)

Assistant SDK も使える

github.com/androidthings/sample-googleassistant assistant = EmbeddedAssistant.Builder()

.setRequestCallback(...)

.setConversationCallback(...) .build();

assistant.connect()

assistant.startConversation()

void onSpeechRecognition(String utterance) {}

void onConversationEvent(EventType eventType)) {}

(21)

MyThings

compile 'com.android.volley:volley:1.0.0'

url = "https://mythings-developers.yahooapis.jp/v2/services/" + serviceId + "/mythings/" + combinationId + "/run"; req = new JsonObjectRequest(Request.Method.POST, url, ...); //...

queue = Volley.newRequestQueue(this); queue.add(req);

参照

関連したドキュメント

喫煙者のなかには,喫煙の有害性を熟知してい

The SLE-revised (SLE-R) questionnaire despite simplicity is a high-performance screening tool for investigating the stress level of life events and its management in both community

サーバー API 複雑化 iOS&Android 間で複雑な API

Analogous to the identification of continuous dynamical systems, identification of discrete- event systems DESs consists of determining the mathematical model that describes

[r]

Economic Resource Type Economic Commitment Economic Event Type Economic Role.

回答番号1:強くそう思う 回答番号2:どちらかといえばそう思う 回答番号3:あまりそう思わない

「TEDx」は、「広める価値のあるアイディアを共有する場」として、情報価値に対するリテラシーの高 い市民から高い評価を得ている、米国