@robotical/webapp-types 3.14.48 → 3.15.1

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.
@@ -4,6 +4,7 @@ import RAFT from "../RAFTs/RAFT";
4
4
  import Marty from "../RAFTs/Marty/Marty";
5
5
  import Cog from "../RAFTs/Cog/Cog";
6
6
  import { FOUND_RAFT_ON_DISCOVERY_RESPONSE } from "../../types/phone-app-communicator";
7
+ import { ColourSensorCalibrationStage } from "../../types/colour-sensor-calibration";
7
8
  import { RaftObserver } from "../RAFTs/RaftObserver";
8
9
  import { RaftInfoEvents } from "../../types/events/raft-info";
9
10
  import { RaftConnEvent, RaftUpdateEvent, RaftPublishEvent, RaftWifiScanResults, RaftWifiConnStatus, RaftOKFail } from "@robotical/raftjs";
@@ -59,7 +60,8 @@ export default class ApplicationManager {
59
60
  getWiFiConnStatusMarty(martyId: string): Promise<boolean | null>;
60
61
  getWifiScanResultsMarty(martyId: string): Promise<RaftWifiScanResults | RaftOKFail | boolean>;
61
62
  calibrateMarty(martyId: string, cmd: string, joints: string): Promise<false | RaftOKFail | undefined>;
62
- calibrateColourSensorsMarty(raftId: string): Promise<unknown>;
63
+ calibrateColourSensorsMarty(raftId: string, stage: ColourSensorCalibrationStage): Promise<unknown>;
64
+ resetColourSensorOffsetsMarty(raftId: string): Promise<unknown>;
63
65
  getCommsStatsMarty(martyId: string): Promise<{
64
66
  msgRxRate: number;
65
67
  msgRoundtripWorstMs: number;
@@ -57,6 +57,7 @@ import SensorsDashboardModal from "../../components/modals/ SensorsDashboardModa
57
57
  import LEDLightsOrQRVerificationModal from "../../components/modals/LEDLightsOrQRVerificationModal";
58
58
  import { CarouselNavigatorManager } from "../../utils/CarouselNavigatorManager";
59
59
  import i18n from "../../i18n";
60
+ import InUnpluggedModalContent from "../../components/modals/InUnplugged";
60
61
  var SHOW_LOGS = true;
61
62
  var TAG = "ApplicationManager";
62
63
  var ApplicationManager = /** @class */ (function () {
@@ -269,11 +270,22 @@ var ApplicationManager = /** @class */ (function () {
269
270
  });
270
271
  });
271
272
  };
272
- ApplicationManager.prototype.calibrateColourSensorsMarty = function (raftId) {
273
+ ApplicationManager.prototype.calibrateColourSensorsMarty = function (raftId, stage) {
273
274
  return __awaiter(this, void 0, void 0, function () {
274
275
  return __generator(this, function (_a) {
275
276
  if (this.connectedRafts[raftId]) {
276
- return [2 /*return*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.MARTY_CALIBRATE_COLOUR_SENSOR, { raftId: raftId })];
277
+ return [2 /*return*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.MARTY_CALIBRATE_COLOUR_SENSOR, { raftId: raftId, stage: stage })];
278
+ }
279
+ Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(raftId, " doesn't exist or is not a Marty"));
280
+ return [2 /*return*/];
281
+ });
282
+ });
283
+ };
284
+ ApplicationManager.prototype.resetColourSensorOffsetsMarty = function (raftId) {
285
+ return __awaiter(this, void 0, void 0, function () {
286
+ return __generator(this, function (_a) {
287
+ if (this.connectedRafts[raftId]) {
288
+ return [2 /*return*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.MARTY_RESET_COLOUR_SENSOR_OFFSETS, { raftId: raftId })];
277
289
  }
278
290
  Logger.warn(SHOW_LOGS, TAG, "RAFT with id: ".concat(raftId, " doesn't exist or is not a Marty"));
279
291
  return [2 /*return*/];
@@ -603,7 +615,12 @@ var ApplicationManager = /** @class */ (function () {
603
615
  raft.stopVerifyingRaft(true);
604
616
  _c.label = 5;
605
617
  case 5: return [2 /*return*/, raft];
606
- case 6: return [2 /*return*/, null];
618
+ case 6:
619
+ if (wasConnectedObj.reason === 'unplugged') {
620
+ modalState.setModal(createElement(InUnpluggedModalContent), i18n.t("calibration_screen.colour_calibration.unplugged_modal_title"));
621
+ }
622
+ _c.label = 7;
623
+ case 7: return [2 /*return*/, null];
607
624
  }
608
625
  });
609
626
  });
@@ -32,6 +32,10 @@ export declare class Marty extends RAFT implements RICInterface {
32
32
  * Gets the battery strength of the RAFT
33
33
  */
34
34
  getBatteryStrength(): number;
35
+ /**
36
+ * Gets if it's connected via USB
37
+ */
38
+ isConnectedViaUSB(): boolean;
35
39
  /**
36
40
  * Highlights Marty by flashing the LED and playing a tune
37
41
  */
@@ -127,8 +127,18 @@ var Marty = /** @class */ (function (_super) {
127
127
  */
128
128
  Marty.prototype.getBatteryStrength = function () {
129
129
  var _a;
130
+ if (this.isConnectedViaUSB()) {
131
+ return 0; // 0 indicates USB is connected
132
+ }
130
133
  return ((_a = this.raftStateInfo) === null || _a === void 0 ? void 0 : _a.power.powerStatus.battRemainCapacityPercent) || 0;
131
134
  };
135
+ /**
136
+ * Gets if it's connected via USB
137
+ */
138
+ Marty.prototype.isConnectedViaUSB = function () {
139
+ var _a;
140
+ return ((_a = this.raftStateInfo) === null || _a === void 0 ? void 0 : _a.power.powerStatus.powerUSBIsConnected) || false;
141
+ };
132
142
  /**
133
143
  * Highlights Marty by flashing the LED and playing a tune
134
144
  */
@@ -3,10 +3,12 @@ import { CenteredView, StyledView, ModalText, ModalTitle, StyledImage, } from ".
3
3
  import imageAbutton from "../../../assets/marty-a-button.png";
4
4
  import modalState from "../../../state-observables/modal/ModalState";
5
5
  import SimpleButton from "../../disposables/buttons/SimpleButton";
6
+ import { useTranslation } from "react-i18next";
6
7
  export default function InUnpluggedModalContent() {
8
+ var t = useTranslation().t;
7
9
  // disconnecting from marty as soon as
8
10
  // the modal comes up because some users might
9
11
  // try pressing A when the modal is still up.
10
12
  // window.marty.disconnect();
11
- return (_jsxs(StyledView, { children: [_jsx(ModalTitle, { children: "Couldn't connect to your Marty!" }), _jsx(ModalText, { children: "Your Marty is currently in unplugged mode. If you want to dissconect Marty from unplugged mode, please press the \"MODE\"/\"A\" button on the back of Marty and try again!" }), _jsx(StyledImage, { src: imageAbutton }), _jsx(CenteredView, { children: _jsx(SimpleButton, { title: "Got it!", onClick: function () { return modalState.closeModal(); } }) })] }));
13
+ return (_jsxs(StyledView, { children: [_jsx(ModalTitle, { children: t("connection.unplugged_modal_heading", "Couldn't connect to your Marty!") }), _jsx(ModalText, { children: t("connection.unplugged_modal_body", 'Your Marty is currently in unplugged mode. If you want to dissconect Marty from unplugged mode, please press the "MODE"/"A" button on the back of Marty and try again!') }), _jsx(StyledImage, { src: imageAbutton }), _jsx(CenteredView, { children: _jsx(SimpleButton, { title: t("connection.unplugged_modal_button", "Got it!"), onClick: function () { return modalState.closeModal(); } }) })] }));
12
14
  }