• The code to generate the string is generated on the Espruino too - an import and an export function. But it does seem to work:

    
    leds.export = function (type,index) {
      console.log(type);
    	try {
    		var eep=eepromtype[type][0];
    		var off=eepromtype[type][1]+eepromtype[type]­[2]*index;
          var lenh=(eepromtype[type][2]/2); //one of the types has length 128 bytes, too long to handle with one call to .apply(), but all are even, so dividing in half is safe. 
          console.log(off);
    		var rv= String.fromCharCode.apply(null,(eep.read­(off,lenh)));
          rv+= String.fromCharCode.apply(null,(eep.read­(off+lenh,lenh)));
          return btoa(rv);
    	} catch (err) {
          console.log(err);
    		return "";
    	}
    	
    };
    
    leds.import = function (type,index,data) {
    	try {
    		var eep=eepromtype[type][0];
    		var off=eepromtype[type][1]+eepromtype[type]­[2]*index;
    		eep.write(off,E.toUint8Array(atob(data))­);
    		return 200;
    	} catch (err) {
    		return 400;
    	}
    };
    
    

    Thanks!

    And yeah, I was getting it confused with .map(), and had forgotten you could pass multiple arguments to String.fromCharCode(). Been writing too much C lately.

About

Avatar for DrAzzy @DrAzzy started