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.
// sur la matrice TM1640:
/*
pour TM1640
CLK D5 -> B13
DIN D7 -> B15
3V3 -> 3V3
5V -> Vout
GND -> GND
*/
require("Font4x6").add(Graphics);
// crée le buffer graphique 8x8 en 1 bit
let 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"];
let phraseTot;
let compteur = 8;
let compteurTable = 0;
let longPhrase;
let first = true;
let verif = [];
function ecrit(){
digitalPulse(LED2, true, 20);
phraseTot = "À quoi bon, ";
// tire la phrase une seule fois.
let tirage;
do { tirage = Math.floor(Math.random()*phrases.length);} while ( verif[tirage]== true );
compteurTable++;
verif[tirage] = true;
phraseTot += phrases[tirage].toLowerCase()+".";
longPhrase = g.stringWidth(phraseTot);
if (compteurTable == phrases.length) {
// reset de la table de verif
verif = [];
compteurTable = 0;
console.log("reset verif[]");
}
console.log(phraseTot, longPhrase);
compteur = 8;
if (first) {
setTimeout(envoieMatrice,500);
first = false;
}
}
function envoieMatrice() {
// raccorde le bout de ligne suivant
if (compteur < -longPhrase){
// si au bout du texte
ecrit();
}
// reset le buffer, ajoute la font, ecrit la chaine de caractères
g.clear();
g.setFont4x6();
/* une fois font utilisée, on connait la longueur de la chaine*/
longPhrase = g.stringWidth(phraseTot);
compteur--;
// ecrit la phrase
g.drawString(phraseTot,compteur,0);
console.log(compteur, longPhrase);
g.setContrast(7); /* val entre 0 et 7 - TM1640*/
g.setRotation(2,true); // TM1640
// mise à jour du display
g.flip();
setTimeout(envoieMatrice, 500);
}
function onInit() {
// importe font
require("Font4x6").add(Graphics);
require('Storage').eraseAll();
USB.setConsole();
// spi mosi=DIN, sck=CLOCK
g = require("TM1640").connect({din: B15, clk: B13});
}
USB.setConsole();
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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