-
• #2
I tried with a larger arrayBuffer
createArrayBuffer(9,8,1);
and an other matrix...same problem!
-
• #3
Yes, drawing text at or straddling the border has their fare share of challenges. If it worked before I could attribute the not working anymore to somer performance (and space) increasing changes within Espruino - if their were actually changes (rendering test algorithm).
I like the approach of choosing a larger buffer.... but I would not directly write out of that buffer w/ flip and then redraw at a new position. Since it is monochrome you have plenty of memory. Write to an even larger buffer - one that hold ALL your text, and then move the view port (view) over the buffer for display... then you do not have the issue with jerky render text into the buffer. You deal only w/ transferring frame by frame to the display. Since it is one byte per column, you can easily increment thru the buffer with the view: first bytes 0..7, then 1..8, then 2..9, etc.
If you have changing text you can even rolling changing it... Define a just one (long) line. Update the line accordingly (by shift and write new text and have the transfer to the display shift its line start in the buffer as well.
-
• #4
Hello @allObjects,
I think I understood the idea of a large ArrayBuffer with the entire line of text and display only part of it. Unfortunately, I am not comfortable with ArrayBuffers nor dataView
The idea is to measure the size of my sentence written in a buffer and generate the correct size Arraybuffer once (between 20 and 60 characters), then go and copy the useful portion to display on the matrix.
Did i well understood?I read on MDN that there was an arrayBuffer.slice (start, end) but on espruino, the function does not return an arrayBuffer but just an array so I remain skeptical about the solution.
Any help would be great for a starting point to explore.
regardsthe basic writing program
const phrases = ["Sourire aux cons","Aquiescer aux injonctions d'un supérieur","Mourir de honte","Mourir d'envie","Sourire aux jolies femmes","s'endormir devant la télévision"]; //it contains more sentence function ecris() { phrase = "À quoi bon, "; tirage = Math.floor(Math.random()*phrases.length); phrase += phrases[tirage].toLowerCase()+"."; return phrase; } console.log(ecris());
a try as you said
let bitIndex = 0; let phraseAB; g = Graphics.createArrayBuffer(8,8,1); const phrases = ["Sourire aux cons","Aquiescer aux injonctions d'un supérieur","Mourir de honte","Mourir d'envie","Sourire aux jolies femmes","s'endormir devant la télévision"]; function ecris() { phrase = "À quoi bon, "; tirage = Math.floor(Math.random()*phrases.length); phrase += phrases[tirage].toLowerCase()+"."; const width = g.stringWidth(phrase); phraseAB = Graphics.createArrayBuffer(width,8,1); phraseAB.drawString(laPhrase, 0, 0); sendDatas(); } function sendDatas() { g = phraseAB.slice(bitIndex, bitIndex+8); g.setContrast(7); /* val entre 0 et 7 - TM1640*/ g.setRotation(2,true); // TM1640 // mise à jour du display g.flip(); bitIndex++; setTimeout(sendDatas, 50); // do it til the end of phraseAB + ecris() + reset bitIndex }
Am i on the good way?
regards
é. -
• #5
Don’t miss to check
-
• #6
this is how it was possible before having g.scroll
https://gist.github.com/MaBecker/b7a7bf082274b69c53a8b92b5d7b85e4
-
• #8
It looks like the drawString does not draw the char if it is on the boarder...
This could be possible - there is some code now which tries to clip offscreen chars to improve rendering speed.
Do you have a really simple example where this fails? For example if you run this code in the IDE:
var g = Graphics.createArrayBuffer(32,8,1); g.clear(); g.setFont("4x6"); g.drawString("ABCDEFG",0,0); g.dump();
You should see
ABCDEFG
in an image in the terminal... But maybe some other font/X/Y can cause it not to render the first characters properly?
Sorry long title...
I'm working with Chrome app (cause i've got custom font) with last firmware (2.05) on Pico board.
I discovered a strange behavior (not seen before)
I'm scrolling a text on a 8x8 led matrix with a TM1640 driver (a wemos matrix shield, chip and easy to drive)
I reuse an early script ( that was working, and working with this driver, not the first time i use it), this time i found the scroll jerky, so i slowed down the scroll and i identified what i was feeling...
the first column of a char is never seen, the buffer (i suppose) saw only the char with 2 column and more (not only one).
There is no missing column on the buffer, i have 8 column lighted
it happens on every letter (even if I delete my custom font) appearing from the right side.
It looks like the
drawString
does not draw the char if it is on the boarder...in my code i use a
setRotation()
, i' tried without it, same pb.any help?
i give my durty code to test
best regards
éric