Most recent activity
-
Well, optimizing for speed is often bad for readability. I wouldn't add "+0.5" to the code, just to save the time needed for this extra operation.
And yes, numbers in square brackets are not rounded to an integer. And we all love code like this:>foo={"0.5": "bar", "1": "foo"}; >foo[0.5]; ="bar" >foo[Math.round(1.5)]; ="foo"
Since prepareDisplay is one of the slowest functions: ColorMap has only 8 different values, Temperature has 208 different values - so it might be feasible to pre-compute things and avoid all division and multiplication operations with Temperature in this function - if there's enough RAM available on the ESP32. Anyway, that's much harder than just removing rounding and clamping for TemperatureMap values. Removing 262 function calls will result in a measurable improvement, even for the compiled version.
-
Just looked at the code, and I think there are still options for improvement: All the clamping and rounding for TemperatureMap values can be omitted:
>let foo = new Uint8ClampedArray(3); =new Uint8ClampedArray(3) >foo[0] = -0.5; foo[1] = 1.5; foo[2] = 255.5; =undefined >foo =new Uint8ClampedArray([0, 1, 255])
One day I'll test this code, I think the effect will be nice.
-
-
I don't think it is easy to fix, especially without breaking existing code. Maybe it is possible to change
digitalPulse(csPin, true, [1, 1, 0.03, 0.03, 0.045]);
to
digitalPulse(csPin, false, [1, 0.03, 0.03, 0.045]);
and get the desired pulse, just a a little delay. Then there would be no code change required, just a note in the documentation.
-
The neopixel module for ESP8266 does a dry-run/pre-roll without emitting any pulses. That dry run is necessary to load the machine code from flash into RAM. Without this dry run the timing of the pules representing the first byte won't have proper timing. It might be the same issue in this case. Reference files:
jswrap_neopixel.c, line 220...
jswrap_io.c, line 201...There is no dry-run for ESP8266 in jswrap_io.c, so I would assume it is the same issue. That code is not capable of producing very short pulses accurately in the first run.
-
A simple FET switch might be all thats needed to turn off the juice to the Neopixel hogs or a relay as indicated in post #2 What about using a pin on the Espruino to control a Buck step-up converter that would supply the 5V? hummmmmm . . . .
Neopixel shall be connected with ground first, i.e. a simple FET wouldn't be a good solution. Get a high rail FET, e.g. MIC94060 or something else with an internal charge pump.
-
-
Your Adruino code looks complicated, and I'm not sure if it's correct, or if you're overwriting the variable IncomingString in the while loop.
The sample code for serial input from https://www.javatpoint.com/arduino-serial-available:
I'd suggest to remove the while and the true/false in your code, and change it according to the sample code.