enabling a bunch of simple sensor services

This commit is contained in:
peli 2021-02-11 04:19:07 -08:00
Родитель 3f71988aa1
Коммит 6a4d9ee566
44 изменённых файлов: 424 добавлений и 164 удалений

23
barometer/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-barometer",
"version": "0.0.0",
"description": "A sensor measuring air pressure of outside environment.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

23
compass/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-compass",
"version": "0.0.0",
"description": "A sensor that measures the heading.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

23
distance/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-distance",
"version": "0.0.0",
"description": "A sensor that determines the distance of an object without any physical contact involved.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

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

@ -13,8 +13,8 @@ namespace modules {
*/
//% blockId=jacdaceco2_101_0
//% group="Equivalent CO₂" blockSetVariable=myModule
//% blockCombine block="e_CO2" callInDebugger
get e_CO2(): number {
//% blockCombine block="e CO2" callInDebugger
get eCO2(): number {
const values = this.values() as any[];
return values && values.length > 0 && values[0];
}

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

@ -12,37 +12,37 @@ namespace jacdac {
* Read-only ppm u22.10 (uint32_t). Equivalent CO (eCO) readings.
*
* ```
* const [e_CO2] = jdunpack<[number]>(buf, "u22.10")
* const [eCO2] = jdunpack<[number]>(buf, "u22.10")
* ```
*/
E_CO2 = 0x101,
ECO2 = 0x101,
/**
* Read-only ppm u22.10 (uint32_t). Error on the reading value.
*
* ```
* const [e_CO2Error] = jdunpack<[number]>(buf, "u22.10")
* const [eCO2Error] = jdunpack<[number]>(buf, "u22.10")
* ```
*/
E_CO2Error = 0x106,
ECO2Error = 0x106,
/**
* Constant ppm u22.10 (uint32_t). Minimum measurable value
*
* ```
* const [minE_CO2] = jdunpack<[number]>(buf, "u22.10")
* const [minECO2] = jdunpack<[number]>(buf, "u22.10")
* ```
*/
MinE_CO2 = 0x104,
MinECO2 = 0x104,
/**
* Constant ppm u22.10 (uint32_t). Minimum measurable value
*
* ```
* const [maxE_CO2] = jdunpack<[number]>(buf, "u22.10")
* const [maxECO2] = jdunpack<[number]>(buf, "u22.10")
* ```
*/
MaxE_CO2 = 0x105,
MaxECO2 = 0x105,
/**
* Constant s uint32_t. Time required to achieve good sensor stability before measuring after long idle period.

23
e-co2/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-eco2",
"version": "0.0.0",
"description": "Measures equivalent CO₂ levels.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

23
gyroscope/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-gyroscope",
"version": "0.0.0",
"description": "A 3-axis gyroscope.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

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

@ -16,7 +16,7 @@ namespace modules {
*/
//% blockId=jacdacheartrate_101_0
//% group="Heart Rate" blockSetVariable=myModule
//% blockCombine block="heart_rate" callInDebugger
//% blockCombine block="heart rate" callInDebugger
get heartRate(): number {
const values = this.values() as any[];
return values && values.length > 0 && values[0];

23
heart-rate/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-heartrate",
"version": "0.0.0",
"description": "A sensor approximating the heart rate. \n\n\n**Jacdac is NOT suitable for medical devices and should NOT be used in any kind of device to diagnose or treat any medical conditions.**",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

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

@ -7,7 +7,6 @@
"client.g.ts"
],
"testFiles": [
"test.ts"
],
"supportedTargets": [
"arcade",

23
illuminance/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-illuminance",
"version": "0.0.0",
"description": "Detects the amount of light falling onto a given surface area.\n\nNote that this is different from *luminance*, the amount of light that passes through, emits from, or reflects off an object.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

23
joystick/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-joystick",
"version": "0.0.0",
"description": "A two axis directional joystick",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

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

@ -1,43 +0,0 @@
namespace jacdac {
// Service: LED Matrix
export const SRV_LEDMATRIX = 0x110d154b
export const enum LEDMatrixReg {
/**
* Read-write bytes. The state of the screen where pixel on/off state is
* stored as a bit, column by column. The column should be byte aligned.
*
* ```
* const [leds] = jdunpack<[Buffer]>(buf, "b")
* ```
*/
Leds = 0x2,
/**
* Read-write ratio u0.8 (uint8_t). Reads the general brightness of the LEDs. ``0`` when the screen is off.
*
* ```
* const [brightness] = jdunpack<[number]>(buf, "u0.8")
* ```
*/
Brightness = 0x1,
/**
* Constant # uint16_t. Number of rows on the screen
*
* ```
* const [rows] = jdunpack<[number]>(buf, "u16")
* ```
*/
Rows = 0x181,
/**
* Constant # uint16_t. Number of columns on the screen
*
* ```
* const [columns] = jdunpack<[number]>(buf, "u16")
* ```
*/
Columns = 0x182,
}
}

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

@ -13,7 +13,7 @@ namespace modules {
*/
//% blockId=jacdaclightlevel_101_0
//% group="Light level" blockSetVariable=myModule
//% blockCombine block="light_level" callInDebugger
//% blockCombine block="light level" callInDebugger
get lightLevel(): number {
const values = this.values() as any[];
return values && values.length > 0 && values[0];

23
light-level/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-lightlevel",
"version": "0.0.0",
"description": "A sensor that measures luminosity level.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

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

@ -3,9 +3,9 @@ namespace modules {
* A 3-axis magnetometer.
**/
//% fixedInstances blockGap=8
export class MagnetoClient extends jacdac.SensorClient<[number,number,number]> {
export class MagnetometerClient extends jacdac.SensorClient<[number,number,number]> {
constructor(role: string) {
super(jacdac.SRV_MAGNETO, role, "i32 i32 i32");
super(jacdac.SRV_MAGNETOMETER, role, "i32 i32 i32");
}
/**
@ -48,5 +48,5 @@ namespace modules {
}
//% fixedInstance whenUsed
export const magneto = new MagnetoClient("magneto");
export const magnetometer = new MagnetometerClient("magnetometer");
}

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

@ -1,7 +1,7 @@
namespace jacdac {
// Service: Magnetometer
export const SRV_MAGNETO = 0x13029088
export const enum MagnetoReg {
export const SRV_MAGNETOMETER = 0x13029088
export const enum MagnetometerReg {
/**
* Indicates the current magnetic field on magnetometer.
* For reference: `1 mgauss` is `100 nT` (and `1 gauss` is `100 000 nT`).
@ -22,7 +22,7 @@ namespace jacdac {
ForcesError = 0x106,
}
export const enum MagnetoCmd {
export const enum MagnetometerCmd {
/**
* No args. Forces a calibration sequence where the user/device
* might have to rotate to be calibrated.

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

23
magnetometer/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-magnetomer",
"version": "0.0.0",
"description": "A 3-axis magnetometer.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

23
motion/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-motion",
"version": "0.0.0",
"description": "A sensor, typically PIR, that detects object motion within a certain range",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

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

@ -13,7 +13,7 @@ namespace modules {
*/
//% blockId=jacdacpower_101_0
//% group="Power" blockSetVariable=myModule
//% blockCombine block="current_draw" callInDebugger
//% blockCombine block="current draw" callInDebugger
get currentDraw(): number {
const values = this.values() as any[];
return values && values.length > 0 && values[0];

23
pulse-oximeter/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-pulseoximeter",
"version": "0.0.0",
"description": "A sensor approximating the oxygen level. \n\n**Jacdac is not suitable for medical devices and should NOT be used in any kind of device to diagnose or treat any medical conditions.**",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

23
rain-gauge/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-raingauge",
"version": "0.0.0",
"description": "Measures the amount of liquid precipitation over an area in a predefined period of time.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

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

@ -44,7 +44,7 @@ namespace modules {
*/
//% blockId=jacdacrealtimeclock_101_2
//% group="Real time clock" blockSetVariable=myModule
//% blockCombine block="day_of_month" callInDebugger
//% blockCombine block="day of month" callInDebugger
get dayOfMonth(): number {
const values = this.values() as any[];
return values && values.length > 0 && values[2];
@ -58,7 +58,7 @@ namespace modules {
*/
//% blockId=jacdacrealtimeclock_101_3
//% group="Real time clock" blockSetVariable=myModule
//% blockCombine block="day_of_week" callInDebugger
//% blockCombine block="day of week" callInDebugger
get dayOfWeek(): number {
const values = this.values() as any[];
return values && values.length > 0 && values[3];

23
real-time-clock/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-realtimeclock",
"version": "0.0.0",
"description": "Real time clock to support collecting data with precise time stamps.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

23
reflected-light/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-reflectedlight",
"version": "0.0.0",
"description": "A sensor that detects light and dark surfaces, commonly used for line following robots.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

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

@ -14,7 +14,7 @@ namespace modules {
*/
//% blockId=jacdacsensoraggregator_101_0
//% group="Sensor Aggregator" blockSetVariable=myModule
//% blockCombine block="current_sample" callInDebugger
//% blockCombine block="current sample" callInDebugger
get currentSample(): Buffer {
const values = this.values() as any[];
return values && values.length > 0 && values[0];

23
soil-moisture/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-soilmoisture",
"version": "0.0.0",
"description": "A soil moisture sensor.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

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

@ -13,7 +13,7 @@ namespace modules {
*/
//% blockId=jacdacsoundlevel_101_0
//% group="Sound level" blockSetVariable=myModule
//% blockCombine block="sound_level" callInDebugger
//% blockCombine block="sound level" callInDebugger
get soundLevel(): number {
const values = this.values() as any[];
return values && values.length > 0 && values[0];

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

@ -1,23 +0,0 @@
namespace modules {
//% fixedInstances
//% blockGap=8
export class SoundLevelClient extends jacdac.SensorClient<[number]> {
constructor(role: string) {
super(jacdac.SRV_SOUND_LEVEL, role, "u0.16");
}
/**
* Reads the microphone level between 0 (silent) and 255 (loud)
*/
//% blockId=jacdacsoundlevelreading block="%sensor sound level"
//% group="Sound Level"
get soundLevel(): number {
// map 0..1 to 0..255
const [value] = this.values();
return ((value || 0) * 0xff) >> 0;
}
}
//% fixedInstance whenUsed
export const soundLevel = new SoundLevelClient("soundLevel");
}

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

@ -1,19 +0,0 @@
{
"name": "jacdac-microphone",
"version": "0.3.0",
"description": "MakeCode support for JACDAC Microphone service",
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"files": [
"constants.ts",
"client.ts"
],
"supportedTargets": [
"arcade",
"maker",
"microbit"
],
"preferredEditor": "tsprj"
}

23
thermocouple/pxt.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"name": "jacdac-thermocouple",
"version": "0.0.0",
"description": "A thermocouple using a heat probe to gather temperatures.",
"files": [
"constants.ts",
"client.g.ts"
],
"testFiles": [
],
"supportedTargets": [
"arcade",
"microbit",
"maker"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
}

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

@ -3,7 +3,7 @@ namespace modules {
* Measures equivalent Total Volatile Organic Compound levels.
**/
//% fixedInstances blockGap=8
export class TVOCClient extends jacdac.SensorClient<[number]> {
export class TvocClient extends jacdac.SensorClient<[number]> {
constructor(role: string) {
super(jacdac.SRV_TVOC, role, "u22.10");
}
@ -23,5 +23,5 @@ namespace modules {
}
//% fixedInstance whenUsed
export const TVOC = new TVOCClient("TVOC");
export const tvoc = new TvocClient("tvoc");
}

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

@ -1,7 +1,7 @@
namespace jacdac {
// Service: Total Volatile organic compound
export const SRV_TVOC = 0x12a5b597
export const enum TVOCReg {
export const enum TvocReg {
/**
* Read-only ppb u22.10 (uint32_t). Total volatile organic compound readings in parts per billion.
*
@ -24,19 +24,19 @@ namespace jacdac {
* Constant ppb u22.10 (uint32_t). Minimum measurable value
*
* ```
* const [min_TVOC] = jdunpack<[number]>(buf, "u22.10")
* const [minTVOC] = jdunpack<[number]>(buf, "u22.10")
* ```
*/
Min_TVOC = 0x104,
MinTVOC = 0x104,
/**
* Constant ppb u22.10 (uint32_t). Minimum measurable value
*
* ```
* const [max_TVOC] = jdunpack<[number]>(buf, "u22.10")
* const [maxTVOC] = jdunpack<[number]>(buf, "u22.10")
* ```
*/
Max_TVOC = 0x105,
MaxTVOC = 0x105,
/**
* Constant s uint32_t. Time required to achieve good sensor stability before measuring after long idle period.

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

@ -7,7 +7,6 @@
"client.g.ts"
],
"testFiles": [
"test.ts"
],
"supportedTargets": [
"arcade",

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

@ -13,7 +13,7 @@ namespace modules {
*/
//% blockId=jacdacuvindex_101_0
//% group="UV index" blockSetVariable=myModule
//% blockCombine block="uv_index" callInDebugger
//% blockCombine block="uv index" callInDebugger
get uvIndex(): number {
const values = this.values() as any[];
return values && values.length > 0 && values[0];

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

@ -7,7 +7,6 @@
"client.g.ts"
],
"testFiles": [
"test.ts"
],
"supportedTargets": [
"arcade",

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

@ -1,39 +0,0 @@
namespace jacdac {
// Service: UV index
export const SRV_UVINDEX = 0x1f6e0d90
export const enum UVIndexVariant { // uint8_t
UVA_UVB = 0x1,
Visible_IR = 0x2,
}
export const enum UVIndexReg {
/**
* Read-only uv u16.16 (uint32_t). Ultraviolet index, typically refreshed every second.
*
* ```
* const [uvIndex] = jdunpack<[number]>(buf, "u16.16")
* ```
*/
UvIndex = 0x101,
/**
* Read-only uv u16.16 (uint32_t). Error on the UV measure.
*
* ```
* const [uvIndexError] = jdunpack<[number]>(buf, "u16.16")
* ```
*/
UvIndexError = 0x106,
/**
* Constant Variant (uint8_t). The type of physical sensor and capabilities.
*
* ```
* const [variant] = jdunpack<[UVIndexVariant]>(buf, "u8")
* ```
*/
Variant = 0x107,
}
}

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

@ -7,7 +7,6 @@
"client.g.ts"
],
"testFiles": [
"test.ts"
],
"supportedTargets": [
"arcade",

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

@ -7,7 +7,6 @@
"client.g.ts"
],
"testFiles": [
"test.ts"
],
"supportedTargets": [
"arcade",

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

@ -13,7 +13,7 @@ namespace modules {
*/
//% blockId=jacdacwinddirection_101_0
//% group="Wind direction" blockSetVariable=myModule
//% blockCombine block="wind_direction" callInDebugger
//% blockCombine block="wind direction" callInDebugger
get windDirection(): number {
const values = this.values() as any[];
return values && values.length > 0 && values[0];

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

@ -7,7 +7,6 @@
"client.g.ts"
],
"testFiles": [
"test.ts"
],
"supportedTargets": [
"arcade",

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

@ -13,7 +13,7 @@ namespace modules {
*/
//% blockId=jacdacwindspeed_101_0
//% group="Wind speed" blockSetVariable=myModule
//% blockCombine block="wind_speed" callInDebugger
//% blockCombine block="wind speed" callInDebugger
get windSpeed(): number {
const values = this.values() as any[];
return values && values.length > 0 && values[0];

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

@ -7,7 +7,6 @@
"client.g.ts"
],
"testFiles": [
"test.ts"
],
"supportedTargets": [
"arcade",