Skip to content

Instantly share code, notes, and snippets.

View jaafreitas's full-sized avatar

João Adriano Freitas jaafreitas

View GitHub Profile
#include <SerialDisplay.h>
const int pinOE = D2;
const uint8_t totalModulos = 4;
SerialDisplay displays(D3, D4, totalModulos); // (data, clock, number of modules)
int pwm = 0;
void setup(){
Serial.begin(115200);
displays.setBrightnessPin(pinOE);
@jaafreitas
jaafreitas / gist:415ff4f501ad382b5963f2ea8f5824a9
Created October 4, 2020 03:54
Load a Scratch project file from a URL
const onVmInit = vm => {
// Load a project from a URL. Example: ?project_url=/example.sb3
let projectLoaded = false;
// We need to wait the VM start and the default project to be loaded before
// trying to load the url project, otherwiste we can get a mix of both.
vm.runtime.on('PROJECT_LOADED', () => {
if (!projectLoaded) {
const projectFileMatches = window.location.href.match(/[?&]project_url=([^&]*)&?/);
const projectFile = projectFileMatches ? decodeURIComponent(projectFileMatches[1]) : null;
if (projectFile) {