-
• #2
Hi - yes, it could definitely be tweaked. I guess you'd want
1.234
to effectively put the dot on the 1 digit?Can you try adding this code after you have initialised the MAX7219 and trying again?
disp.set = function(val) { spi.write([0x9,0xff],cs); // decode all as numbers var map = "0123456789-EHLP "; var a = new Array(8); a.fill(15); // all off val = val.toString(); var hadDot = false; var j = 7; for (var i=val.length-1;i>=0;i--) { if (val[i]!=".") { if (j>=0) a[j--] = map.indexOf(val[i]) | (hadDot?128:0); hadDot = false; } else hadDot = true; } for (i=0;i<8;i++) spi.write([8-i,a[i]],cs); spi.write([0x0c,1],cs); // no shutdown };
-
• #4
No problem! Let me know if it works for you and I'll update the module's code with the new function :)
-
• #5
it works like a charm! tested with
disp.set("HH"); disp.set("H------H"); disp.set(3); disp.set(3.1); disp.set(3.14); disp.set(3.14159); disp.set(3.14159+"H"); disp.set("3.14159H");
Everything is working as expected. Thank you very much @Gordon !!
Regarding the above testing, I think the module can be upgraded :)
-
• #6
Whoops, I spoke a little quickly. I did not test a specific case when there is not sufficient digits to print the value:
disp.set(99999999.1)
On the display, the value99999403
is displayed instead. -
• #7
I just tested that, and it's to be expected. Because of rounding,
99999999.1
ends up turning into99999999.09999999403
when converted to a string withtoString
, and it's the last few digits that get shown.If you want full control over it, convert it to a string manually yourself and pass the string in - eg:
disp.set((99999999.1).toFixed(1))
I'll update the library with the new code :)
-
• #8
I just tested that, and it's to be expected. Because of rounding, 99999999.1 ends up turning into 99999999.09999999403 when converted to a string with toString, and it's the last few digits that get shown.
I didn't even thought this far. This seems to make sense. Thanks!
-
• #9
It's all updated now, so using
disp.set
without that extra bit of code I gave you should work fine :) -
• #10
It's all updated now, so using disp.set without that extra bit of code I gave you should work fine :)
Thank you very much, it works well!
Hi there,
I wonder if anyone has tried to handle the dot (".") LED for displaying floating numbers, using this piece of HW? https://www.espruino.com/MAX7219
In the MAX7219 datasheet, page 7 ( https://www.espruino.com/datasheets/MAX7219.pdf ) , it says
Which seems to allow handling the dot (DP).
Do you guys think the MAX7219 module could be upgraded in order to support displaying floating numbers?