2018-01-04 01:18:39 +01:00
|
|
|
/// <reference path="../node_modules/pxt-core/built/pxteditor.d.ts"/>
|
|
|
|
/// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/>
|
|
|
|
|
2019-09-27 15:53:26 +02:00
|
|
|
import { deployCoreAsync, initAsync, canUseWebSerial, enableWebSerial } from "./deploy";
|
2018-01-04 01:18:39 +01:00
|
|
|
|
2018-01-30 00:21:15 +01:00
|
|
|
pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
2018-01-04 01:18:39 +01:00
|
|
|
pxt.debug('loading pxt-ev3 target extensions...')
|
|
|
|
const res: pxt.editor.ExtensionResult = {
|
2018-01-30 00:21:15 +01:00
|
|
|
deployCoreAsync,
|
|
|
|
showUploadInstructionsAsync: (fn: string, url: string, confirmAsync: (options: any) => Promise<number>) => {
|
|
|
|
// https://msdn.microsoft.com/en-us/library/cc848897.aspx
|
|
|
|
// "For security reasons, data URIs are restricted to downloaded resources.
|
|
|
|
// Data URIs cannot be used for navigation, for scripting, or to populate frame or iframe elements"
|
|
|
|
const downloadAgain = !pxt.BrowserUtils.isIE() && !pxt.BrowserUtils.isEdge();
|
|
|
|
const docUrl = pxt.appTarget.appTheme.usbDocs;
|
|
|
|
|
|
|
|
const htmlBody = `
|
2018-05-07 23:59:29 +02:00
|
|
|
<div class="ui grid stackable">
|
|
|
|
<div class="column five wide" style="background-color: #E2E2E2;">
|
|
|
|
<div class="ui header">${lf("First time here?")}</div>
|
2018-06-18 17:16:16 +02:00
|
|
|
<strong style="font-size:small">${lf("You must have version 1.10E or above of the firmware")}</strong>
|
2018-05-07 23:59:29 +02:00
|
|
|
<div style="justify-content: center;display: flex;padding: 1rem;">
|
2018-09-21 18:38:48 +02:00
|
|
|
<img class="ui image" src="/static/download/firmware.png" style="height:100px;" />
|
2018-01-30 00:21:15 +01:00
|
|
|
</div>
|
2018-05-07 23:59:29 +02:00
|
|
|
<a href="/troubleshoot" target="_blank">${lf("Check your firmware version here and update if needed")}</a>
|
2018-01-30 00:21:15 +01:00
|
|
|
</div>
|
2018-05-07 23:59:29 +02:00
|
|
|
<div class="column eleven wide">
|
|
|
|
<div class="ui grid">
|
|
|
|
<div class="row">
|
|
|
|
<div class="column">
|
|
|
|
<div class="ui two column grid padded">
|
|
|
|
<div class="column">
|
|
|
|
<div class="ui">
|
|
|
|
<div class="image">
|
2018-09-21 18:38:48 +02:00
|
|
|
<img class="ui medium rounded image" src="/static/download/connect.svg" style="height:109px;width:261px;margin-bottom:1rem;" />
|
2018-05-07 23:59:29 +02:00
|
|
|
</div>
|
|
|
|
<div class="content">
|
|
|
|
<div class="description">
|
|
|
|
<span class="ui yellow circular label">1</span>
|
|
|
|
<strong>${lf("Connect the EV3 to your computer with a USB cable")}</strong>
|
|
|
|
<br />
|
2018-05-31 00:42:17 +02:00
|
|
|
<span style="font-size:small">${lf("Use the miniUSB port on the top of the EV3 Brick")}</span>
|
2018-05-07 23:59:29 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="column">
|
|
|
|
<div class="ui">
|
|
|
|
<div class="image">
|
2018-09-21 18:38:48 +02:00
|
|
|
<img class="ui medium rounded image" src="/static/download/transfer.svg" style="height:109px;width:261px;margin-bottom:1rem;" />
|
2018-05-07 23:59:29 +02:00
|
|
|
</div>
|
|
|
|
<div class="content">
|
|
|
|
<div class="description">
|
|
|
|
<span class="ui yellow circular label">2</span>
|
2018-05-31 00:42:17 +02:00
|
|
|
<strong>${lf("Move the .uf2 file to the EV3 Brick")}</strong>
|
2018-05-07 23:59:29 +02:00
|
|
|
<br />
|
|
|
|
<span style="font-size:small">${lf("Locate the downloaded .uf2 file and drag it to the EV3 USB drive")}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-01-30 00:21:15 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>`;
|
|
|
|
|
|
|
|
return confirmAsync({
|
|
|
|
header: lf("Download to your EV3"),
|
|
|
|
htmlBody,
|
|
|
|
hasCloseIcon: true,
|
|
|
|
hideCancel: true,
|
|
|
|
hideAgree: false,
|
|
|
|
agreeLbl: lf("I got it"),
|
2018-05-07 23:59:29 +02:00
|
|
|
className: 'downloaddialog',
|
2019-09-27 15:53:26 +02:00
|
|
|
buttons: [canUseWebSerial() ? {
|
|
|
|
label: lf("Bluetooth"),
|
|
|
|
icon: "bluetooth",
|
|
|
|
className: "bluetooth focused",
|
|
|
|
onclick: () => {
|
|
|
|
pxt.tickEvent("bluetooth.enable");
|
|
|
|
enableWebSerial();
|
|
|
|
confirmAsync({
|
|
|
|
header: lf("Bluetooth enabled"),
|
|
|
|
hasCloseIcon: true,
|
|
|
|
hideCancel: true,
|
|
|
|
buttons: [{
|
|
|
|
label: lf("Help"),
|
|
|
|
icon: "question circle",
|
|
|
|
className: "lightgrey",
|
|
|
|
url: "/bluetooth"
|
|
|
|
}],
|
|
|
|
htmlBody: `
|
|
|
|
<p>
|
|
|
|
${lf("Please download again to send your code to the EV3 over Bluetooth.")}
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
${lf("You will be prompted to select a serial port.")}
|
|
|
|
${lf("On Windows, look for 'Standard Serial over Bluetooth link'.")}
|
|
|
|
${lf("If you have paired multiple EV3, you might have to try out multiple ports until you find the correct one.")}
|
|
|
|
</p>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
}
|
|
|
|
} : undefined, downloadAgain ? {
|
2018-01-30 00:21:15 +01:00
|
|
|
label: fn,
|
|
|
|
icon: "download",
|
2018-05-01 19:08:05 +02:00
|
|
|
className: "lightgrey focused",
|
2018-01-30 00:21:15 +01:00
|
|
|
url,
|
|
|
|
fileName: fn
|
|
|
|
} : undefined, docUrl ? {
|
|
|
|
label: lf("Help"),
|
|
|
|
icon: "help",
|
2018-05-01 19:08:05 +02:00
|
|
|
className: "lightgrey",
|
2018-01-30 00:21:15 +01:00
|
|
|
url: docUrl
|
|
|
|
} : undefined]
|
|
|
|
//timeout: 20000
|
|
|
|
}).then(() => { });
|
|
|
|
}
|
2018-01-04 01:18:39 +01:00
|
|
|
};
|
|
|
|
initAsync().catch(e => {
|
|
|
|
// probably no HID - we'll try this again upon deployment
|
|
|
|
})
|
|
|
|
return Promise.resolve<pxt.editor.ExtensionResult>(res);
|
2017-07-06 18:34:31 +02:00
|
|
|
}
|
2017-07-25 12:48:02 +02:00
|
|
|
|
2018-01-04 01:18:39 +01:00
|
|
|
// When require()d from node, bind the global pxt namespace
|
|
|
|
// namespace pxt {
|
|
|
|
// export const dummyExport = 1;
|
|
|
|
// }
|
|
|
|
// eval("if (typeof process === 'object' && process + '' === '[object process]') pxt = global.pxt")
|