-
-
-
If I use the the custom espruino graphics canvas how will it work when running in a browser?
Also if I draw directly to the dmd controller board canvas how will this work inside the browser? I had a look at what that board supports and i dont think it supports enough to do what I need. (would need a new font for a start!)(and can you draw fonts half off the canvas?)
Using my own (very simple) byte array canvas (it only supports drawText and copyCanvas) and will work in the browser and on a micro controller (I am thinking of using the stmf4? which definitely has enough ram for all my little byte array canvas's)
Another reason is if i do decide to just straight port this and run in c on a micro controller I can pretty much copy and paste all my logic and canvas code I am not relying on a certain os canvas library.
I spoke to embedded adventures and they say I can either bump up the uart or use the i2c (need to write bit of code my self) to send the frame data to the dmd controller board. Which is my preferred method.
Its cool to see the espruino making and parsing the networkrail request though using that wireless board. One step closer :D
-
Hey
Wow that's pretty cool to see it running on the web ide :)
Regards to the json parser I did not actually know there was a native one! I will definitely use it know I know it exists :) (I did come across it in node js and just assumed it was a node js thing did not know it was a standard javascript method hehe)
I have almost got it working with the removed html canvas :) still working on that canvasCopy method (not quite working right lol) Hopefully finish it off tomorrow in work. But it still all runs fast and is looking good and is using pure byte arrays now :D not relying on html canvas which is nice if I ever wanted to port this to another language.
-
Ah yes that is the file I have included in my php :)
Almost converted html canvas to my own custom byte canvas just need to write the copyCanvas function now :)
Spent ages trying to figure out why my chars where being clipped off. eventually found out that javascript bitwise shift right does not wrap??? and just fills with 0's useless! hehe.
My led panels turned up today but one was damaged in the post :( hoping it still works but will see once driver board turns up hehe (embedded adventures says they will replace if not working 100%) which is good.
-
Ah another reason for the php is if you have multiple destination states the php has to make multiple calls to the networkrail api it also has to make a separate request to collect the calling at stations data (forgot about this lol) then packages it all up in one friendly json response.
If it is written to use require (to load the js files) does this still run inside a browser? I will do some research on this and try and implement it :)
I have included the php file in this reply so you can see what it is doing. I guess it is doing quite a lot and saves the js from making multiple requests and just hides/removes all the train api crap from it which it doesn't really care about. It just wants to make one request and get back just the data it needs :) (way I see it hehe)
Its not 100% finished I still need to sort out the station service messages.
-
-
hehe yes just for development lol I will remove once complete lol
This is the api
http://www.livedepartureboards.co.uk/ldbws/Yes you have your own private key which is in the php file. Also some one made a php example of how to receive the data using SOAP so I just copied this and converted to json. That's all the php script does really :)
You could talk directly from the javascript I guess but I have no idea how plus your key would be reviled.
-
Yes you are correct it talks to a php script that sits on my amazon aws server. This script actually makes the calls to the network rail LDBWS api and receives the data. I then rip out the parts I want and convert it to an json object and this is what is returned.
I am using a naughty header('Access-Control-Allow-Origin: *'); to allow the javascript to talk to my php while developing from my local machine.
My html literally just creates a canvas this is because the project was always aimed to just be run on hardware but people in the office liked it so much and use it for there trains I decided to try and keep it cross platform so they can still use it in the browser.
If I am reading what you are saying correctly. You would be able to convert this to run on espruino but have a module that draws it onto your lcd. And I would then replace with a module that just sends the canvas data to my DMD board using i2c instead. I am still a little bit worried about about memory? all the little temporary canvas's will use up to much ram? If you could help me with this project I would really appreciate it :)
-
The hardware I will be using is.
3x http://www.embeddedadventures.com/led_matrix_display_LDP-6432.htmlHow I control this I am still trying to decide hehe. I have ordered one of these.
http://www.embeddedadventures.com/led_matrix_display_driver_plt-2001.htmlAnd raspberry pi
http://www.raspberrypi.org/products/model-a-plus/I also have a few stmf4 dev boards lying around hehe.
My three routes at the moment are run this javascript (converted version) in node js on a raspberry pi with a node i2c module and stream the data to the dmd controller board and have that take care of the dmd updates. (I will either modify or rewite the current firmware to use the i2c on the dmd board as im not 100% its supported yet)
Or get it running on a espruino board (will buy one once I can confirm i can run some form of this code on one hehe) and then stream the data again using i2c to dmd board
Or (I have experience with the stmf4) just write the code again from scratch in .c and bitbang the dmd my self.
I would like to use my javascript though as a few people around the office like using this project and I would like to continue to add features to it and then be able to create a version I can port to my hardware dmd.
I have little knowledge of node js I have wrote a few little scripts for it.
My language are as2/3,php,javascript and .cIf I am understanding you correct I can leave my project the way it is and use require js to load in the extra files and then override the canvas methods with my own custom byte arrays?
I am currently 30% to converting the javascript canvas with my own byte array one so I think I will continue and finish this hehe. Least it removes the whole html canvas dom problem.
Once that is complete I will be left with a project that has multiple files that will need to be loaded onto the espruino. How much ram does it have because my code does create quite a few little temporary canvas one being (2000*9*2)/8 large will this work at run time?
-
Hey allObjects
Yes I have just figured this out my self hehe, I wrote this in javascript thinking I could directly port it onto a micro because I had heard of them running javascript I should of done a bit more research hehe.
My current plan is to rewrite all canvas code (I only use drawImage and fillRect) my self as byte arrays (very similar to Gordans graphics libary)
I will slightly adjust my textManager to draw the font to the byte array canvas and instead of using drawImage (I was only use this as a canvas copy) I will create a canvasCopy method to copy chunks of one byte canvas to another.
canvasCopy(orig,x,y,w,h,dest,x,y,h,w);
This way I will now not be reliant on any canvas object and could very easily port this to plain .c if I needed to.
My plan for the byte canvas (based on my pinDMD project) as I only need 3 colours I can get away with just (192*32*2)/8 = 1532 bytes canvas array which will save on memory. But then again creating a canvas which support 255 colours (192*32)*8 = 49151 bytes is bit larger and would be better in-case i want to use more colours?
I would convert this larger canvas byte array down to the compressed 4 colour version when sending data over i2c to the dmd controller :)
I would also need to swap out the way my code makes http requests with the wifi hardware ones espruino.
If I can get the core of this project just written in pure javascript I think I will be ok and can have a minifier create a web version and a espruino / or node js version (my code is in multiple files so this all needs to be put into one anyway I guess to work with espruino or node.
Thanks for the help offer I will certainly take you up on that when I get stuck hehe :)
-
-
Perfect :) I will convert that over.
And all this sort of code will run quite happily?
function createDepartureBoard(){ var c = document.getElementById("canvas"); c.width = 192*2; c.height= 32*2; boardCtx2D = c.getContext("2d"); boardBuffer = document.createElement('Canvas'); boardBuffer.width = 192; boardBuffer.height = 64; boardBufCtx2D = boardBuffer.getContext('2d'); msgBuffer = document.createElement('Canvas'); msgBuffer.width = 2000; msgBuffer.height = 32; msgBufCtx2D = msgBuffer.getContext('2d'); }
boardBufCtx2D.drawImage(msgBuffer,msgXPos,0,192,9,0,msgYPos+1,192,9);
-
-
-
Reading the PIC32MX450F128H datasheet (quite a nice little microcontroller actually hehe)
http://ww1.microchip.com/downloads/en/DeviceDoc/60001185C.pdfSays
• Baud rates ranging from 76 bps to 25 Mbps at 100 MHzHopefully I can just bump the UART to a faster speed and use this. How fast can I send data using the Espruino UART?
-
It comes with full source code. So at the very worst I will just add in the i2c part my self. Or maybe up the uart? How fast can PIC uart hardware go? Like you said would also need to add some way of sending raw pixel data as well. So Cant really use this project out the box but I think it will still save me a lot of work even if I just wrote the firmware from scratch!
Unless I can get the dot matrix driver code hardware timer interrupt driven on Pi or Espruino it will be jumpy I think.
Maybe writing a small c class that runs the dot matrix display with hardware timers on the Espruino might be the way forward? and send it the frame data from the javascript
This was one of my other projects
http://www.pindmd.com/default.phpIt used very similar hardware to yours the STMF4 which is a powerful arm chip and when running the display just off software delays with the usb running as well the display was jumpy. I had to put the display update in a hardware timer driven routine to force it having priority and this solved the problem. Hopefully would be the same with the Espruino.
Least I got a few routes to go down :)
Basically a mixture of using Rasp Pi by its self or with the DMD controller board.
or Espruino by its self or with the DMD controller board. -
The dot matrix board serial is 115,200bps
If my math is correct this is far to slow for me to run 24fps :(
192x32x2 = 12288 bits
/ 8 = 1536 bytes (one frame, 3 colours)- 24 = 36864 bytes per second is the transfer rate I need to update this display.
This is why I will need to use its i2c interface (hopefully been written or I will be downloading the pic dev tools as well hehe)
- 24 = 36864 bytes per second is the transfer rate I need to update this display.
-
Yeah I see what your are saying, I am trying to keep the code this way so I can still run the js in a normal browser and have it work as is.
I might have a look at writing the i2c Rasp Pi stuff because I will need to use this. I don't think i will be able to send all the frame data at 24fps over serial?
I have looked at node.js and there are a few canvas modules I can use.
I might look at rewriting it not to use the 'canvas' at all for the internal animations and just use my own byte array to store the pixel data. Then just have a switch for if its run in browser mode or on device. When on deivce it just sends the byte canvas directly to the dot matrix driver (in correct format) or if running in browser just draw my byte canvas onto a js canvas.
I will see what I get away with before I make this move hehe.
-
Just a personal project using the network rail LDB api. I take the train from bristol to reading every day for work so its nice just to see what the next trains I can take are / delays / cancellations etc..
My canvas only uses fillRect (just to draw a 1x1 pixel and drawImage (to copy different canvas's around) Is all this supported?
I think I will use that dot matrix driver board to drive the displays as all the code has been written and I can just plug the displays directly into it. Will save me a lot of time and effort hehe. (so will not need to write any dot matrix driver stuff my self hehe)
I read in another thread of yours we can run espruino on a rasp pi? I have one of the new A Plus models so was thinking run my little app on that and have it talking i2c to the dot matrix driver board. This way the rasp pi can take care of the networking and js canvas side and the dot matrix can take care of the display updates.
-
-
Basically I have written this live train departure board in js using the canvas.
http://54.148.129.10/index.html?orig=RDG&dest=BPWI want to know display this data on a real dot matrix (the ones i linked to)
I think I will get that little driver board as it will save me time and pain :DI was under the impression espruino would be able to basically run this code standalone but instead of seeing it on a html page i will just copy the canvas pixel and convert to byte array and send them to the dot matrix driver board. (when animating it runs at around 24fps and the scroll is 12fps)
Once done it should not be connected to a pc. It should run 100% standalone and get its data using wireless and then send the data to the dot matrix driver board.
I wrote this project is js because i like using the canvas for graphical projects its easy to set pixels and so on. Maybe i should of just wrote it in .c and made a byte canvas and but then I would need to implement all the (comes for free with js) canvas methods like drawing and buffers and so on.
Also there is no font rendering going on that font is a custom (exact map of network rail font) but stored as my own format and i decode and draw it my self. Its not using canvas text.
Another quick question :)
Can we mix .c code and javascript? I know from above conversation calling asm is possible but can i write half this project in .c and have that running on the stm and then make calls to this from the javascript? -
Yup 4 lines which are 2 clocks and 2 data out lines which 2 SPI interfaces would cover? Can I not use the 2 SPI interfaces on this board at the same time?
I have used hardware SPI to clock out dot matrix data in the past it works well :)
I looked at Raspberry Pi But they only have 1 SPI I really need 2.
I have no problem writing the core display update code in asm as long as its interrupt driven.
Edit:
I miss read the datasheet your right it is 1 clock and 4 actual data lines 2 colours but on 2 rows! Ah crap.I can offload the display update work to this board
http://www.embeddedadventures.com/led_matrix_display_driver_plt-2001.htmlI am hoping the i2c interface is supported on it though as I don't think uart will be quick enough to send all the pixel data. This is also open source so I can edit it to support i2c if not supported (They have a i2c header)
I have worked with UK fruit machine (slot machines to the Americans :D) reels before and they are driven using stepper Motors like allObjects has mentioned they need a ramp up and down tables or the motor will just jump. But using a geared one shouldn't need this? (Fruit machines drive a 12inch reel drum directly)