Hello,
I need a clock with timer in nanaoseconds. How can I do it?
Thinks
Not possible with AI2 and its clones.
The Clock component needs at least 10-30 ms to be triggered.
You might be able to write an extension for App Inventor, or request one from an extension developer.
What needs to happen in nanoseconds on a smartphone ? (serious, of interest, question)
https://developer.android.com/reference/java/lang/System#nanoTime()
com.KIO4_System.aix (5.0 KB)
package com.KIO4_System;
// © Juan Antonio Villalpando
// kio4.com
// System Abril 2020
import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.util.MediaUtil;
import com.google.appinventor.components.runtime.*;
import java.lang.System;
@DesignerComponent(version = KIO4_System.VERSION,
description = "The System class contains several useful class fields and methods.. "
+ "Juan Antonio Villalpando - KIO4.COM ",
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = "http://juanant91.byethost3.com/notificacion2.gif")
@SimpleObject(external = true)
public class KIO4_System extends AndroidNonvisibleComponent implements Component {
public static final int VERSION = 1;
private ComponentContainer container;
public KIO4_System(ComponentContainer container) {
super(container.$form());
this.container = container;
}
////////////////////// FUNCIONES ////////////////////////
@SimpleFunction(description = "Returns the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds.")
public long NanoTime() {
long nanot = System.nanoTime();
return nanot;
}
@SimpleFunction(description = "Returns the current time in milliseconds.")
public long CurrentTimeMillis() {
long milit = System.currentTimeMillis();
return milit;
}
} // ==> FIN
By definition of the "foot" as exactly 1/3 yards, and of the international yard as "exactly 0.9144 metres", and of the metre (SI unit) defined by the International Bureau of Weights and Measures as the "length of the path traveled by light in vacuum during a time interval of 1/299792458 of a second". The time taken by light to travel 1 foot in a vacuum is therefore (1/299792458)x(0.9144/3) seconds, or 1.016703362164 nanoseconds.
Collect vibration with high frequency
Thank you