This commit is contained in:
pelikhan 2021-04-22 20:28:09 -07:00
Родитель f45236b41c
Коммит 825d8c6199
19 изменённых файлов: 26 добавлений и 26 удалений

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* A 3-axis accelerometer.
**/
//% fixedInstances blockGap=8
export class AccelerometerClient extends jacdac.SensorClient<[number,number,number]> {
export class AccelerometerClient extends jacdac.SensorClient {
private readonly _forcesError : jacdac.RegisterClient<[number]>;
private readonly _maxForce : jacdac.RegisterClient<[number]>;

Просмотреть файл

@ -1,6 +1,6 @@
namespace modules {
//% fixedInstances
export class AccelerometerClient extends jacdac.BufferedSensorClient<[number, number, number]> {
export class AccelerometerClient extends jacdac.BufferedSensorClient {
constructor(role: string) {
super(jacdac.SRV_ACCELEROMETER, role, "i6.10 i6.10 i6.10");
}

Просмотреть файл

@ -4,7 +4,7 @@ namespace modules {
* If a device has multiple controllers, it should have multiple gamepad services, using consecutive service identifiers.
**/
//% fixedInstances blockGap=8
export class ArcadeGamepadClient extends jacdac.SensorClient<[([jacdac.ArcadeGamepadButton, number])[]]> {
export class ArcadeGamepadClient extends jacdac.SensorClient {
private readonly _availableButtons : jacdac.RegisterClient<[jacdac.ArcadeGamepadButton[]]>;

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* A push-button, which returns to inactive position when not operated anymore.
**/
//% fixedInstances blockGap=8
export class ButtonClient extends jacdac.SensorClient<[boolean]> {
export class ButtonClient extends jacdac.SensorClient {
constructor(role: string) {

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* Senses RGB colors
**/
//% fixedInstances blockGap=8
export class ColorClient extends jacdac.SensorClient<[number,number,number]> {
export class ColorClient extends jacdac.SensorClient {
constructor(role: string) {

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* A 3-axis gyroscope.
**/
//% fixedInstances blockGap=8
export class GyroscopeClient extends jacdac.SensorClient<[number,number,number]> {
export class GyroscopeClient extends jacdac.SensorClient {
private readonly _rotationRatesError : jacdac.RegisterClient<[number]>;
private readonly _maxRate : jacdac.RegisterClient<[number]>;

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* A two axis directional joystick
**/
//% fixedInstances blockGap=8
export class JoystickClient extends jacdac.SensorClient<[number,number]> {
export class JoystickClient extends jacdac.SensorClient {
private readonly _variant : jacdac.RegisterClient<[jacdac.JoystickVariant]>;
private readonly _digital : jacdac.RegisterClient<[boolean]>;

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* A 3-axis magnetometer.
**/
//% fixedInstances blockGap=8
export class MagnetometerClient extends jacdac.SensorClient<[number,number,number]> {
export class MagnetometerClient extends jacdac.SensorClient {
private readonly _forcesError : jacdac.RegisterClient<[number]>;

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* A matrix of buttons connected as a keypad
**/
//% fixedInstances blockGap=8
export class MatrixKeypadClient extends jacdac.SensorClient<[number[]]> {
export class MatrixKeypadClient extends jacdac.SensorClient {
private readonly _rows : jacdac.RegisterClient<[number]>;
private readonly _columns : jacdac.RegisterClient<[number]>;

Просмотреть файл

@ -7,7 +7,7 @@ namespace modules {
* Multiple instances of this service may be present, if more than one model format is supported by a device.
**/
//% fixedInstances blockGap=8
export class ModelRunnerClient extends jacdac.SensorClient<[number[]]> {
export class ModelRunnerClient extends jacdac.SensorClient {
private readonly _autoInvokeEvery : jacdac.RegisterClient<[number]>;
private readonly _inputShape : jacdac.RegisterClient<[number[]]>;

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* A sensor, typically PIR, that detects object motion within a certain range
**/
//% fixedInstances blockGap=8
export class MotionClient extends jacdac.SensorClient<[boolean]> {
export class MotionClient extends jacdac.SensorClient {
private readonly _maxDistance : jacdac.RegisterClient<[number]>;
private readonly _angle : jacdac.RegisterClient<[number]>;

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* A capacitive touch sensor with multiple inputs.
**/
//% fixedInstances blockGap=8
export class MultitouchClient extends jacdac.SensorClient<[number[]]> {
export class MultitouchClient extends jacdac.SensorClient {
constructor(role: string) {

Просмотреть файл

@ -4,7 +4,7 @@ namespace modules {
*/
//% fixedInstances
//% blockGap=8
export class MultiTouchClient extends jacdac.SensorClient<number[]> {
export class MultiTouchClient extends jacdac.SensorClient {
constructor(role: string) {
super(jacdac.SRV_MULTITOUCH, role, "i32[]");
}
@ -17,7 +17,7 @@ namespace modules {
value(index: number): number {
if (!this._reading.hasValues())
pauseUntil(() => this._reading.hasValues(), 2000)
const values = this._reading.values;
const values = this._reading.values as number[];
const value = values[index >> 0];
return value != null ? value : -1;
}

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* Real time clock to support collecting data with precise time stamps.
**/
//% fixedInstances blockGap=8
export class RealTimeClockClient extends jacdac.SensorClient<[number,number,number,number,number,number,number]> {
export class RealTimeClockClient extends jacdac.SensorClient {
private readonly _error : jacdac.RegisterClient<[number]>;
private readonly _precision : jacdac.RegisterClient<[number]>;

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* A roving robot.
**/
//% fixedInstances blockGap=8
export class RoverClient extends jacdac.SensorClient<[number,number,number,number,number]> {
export class RoverClient extends jacdac.SensorClient {
constructor(role: string) {

Просмотреть файл

@ -4,7 +4,7 @@ namespace modules {
* (often used as input to machine learning models on the same device, see model runner service).
**/
//% fixedInstances blockGap=8
export class SensorAggregatorClient extends jacdac.SensorClient<[Buffer]> {
export class SensorAggregatorClient extends jacdac.SensorClient {
private readonly _inputs : jacdac.RegisterClient<[number,number,([Buffer, number, number, number, jacdac.SensorAggregatorSampleType, number])[]]>;
private readonly _numSamples : jacdac.RegisterClient<[number]>;

Просмотреть файл

@ -1,8 +1,8 @@
namespace jacdac {
//% fixedInstances
//% weight=1
export class SensorClient<TReading extends PackSimpleDataType[]> extends Client {
protected readonly _reading: RegisterClient<TReading>
export class SensorClient extends Client {
protected readonly _reading: RegisterClient<PackSimpleDataType[]>
public isStreaming = false
@ -34,8 +34,8 @@ namespace jacdac {
}
}
export class BufferedSensorClient<TReading extends (string | number | Buffer)[]> extends SensorClient<TReading> {
protected _samples: TReading[]
export class BufferedSensorClient extends SensorClient {
protected _samples: any[]
protected _numSamples: number
protected _interval: number
protected _lastTimestamp: number
@ -59,7 +59,7 @@ namespace jacdac {
handlePacket(packet: JDPacket) {
if (this._samples && packet.serviceCommand == (CMD_GET_REG | jacdac.SystemReg.Reading)) {
const v = jdunpack(packet.data, this._reading.packFormat) as TReading;
const v = jdunpack(packet.data, this._reading.packFormat) as any[];
if (v != null) {
let num = 1
if (this._lastTimestamp != undefined) {
@ -80,7 +80,7 @@ namespace jacdac {
}
//% fixedInstances
export class SimpleSensorClient extends SensorClient<[number]> {
export class SimpleSensorClient extends SensorClient {
constructor(deviceClass: number, role: string, stateFormat: string) {
super(deviceClass, role, stateFormat);
}
@ -97,7 +97,7 @@ namespace jacdac {
let last: number = this.reading()
this.onStateChanged(() => {
const [current] = this._reading.values
const [current] = this._reading.values as any[] as [number]
if (current == null)
return; // ignore missing data

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* A microphone that analyzes the sound specturm
**/
//% fixedInstances blockGap=8
export class SoundSpectrumClient extends jacdac.SensorClient<[Buffer]> {
export class SoundSpectrumClient extends jacdac.SensorClient {
private readonly _enabled : jacdac.RegisterClient<[boolean]>;
private readonly _fftPow2Size : jacdac.RegisterClient<[number]>;

Просмотреть файл

@ -3,7 +3,7 @@ namespace modules {
* A switch, which keeps its position.
**/
//% fixedInstances blockGap=8
export class SwitchClient extends jacdac.SensorClient<[boolean]> {
export class SwitchClient extends jacdac.SensorClient {
private readonly _variant : jacdac.RegisterClient<[jacdac.SwitchVariant]>;
private readonly _autoOffDelay : jacdac.RegisterClient<[number]>;