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();
@user7114 started
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.
Code that fails BigRam excluding other user application coding.
This code is pretty straightforward.