Nightly 'bigram' (3250 jsvar) builds for Espruino Board 1.3/1.4

Posted on
Page
of 2
Prev
/ 2
  • Someone could take a look at this if they wanted. The Web IDE is easy enough to tweak, and the relevant APIs are:

    https://developers.google.com/closure/co­mpiler/docs/api-tutorial1
    https://developers.google.com/closure/co­mpiler/docs/api-ref

    Probably what's required is externs_url and a file that contains all of Espruino's built-in functions.

    However: once you stop the minifier renaming Espruino's built-in functions, it won't compress your code as much - so I wonder if it's really worth it. If modules were properly inlined the minifier would be able to do a much better job, but right now the only way of doing that is to manually copy the module code into the same file.

    Have you tried one of @DrAzzy's recent big ram builds?

  • No luck, as of 8/12 build BigRam still "hangs" on my Espruino chip.

    I would like to state the obvious. (No offense or insults to your customers) With all the suggestions on this board to increase the jsvars, there is no mention of code efficiency. There is a difference between the professional Javascript "Gordons" of the world and novice, hackers like me. My user application bloatware, through efficient "professional" programming, could be reduced to the bare minimum and save hundreds of jsvars!

  • BigRam has consistently failed "hangs" on my user application.
    There are only two possibilities. My user code cause BigRam to fail or it was my Espruino chip? Everything, until now, pointed to my chip. Out of total frustration, I rewrote a large algorithm for auto DST (daylight savings time - module DS3231) since the DST is made for UK and not USA. Now, 8/12 BigRam release works on my chip? BigRam did not like my "old" user application code!
    Total happiness is having 3250 jsvars!!!!

  • Glad you got it working!

    That is a strange one... If you can track it down to one section of code that fails in bigram I'd be really interested to see it...

  • Code that fails BigRam excluding other user application coding.
    This code is pretty straightforward.

    var lcd,rtc,rtc1,gps;
    var gps_flag = false;
    var mon_1  = "  ";
    var date_1 = "  ";
    var yr_1   = "  ";
    var hr_1   = "  ";
    var min_1  = "  ";
    var sec_1  = "  ";
    var date_time1 = " ";
    var mon_2  = "  ";
    var date_2 = "  ";
    var yr_2   = "  ";
    var hr_2   = "  ";
    var min_2  = "  ";
    var sec_2  = "  ";
    var date_time2 = " ";
    
    var SF2014x = new Date(2014,2,9,2,0,0); 
    var SF2014 = SF2014x.getTime(); 
    
    var FB2014x = new Date(2014,10,2,2,0,0);
    var FB2014 = FB2014x.getTime();
    
    var SF2015x = new Date(2015,2,10,2,0,0);
    var SF2015 = SF2015x.getTime();
    
    var FB2015x = new Date(2015,10,3,2,0,0);
    var FB2015 = FB2015x.getTime();
    
    var SF2016x = new Date(2016,2,13,2,0,0);
    var SF2016 = SF2016x.getTime();
    
    var FB2016x = new Date(2016,10,6,2,0,0);
    var FB2016 = FB2016x.getTime();
    
    var SF2017x = new Date(2017,2,12,2,0,0);
    var SF2017 = SF2017x.getTime();
    
    var FB2017x = new Date(2017,10,5,2,0,0);
    var FB2017 = FB2017x.getTime();
    
    var SF2018x = new Date(2018,2,11,2,0,0);
    var SF2018 = SF2018x.getTime();
    
    var FB2018x = new Date(2018,10,4,2,0,0);
    var FB2018 = FB2018x.getTime();
    
    var SF2019x = new Date(2019,2,10,2,0,0);
    var SF2019 = SF2019x.getTime();
    
    var FB2019x = new Date(2019,10,3,2,0,0);
    var FB2019 = FB2019x.getTime();
    //
    var TZ = -1; 
    var EDT_EST = false; 
                         
    var dstLockout = false;
    var DST = 0;
    var idx1 = false;
    var idx2 = false;
    var gps_fix  = false;
    
    
     
    function onInit(){
    I2C1.setup({scl:B8,sda:B9});  
    lcd = require("HD44780").connectI2C(I2C1);
    digitalWrite([LED1,LED2,LED3],4);
    setTimeout("digitalWrite([LED1,LED2,LED3­],2);", 1000);
    setTimeout("digitalWrite([LED1,LED2,LED3­],1);", 2000);
    setTimeout("digitalWrite([LED1,LED2,LED3­],0);", 3000);
    
      
    lcd.clear(); 
    
    
      
    I2C2.setup({scl:B10, sda:B11});
    rtc1 = require("DS3231R1").connect(I2C2); 
        
    I2C1.setup({scl:B8, sda:B9});
    rtc = require("DS3231R1").connect(I2C1); 
     
    rtc.i2c.writeTo(0x68,0x0E,0x60);
    
    pinMode(C11,'input_pullup'); 
    Serial4.setup(9600,{tx:C10,rx:C11});
    gps = require("GPS").connect(Serial4, function(data) {
    gps_flag = true;      
    }); 
      
    lcd.setCursor(0,0);
    lcd.print("GPS No Button Clock");
    pinMode(B3,'input_pullup');    
    }
    
    function RTC_INT_1Hz () {
        digitalPulse(LED3, 1, 25);
    
        date_time1 = rtc.readDateTime();
      
        date_time2 = rtc1.readDateTime();
       
        mon_1  = date_time1.charAt(0) + date_time1.charAt(1);
        date_1 = date_time1.charAt(3) + date_time1.charAt(4);
        yr_1   = date_time1.charAt(6) + date_time1.charAt(7);
      
        hr_1   = date_time1.charAt(9)  + date_time1.charAt(10);
        min_1  = date_time1.charAt(12) + date_time1.charAt(13);
        sec_1  = date_time1.charAt(15) + date_time1.charAt(16);
       
        mon_2  = date_time2.charAt(0) + date_time2.charAt(1);
        date_2 = date_time2.charAt(3) + date_time2.charAt(4);
        yr_2   = date_time2.charAt(6) + date_time2.charAt(7);
      
        hr_2   = date_time2.charAt(9)  + date_time2.charAt(10);
        min_2  = date_time2.charAt(12) + date_time2.charAt(13);
        sec_2  = date_time2.charAt(15) + date_time2.charAt(16);
    
    a = new Number(mon_1);
      if (a === 0) {
      }
      else
      {
      a = a-1;
      }
    b = new Number(date_1);
    c = new Number(yr_1);
    c = c + 2000;
    d = new Number(hr_1);
    e = new Number(min_1);
    f = new Number(sec_1);
    
    var utcDate = new Date(c,a,b,d,e,f,0);
    var utcDate_ms = utcDate.getTime();   
    
    a = new Number(mon_2);
      if (a === 0) {
      }
      else
      {
      a = a-1;
      }
    b = new Number(date_2);
    c = new Number(yr_2);
    c = c + 2000;
    d = new Number(hr_2);
    e = new Number(min_2);
    f = new Number(sec_2);
      
    var localDate = new Date(c,a,b,d,e,f,0);   
    var localDate_ms = localDate.getTime(); 
      
    EDT_EST = checkDST(localDate_ms);
      if (EDT_EST === true){
        TZ = -4; 
      }
      else
      {
        TZ = -5; 
      }   
     
    DST = processDST(localDate_ms);
     
      if ((DST  ===  1) && (dstLockout === false)) {
      digitalWrite(LED1,true);
      dstLockout = true;
      } 
     
      if ((DST  === -1) && (dstLockout === false)) {      
      digitalWrite(LED1,true);  
      dstLockout = true; 
      }
     
      
      if (localDate.getHours() === 3) {
        dstLockout = false;
        digitalWrite(LED1,false);
        digitalWrite(LED2,false);
      }
      
    var TZdiff_ms = utcDate_ms-localDate_ms; 
    var ms_diff = utcDate_ms + (TZ * 3600000) - localDate_ms;
      
    
      if ((utcDate.getHours() === 11) && (utcDate.getMinutes() === 59) && (utcDate.getSeconds() === 59)) {  
        if ((ms_diff >= -5000 ) && (ms_diff <= 5000)){
          rtc1.setTime(utcDate.getHours()+ TZ + 1,0); 
          digitalWrite(LED2,true);
         }
      }
      
       
        
        lcd.setCursor(0,1);    
        lcd.print(date_time1);
        lcd.print(" U");
        idx1 = !idx1;
        if (idx1 === true){ lcd.print("*");}
        if (idx1 === false){ lcd.print(" ");}
      
        lcd.setCursor(0,2);   
        lcd.print(date_time2);
        lcd.print(" L");
        idx2 = !idx2;
        if (idx2 === true){ lcd.print("*");}
        if (idx2 === false){ lcd.print(" ");}
      
       
       
       
        lcd.setCursor(0,3);
        
      if (TZ === -4){
          lcd.print("EDT Sum ");
       }
       else
       { 
          lcd.print("EST Win ");
       }
        lcd.print("TZ");
        lcd.print(new String(TZ));
        lcd.print(" ");  
      
       var dw = localDate.getDay(); 
      
       if (dw === 0) {lcd.print("Sun");}
       if (dw === 1) {lcd.print("Mon");}
       if (dw === 2) {lcd.print("Tue");}
       if (dw === 3) {lcd.print("Wed");}
       if (dw === 4) {lcd.print("Thu");}
       if (dw === 5) {lcd.print("Fri");}
       if (dw === 6) {lcd.print("Sat");} 
      
       lcd.print(" ");
    
       var month = localDate.getMonth();
       if (month === 0)  {lcd.print("Jan");}
       if (month === 1)  {lcd.print("Feb");}
       if (month === 2)  {lcd.print("Mar");}
       if (month === 3)  {lcd.print("Apr");}
       if (month === 4)  {lcd.print("May");}
       if (month === 5)  {lcd.print("Jun");}
       if (month === 6)  {lcd.print("Jul");}
       if (month === 7)  {lcd.print("Aug");}
       if (month === 8)  {lcd.print("Sep");}
       if (month === 9)  {lcd.print("Oct");}
       if (month === 10) {lcd.print("Nov");}
       if (month === 11) {lcd.print("Dec");}  
        
      if (gps_flag === true){
        //print("got GPS");
        gps_fix = !gps_fix;
        lcd.setCursor(19,0);
        if (gps_fix === true){ lcd.print("*");}
        if (gps_fix === false){ lcd.print(" ");}
        lcd.setCursor(0,1);
        gps_flag = false;
      }
    }
    
    
    
    function checkDST(current_ms){  
      if ((current_ms >= SF2014 ) && (current_ms <= FB2014)){ return true;}
      if ((current_ms >= SF2015 ) && (current_ms <= FB2015)){ return true;}
      if ((current_ms >= SF2016 ) && (current_ms <= FB2016)){ return true;}
      if ((current_ms >= SF2017 ) && (current_ms <= FB2017)){ return true;}
      if ((current_ms >= SF2018 ) && (current_ms <= FB2018)){ return true;}
      if ((current_ms >= SF2019 ) && (current_ms <= FB2019)){ return true;} 
      return false;
    }
    
    function processDST(local_ms){
      if (local_ms === SF2014 ) {return  1;}
      if (local_ms === FB2014 ) {return -1;}
      if (local_ms === SF2015 ) {return  1;}
      if (local_ms === FB2015 ) {return -1;} 
      if (local_ms === SF2016 ) {return  1;}
      if (local_ms === FB2016 ) {return -1;} 
      if (local_ms === SF2017 ) {return  1;}
      if (local_ms === FB2017 ) {return -1;} 
      if (local_ms === SF2018 ) {return  1;}
      if (local_ms === FB2018 ) {return -1;} 
      if (local_ms === SF2019 ) {return  1;}
      if (local_ms === FB2019 ) {return -1;} 
      return 0;
    }  
      
    
        
    setWatch(RTC_INT_1Hz, B3, { repeat: true, edge:'falling', debounce:0});
    
    
    onInit();
    
  • What are you seeing when you run tht code?

    When I do it, on bigram or normal, I see a big delay during which it looks non responsive (due to echo(0) not having been unset until onInit() is finished - this is why I never put onInit() at the end of my code, and always do that manually - so I can see what's going on)

  • After uploading the code to the Espruino it "hangs/stop/halts" the communications and the > prompt does not return. The only way to "unhang" the Espruino is to do a dis-connect/reset the Espruino/reconnect.

    I figure if my new code works with BigRam then everything should be OK since all my RTCs
    are running in my application user code.

    So far, one person has reported getting an espruino with a chip that
    doesn't work with bigram.

    That is truly amazing since ...

    The Espruino Board was Crowdfunded in September 2013 - and we've
    already shipped almost 4000 boards to over 2000 customers!

    1 out of 4000 Espruino boards and not counting the clones!

  • You're the one person with the chip that I thought didn't work with bigram.

    Sorry, I thought your post was the last, but there were a few more between your last post and the last post I'd read that I missed.

    I can't reproduce that behavior.

    I get a hang, but only while onInit() is running (you will not get a cursor while onInit() is running if you have onInit() at the bottom of the code you send from the right window - echo will still be off until it's done running) - for me that hang is very brief, because onInit() quickly crashes because I don't have any of the hardware you talk to.

    Same behavior on bigram and normal.

  • You're the one person with the chip that I thought didn't work with
    bigram.

    Make that 0 out of 4000 boards for 100% users that are able to run your BigRam except when
    there is an unknown user code problem.

    My new code workaround did the trick.

  • Glad you got it sorted! What was the problem?

    Looking at your code, the following might help with memory usage:

    • You can use string[index] instead of string.charAt(index) and save a few characters, or for extracting a substring you could use substr,substring or slice (all of which do basically the same thing)
    • Instead of if (dw === 0) {lcd.print("Sun");} ... what about lcd.print(["Mon","Tue","Wed",...][dw]); - stuff like that will really compact your code.
    • I don't know what you intend, but if you define a variable in a function without adding var before it (eg. a=5 vs var a=5), that variable becomes global and will always take up memory. If you add the var before it then the variable is local to the function, and the memory it uses will be freed after the function is done executing...
  • What was the problem?

    Something in the code (above) stops BigRam. Since I re-wrote the code to minimize the DST
    algorithm, the problem went away mysteriously.

  • The site was down for a day or two due to an amazon "maintenance" during which the instance was forcibly shutdown (I got an emailed warning in early august, which I promptly forgot about) - and I didn't have apache set up to start on boot like I thought I did.

    But an interesting aside: It would appear that this "maintenance" moved it to some much spiffier hardware - prior to the maintenance, it was taking about 12 minutes for the two builds. Now it takes 2.

  • Added links showing the changelog to the page, to help figure out which is which.

  • Website reshuffle.

    Old links should still autoredirect, let me know if it's busted in any way.

  • Wiznet builds fixed.

  • I manually rebuild the 12/17 bigram so it includes the fix for issue #460 (checked in earlier today).

    Also, bumping the thread for people who haven't seen it.

  • Builds will now only be performed if there has been a commit since the last time it was built, instead of every night. No point in building the same binary over and over. Same applies to the nucleo builds.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Nightly 'bigram' (3250 jsvar) builds for Espruino Board 1.3/1.4

Posted by Avatar for DrAzzy @DrAzzy

Actions