-
Hello,
Sorry this isn't strictly Espruino related but wondering if someone could point me in the right direction.I'm looking at getting 50 of these 1W fibre optic light sources for an art project. https://www.adafruit.com/product/4168
They are simply LEDs that require 12V and 100mA.
My question is what do I need to be able to dim each one individually?
I found this nice PWM LED driver board but each output can only handle 30mA https://www.adafruit.com/product/1429
Do you know of any driver or other idea that could allow me to accomplish this? -
Thanks for replying. It's a very basic scope but works great for simple tasks like this.
Here are the results, I'm no expert but I don't see any spike so I guess we're Ok?
If you can see any issues please let me know.2V DC 0.1ms
1V DC 0.1ms
50ms view of pluses
Video of pluses https://imgur.com/UJp8tJp
-
I have a cheap DIY oscilloscope. Would that do the job? https://www.aliexpress.com/item/1005002761916872.html
This is a bit beyond me. If you can tell me how to set it up and what to look for I'll give it a go.
-
-
After some more playing around I think I misunderstood the AC part.
I don't think it requires AC but rather 'alternating' pulses. When wiring up the counter directly to pins A0 & A1 the following code works.
Can you see any issues with this? It seems to work Ok, but I'm worrying I'm still misunderstanding something.var on = false; setInterval(function() { on = !on; digitalWrite(A0, !on); digitalWrite(A1, on); }, 50);
-
Hello,
I have an electrical mechanical counter that I'd like to control with Espruino.
https://www.ivy-metering.com/russia-market/196.htmlThe counter takes a 5V pulse to count up, which sounds simple but apparently, it is 5V AC, not DC.
Does anyone know how I can pulse 5V AC for 50ms?Thank you
-
-
Has anyone used Espruino with a P3 RGB pixel matrix like this? Where would I begin?
https://www.aliexpress.com/item/P3-RGB-pixel-panel-HD-display-64x32-dot-matrix-p3-smd-rgb-led-module/32728985432.html -
Hi,
I think this is the working code but haven't tested it in a while. Read the comment at the top for the wiring, matrix and Glediator settings.
Let me know if that works or not. I was using the Pico but it shouldn't matter which espruino you use./** Glediator settings Driver: Glediator COM6 Baud 1000000 Colour order: GRB Pixel order: HS_TL */ var fps = 0, buf = new Uint8Array(15*15*3), bufIdx = 0, cmd = ""; function onInit() { SPI1.setup({baud:3200000, mosi:A7}); Serial1.setup(115200, {tx:B6,rx:B7}); Serial1.on('data', function (data) { buf.set(data, bufIdx); bufIdx += data.length; if (data.indexOf("\1") >= 0) { var idx = bufIdx + data.indexOf("\1"); var line = new Uint8Array(buf.buffer, 0, idx); console.log(idx); SPI1.send4bit(line, 0b0001, 0b0011); buf.set(new Uint8Array(buf.buffer, idx, bufIdx-idx), 0); bufIdx -= idx; fps++; } }); var fps = setInterval(function() { console.log('fps: ' + fps); fps = 0; }, 1000); } onInit();
-
The apple-eating animation is a hollow circle that grows from the point of the apple and fades its colour out on each step.
I added a helper function to draw the circle that was fast enough not to affect the frame rate. I don't know much C but I can try port it to be used in the Espruino graphic library.m.drawCircle = function(posX, posY, radX){ var radY = 0; // Decision criterion divided by 2 evaluated at radX=radX, radY=0 . var decisionOver2 = 1 - radX; while (radX >= radY) { m.setPixel(radX + posX, radY + posY); m.setPixel(radY + posX, radX + posY); m.setPixel(-radX + posX, radY + posY); m.setPixel(-radY + posX, radX + posY); m.setPixel(-radX + posX, -radY + posY); m.setPixel(-radY + posX, -radX + posY); m.setPixel(radX + posX, -radY + posY); m.setPixel(radY + posX, -radX + posY); radY++; if (decisionOver2 <= 0) { // Change in decision criterion for radY -> radY+1 . decisionOver2 += 2 * radY + 1; } else { radX--; // Change for radY -> radY+1, radX -> radX-1 . decisionOver2 += 2 * (radY - radX) + 1; } } };
-
Hello, I've just finished writing my version on Snake on Espruino to be played on a 15x15 RGB LED martix board (I can do a write up on how I built it if anyone would be interested).
For the controls I used an analog 2-axis thumb joystick wired onto the Espruino Pico.
You can find the code on GitHub and use it how ever you wish, I've added lots of comments explaining what's going on and by changing the settings at the beginning you'll easily be able to get it working on any similar devices.
Code: https://github.com/owenmcateer/espruino-snakeDemo video https://www.youtube.com/watch?v=C0IXREfDMOk
-
That's an interesting idea. I've also been looking at a similar method where you removed any frame based animation and only use time based animation. So instead of for example "5 spaces per frame" you use "150 spaces per second" and the code decided how to move the item each frame output.
Here is a detailed article on JavaScript game loops and timing: http://www.isaacsukin.com/news/2015/01/detailed-explanation-javascript-game-loops-and-timing
-
Hello,
What is the best method for frame based animations/games to get accurate FPS?
The two methods I've tried are:setInterval(tick, 1000 / 30);
This works well but if the tick() function ever takes longer than the interval time they can begin to stack up on one another.
The second method I've tried is setTimeout from within the tick() function. The only problem I have here is the FPS drop a lot as each frame is tick() excuse time + frame timeout.
function tick() { setTimeout(tick, 1000 / 30); } tick();
Are there any other methods I can look at, like using the system time to decide when to next call tick()?
-
-
-
I just bought a new ESP8266-01 wifi module to use on my Pico but before I solder it onto the Pico shim I want to make sure the ESP8266s firmware is Ok. I connected it to a USB-TTL converter and powered up. On COM6 at 115200 I get the following:
AT+GMR
AT version:0.40.0.0(Aug 8 2015 14:45:58) SDK version:1.3.0 Ai-Thinker Technology Co.,Ltd. Build:1.3.0.2 Sep 11 2015 11:48:04 OK
AT+RST
OK ets Jan 8 2013,rst cause:4, boot mode:(3,0) wdt reset load 0x40100000, len 1396, room 16 tail 4 chksum 0x89 load 0x3ffe8000, len 776, room 4 tail 4 chksum 0xe8 load 0x3ffe8308, len 540, room 4 tail 8 chksum 0xc0 csum 0xc0 2nd boot version : 1.4(b1) SPI Speed : 40MHz SPI Mode : DIO SPI Flash Size & Map: 8Mbit(512KB+512KB) jump to run user1 @ 1000 rŽÃ9l€dÿ Ai-Thinker Technology Co.,Ltd. ready
I want to make sure the Pico can work with this firmware version and the memory 8Mbit(512KB+512KB) before soldering it on. Can somebody confirm?
-
Success! I've got it running the full 225 pixels at 25fps!
I kept tweaking the code and optimising as must as I could with no real change even at 115200. Then I change Serial1 to USB and boom full board working at full fps.
Changing to USB doesn't make it easy to work with but now I have a plug-n-play matrix output stick. -
The slowest baud-rate Glediator has is 115200 which might still be too fast.
I guess it just comes down to too many pixels to process at once. In my 15x15 matrix that is 255 pixels.
225 * 24 bits = 5400 bits
5400 bits * 1.25us = 6.75msIf I could get Glediator to pause after each frame to allow Espruino to shift out the data it might work better but I don't think that's possible. You can't even limit the frame-rate from Glediator which may also be causing problems.
Increasing the Picos input buffer size might work but I've no idea how to do that. -
Here is the full output for two seconds: http://pastebin.com/M5Gien3D
After doing some more research I don't think there is anything wrong with the code and that it's been optimised as much as it can be the problem is there just isn't memory to process so many pixels fast enough. "FIFO_FULL" keeps poping up if I try and send more than around 150 pixels at 25fps. -
I've attached the exact code I used and below is the console output.
idx 4 buf 1000 line 4 idx 109 buf 1000 line 109 idx 2 buf 1000 line 2 idx 109 buf 1000 line 109 idx 2 buf 1000 line 2 idx 109 buf 1000 line 109 idx 4 buf 1000 line 4 idx 111 buf 1000 line 111 idx 4 buf 1000 line 4 idx 110 buf 1000 line 110 idx 4 buf 1000 line 4 idx 110 buf 1000 line 110 idx 2 buf 1000 line 2 idx 110 buf 1000 line 110 idx 4 buf 1000 line 4 idx 110 buf 1000 line 110 idx 5 buf 1000 line 5 idx 110 buf 1000 line 110 idx 4 buf 1000 line 4 idx 110 buf 1000 line 110 idx 4 buf 1000 line 4 idx 109 buf 1000 line 109 idx 3 buf 1000 line 3 idx 110 buf 1000 line 110 idx 2 buf 1000 line 2
With the attached code "line" is only 4 bits in length;
JSON.stringify(line) "new Uint8Array([37,0,37,32])"
Using the original working code I managed to get a complete frame of data in line which I've pasted below.
>USB.print(JSON.stringify(line)); "?\x00?D\x00DD\x00D?\x00?9\x0094\x004/\x00/*\x00*$\x00$ \x00 \x1B\x00\x1B\x17\x00\x17\x13\x00\x13\x0F\x00\x0F\f\x00\f\f\x00\f\x0F\x00\x0F\x13\x00\x13\x17\x00\x17\x1B\x00\x1B \x00 $\x00$*\x00*/\x00/4\x0049\x009?\x00?D\x00DD\x00D?\x00??\x00?D\x00DD\x00D?\x00?9\x0094\x004/\x00/*\x00*$\x00$ \x00 \x1B\x00\x1B\x17\x00\x17\x13\x00\x13\x0F\x00\x0F\f\x00\f\f\x00\f\x0F\x00\x0F\x13\x00\x13\x17\x00\x17\x1B\x00\x1B \x00 $\x00$*\x00*/\x00/4\x0049\x009?\x00?D\x00DD\x00D?\x00??\x00?D\x00DD\x00D?\x00?9\x0094\x004/\x00/*\x00*$\x00$ \x00 \x1B\x00\x1B\x17\x00\x17\x13\x00\x13\x0F\x00\x0F\f\x00\f\f\x00\f\x0F\x00\x0F\x13\x00\x13\x17\x00\x17\x1B\x00\x1B \x00 $\x00$*\x00*/\x00/4\x0049\x009?\x00?D\x00DD\x00D?\x00??\x00?D\x00DD\x00D?\x00?9\x0094\x004/\x00/*\x00*$\x00$ \x00 \x1B\x00\x1B\x17\x00\x17\x13\x00\x13\x0F\x00\x0F\f\x00\f\f\x00\f\x0F\x00\x0F\x13\x00\x13\x17\x00\x17\x1B\x00\x1B \x00 $\x00$*\x00*/\x00/4\x0049\x009?\x00?D\x00DD\x00D?\x00??\x00?D\x00DD\x00D?\x00?9\x0094\x004/\x00/*\x00*$\x00$ \x00 \x1B\x00\x1B\x17\x00\x17\x13\x00\x13\x0F\x00\x0F\f\x00\f\f\x00\f\x0F\x00\x0F\x13\x00\x13\x17\x00\x17\x1B\x00\x1B \x00 $\x00$*\x00*/\x00/4\x0049\x009?\x00?D\x00DD\x00D?\x00??\x00?D\x00DD\x00D?\x00?9\x0094\x004/\x00/*\x00*$\x00$ \x00 \x1B\x00\x1B\x17\x00\x17\x13\x00\x13\x0F\x00\x0F\f\x00\f\f\x00\f\x0F\x00\x0F\x13\x00\x13\x17\x00\x17\x1B\x00\x1B \x00 $\x00$*\x00*/\x00/4\x0049\x009?\x00?D\x00DD\x00D?\x00??\x00?D\x00DD\x00D?\x00?9\x0094\x004/\x00/*\x00*$\x00$ \x00 \x1B\x00\x1B\x17\x00\x17\x13\x00\x13\x0F\x00\x0F\f\x00\f\f\x00\f\x0F\x00\x0F\x13\x00\x13\x17\x00\x17\x1B\x00\x1B \x00 $\x00$*\x00*/\x00/4\x0049\x009?\x00?D\x00DD\x00D?\x00??\x00?D\x00DD\x00D?\x00?9\x0094\x004/\x00/*\x00*$\x00$ \x00 \x1B\x00\x1B\x17\x00\x17\x13\x00\x13\x0F\x00\x0F\f\x00\f"=undefined >
-
I changed that because idx will always been greater than -1 after the first loop because it's get added the value of bufIdx.
The output now is a very low number of idx, basically every bit of data received. The fps count jumps way up to over 200. See the example output below:
fps: 232 29 34 30 29 30 29 7 0 25 28 30 29 29 30 29 29 30 29 29 30 29 29 29 28 28 29 13 0
-
Hi Gordon,
I understand the idea but can't get it to work. It is outputting mostly random colours and the idx.length looks too small. My guess is it's receiving the data but doesn't know where the frame begins or perhaps the frame break "\1" is being included in the output.
I've tweaked your code a bit to get it working but with the problems above.
PS. I've been running this code on both the Pico and orgional Espruino with the same results on both./** Glediator settings Driver: Glediator Baud 115200 Colour order: GRB Pixel order: HS_TL */ var fps = 0, buf = new Uint8Array(15*15*3), bufIdx = 0, cmd = ""; function onInit() { SPI1.setup({baud:3200000, mosi:A7}); Serial1.setup(115200, {tx:B6,rx:B7}); Serial1.on('data', function (data) { buf.set(data, bufIdx); bufIdx += data.length; if (data.indexOf("\1") >= 0) { var idx = bufIdx + data.indexOf("\1"); var line = new Uint8Array(buf.buffer, 0, idx); console.log(idx); SPI1.send4bit(line, 0b0001, 0b0011); buf.set(new Uint8Array(buf.buffer, idx, bufIdx-idx), 0); bufIdx -= idx; fps++; } }); var fps = setInterval(function() { console.log('fps: ' + fps); fps = 0; }, 1000); } onInit();
This outputs the following:
594 594 593 593 594 593 594 594 594 594 594 593 fps: 12 593 594 593 593 593 594 593 594 593 593 594 fps: 11
-
-
Sorry to reopen topic but I think it's the best place. Since my last post here I've built a much bigger RGB LED matrix (15x15) and beginning to run into some serial data issues.
On my 15x15 board I can easily output the first 168 pixels but any more and it all goes wrong. I'm not sure if this is an issue with Glediator, USB2Serial, Espruino reading the serial data or Espruino outputting the SPI data?
I don't believe Espruino is the issue but I'm really not sure what is. The code below does the same as above but outputs the "line" length (the graphic SPI data). For 15x15 it should always be 675 but rarely is..function onInit() { SPI2.setup({baud:3200000, mosi:B15}); var cmd = ""; Serial1.setup(1000000, {tx:B6,rx:B7}); Serial1.on('data', function (data) { cmd+=data; var idx = cmd.indexOf("\1"); while (idx>=0) { var line = cmd.substr(0,idx); cmd = cmd.substr(idx+1); idx = cmd.indexOf("\1"); console.log(line.length); SPI2.send4bit(line, 0b0001, 0b0011); } }); }
And the console returns:
Running onInit()... 0 675 504 664 504 504 602 504 504 504 545 504 1002 219 504 504 504 504 504 504 504 504 504 504 504 1076 147 504 504 833 390 504 504 504 725 1128 88 504 504 504 661 504 504 1077 144 504 504 504 504 504 834 389 504 504 504 904 895
675 only appears a couple of time while 504 appears many but again there are lots of other seemly random lengths.
Is the problem the serial data that's being sent from Glediator or the way I'm detecting a new frame "\1" ?
Let me know if there is anything I can try to debug this or if the magic length 504 means anything? Thanks
I don't think my eletricronic knowledge isn't good enough to create custom pbc using chips like that. But it's a good option.
For now I found these DMX decoder boards that can supply 9-24V@4A per output which is more than enough.
https://www.aliexpress.com/item/1005003306910345.html