@microbit/microbit-connection 0.9.0-apps.alpha.18 → 0.9.0-apps.alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/build/cjs/bluetooth/connection.d.ts +242 -1
  2. package/build/cjs/bluetooth/connection.js +52 -4
  3. package/build/cjs/bluetooth/connection.js.map +1 -1
  4. package/build/cjs/bluetooth/device-wrapper.d.ts +6 -0
  5. package/build/cjs/bluetooth/device-wrapper.js +27 -0
  6. package/build/cjs/bluetooth/device-wrapper.js.map +1 -1
  7. package/build/cjs/bluetooth/flashing/nordic-dfu.js +14 -3
  8. package/build/cjs/bluetooth/flashing/nordic-dfu.js.map +1 -1
  9. package/build/cjs/bluetooth/services/event-service.d.ts +48 -0
  10. package/build/cjs/bluetooth/services/event-service.js +273 -0
  11. package/build/cjs/bluetooth/services/event-service.js.map +1 -0
  12. package/build/cjs/bluetooth/services/event-service.test.d.ts +1 -0
  13. package/build/cjs/bluetooth/services/event-service.test.js +252 -0
  14. package/build/cjs/bluetooth/services/event-service.test.js.map +1 -0
  15. package/build/cjs/bluetooth/services/io-pin-service.d.ts +65 -0
  16. package/build/cjs/bluetooth/services/io-pin-service.js +173 -0
  17. package/build/cjs/bluetooth/services/io-pin-service.js.map +1 -0
  18. package/build/cjs/bluetooth/services/temperature-service.d.ts +14 -0
  19. package/build/cjs/bluetooth/services/temperature-service.js +80 -0
  20. package/build/cjs/bluetooth/services/temperature-service.js.map +1 -0
  21. package/build/cjs/index.d.ts +4 -3
  22. package/build/cjs/index.js +4 -1
  23. package/build/cjs/index.js.map +1 -1
  24. package/build/cjs/microbit-events.d.ts +67 -0
  25. package/build/cjs/microbit-events.js +55 -0
  26. package/build/cjs/microbit-events.js.map +1 -0
  27. package/build/cjs/service-events.d.ts +49 -1
  28. package/build/cjs/service-events.js.map +1 -1
  29. package/build/esm/bluetooth/connection.d.ts +242 -1
  30. package/build/esm/bluetooth/connection.js +53 -5
  31. package/build/esm/bluetooth/connection.js.map +1 -1
  32. package/build/esm/bluetooth/device-wrapper.d.ts +6 -0
  33. package/build/esm/bluetooth/device-wrapper.js +27 -0
  34. package/build/esm/bluetooth/device-wrapper.js.map +1 -1
  35. package/build/esm/bluetooth/flashing/nordic-dfu.js +14 -3
  36. package/build/esm/bluetooth/flashing/nordic-dfu.js.map +1 -1
  37. package/build/esm/bluetooth/services/event-service.d.ts +48 -0
  38. package/build/esm/bluetooth/services/event-service.js +269 -0
  39. package/build/esm/bluetooth/services/event-service.js.map +1 -0
  40. package/build/esm/bluetooth/services/event-service.test.d.ts +1 -0
  41. package/build/esm/bluetooth/services/event-service.test.js +250 -0
  42. package/build/esm/bluetooth/services/event-service.test.js.map +1 -0
  43. package/build/esm/bluetooth/services/io-pin-service.d.ts +65 -0
  44. package/build/esm/bluetooth/services/io-pin-service.js +169 -0
  45. package/build/esm/bluetooth/services/io-pin-service.js.map +1 -0
  46. package/build/esm/bluetooth/services/temperature-service.d.ts +14 -0
  47. package/build/esm/bluetooth/services/temperature-service.js +76 -0
  48. package/build/esm/bluetooth/services/temperature-service.js.map +1 -0
  49. package/build/esm/index.d.ts +4 -3
  50. package/build/esm/index.js +2 -1
  51. package/build/esm/index.js.map +1 -1
  52. package/build/esm/microbit-events.d.ts +67 -0
  53. package/build/esm/microbit-events.js +52 -0
  54. package/build/esm/microbit-events.js.map +1 -0
  55. package/build/esm/service-events.d.ts +49 -1
  56. package/build/esm/service-events.js.map +1 -1
  57. package/package.json +1 -1
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Well-known micro:bit message bus event source IDs and values.
3
+ *
4
+ * Source IDs differ between V1 (DAL) and V2 (CODAL). Event values are
5
+ * identical across versions (V2 adds TwoG to gesture values).
6
+ *
7
+ * @see https://lancaster-university.github.io/microbit-docs/
8
+ */
9
+ /**
10
+ * Event source IDs for micro:bit V1 (DAL).
11
+ */
12
+ export declare const V1Source: {
13
+ readonly ButtonA: 1;
14
+ readonly ButtonB: 2;
15
+ readonly ButtonAB: 26;
16
+ readonly Gesture: 27;
17
+ };
18
+ /**
19
+ * Event source IDs for micro:bit V2 (CODAL).
20
+ */
21
+ export declare const V2Source: {
22
+ readonly ButtonA: 1;
23
+ readonly ButtonB: 2;
24
+ readonly ButtonAB: 3;
25
+ readonly Gesture: 13;
26
+ readonly Logo: 121;
27
+ };
28
+ export declare const EventSource: {
29
+ readonly v1: {
30
+ readonly ButtonA: 1;
31
+ readonly ButtonB: 2;
32
+ readonly ButtonAB: 26;
33
+ readonly Gesture: 27;
34
+ };
35
+ readonly v2: {
36
+ readonly ButtonA: 1;
37
+ readonly ButtonB: 2;
38
+ readonly ButtonAB: 3;
39
+ readonly Gesture: 13;
40
+ readonly Logo: 121;
41
+ };
42
+ };
43
+ export declare const GestureEvent: {
44
+ readonly TiltUp: 1;
45
+ readonly TiltDown: 2;
46
+ readonly TiltLeft: 3;
47
+ readonly TiltRight: 4;
48
+ readonly FaceUp: 5;
49
+ readonly FaceDown: 6;
50
+ readonly Freefall: 7;
51
+ readonly Acceleration3g: 8;
52
+ readonly Acceleration6g: 9;
53
+ readonly Acceleration8g: 10;
54
+ readonly Shake: 11;
55
+ /** V2 only. */
56
+ readonly Acceleration2g: 12;
57
+ };
58
+ export type GestureEvent = (typeof GestureEvent)[keyof typeof GestureEvent];
59
+ export declare const ButtonAction: {
60
+ readonly Down: 1;
61
+ readonly Up: 2;
62
+ readonly Click: 3;
63
+ readonly LongClick: 4;
64
+ readonly Hold: 5;
65
+ readonly DoubleClick: 6;
66
+ };
67
+ export type ButtonAction = (typeof ButtonAction)[keyof typeof ButtonAction];
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Well-known micro:bit message bus event source IDs and values.
3
+ *
4
+ * Source IDs differ between V1 (DAL) and V2 (CODAL). Event values are
5
+ * identical across versions (V2 adds TwoG to gesture values).
6
+ *
7
+ * @see https://lancaster-university.github.io/microbit-docs/
8
+ */
9
+ /**
10
+ * Event source IDs for micro:bit V1 (DAL).
11
+ */
12
+ export const V1Source = {
13
+ ButtonA: 1,
14
+ ButtonB: 2,
15
+ ButtonAB: 26,
16
+ Gesture: 27,
17
+ };
18
+ /**
19
+ * Event source IDs for micro:bit V2 (CODAL).
20
+ */
21
+ export const V2Source = {
22
+ ButtonA: 1,
23
+ ButtonB: 2,
24
+ ButtonAB: 3,
25
+ Gesture: 13,
26
+ Logo: 121,
27
+ };
28
+ export const EventSource = { v1: V1Source, v2: V2Source };
29
+ export const GestureEvent = {
30
+ TiltUp: 1,
31
+ TiltDown: 2,
32
+ TiltLeft: 3,
33
+ TiltRight: 4,
34
+ FaceUp: 5,
35
+ FaceDown: 6,
36
+ Freefall: 7,
37
+ Acceleration3g: 8,
38
+ Acceleration6g: 9,
39
+ Acceleration8g: 10,
40
+ Shake: 11,
41
+ /** V2 only. */
42
+ Acceleration2g: 12,
43
+ };
44
+ export const ButtonAction = {
45
+ Down: 1,
46
+ Up: 2,
47
+ Click: 3,
48
+ LongClick: 4,
49
+ Hold: 5,
50
+ DoubleClick: 6,
51
+ };
52
+ //# sourceMappingURL=microbit-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"microbit-events.js","sourceRoot":"","sources":["../../src/microbit-events.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,EAAE;IACZ,OAAO,EAAE,EAAE;CACH,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,GAAG;CACD,CAAC;AAEX,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAW,CAAC;AAEnE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,SAAS,EAAE,CAAC;IACZ,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,cAAc,EAAE,CAAC;IACjB,cAAc,EAAE,CAAC;IACjB,cAAc,EAAE,EAAE;IAClB,KAAK,EAAE,EAAE;IACT,eAAe;IACf,cAAc,EAAE,EAAE;CACV,CAAC;AAGX,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,CAAC;IACP,EAAE,EAAE,CAAC;IACL,KAAK,EAAE,CAAC;IACR,SAAS,EAAE,CAAC;IACZ,IAAI,EAAE,CAAC;IACP,WAAW,EAAE,CAAC;CACN,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { DeviceConnectionEventMap } from "./device.js";
2
+ import type { GestureEvent, ButtonAction } from "./microbit-events.js";
2
3
  export interface AccelerometerData {
3
4
  x: number;
4
5
  y: number;
@@ -10,7 +11,7 @@ export declare const ButtonState: {
10
11
  readonly LongPress: 2;
11
12
  };
12
13
  export type ButtonState = (typeof ButtonState)[keyof typeof ButtonState];
13
- export type ButtonEventType = "buttonachanged" | "buttonbchanged";
14
+ export type ButtonActionType = "buttonachanged" | "buttonbchanged";
14
15
  export interface ButtonData {
15
16
  button: "A" | "B";
16
17
  state: ButtonState;
@@ -26,6 +27,45 @@ export interface MagnetometerData {
26
27
  y: number;
27
28
  z: number;
28
29
  }
30
+ export interface TemperatureData {
31
+ celsius: number;
32
+ }
33
+ export interface PinValue {
34
+ /** Pin number (0-18). */
35
+ pin: number;
36
+ /**
37
+ * Pin value. For digital pins: 0 or 1.
38
+ * For analog pins: 0-255 (the 10-bit analog reading scaled to 8 bits).
39
+ */
40
+ value: number;
41
+ }
42
+ /**
43
+ * Data from a `pinchanged` event.
44
+ *
45
+ * Contains only the input pins whose values changed since the last
46
+ * notification, up to a firmware limit of 10 pins per event
47
+ * (lowest-numbered first). Use {@link MicrobitBluetoothConnection.readPins}
48
+ * to read all input pins on demand.
49
+ */
50
+ export interface PinData {
51
+ data: PinValue[];
52
+ }
53
+ export interface GestureData {
54
+ gesture: GestureEvent;
55
+ }
56
+ export interface ButtonActionData {
57
+ button: "A" | "B" | "AB" | "Logo";
58
+ action: ButtonAction;
59
+ }
60
+ /**
61
+ * A raw event from the micro:bit's message bus, received via the
62
+ * BLE Event Service. Use {@link MicrobitBluetoothConnection.subscribeToEvent}
63
+ * to register which events the micro:bit should forward.
64
+ */
65
+ export interface MicrobitEventData {
66
+ source: number;
67
+ value: number;
68
+ }
29
69
  export interface UartData {
30
70
  value: Uint8Array;
31
71
  }
@@ -38,6 +78,14 @@ export interface ServiceConnectionEventMap {
38
78
  buttonachanged: ButtonData;
39
79
  buttonbchanged: ButtonData;
40
80
  magnetometerdatachanged: MagnetometerData;
81
+ temperaturechanged: TemperatureData;
82
+ pinchanged: PinData;
83
+ gesturechanged: GestureData;
84
+ buttonaaction: ButtonActionData;
85
+ buttonbaction: ButtonActionData;
86
+ buttonabaction: ButtonActionData;
87
+ logoaction: ButtonActionData;
88
+ microbitevent: MicrobitEventData;
41
89
  uartdata: UartData;
42
90
  }
43
91
  type AllEventMap = ServiceConnectionEventMap & DeviceConnectionEventMap;
@@ -1 +1 @@
1
- {"version":3,"file":"service-events.js","sourceRoot":"","sources":["../../src/service-events.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,CAAC;IACb,SAAS,EAAE,CAAC;CACJ,CAAC"}
1
+ {"version":3,"file":"service-events.js","sourceRoot":"","sources":["../../src/service-events.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,CAAC;IACb,SAAS,EAAE,CAAC;CACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microbit/microbit-connection",
3
- "version": "0.9.0-apps.alpha.18",
3
+ "version": "0.9.0-apps.alpha.19",
4
4
  "main": "./build/cjs/index.js",
5
5
  "module": "./build/esm/index.js",
6
6
  "types": "./build/esm/index.d.ts",