-
-
-
-
I think we need a bit more info @Aleksandrs. Can you upload firmware or does even that give you errors?
-
Thank you for your extensive answer @Kolban. Now I understand.
-
-
Thank you for taking the time to look into this. Here is the code:
var pinButton = NodeMCU.D3; var pinLed = NodeMCU.D7; var pinRelay = NodeMCU.D6; var statusRelay = false; var statusAlarm = null; var statusAlarmRunning = false; // Initalisation of pins var initializePins = function() { console.log("Initialize pins..."); pinMode(pinRelay, "output"); pinMode(pinButton, "input"); pinMode(pinLed, 'output'); }; var initializeButton = function() { setWatch( longButtonPress, pinButton, { repeat:true, debounce: 2000, edge:"falling"} ); setWatch( buttonPressed, pinButton, { repeat:true, debounce: 70, edge:"falling"} ); }; var buttonPressed = function() { console.log("short press"); statusRelay = !statusRelay; digitalWrite(pinRelay, statusRelay); digitalWrite(pinLed,!statusRelay); }; var longButtonPress=function(){ console.log('long press'); // ESP8266.reboot(); }; function init() { initializeButton(); initServer(); setInterval(function(){ console.log(process.memory()); }, 100000); require("ESP8266").setLog(2); } function playAlarm() { statusAlarmRunning = !statusAlarmRunning; console.log("Toggle relay: " + statusAlarmRunning); digitalWrite(pinRelay, statusAlarmRunning); } function initServer() { var http = require("http"); initializePins(); console.log("Initalizing server instance..."); http.createServer(function (req, res){ var request = url.parse(req.url, true); var action = request.query; if (action) { var target = ""; var setting = ""; for (var key in action){ if (action.hasOwnProperty(key)) { target = key.toLowerCase(); setting = action[key].toLowerCase(); if (statusAlarm !== null) { clearInterval(statusAlarm); statusAlarmRunning = false; statusAlarm = null; } switch(target) { case "switch" : if (setting === "on") { // switch relay on console.log("Switch relay ON"); digitalWrite(pinRelay, 1); digitalWrite(pinLed,0); break; } else if (setting === "off"){ // switch relay off console.log("Switch relay OFF"); digitalWrite(pinRelay, 0); digitalWrite(pinLed,1); break; } else if (setting === "toggle") { statusRelay = !statusRelay; console.log("Switch: Toggle to " + statusRelay); digitalWrite(pinRelay, (statusRelay === true) ? 1 : 0); digitalWrite(pinLed, (statusRelay === true) ? 0 : 1); break; } break; case "status" : console.log("Switch status: " + statusRelay); break; case "alarm" : if (!statusAlarm) { statusAlarm = setInterval(playAlarm, 300); } break; } } } target = null; setting = null; } res.writeHead(200); res.end("Hello World"); }).listen(8080); } E.on('init', function() { init();});
-
When I do a dump() on an ESP8266 (that runs my code perfectly well) it doesn't show all the JS code. At some point the console just stops listing the code and the cursor stays at end of line.
When I do a carriage return (on keyboard), the prompt comes back.
I checked the console log, but nothing strange there.
Any ideas what could cause this?
-
-
Now that I have my SSD1306 working nicely I was looking for information if it is possible to use fancy stuff like scroll, clear an area instead of the whole display, etc...
I noticed that the module is based on code from Sam Sykes. Could it be that it is this: https://github.com/squix78/esp8266-oled-ssd1306? It seems to be do a lot more than currently is possible with the SSD1306 module.
Module code here: http://www.espruino.com/modules/SSD1306.js
Any pointers on how to extend the current functionality?
-
Good catch @Gordon, that solved it!
-
I have defined two images in code. One is shown when wifi is connected/associated, the other is shown when wifi disconnects.
var imgNetworkSignal = { width : 8, height : 8, bpp : 1, transparent : 0, buffer : new Uint8Array([ 0b00000000, 0b00000011, 0b00000011, 0b00011011, 0b00011011, 0b00011011, 0b11011011, 0b11011011, ]).buffer }; var imgNoNetworkSignal = { width : 8, height : 8, bpp : 1, transparent : 0, buffer : new Uint8Array([ 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b11111111, 0b11111111, ]).buffer };
The wifi connected image is correctly shown as soon as soon as the NodeMCU I am using connects to Wifi. When I disconnect from wifi I expect the other image to show, but I still see the wifi-connected image. I need to specifically use a clear-command to remove everything (there is only a wifi-signal image) before showing the wifi-disconnected image. Strangely enough, it works the other way around. This makes me think that the zero's in the wifi-disconnected icon are not correctly resetting the one's from the wifi-connected icon.
var wifiDisconnectImage = function() { console.log("Disconnect icon should show"); graph.clear(); // <- required to clear OLED graph.drawImage(imgNoNetworkSignal, graph.getWidth()-8, 0); graph.flip(); }; var wifiConnectImage = function() { console.log("Connect icon should show"); // graph.clear(); <--- works without the clear graph.drawImage(imgNetworkSignal, graph.getWidth()-8, 0); graph.flip(); };
-
-
Thanks @Wilberforce. I will try to power my Sonoff from external power while connecting tx/rx over the ftdi usb programmer.
-
I am trying to flash a Sonoff with Espruino.
It seems that erasing flash and flashing works, but the Espruino Web IDE does not. After connecting (while holding the button I insert the connected USB programmer into an USB port) I select the correct port and get a connected message in the console. However, the console does not respond to any key I enter.
In Settings -> Console I see:
>>> Connecting... Set Slow Write = true [object Object] Connected [object Object] Found a prompt... great! >>> Sending... ---> "echo(0);\nconsole.log(\"<\",\"<<\",JSON.stringify(process.env),\">>\",\">\");echo(1);\n" Sending block "echo(0);\nconsol", wait 50ms Sent Sending block "e.log(\"<\",\"<<\",", wait 50ms Sent Sending block "JSON.stringify(", wait 50ms Sent Sending block "process.env),\">", wait 50ms Sent Sending block ">\",\">\");echo(1)", wait 50ms Sent Sending block ";\n", wait 50ms Sent >>> Sent WARNING: No result found - just got "" Device found (connectionId=9) >>> Connected to port COM4
Please note the: Warning No result found - just go"". This has been discussed in this thread too, however the suggestions do not seem to work.
Also when connecting to the Sonoff through Putty does not show any characters coming from Sonoff.
After each erase or flash I disconnect the Sonoff from my PC.
I appreciate any suggestions to try.
-
-
This seems to have solved the issue @virtualcodewarrior reported above for me too. However, after doing a dump() (after doing a 'Send to Espruino' in the WebIDE) I see the original code that is available right after flash below my own code:
pinMode(D0, "input_pullup"); pinMode(D2, "opendrain"); pinMode(D4, "input_pullup"); pinMode(D5, "input_pullup"); pinMode(D12, "input_pullup"); pinMode(D13, "input_pullup"); pinMode(D14, "input_pullup"); pinMode(D15, "input_pullup");
How do I get rid of that?
-
Has anyone tested my changes? @Gordon?
Is there a chance that my changes make it to the version in the Chrome store? If so, would I need to initiate that? How?
Thanks!
-
-
@conor Thank you for the update. Visual Studio is what I am planning to use it with too!
-
@Gordon I moved my changes from editorBlockly.js and code.js to editorJavascript.js. Seem to work...
Anyone wants to try?
-
Without using the setting @Gordon referred to I have been able to get it working to my liking, including making it an option in General Settings. Not sure about the quality of my code, so I will not submit my changes. However, most likely tomorrow I will make a version available from my own site so someone can have a look at it.
Any objections?
-
For future reference, he is some information for people who want to try running the Espruino command line version on Windows (10).
The requirements are pretty well described here: http://www.serverpals.com/blog/building-using-node-gyp-with-visual-studio-express-2015-on-windows-10-pro-x64
I had to install Python 2.7(.11). The latest version of Python did NOT work so get version 2.7. I already had Visual Studio 2015 Community Edition installed. Make sure you select the Visual C++ option during your install.
Other requirements for me were:
- SET PYTHON=C:\Python27 (The installer put Python in that folder)
- Just to be sure I added the Python path also to my path with SET PATH=%PATH%;C:\Python27
- Open a Command Prompt with Administrative rights!
After make sure everything was installed correctly I was able to use NPM install -g Espruino for a successful install. Unfortunately, I don't have an Espruino (or ESP8266) with me to test if it works. If nothing is connected to a serial port, then starting Espruino comes up with an error:
C:\WINDOWS\system32>espruino Espruino Command-line Tool 0.0.13 ----------------------------------- C:\Program Files (x86)\nodejs\node_modules\espruino\bin\espruino-cli.js:277 throw new Error("No Ports Found"); ^ Error: No Ports Found at C:\Program Files (x86)\nodejs\node_modules\espruino\bin\espruino-cli.js:277:15 at eval (eval at loadJS (C:\Program Files (x86)\nodejs\node_modules\espruino\index.js:9:15), <anonymous>:56:11) at eval (eval at loadJS (C:\Program Files (x86)\nodejs\node_modules\espruino\index.js:9:15), <anonymous>:13:12)
- SET PYTHON=C:\Python27 (The installer put Python in that folder)
Would be nice if it could be added!
Thank you @ClearMemory041063 and @Kolban for explaining!