AI2 Component  (Version nb184)
Thermometer.java
Go to the documentation of this file.
1 // -*- mode: java; c-basic-offset: 2; -*-
2 // Copyright 2019 MIT, All rights reserved
3 // Released under the Apache License, Version 2.0
4 // http://www.apache.org/licenses/LICENSE-2.0
5 
6 
7 package com.google.appinventor.components.runtime;
8 
17 
18 import android.hardware.Sensor;
19 
24 @DesignerComponent(version = YaVersion.THERMOMETER_COMPONENT_VERSION,
25  description = "A sensor component that can measure the ambient (external) temperature. " +
26  "Most Android devices do not have this sensor.",
27  category = ComponentCategory.SENSORS,
28  nonVisible = true,
29  iconName = "images/thermometer.png")
30 @SimpleObject
31 public class Thermometer extends SingleValueSensor {
37  public Thermometer(ComponentContainer container) {
38  super(container.$form(), Sensor.TYPE_AMBIENT_TEMPERATURE);
39  }
40 
41  @Override
42  protected void onValueChanged(float value) {
44  }
45 
51  @SimpleEvent(description = "Called when a change is detected in the temperature (in degrees Celsius).")
52  public void TemperatureChanged(float temperature) {
53  EventDispatcher.dispatchEvent(this, "TemperatureChanged", temperature);
54  }
55 
63  @SimpleProperty(description = "The temperature in degrees Celsius, if the sensor is available and enabled")
64  public float Temperature() {
65  return getValue();
66  }
67 }
com.google.appinventor.components.runtime.EventDispatcher
Definition: EventDispatcher.java:22
com.google.appinventor.components.runtime.Thermometer
Definition: Thermometer.java:31
com.google.appinventor.components.annotations.SimpleFunction
Definition: SimpleFunction.java:23
com.google.appinventor.components.common.YaVersion
Definition: YaVersion.java:14
com.google.appinventor.components.runtime.Thermometer.Temperature
float Temperature()
Definition: Thermometer.java:64
com.google.appinventor.components.annotations.DesignerProperty
Definition: DesignerProperty.java:25
com.google.appinventor.components
com.google.appinventor.components.annotations.DesignerComponent
Definition: DesignerComponent.java:22
com.google.appinventor.components.annotations.SimpleEvent
Definition: SimpleEvent.java:20
com.google.appinventor.components.runtime.SingleValueSensor.getValue
float getValue()
Definition: SingleValueSensor.java:191
com.google.appinventor.components.runtime.SingleValueSensor
Definition: SingleValueSensor.java:27
com.google.appinventor.components.runtime.Thermometer.Thermometer
Thermometer(ComponentContainer container)
Definition: Thermometer.java:37
com.google.appinventor.components.runtime.EventDispatcher.dispatchEvent
static boolean dispatchEvent(Component component, String eventName, Object...args)
Definition: EventDispatcher.java:188
com.google.appinventor.components.annotations.SimpleProperty
Definition: SimpleProperty.java:23
com.google.appinventor.components.runtime.ComponentContainer
Definition: ComponentContainer.java:16
com.google.appinventor.components.common
Definition: ComponentCategory.java:7
com.google.appinventor.components.common.ComponentCategory
Definition: ComponentCategory.java:48
com.google.appinventor.components.runtime.Thermometer.onValueChanged
void onValueChanged(float value)
Definition: Thermometer.java:42
com.google.appinventor.components.annotations.SimpleObject
Definition: SimpleObject.java:23
com.google
com
com.google.appinventor.components.runtime.SingleValueSensor.value
float value
Definition: SingleValueSensor.java:33
com.google.appinventor.components.runtime.ComponentContainer.$form
Form $form()
com.google.appinventor.components.annotations
com.google.appinventor.components.runtime.Thermometer.TemperatureChanged
void TemperatureChanged(float temperature)
Definition: Thermometer.java:52
com.google.appinventor