:) The custom font is slower because Espruino has to unpack it from RAM - in Espruino things sometimes aren't stored in one block of memory to work around fragmentation - so for every access it has to check.
When using the built-in font it's using very specific, fast code to access flash.
Did you try the new firmware I linked? That should be a lot faster.
Actually thinking about it, it seems that atob doesn't create a flat string when it could do.
You might get faster rendering by doing:
var font = E.toString(atob("AAAAAPoAwADAAFhw2HDQAGSS/5JMAGCW+DzSDAxSolIMEsAAPEKBAIFCPABIMOAwSAAQEHwQEAABBgAQEBAQAAIAAwwwwAB8ipKifABA/gBChoqSYgCEkrLSjAAYKEj+CADkoqKinAA8UpKSDACAgI6wwABskpKSbABgkpKUeAAiAAEmABAoRAAoKCgoKABEKBAAQIqQYAA8WqW9RDgOOMg4DgD+kpKSbAB8goKCRAD+goJEOAD+kpKCAP6QkIAAfIKCklwA/hAQEP4A/gAMAgIC/AD+EChEggD+AgICAP5AIED+AP7AMAz+AHyCgoJ8AP6QkJBgAHyChoN8AP6QmJRiAGSSkpJMAICA/oCAAPwCAgL8AOAYBhjgAPAOMA7wAMYoECjGAMAgHiDAAI6SosIA/4EAwDAMAwCB/wBAgEAAAQEBAQEBEn6SggQABCoqHgD+IiIcABwiIhQAHCIi/gAcKioYACB+oIAAGCUlPgD+ICAeAL4AAQG+AP4IFCIA/AIAPiAeIB4APiAgHgAcIiIcAD8kJBgAGCQkPwA+ECAgABIqKiQAIPwiADwCAjwAIBgGGCAAOAYIBjgAIhQIFCIAIRkGGCAAJioyIgAQboEA5wCBbhAAQIDAQIAAPFqlpUI8cPh8+HAAcDhwACBg/mAgAAgM/gwIABA4fBAQABAQfDgQAHxERER8AHxE9CRcAHxUbFR8AP58OBAAEDh8/gACAAIAAgB8fHx8fAD+/gD+/gACilIiAgACIlKKAgA+Yu5iPgACAgICAgAGBgYGBgAODg4ODgAeHh4eHgA+Pj4+PgB+fn5+fgD+/v7+/gD+/v7+/gAAAAAA/gD+/gD+/v4A/v7+/gD+/v7+/gA4OHz+/gAMDPBAIACeADhE/kQIABJ8koIEAEQ4KDhEAKhoPmioACh8qqqCAARSqpRAAJCkqKSQAP6CupL+ABKqqqp6ABAoVChEADh8fHw4ADhUbFQ4AP6Cpor+ABAYHBgQAGCQkGAAIiL6IiIASJioSACIqKhQACBAgAB/BAQIfABgkP6A/gAwMAAAAAAASPgIADlFRUU5AEQoVCgQAOgWKl+CAOgQKVONAKj4BgofAAYJUQIADpRkFA4ADhRklA4ADlSUVA4ATpSUVI4AjjjIOI4ADlS0VA4APkj+kpIAeISFh0gAPqpqKiIAPmqqKiIAPmqqaiIAPqoqqiIAon4iACJ+ogBivmIAYj5iABB+UkI8AH6QiES+AByiYiIcABwiYqIcAAxSklIMAEySklKMALxCQkK8ACIUCBQiAD5DXWE+ADyCQgI8ADwCQoI8ABxCgkIcALwCAgK8ACAQTpAgAIH/JSQYAH+SkmwABKpqHgAEKmqeAARqql4ARKqqXoCEKiqeAARqql4ATFI8UjQAGCUnJAgAHKpqKhgAHCpqmAAcaqpYAByqKpgAon4CACJ+ggBivkIAYj5CAKRKqhoMAF6QkE6AAAySUgwADBJSjAAMUpJMAEySUowAnCIinAAQEFQQEAA6TFRkuAAcgkIcABxCghwAHEKCXABcAgJcADAKSoo8AIH/FQgAMIoKijwA"));
var widths = E.toString(atob("BAIEBgYGBgIEBAYGAwUCBQYDBgYGBgYGBgYCAwQGBAUGBgYGBgUFBgYCBgYFBgYGBgYGBgYGBgYGBgUDBQMEBgYFBQUFBQUFBQIEBQMGBQUFBQUFBAUGBgYGBQQCBAYGBgQGBgYGBgYGBQUGBgYGBgYGBgYGBgYGBgQCAwQFBgYGAgYGBgYGBgYGBgYGBgYGBQYFBQQGBgMEBAYGBgYGBQYGBgYGBgYGBgYGBgQEBAQGBgYGBgYGBgYGBgYGBgYFBQUFBQUFBgYGBQUFBAQEBAYGBQUFBQUGBgUFBQUGBQY="));
Graphics.prototype.setFontDennis8 = function() {
this.setFontCustom(font, 32, widths, 8);
};
So basically Dennis8, but with E.toString around atob. I'd be interested to see what difference that makes?
I'll make a note to improve atob - there's no reason it shouldn't use flat strings, which would be a lot faster and more efficient
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.
:) The custom font is slower because Espruino has to unpack it from RAM - in Espruino things sometimes aren't stored in one block of memory to work around fragmentation - so for every access it has to check.
When using the built-in font it's using very specific, fast code to access flash.
Did you try the new firmware I linked? That should be a lot faster.
Actually thinking about it, it seems that
atob
doesn't create a flat string when it could do.You might get faster rendering by doing:
So basically Dennis8, but with
E.toString
aroundatob
. I'd be interested to see what difference that makes?I'll make a note to improve
atob
- there's no reason it shouldn't use flat strings, which would be a lot faster and more efficient