Commit graph

162 commits

Author SHA1 Message Date
Evelyn Eastmond
53c165c2f6 Close Scratch Link web socket on every new peripheral scan attempt (#1696)
* Progress towards: #1671: Close web socket before making a new one for hardware extensions.

* Always disconnect before scanning for new peripheral.  Removing console logs.

* Removing unused test code.
2018-11-08 15:21:28 -05:00
Eric Rosenbaum
eef1885fad
On websocket error, use sendRequestError instead of disconnect (#1736) 2018-11-07 10:25:09 -05:00
Karishma Chadha
fd5e178d3b
Merge pull request #1703 from kchadha/cloud-io
Cloud IO
2018-10-30 11:57:20 -04:00
Karishma Chadha
991d7be7f4 Fix documentation of cloud io device. 2018-10-29 18:31:35 -04:00
Karishma Chadha
4959ab9ff3 Create a new cloud io device 2018-10-29 00:58:30 -04:00
Paul Kaplan
e002db48f2 Add logic to trigger click hats on mouse up on a draggable target
As long as the event was not a drag
2018-10-25 15:08:37 -04:00
Paul Kaplan
ef50092daa Make when clicked hats trigger on mouse down 2018-10-25 14:06:36 -04:00
Evelyn Eastmond
2564b24d71 Differentiate peripheral errors: request vs. disconnect (#1654)
* Beginning to add differentiation for hardware disconnect alerts.

* Set connected status after error is sent.
2018-10-17 15:48:07 -04:00
Evelyn Eastmond
1efead8a26 Resolves #1615: Prevent multiple hardware disconnect alerts. 2018-10-05 11:24:52 -04:00
Evelyn Eastmond
cce03d0304 Removing console logs. 2018-09-22 15:20:35 -04:00
Evelyn Eastmond
3c905503b7 Adding extension ids to customize error alerts for extensions. 2018-09-22 14:48:41 -04:00
Evelyn Eastmond
ad3328197e Testing adding message/extensionId passing into specific, custom alerts. 2018-09-22 14:04:37 -04:00
Evelyn Eastmond
96327c66f3 Passing custom alert messages with PERIPHERAL_ERROR. 2018-09-22 14:04:37 -04:00
Evelyn Eastmond
ec432e3b2f Refactor for hardware extensions (#1555)
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.

* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.

* Changing 'device' to 'peripheral', etc.

* Changing 'session' to 'socket'.

* Fixing EV3 menus and menu arg validation, reordering functions, etc.

* Add _send, add some references to documentation, etc.

* Factored out _outputCommand and _inputCommand, renamed some enums, etc.

* Fixed _outputCommand, some other minor cleanup.

* Make _outputCommand and _inputCommand public.

* Added TODO.

* Renamed BLE UUID enums to be clearer.

* Change WeDo2 in comments to WeDo 2.0, etc.

* Changed some WeDo2Motor command names, cleaned up some JSDocs.

* Beginning a major EV3 refactor.

* WeDo2 formatting and comment changes.

* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.

* Add reminders to possibly cast motor menu args in WeDo2.

* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.

* Factoring EV3 polling value commands, etc.

* Fixing EV3 motor power, position and button pressed, and some commenting, etc.

* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.

* Changed WeDo2 motor label enum name.

* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.

* Fixing comments and documentation.

* Some commenting.

* Adding further documentation and references to PDFs, changed reply check to be safer, etc.

* Some comment changes.

* Moving some functions around in EV3 and WeDo2 to match.

* Commenting, etc.

* Some renaming of session, etc.

* Fix stopAllMotors in EV3.

* Fixing clearing of motors in EV3.

* Some comment changes.

* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.

* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.

* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.

* Adding a reminder to rename something.

* JSDoc fix in EV3Motor class.

* Fixing microbit function name.

* Adding a todo item.

* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.

* Fixing EV3 ports again, and button pressed returning a boolean.

* Fixing menu value to be a string in EV3.
2018-09-07 17:01:23 -04:00
Evelyn Eastmond
5320dfb676 WeDo2 backwards compatibility update (#1518)
* Resolving #1492: No longer trying to make WeDo2 backwards compatible with Scratch Link API v1.0.

* Closing the socket on all BLE/BT errors.

* Adding BT disconnection.
2018-08-22 17:45:26 -04:00
Evelyn Eastmond
5395f9c321 WeDo2 changes for upcoming smoke test (#1493)
* Starting on #1491: use 'startNotifications' instead of 'read'.  Still need to make backwards compatible.

* Fixing #1489: WeDo2 set light color block should wrap values to 0-100.

* Fixing #1488: WeDo2 should not clear LED light on stop button.

* Fixing to support negative LED light color inputs.

* Removing a binding.

* Using wrapClamp for inputHue for LED color block.
2018-08-19 22:09:57 -04:00
Eric Rosenbaum
83b3eabf1d
Regulate micro:bit send timing (#1471)
* display blocks yield for 50ms

* WIP on microbit command send timing

* WIP on microbit command send timing

* Cleanup and JSDOC

* Send “withResponse” param to Link

* Remove caching, add busy timeout
2018-08-16 15:38:03 -04:00
Evelyn Eastmond
82df80a04c Fixing lint error. 2018-08-15 11:44:49 -04:00
Evelyn Eastmond
d61f6e3d6f Fixing #1460: 'set motor direction' block should work while a motor is running. 2018-08-15 11:39:26 -04:00
Evelyn Eastmond
f01733f019 WeDo2 Extension: First Pass (#1441)
* Adding WeDo2 connection/disconnection over Scratch Link BLE.

* Testing motor and LED output.

* Reading sensor attachment and registering for sensor notifications.

* Motor indexing.

* Some refactoring notes.  Moving some functions around.

* Refactoring and enums.

* Removing some comments

* Fixing linting error.

* Fixing tilt reporter values and added stopAll bound to stop button to stop piezo, LED and motors.
2018-08-13 17:10:55 -04:00
Paul Kaplan
ac550d2d38
Merge pull request #1387 from paulkaplan/userdata-io-device
Add UserData ioDevice for setting and getting username from blocks
2018-07-24 15:13:15 -04:00
Evelyn Eastmond
6444cf071d Feature/critical extension fixes (#1383)
* Resolves - Turning micro bit power off doesn't disconnect microbit #1366.

* Resolves EV3 motor block causes distance to return 0 #1363.

* Fixing linting.

* Tweak micro:bit auto-disconnect timeout.
2018-07-24 11:08:48 -04:00
Paul Kaplan
6d4c6df692 Add UserData ioDevice for setting and getting username from blocks 2018-07-23 09:38:58 -04:00
Evelyn Eastmond
c4ee7065a2 EV3/Microbit critical fixes for code freeze (#1354)
* Resolves - BLESession and BTSession should emit PERIPHERAL_SCAN_TIMEOUT #1348.

* Resolves - BLESession should handle 'could not find service' error #1350.

* Resolves - BTSession should handle 'no peripheral connected' error #1351.

* Fixing a typo that caused device scan timeout bugs.

* Resolves - Add casting and clamping throughout the EV3 extension #1352.

* Fixing a linting error.

* Further fixes for issue #1351.
2018-07-17 16:03:05 -04:00
Eric Rosenbaum
1dcdfc9548
Use secure web socket address for ble and bt connection (#1359) 2018-07-17 15:40:47 -04:00
Evelyn Eastmond
133ade7f48 EV3 port and sensor polling updates (#1342)
* Add motor rotate, without coasting yet.  Fixed some todos.

* Removing logging.

* Implemented motor set position, motor set power, and beep note for time blocks.  Changed labels on motor blocks.  Tracking motor speeds for all ports.

* Fixing motor ports to 0-3 and then output bit field when sending commands.

* Added stop all motors with stop button.  Added port masking function.  Some cleanup.  Moved beeping up an octave.

* Combine device list polling and sensor polling into a single timeout call, device list requested every 20 times.

* Don't reset sensors on device update.  Don't store undefined sensor/motor values.  Some comments.

* Fixing some linting.
2018-07-13 13:14:53 -04:00
Paul Kaplan
82a33691d3 Set internal connected flag before emitting event 2018-07-10 15:57:25 -04:00
Eric Rosenbaum
1cc013ea1b Stringify errors 2018-07-09 13:49:41 -04:00
Evelyn Eastmond
d79efbece8 Some logging cleanup. 2018-07-09 13:49:41 -04:00
Eric Rosenbaum
6f5ff31eb3 Add disconnectExtensionSession and getPeripheralIsConnected 2018-07-09 13:49:41 -04:00
Evelyn Eastmond
613a9f96c3 Adding initial test polling for EV3 distance sensor data. 2018-07-09 13:49:41 -04:00
Evelyn Eastmond
0280966a61 Connected Ev3 extension to device connection modals. 2018-07-09 13:49:40 -04:00
Evelyn Eastmond
2d8ad05a78 Adding Ev3 extension with three test blocks to latest device-connection work, auto-connecting to device for now. 2018-07-09 13:49:40 -04:00
Evelyn Eastmond
4332725d33 Adding more errors based on web socket onerror and onclose. Moved extension runtime mapping of devices back to MicroBit class. 2018-07-09 13:41:57 -04:00
Evelyn Eastmond
9d66c54f8a Adding error reporting to runtime from BLESession. 2018-07-09 13:41:57 -04:00
Evelyn Eastmond
73cc149783 Adding promises to return on BLE write. Some refactoring. 2018-07-09 13:41:57 -04:00
Evelyn Eastmond
701f430e56 Remove pinging in BLE connection. 2018-07-09 13:41:57 -04:00
Evelyn Eastmond
730b798686 Extension/runtime protocol refactoring. 2018-07-09 13:41:57 -04:00
Eric Rosenbaum
d778ddf00e wip 2018-07-09 13:41:57 -04:00
Evelyn Eastmond
d09c3f0418 MicroBit extension, Scratch Link first draft. (#1230)
* First microbit gui tests

* Fixed JSONRPC inheritance.  Renamed ScratchBLE/ScratchBT files.  Removed ScratchBT test code from Microbit extension.  Renamed addLine to log.

* Fixed log comments.  Removed addLine from Microbit.

* Adding auto-connect to Microbit at extension loading.  Adding hack for displayText block to Scratch-Link.

* Resolved merge conflicts and brought in latest microbit extension example code.

* Updated microbit write tests for displayText and displaySymbol blocks.  Some linting.

* Some linting and adding of BLE Characteristic consts.

* Linting fixes.

* Moving micro:bit device connection code all to the MicroBit class, decoupling Scratch3MicroBitBlocks from connection code.

* Removing old disconenct handlers from MicroBit class.  Moved service into new BLEUUID data structure.

* Renamed _write to _send.  Moved all BLE encoding concerns to the _send method.

* Using the util log.  Some linting.

* Added _read method to MicroBit class.  Renamed _send to _write.

* Some linting and formatting comments.

* First pass at peripheral chooser pattern for ScratchBLE.

* Testing characteristicDidChange events, and some changes to ScratchBLE on ready events.

* Refactoring work on PeripheralChooser and ScratchBLE.

* Some variable renaming and method signature stubs.

* Peripheral chooser method signatures.

* Moved base64 encoding/decoding to util.  Some method signature formatting.

* Adding test stubs for new util and io classes.

* Adding test stub for MicroBit extension.

* Clean up for PR.

* Clean up for PR.

* Final cleanup for PR.

* Removed logging to console.

* Adding 'btoa' and 'atob' node modules and using them in Base64Util.
2018-06-18 14:56:51 -04:00
kchadha
a85f641d25
Merge pull request #1148 from kchadha/stage-layering
Layer group ordering.
2018-05-25 09:10:05 -04:00
Eric Rosenbaum
508ac91b82 Runtime emits key pressed event 2018-05-22 17:24:22 -04:00
Karishma Chadha
5e40bfb7ee No more explicit layer groups, and separate extension into video and pen. 2018-05-20 22:30:20 -04:00
Karishma Chadha
67b114b9c9 Layer group ordering. 2018-05-15 22:22:44 -04:00
Eric Rosenbaum
9979391200
Merge pull request #1085 from ericrosenbaum/feature/key-droppability
Re-write keyboard IO for droppability support
2018-05-03 11:10:24 -04:00
Eric Rosenbaum
49802688dd Move key name strings to top 2018-05-02 15:34:17 -04:00
Eric Rosenbaum
23dd898daf Use obj.map (can’t use obj.values) 2018-05-02 09:52:04 -04:00
Eric Rosenbaum
85ac307261 Access key name strings from a getter 2018-05-01 09:01:36 -04:00
Eric Rosenbaum
fbeaec600c Detect arrow keys on Windows Edge 2018-04-30 17:06:23 -04:00
Eric Rosenbaum
64869e5a87 Check for “ “ (the space char) 2018-04-30 17:05:33 -04:00
Karishma Chadha
857f77c511 Addressing PR comments. 2018-04-29 19:52:21 -04:00
Karishma Chadha
271a19c05d Add runtime/render related functionality back to VM. 2018-04-26 19:17:41 -04:00
Karishma Chadha
5f4139cbe4 Use video provider instead of making call to getUserMedia directly. 2018-04-26 13:24:31 -04:00
Eric Rosenbaum
999fb10d15 Re-write keyboard IO for droppability support 2018-04-25 11:58:50 -04:00
Eric Rosenbaum
2590cf53e7 wip 2018-04-23 17:49:01 -04:00
Paul Kaplan
978906d926 Activate stage click hats if no other clicks are hit.
Also check the bounds before to make sure clicks are inside the stage bounds.
2018-04-23 14:25:58 -04:00
Paul Kaplan
0838f6c875 Remove duplicate play 2018-04-13 11:12:44 -04:00
Paul Kaplan
71333765c9 Use new mediaDevices API for getUserMedia 2018-04-13 11:08:32 -04:00
Corey Frang
fe7aa8a78f
Add @param documentation for the frameInfo descriptor param 2018-04-10 13:59:23 -04:00
Corey Frang
a86202b8e2
make onError a prototype method 2018-04-10 13:59:23 -04:00
Corey Frang
0180964333
Simplify setup method promise, add onError 2018-04-10 13:59:23 -04:00
Corey Frang
89dd4720a4
store ghost state so previews will use last value whenever setup 2018-04-10 13:59:23 -04:00
Corey Frang
d0a71dcaf9
store the ghost effect in case preview is setup after it was last set 2018-04-10 13:59:23 -04:00
Corey Frang
9cd5e4da2b
Reduce indentation waterfall 2018-04-10 13:59:22 -04:00
Corey Frang
f3a956af2b
add enabled state tracking, disable state waits for setup complete 2018-04-10 13:59:22 -04:00
Corey Frang
ce03e978dc
stop the track in the "on-off" scenario 2018-04-10 13:59:22 -04:00
Corey Frang
825ff22fa4
Guard against some issues that could happen with enable/disable video quickly 2018-04-10 13:59:22 -04:00
Corey Frang
f19ae793c0
enableVideo - get rid of "requests" 2018-04-10 13:59:22 -04:00
Corey Frang
efa6b3a069
stop track 2018-04-10 13:59:22 -04:00
Corey Frang
46b4ef4d80
Use a global mirror state 2018-04-10 13:59:21 -04:00
Corey Frang
90166dc732
Add extra control blocks for video transparency and on/off control 2018-04-10 13:59:21 -04:00
Corey Frang
e4bd9cf6b2
Move methods around to sort the public interface nearer the top 2018-04-10 13:57:54 -04:00
Corey Frang
992e884668
Make disableVideo a public method 2018-04-10 13:57:54 -04:00
Corey Frang
d512042415
Add set preview ghost 2018-04-10 13:57:54 -04:00
Corey Frang
da05e673fa
_singleSetup makes more sense 2018-04-10 13:57:54 -04:00
Corey Frang
c10696f88c
Rewrite the setup/disable process from review comments 2018-04-10 13:57:53 -04:00
Corey Frang
eef88f6c2d
First draft of video IO device 2018-04-10 13:57:53 -04:00
Paul Kaplan
140094a7ad Make "when clicked" blocks target dependent.
This involves adding a new opcode, event_whenstageclicked, and adding a
method to the blocks container to update the opcode pair depending on
whether the target is the stage. This method is then called in two
places: first after the sb2 import parses the blocks (not done in the
sb2 parsing itself because no other blocks are target specific) and then
again when blocks are shared between targets.

Also added tests for the block container method, and a fixture project
that tests the opcode splitting on sb2 import.
2018-03-20 10:41:50 -04:00
Karishma Chadha
d51a2ad39f Use wasDragged flag to selectively activate 'when this sprite clicked' block on mouse up. 2018-02-28 16:45:26 -05:00
Florrie
be83c0ee74 Mouse wheel IO system
Towards fixing #865. This adds an IO class for detecting the mouse wheel
being scrolled. Basic tests are included; they mock the runtime to see
what blocks are activated by scrolling.
2018-01-26 17:13:01 -04:00
Paul Kaplan
327d1179d9 Update the mouse io to give scratch coordinates and client coordinates
Fixes GUI #642 https://github.com/LLK/scratch-gui/issues/642

Fixes GUI #179 https://github.com/LLK/scratch-gui/issues/179
2018-01-09 10:37:16 -05:00
Paul Kaplan
bbcb6bd5b7 Differentiate clamped from non clamped mouse io data (GUI#179) 2018-01-09 09:42:16 -05:00
Andrew Sliwinski
b78bdb4c93 Address feedback from review 2017-11-27 15:00:53 -05:00
Andrew Sliwinski
a8c629dc9b Replace 'got' module with 'nets'. Resolves GH-802 2017-11-20 17:04:17 -05:00
Ray Schamp
32bc087bba Fix remaining lint issues 2017-08-26 13:24:10 -04:00
Christopher Willis-Ford
9d306962bd Fix socket.io-client dependency problems re: build
The Socket.io client library pulls in some extra dependencies in a way
that isn't fully compatible with Webpack. Switching to their build
output file, instead of the file specified in their `package.json`,
makes those errors go away.
2017-05-11 12:07:46 -07:00
Christopher Willis-Ford
35d0544ce0 Respond to review comments
- Pin `got` and `socket-io.client`
- Finish removing `removeSocket`-related code
2017-05-05 10:37:29 -07:00
Christopher Willis-Ford
e096f43487 DeviceManager: add more jsdoc, remove _sockets
It turns out we don't need the Device Manager to centrally track each
socket, so this change removes the Device Manager's `_sockets` property
and related code.
2017-05-03 16:28:06 -07:00
Christopher Willis-Ford
9a9c509e76 Implement a few tests for io/deviceManager 2017-04-28 14:50:57 -07:00
Christopher Willis-Ford
f3c6be2881 Add an I/O device to represent the Device Manager 2017-04-28 13:40:13 -07:00
Ray Schamp
a4f095db5e Use ES6 style classes 2017-04-17 19:42:48 -04:00
Ray Schamp
e01c4ae108 Pass with --fix 2017-04-17 15:10:04 -04:00
Ray Schamp
11e28111c5 Activate click hats on mouse up to match 2.0 2017-03-02 11:32:10 -05:00
SillyInventor
8354774fcf Switch from return null to return empty string in keyCodeToScratchKey 2017-02-09 14:09:01 -05:00
Andrew Sliwinski
1b4a1ca1bc Resolve merge conflicts 2016-10-24 15:53:42 -04:00
Andrew Sliwinski
153df22918 Address feedback from PR review 2016-10-24 15:16:06 -04:00
Andrew Sliwinski
279a9560af Resolve JSDoc lint errors 2016-10-24 12:04:06 -04:00
Andrew Sliwinski
336bc65e2d Add minimal test coverage and docs for mouse module 2016-10-24 11:56:52 -04:00
Andrew Sliwinski
2de58050dd Conform JSdoc for keyboard module to format used elsewhere 2016-10-24 11:40:07 -04:00
Ray Schamp
7712b2902f Fix quote-props 2016-10-24 11:02:19 -04:00