-
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
é. -
about the font.
I worked from the @Dennis file (thank you @Dennis for the great work) and I redesigned the uppercase letters a little narrower by one pixel and reviewed the accented lowercase and some other lowercase letters.
I find it more pleasant to read on a matrix...
i put in attachment the 2 Dennis's file and my fork.
i think i need a more work, but it's good for me.
if you want i can provide the converted file.
é.
-
Thanks @MaBe for pointing urls, i will try to store the font as you show.
-
@allObjects hello Markus,
the confinement of COVID gave me time to write texts and now is the time to port them to my favorite microcontroller.
I also received a ZD915 desoldering station and I try my and zd915 abilities on a 20mm led matrix replacement on the wemos module.
I tried last night to test the modified module and that's where I encountered some problems . (see my other post http://forum.espruino.com/conversations/347612/)I hope you are in good health and stay careful with this terrifying COVID.
best regards
é. -
-
Hello,
i do not find how to add a custom local modules with the online IDE (not the Chrome app)!
Is it possible?
i use a custom font but can't use the online ide with it! (I'm not proud enough of my work to inflict it on everyone and push it on the git :/)@Gordon, by the way, my uploaded scripts in utf-8 have accents problem in the Online IDE!
For diacritic langages as mine it's really annoying. do i have to encode my scripts in an other way?regards
éric
-
-
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 lightedit 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?
frame 1 |frame 2 |frame 3 00000000|00000000|00000000 00000000|000000x0|00000x00 00000000|000000xx|00000xxx 00000000|000000x0|00000x00 00000000|000000x0|00000x00 00000000|000000x0|00000x00 00000000|0000000x|000000xx 00000000|00000000|00000000
i give my durty code to test
// 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();
best regards
éric
-
Cannot cancel a locked stream
this is the error from the browser... sorry ;)
the page is connected to espruino
on the espruino:const onInit = () => { var step = 0; require("Encoder").connect(A8,A5, (dir) => { step += dir; print(step); if (dir > 0) { //allume la led 20ms digitalPulse(LED1, 1, 20); } else { digitalPulse(LED2, 1, 20); } }); };
i suppose the port is in use and therfor browser can not cancel connection...
thanks for your time.
é. -
-
Hello,
i'm playing with the uart.js lib to connect an espruino to a webpage.
Is it possible to connect to an espruino by command line (js) without the menu "bt4 or webserial", if i know the name of my espruino?
and can i use connection.close() (line 3) to disconnect the espruino from the page (without closing the webpage)? (to update the code in the webIDE)i use this example
let connection; if (connection) { connection.close(); connection = undefined; } UART.connect((c) => { if (!c) { console.log("Pas de connexion"); alert("Impossible de se connecter"); return; } console.log("Connecté"); connection = c; // Handle the data we get back, and call 'onLine' // whenever we get a line resultData = ""; connection.on("data", (d) => { resultData = d; resultData = resultData.replace(/\r\n|>|\[J/g, ''); if (resultData.length > 1) { document.querySelector("article").innerHTML = resultData; } }); });
regards
é.
-
Gorgeous!
I tested uart.js. Works fine and just as i need.
Thanks very much @Gordon for your work.
I took some time to request a serialapi token. It works in local (i was afraid to have to work online but i does not)
I’m a happy guy. I have all i need. -
-
Hello @Gordon
i use the Chrome App... (since the first time...) sometime i open the IDE whitout an internet connection, therefore i got into my habits to use the Chrome app.
In an old project i have to minify code to put all the code in the pico, i checked the minify option on and never unchecked.
As my skills level increase in js, i want to write code in the same way in espruino and web... and arrow function are really cool feature (for me)
I've unchecked the minify option for the moment...to avoid the esprima error...regards
-
@AkosLukacs
the other minification are online... i'm coding in train (now) and there is lot of "white zone" :/
online access can't be a statement! sorry :)i don't minify the code
-
this is the exact code... copy/paste
the pb does not come from the digitalPulse. If i comment all the. line in the block the error stay...i use minification (esprima), if i remove it, it works.
with or without checked option, it does not work!é.
VERSION: "2v04", GIT_COMMIT: "3956264e", BOARD: "PICO_R1_3", FLASH: 393216, RAM: 98304, SERIAL: "5a004e00-04513634-30323836", CONSOLE: "USB", MODULES: "Flash,Storage,hea" ... "v,crypto,neopixel", EXPTR: 536871212 }
-
if you try this simple example
let p = 0; function onInit() { setInterval(() => { //allume la led 50ms digitalPulse(LED2, 1, 20); console.log((Math.sin(p)+1)/2);//, (Math.cos(p)+1)/2, tab.BUTTONS.NONE); p += 0.02; }, 50); } USB.setConsole();
and upload, i receive :
Uncaught SyntaxError: Got ';' expected ','
at line 1 col 79
...((Math.sin(p)+1)/2),p+=0.02;,50);in function called from system
-
i tested chrome app with Serial connection...
the example to connect an espruino in the google github doesn't work !
....
The console.log output (or print()) is huggly to parse in a browser and lot of frame (1/3) are lost even in 9600baud...
is there a better way to "print" to the serial port? (for sure there is but i'm a stupid graphic designer with too few knowledge in code) ;)thanks for your help
regards
ps: i'm looking for a "simple way" to introduce "tangible interface" (input from real world) for graphic design's students (with html5 and js bases NO Processing.org)... i'm testing chrome-app ... it's not the best way but the "easiest". (for my pov to combine : cheap hardware +html5/css/js (webtech) + newb.
ok, i have to coming out: "i love espruino for learning only one langage to code Hardware and Web..."
i have a lot of arduino compatible board but... i do not like the langage... therefore they take dust... -
Thanxs @Gordon for the HIDtablet...
but in my browser, i'm enable to fire an event
no touchstart
no mouse click
no mousemovewhich event do i listen?
regards
é. -
-
-
Hello i'm trying to simulate a mouse with a HC-sr04.
it works well with the x,y coord for the mouse from the example
mouse.send(0,valueFromHcSR04,mouse.BUTTONS.NONE); // X movement, Y movement, buttons pressed
in the report descriptor from here, there is line for x, y and mouseScroll 0x038
description commented found on sparkfun's forum0x09, 0x30, 0x09, 0x31, 0x09, 0x38,
How to send a mousescroll ? and which value should i send?
best regards
é.
-
-
Ok, i stop to try to work with the ht16k33 and return to the « good old shit » alias the max7219.
Spi nor i2c...
With a delay of 100ms for the setup, it works fine (everytime) and is cheaper and easier to find!Thanks for your help @allObjects
Ps: i tried to remove the 10k with just a bridge... and with a 4k7... no more results... grrrrrrr
I was looking for a solution to have only 3v3, but it does not work as expected .fu...
@MaBe :) thanks