scratchfoundation / scratch-extension-docs Goto Github PK
View Code? Open in Web Editor NEW[Deprecated] Sample code for Scratch 2.0 hardware and web extensions.
[Deprecated] Sample code for Scratch 2.0 hardware and web extensions.
When someone removes an extension from a project, the ext._shutdown() function is not called.
Steps to reproduce:
I'm not certain about the semantics for this; perhaps there is something like ext.trigger('greenFlag'). In any event, it would be particularly helpful in large extensions.
When an exception occurs it would be nice to be able to stop all scripts from executing. We can notify the user via a js alert, but if they're using a loop the alert will keep coming back unless we have a way to stop all scripts.
In scratch_ext.js, extension will disconnect if there is no data read. However, The extension has no ideas when data comes from HID. So we need to keep polling even there is no data. Scratch shouldn't disconnect just because there is nothing to read.
this.read = function(len) {
if(!dev) return null;
if(!len) len = 65;
var data = dev.read(len);
if(window.ActiveXObject) data = data(len);
if(data.byteLength == 0) disconnect();
return data;
};
Would it be possible when specifying the block text in the .js file to also specify a block color?
I am writing an extension that will have similar functionality for several hardware devices and would like to classify/separate the device types by color.
Also, it would be nice to be able to draw a separator line between any given blocks so that "classes" of extension blocks would be more apparent.
Hi.
I'm experiencing problems in HID extension. Sometimes the extension keeps reconnecting device. And if I upload an extension. The scratch won't work if I restart my computer. Unless I remove extension from server and re-add the extension.
Now I see source JS code handling HID is compressed. So I can not add breakpoints or modify code to locate the source of problem. If I can open uncompressed code in chrome it will help a lot in debugging.
Thanks
Hi.
I have a HID hardware with has 3 interfaces (or there will be trouble on Mac). The first interface in a keyboard, the second one is a gamepad and the third is a raw data one
I have a protocol to communicate with the third port. However when I open a device in scratch, the id is the first interface's. I don't have an option to choose the other interfaces.
However I can change my firmware to make the desired interface the first one and I made it work. I wish there is a parameter for interface.
if (e.hid) {
var s = n.hid_list(),
a = e.hid;
for (var f = 0; f < s.length; f++) {
var t = a[s[f].vendor_id + "_" + s[f].product_id];
t && r[t]._deviceConnected(new m(s[f].path, t))
}
}
Here is info from HIDAPI java library:
HIDDeviceInfo [path=?\hid#vid_94d8&pid_0055&mi_00#9&39c54981&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}, vendor_id=38104, product_id=85, serial_number=?, release_number=1, manufacturer_string=Microchip Technology Inc., product_string=Analog Keyboard, usage_page=65280, usage=1, interface_number=0]
HIDDeviceInfo [path=?\hid#vid_94d8&pid_0055&mi_01#9&2201bd3c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}, vendor_id=38104, product_id=85, serial_number=?, release_number=1, manufacturer_string=Microchip Technology Inc., product_string=Analog Keyboard, usage_page=1, usage=6, interface_number=1]
HIDDeviceInfo [path=?\hid#vid_94d8&pid_0055&mi_02#9&756a6ed&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}, vendor_id=38104, product_id=85, serial_number=?, release_number=1, manufacturer_string=Microchip Technology Inc., product_string=Analog Keyboard, usage_page=1, usage=5, interface_number=2]
It would be useful to have an argument type that would accept an integer or string in addition to a drop down menu. The same way the "point in direction" blocks works.
The ability to add a divider with an optional title would be helpful in keeping extension blocks organized.
If I go to the More Blocks/Add an Extension/My Extensions and I load my extension, the blocks are shown correctly.
However, if I save the blocks to an .sb2 project, when I load that project, the blocks do not load.
This is new behavior.
Have JavaScript extensions been disabled when loading from a .sb2 file?
I believe the "Blocks" section of the extension doc has the definitions of asynchronous and synchronous reversed. Asynchronous means send the message and don't wait, while synchronous means send the message and "wait" (for reply, action, callback, etc.). I think the hat block is synchronous and that designation is correct.
Will it also be able to add new menu items to the Editor's menus?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.