-
-
-
Hello,
I think I may have killed my Pico as I can no longer connect to it.
After soldering the ESP8266 onto it with the shim my PC could no longer find the Pico com port and couldn't tell if the red LED was lighting up when plugged in. I removed the ESP8266 but not the Shim and plugged in back in. Again I couldn't find its com port to connect it. I've also tried on another PC and exact same result.
When I plug it in the red LED lights up but very dim. If I plug it in while holding the reset button I get the same result, red LED dimly lit.
I'm worried I may have had a solder short when I first plug it in but can't tell. I used my multimeter's continuity function to check but I have since removed the ESP8266.
What should I do next to debug the problem?
-
I had a to change a few little bits. For example I had to remove the call to onInit(); other wise the serial on(data) was getting fired twice on boot which messed up the output.
I also added a frame per second counter for testing and I get a steady 25 fps!
My next task maybe to try and get this working over USB alone but if I need console access this might not be possible. maybe I could move console onto Bluetooth..
Here is the full code used in the video:var fps = 0; function onInit() { SPI2.setup({baud:3200000, mosi:B15}); var cmd = ""; Serial3.setup(1000000, {tx:C10,rx:C11}); Serial3.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"); SPI2.send4bit(line, 0b0001, 0b0011); fps++; } }); var fps = setInterval(function() { console.log('fps: ' + fps); fps = 0; }, 1000); }
-
Success! You're a genius Gordon \1 was it! It works perfectly and with great frame rates.
I had a problem with random colours appearing when powering the Espruino directly off 5V and not the PC but I fixed that by simple grounding the USB-TTL to the 5V supply.
https://www.youtube.com/watch?v=Yk55bTqTVDY
-
-
-
-
Part success!
I've got Serial3 receiving data, issue appeared to be that I needed to give the pins in Serial3.setup
I ran many tests and passed it simple test strings to confirm that it was working and the while() loop would wait until it saw \r
Now I've begun passing it the matrix data from Glediator and..part success. The serial data is being received and using SPI2.send4bit I push it out onto the matrix. But the matrix lights up crazy, see the photo below.
Now as crazy as it is, the movement of the pixels and overall colour does match that from Glediator so I'm thinking the issue is more to do with me not correctly finding the beginning of the data. If it is not \r what else could it be?
Or is there something else I'm missing completely? I've attached my full code below:function onInit() { SPI2.setup({baud:3200000, mosi:B15}); var m = Graphics.createArrayBuffer(15,15,24,{zigzag:true,color_order:'bgr'}); m.flip = function(){ SPI2.send4bit(m.buffer, 0b0001, 0b0011); }; var cmd = ""; Serial3.setup(1000000, {tx:C10,rx:C11}); Serial3.on('data', function (data) { cmd+=data; var idx = cmd.indexOf("\r"); while (idx>=0) { var line = cmd.substr(0,idx); cmd = cmd.substr(idx+1); idx = cmd.indexOf("\r"); SPI2.send4bit(line, 0b0001, 0b0011); } }); } onInit();
-
I've tried a few different things but nothing fully working yet. I've confirmed that serial data is being correctly sent out of the PC, Espruino just can't seem to read it.
I have changed my setup to use a USB-TTL. The Espruino USB is now being use for code uploading and console. All serial data is being sent to the USB-TTL and then into Espruino on the following pins. I'm using the original Espruino board for now and my wiring for the USB-TTL Converter is RXD > C10 & TXD > C11
I don't think I can use A9&10 as I have a bluetooth module attached.After running my test code .on('data' still isn't receiving anything. As a basic test I tried the following code with nothing connected and the results are strange, am I doing something wrong?
function onInit() { //Serial1.setup(115200); Serial3.setup(9600); Serial3.on('data', function (data) { console.log("<Serial3> "+data); }); Serial3.print("Hello World"); console.log('Code is running.'); } onInit();
After uploading code:
>echo(0); Code is running. =undefined
Nothing is outputted?
After entering save():
Running onInit()... Code is running. <Serial3> <Serial3> >
Serial3 is outputted but not the "Hello world"
If I set a baud rate of 115200 Serial3 isn't outputted. -
-
I'm trying to use Espruino as the controller to take LED matrix data from the Glediator over USB and output it onto an RGB LED matrix.
The Matrix is made up on 16x8 WS2812B pixels. I've attached the example code from Glediator for using an Arduino as the controller which I've tried ported to JS (see below).
I've tried using the example USART code from here: http://www.espruino.com/USART along with other code I found on the forum but so far nothing has worked. Is there something I'm missing in the code below? I'm unsure if data is being received but Espruino as I can't connect while data is being sent to check.function onInit() { SPI2.setup({baud:3200000, mosi:B15}); var m = Graphics.createArrayBuffer(16,8,24,{zigzag:true,color_order:'bgr'}); m.flip = function(){ SPI2.send4bit(m.buffer, 0b0001, 0b0011); }; // Not sure if I need this line? USB.setup(115200); portData(); } function portData() { USB.on('data', function (data) { USB.print(data); cmd+=data; var idx = cmd.indexOf("\r"); while (idx>=0) { var line = cmd.substr(0,idx); cmd = cmd.substr(idx+1); var s = "'"+line+"' = "+eval(line); print(s); USB.println(s); idx = cmd.indexOf("\r"); SPI2.send4bit(cmd, 0b0001, 0b0011); } }); }
-
I finished some more of the code and now I have a fully working game of Tetris.
I created a post in 'Projects' with more details, a video and the code: http://forum.espruino.com/conversations/265028/
Thank for all your help on this guys. -
I build Tetris on Espruino and output it on a 16x8 RGB matrix. I'm controlling it work some push buttons which works well but I might build something better.
You can download the code here, it will work with most displays just change the Graphic settings at the top. There are still a few small bugs and lots of features I want to add.
https://github.com/owenmcateer/espruino-tetrisHere is a quick video showing the game play (excuse the crappy paper diffuser but my camera can't focus on the LEDs without it)
https://www.youtube.com/watch?v=q_Ut3KzdzRU
-
I haven't yet had any more time to work on this, but if you want to see the code from the video here it is: https://gist.github.com/owenmcateer/0a57634498a922a09db1
-
-
Thank Gordon that works perfectly and using getPixel() for collision detection works really well.
It's starting to come together now, see the short video below.
Next I will add some hardware controls, line clearing and difficulty settings.
https://www.youtube.com/watch?v=obvVTwzZa-o
-
I still get an error when trying to copy the buffer even when there is output data in it? Here is the full test code.
// Set up matrix SPI2.setup({baud:3200000, mosi:B15}); var m = Graphics.createArrayBuffer(16,8,24,{zigzag:true}); m.flip = function(){ SPI2.send4bit(m.buffer, 0b0001, 0b0011); }; m.setRotation(1); // Rotate board 90degs var mCopy = Graphics.createArrayBuffer(16,8,24,{zigzag:true}); m.setColor(0.3, 0.5, 0.7); m.setPixel(0,0); m.setPixel(4,4); m.flip(); // Save copy mCopy.buffer.set(m.buffer); // Clear matrix m.clear(); m.flip(); // copy it back m.buffer.set(mCopy.buffer); m.flip();
Uncaught Error: Field or method does not already exist, and can't create it on ArrayBuffer at line 1 col 13 mCopy.buffer.set(m.buffer); ^ at line 1 col 9 m.buffer.set(mCopy.buffer);
-
Ok, so using the output buffer array for collision detection is a bad idea.
I'll try going back to an array of the fallen blocks to check for collisions.@Gordon I get an error when I try to use m.buffer.set()
Uncaught Error: Field or method does not already exist, and can't create it on ArrayBuffer at line 1 col 13 mCopy.buffer.set(m.buffer); ^ at line 1 col 9 m.buffer.set(mCopy.buffer); ^
-
Thanks for the advice guys I've been rewriting all the code and it's much faster now. For the 'fallen' blocks that need to get rendered and checked for collisions I think I can copy and use the Graphics.buffer Array. I can renderer it using Graphics.drawImage() and easily check pixels for collisions by looking in the array (if it's colour is zero, it's empty).
This method seems to work perfect, except one little issue. I have a 16x8 matrix which I've turned sideways and used Graphics.setRotation(1); . Sadly this breaks Graphics.drawImage(myCopyGraphicsBuffer);
Is there a way to fix this?// Example code var m = Graphics.createArrayBuffer(16,8,24,{zigzag:true}); m.flip = function(){ SPI2.send4bit(m.buffer, 0b0001, 0b0011); }; m.setRotation(1); m.setColor(1,1,1); m.setPixel(0,0); // Top-left m.flip(); // Copy buffer and clear matrix var a = new Uint8Array(m.buffer); var myBuffer = new Uint8Array(a); m.clear(); var boardImg = { width: 16, height: 8, bpp: 24, buffer: myBuffer }; m.drawImage(boardImg, 0, 0); m.flip();
If you run this code the top-left pixel will flash white very quickly and disapear. If you comment out line 4 (m.setRotation(1);) the code work but obviously the bottom-left pixel lights up.
-
I'm coding Tetris. The code below is unfinished and still very rough around the edges with lots of improvements to be made. Here is what I've done so far.
- Added all block types and their rotations
- Block fall and can be moved/rotated (Use blockOp.left() blockOp.right() blockOp.rotate() blockOp.down() )
- Wall and floor collision detection
- All blocks are the same colour but want to add full RGB later
The next part I'm working on is storing the fallen blocks in an Array so I can render them on each frame and then detect when other falling blocks need to settle on top of them.
Here is a link to see the full code. The output is a 16x8 RGB-123 LED Matrix (the code should run fine without connecting anything) Line 191 logs the stored fallen blocks array when I then want to loop for rendering and collision detection but it's is very slow.
http://jsfiddle.net/t0ucb1yt/1/ - Added all block types and their rotations
-
Hello,
I've got an 8x16 LED matrix and I'm using the Graphics module to draw a simple game onto it. I'm using an Array to hold some background pixels with I then loop and use Graphics.setPixel() to output. Everything works fine but looping my array for active pixels seems very slow. So my question is, is there a fast/better way to be doing the following?// Create empty array var board = Array(); for (var r=0; r < 16; r++) { board[r] = Array(); for (var c=0; c < 8; c++) { board[r][c] = 0; } } // (un)set pixels in array code here // Loop and output pixels for(var r=0; r < 16; r++) { for(var c=0; c < 8; c++) { if(board[r][c] == 1) { martix.setPixel(c,r); } } }
-
-
Hello,
I have daisy chained two HC959 ICs together and wired them up to 16 LEDs. The code below produces a Nightriders effect with the LEDs running up and down. Everything is working well but I must be doing something wrong as the LED 8 above or below the lit one very quickly flashes on too. This would be coming from the other IC so I think the issuebut not sure how to fix it?SPI1.setup({ mosi:B5, sck:B3 }); var i = 2, dir = true; function loop() { SPI1.send(i>>8,B8); SPI1.send(i,B8); if(dir) { i = i<<1; } else { i= i>>1; } // Change direction if(i >= 25536 || i <= 2) { dir = !dir; } } setInterval(loop, 60);
Is it safe to use the 595 to run 8 LEDs at once? I think I remember reading somewhere you shouldn't do that as the current it too high for the IC but I could be wrong?
I'm a complete noob at electrictronics and still learning.
PS.where is a good place to learn/find out about ICs?