-
Likely I will use an ESP32 board with the PSRAM once those are supported for JSVars in order to have more memory to store historical data
The esp32 build has 1mb devoted to a flash file system. That should be plenty of space to log to, with no extra hardware. The normal
fs
module andfile
objects work as if it is an sd card. If you buffer to ram, and then write 4096k chunks, it should be pretty easy on the flash. -
-
I think you are expecting your
setTimeout('pause()', 20);
to delay the running of the code for 20 milliseconds.....What you have written is basically this:
while (1) { digitalWrite(A4, 0); digitalWrite(B4, 1); digitalWrite(B3, 0); digitalWrite(A4, 1); digitalWrite(B4, 0); digitalWrite(B3, 1); }
So it is looping forever toggling the state of the pins. It is also adding new timeouts, faster than they can be executed.
The timeout calls are a callback. This means that
pause()
will be called 20 milliseconds later, however the next statementdigitalWrite(B4, 1);
gets written straight away - it does not wait 20ms before doing that.To achieve what you want - you will need to chain calls so that the next action occurs in a call back - not directly.
I hope this helps.
-
Thanks for this guys.
I've pulled and done a build....
The vars have increased after:
>ESP32.enableBLE(false); Erasing saved code. Done! >process.memory(); ={ "free": 4238, "usage": 62, "total": 4300, "history": 4, "gc": 0, "gctime": 3.282 }
WARNING: Bluetooth is disabled per ESP32.enableBLE(false) WARNING: has simple connection not implemented yet
The last message suggests that some intialisation code is still running?
The NRF object is still visible - I'm not sure if this is an issue or not.
Do you want to continue the conversation here or on github?
-
-
-
-
The esp32 esp-idf allows a string to be sent - can you think of a way of keeping the existing code and also using the output as a string ? I suppose it could be done with the #ifdef but wondering if there is a cleaner way?
-
-
Great to hear you have an esp32 to play with now!
I think @JumJum has made more progress on the uart - however has not updated any github repository yet.
I'm trying to get the Bluetooth scanning working - I'm trying to connect to a digital thermometer called a Tilt - however at this stage can set it with scans using the esp32. I don't know if it's an implementation issue on esp32. I've managed to get a puck working- so I'll try a scan on that and compare the output.
-
Hi @Joakim, I'm getting this:
root@office-pc:~/builder/rollup# rollup -c [!] Error: Cannot find module 'lodash.forEach' Error: Cannot find module 'lodash.forEach' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15) at Function.Module._load (internal/modules/cjs/loader.js:497:25) at Module.require (internal/modules/cjs/loader.js:626:17) at require (internal/modules/cjs/helpers.js:20:18) at Object.<anonymous> (/root/node_modules/rollup-plugin-espruino/dist/index.cjs.js:8:31) at Module._compile (internal/modules/cjs/loader.js:678:30) at Module._extensions..js (internal/modules/cjs/loader.js:689:10) at Object.require.extensions..js (/root/.nvm/versions/node/v10.1.0/lib/node_modules/rollup/bin/rollup:2834:17) at Module.load (internal/modules/cjs/loader.js:589:32) at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
Any ideas?
Thanks -
-
- Should we use partition free, or is there a better place ?
That 'free' paritition is actually in use! Or it's labelled as such as it's in the flash available list...
And 1 page for a single var is a littlw wasteful!The wifi config is actually stored in esp-idf nvs (non-volatile-storage ) area. There is a partition set up for this (12K) .
http://esp-idf.readthedocs.io/en/latest/api-reference/storage/nvs_flash.html?highlight=nvs
So it would be easy to use this library to store blu config details.
However, as @Gordon has said above - the Storage module might be better.
@MaBe has ported the ESP8266 to store the wifi details in the Storage module:
https://github.com/MaBecker/Espruino/blob/33fa7dcfbb30a2e253416c7e73a89a3fe922efe8/libs/network/esp8266/jswrap_esp8266_network.c#L870-L887So this might be the better way to go. I was considering porting the ESP32 wifi config to use this, as it we can extend the fuctionality to store multiple AP details etc.
Gordon >Use a 'file' in require("Storage") - so use jsfFindFile. jsfReadFile would be perfect but
you can't use it because you won't have any JsVars available :)One way of dealing with this would be that if this setting is changed, the board saves the setting. Then a reboot - is forced - so the system then starts with the new setting?
The number of jsvars could be varied at this point.
Do we need a message during startup, that BLE is disabled ? and 3. Is there a way to make NRF, Bluetooth and others inactive, so they cannot be called by accident ?
Gordon > Not easily. You could add a if (!jsBleActive()) return 0 to every function, and then do:
How about undefining the BLE var ?
Then any use would fail... the exception could have a help message?Is there an option to use of HWReset ?
You mean like a reboot - like I mentioned above?
I don't think it is unreasonable to reboot on a config change if you free up a heap of memory in the process.what should be default setting, with or without BLE ?
Probably on - We have wifi and AP on at the moment and you have to turn off AP, so BLE on by default make sense.
- Should we use partition free, or is there a better place ?
-
-
Thanks. The ble code has been added to master, so this will be part of the normal build now.
Best to erase the flash as the partition table has changed. Sadly there is only 2500 vars now as ble consumes more precious memory. There is more space allocated for js code - 256k - so if you have set up to save code in flash there will be plenty of space for run time jsvars.
Depending on demand, we might need a way of turning on and off ble. And if it off - allocate for space for js vars..
Then there is the vroom with an extra 20,000k of ram - however the support in the ESP-idf 3.0 is not there yet.
-
There's is an mDns library in the esp32 esp-idf library - however it's not been implemented as at the time there was some discussion around using a pure JavaScript module that could then be used across all platforms.
Is this to know what ip to connect to? You can add the MAC address to your router and dish out a static fixed ip on your network as a work around.
As Gordon mentioned, the timers are abstracted in JavaScript. How precise do you want your alarms to be? If they are the only thing running, then the event will get fire and run pretty close to the time.... what is you want to do?
-
Came across these guys as they referenced the esp32 ble stuff.
https://github.com/Moddable-OpenSource
Might be something of interest to someone... there are a few modules written in JavaScript that could be a good reference.
-
-
-
@JumJum published a build here:
You will need to use all bin files, as the partition table is different. Please note that it will be changing from what is in the firmware linked above. You might want to do a flash erase.
If you do get a puck linked to the esp32 as a bridge, please start a new topic and share!
-
See this thread:
http://forum.espruino.com/conversations/298523
Is there a way of tying the build into visual studio Code?