-
@Gordon,
I've added a function to read screendata. This data is given as 3 bytes for r/g/b.
Colourdata for writing is a word (5 bit for red, 6 bits for green and 5 for blue).
Reading data is done this way..... sData = new Uint16Array(cnt); //cnt is number of pixels to be read writeCMD(0x2E); //read memory command dc.write(1); spi.send(z); //z is any value, this needs to be sent for unknown reason for(var i = 0; i < cnt; i++){ r = spi.send(z)>>3;g = spi.send(z)>>2; b = spi.send(z)>>3; //read 3 bytes for 3 colours sData[i] = (r<<11) + (g<<5) + b; } ce.write(1); return sData;
Data should have same format as for writing. I could switch upper and lower byte, thats correct. Any suggestion, how to do that ? May be a short assembler is best solution ?
BTW, reading data this way is very slow, any suggestion to do better ? -
Thanks for the feedback, I now have some more options:
1. sData.forEach(function(s) {spi.send([s>>8,s]);}); 2. for(i = 0; i < cnt; i++){spi.send(String.fromCharCode(sData[i]>>8)+String.fromCharCode(sData[i]));} 3. spi.send(sData.buffer); 4. spi.send(new Uint8Array(sData.buffer)); 5. spi.send(sData);
I'm sending 0xf800, which for ILI9341 is red
1st works fine and is very slow
2nd works fine and doubles speed
3rd and 4th are really fast, but dont display red, its blue. So 0xF800(63488) becomes 248(0x00F8)So,where is the problem, between my ears, or in interpretation of data ?
Oh, just checked version from yesterday, there is a new parameter for SPI called order. Will check it later today or tomorrow.
-
For the ILI99341 driver, I would like to send an Uint16Array via spi.send
I tried 3 versions yet1. for(i = 0; i < sData.length; i++){ spi.send(String.fromCharCode(sData[i]>>8)+String.fromCharCode(sData[i])); } 2. spi.send(sData.buffer); 3. spi.send(sData);
1st version is slowest, but works fine
2nd shows wrong colors and other minor problems
3rd is totally wrong
I did not test another option given with Graphics.drawImage. In my (poor) understanding, this is based on setPixel, which would be very slow.
For now I live with 1st solution, any other idea ? -
-
Tried rotation (from 0 to 3, true) with drawRect(0,10,20,30) and got:
0: 219,10,239,30
1: 209,299,229,319
2: 0,289,20,309
3: 10,0,30,20
next tried rotation(from 0 to 3,false) with drawRect(0,10,20,30) and got:
0: 0,10,20,30
1: 209,0,229,20
2: 219,289,239,309
3: 10,299,30,319So, in my case setRotation(0,false) seems to be correct.
-
Using this code, it looks like y is starting from bottom not from top as it was before.
String looks like being mirrored.
Tested with last nightly build (1v62)var g,p,n,d; function firstDraw(){ g.setBgColor(0.8,0.8,0.8); g.clear(); g.setFontVector(24); g.drawString("Espruino",10,10); g.fillRect(40,40,100,100); } SPI2.setup({sck:B13, miso:B14, mosi:B15, baud: 1000000}); g = require("ILI9341").connect(SPI2,C6,C7,C8,firstDraw);
-
-
My knowledge around c++ is poor. Compiling Espruino by myself is out of my knowledge too. Working with assembler is something I will have a fair chance.
Therefore I would like to ask if there is a "not complicated way" to do some of this in assembler- set values in an array (typed or not, it doesn't care)
- return an array
- return a string
- support call of internal function (old basic version had something like adressOf(spi.send) for that)
- set values in an array (typed or not, it doesn't care)
-
During my learningphase I created an ASM call which only returns one out of a row of parameters. Parameter are stored in reg and in stack.
This is compiled with an external compiler (FASM), it will not run directly with the one in WebIDE.
I still would like to work with Uint-arrays directly. I'm pretty sure this kind of data is stored in memory directly, at least this is what I would like to have :-) get.
Would it be an option to have a function, something like adressOfData() which returns startadress in memory for Uint-Arrays ?thumb; cmp r0,#0 ;1st parameter is pointer to following args beq return ;pointer to first arg which is in r0 cmp r0,#1 bgt isgt1 mov r0,r1 ;2nd arg is in r1 b return isgt1: cmp r0,#2 bgt isgt2 mov r0,r2 ;3rd in r2 b return isgt2: cmp r0,#3 bgt isgt3 mov r0,r3 ;4th in r3 b return isgt3: sub r0,#4 ;since 5th arg is somewhere else lsl r0,r0,#2 ;data uses 4 bytes, so left shift by 2 is like multiplication by 4 ldr r0,[sp,r0] ;load from stack return: bx lr ;return value is in r0
-
Based on last daily, I did some more testing.
Your link to Calling_convention gave a first help.
In my best understanding reg0 to reg3 are used for getting data.
By testing this, I could get 4 values back, but where is the 5th ?var adder = E.asm("int(int,int,int,int,int)", "mov r0,rn", where n is 1 to 3 "bx lr");
Another problem is JsVar, how could this be interpreted ?
I would like to play around with Uint-Arrays.
This one works, but now I want to change a value in the array.
My understanding of C is too poor to get this out of the sources.var x,i; x = Uint8Array(10); for(i = 0; i < 10; i++) x[i] = i; var adder = E.asm("JsVar(JsVar)", "bx lr"); adder(x)
-
-
It is here : http://www.espruino.com/modules
Or take the WebIDE, click on settings, select communications and you will see. -
-
-
@Gordon, you opened Pandora's box, so I decided to "let's see what inside".
My background is assembler long time ago, but not ARM.- first step playing around with given example.
It works, good news. So have a look at minor changes.
Add 7 instead of 2 is simple by altering first command to movs r2, #7 .
Double given parameter simply add this adds r0,r0,r0
BTW, interesting to work with 3 parameters. switch to external assembler.
The internal assembler, even if limited is a good starting point.
By searching for a "full blown" assembler I found http://flatassembler.net/
At this point I learned something about THUMBS and ARM commands.
To get same results as in Gordons example this needs to be done.thumb; ldr r2, [hugo] mov.w r3, #57344 str r3, [r2, #0] str r3, [r2, #4] bx lr hugo: dw 0x40010810
As you can see, first line switches to thumb mode.
One of the main futures of an assembler is last line. You don't have to count the number of word ´s to get the adress of GPIO adress.
Ok, there is another difference, use dw instead of .word- after compilation we get a bin file.
Right now I read this with Hex Editor and type it in manually. Don't forget to switch the bytes ;-) What about using 2 parameters for a function like this adder(2,3)
var adder = E.asm("long(long,long)", "bx lr"); adder(2,3);
And I get an error no caller for argument 438
- tried with all given datatypes, to see whats given by
int, bool and Pin return an error. - Where are the parameters, and how could I interpret those ?
Big question, as far as I can see, r0 is used in the example for input and return value
If somebody has more examples, please share it - Whats now, hmmm
During development of Display driver for ILI9341 Gordon mentioned something like "we could speed it up by using SPI.send with repeat option".
Would it be possible to have something like a list of "interesting entrypoints". There is something like spi_sender_software in jswrap_spi_i2c.c
This could be an additional file created during compilation of new version, and could be used similiar to boardinfo. A new processor for Web IDE could replace adresses and ....
Hey Gordon, its you who opened Pandora's box ;-))
Juergen
- first step playing around with given example.
-
In new IDE sometimes, the list of ports is not refreshed.
In my case it shows available port, but does not connect.
Even after removing USB cable, it still lists the port.
Restarting WebIDE does not change this, port is still listed.
Sometimes then disconnecting USB cable and connecting again helps.
Sometimes it needs an additional reset on Espruino.
Never had this problem with old version. -
It's an interesting balancing act supporting a high level language on one side and assembler on the other one.
Just downloaded Web IDE, but I'm unsure about nightly build. Last nightly build is much smaller for last 4 versions and tests.log is empty since yesterday 1:14 pm. Is latest built best choice ?
Last time I did something in assembler is long long ago, the time of Z80, 6502 and last one 68000. Lets see what ARM assembler is at the end, confusing like Intel or structured like Motorola. -
I would like to play around a little bit with this. RGB123 is too expensive having in mind to play only. What is the "chinese version" of that ?
I only found this: http://www.banggood.com/MAX7219-Dot-Matrix-MCU-LED-Display-Control-Module-Kit-For-Arduino-p-915478.html for 2.54€ with red LEDs only. -
-
-
-
-
I'm pretty sure, we have at least 2 problems, may be 3.
1st happens mostly after connecting. The function to get process.env is waiting for characters very long, nothing happens. So it runs into timeout and switches back to previous listener. And now something magic sends the missing chars. I changed timeout to 1 minute, and the same happened.
2nd is the problem of sending code to Espruino and running into errormessages. Backdoor for this is to use slow mode. Here both problems are in contact. Whenever 1st problem appears, Web IDE will not recognize the board, and therefore switches to slow mode. Interesting is, that flashing a new version runs in fast mode without problems.
3rd is similiar to 1. After sending reset from terminalwindow, sometimes only parts of the messsage are in the window. In this case it helps to type a space. After that, missing part is received. -
You are right, it is an old problem.
Would it be an option to have 2 throttle buttons ?- one for flash
- one for sending code
The problem with terminal stopping to listen (or stop to receive) seems to be Chrome related. This happens very often from terminal window, not only after connecting. Is there any known bypass, which can run in the background ?
- one for flash
Is process.env or process.env.VERSION what you need ?