diff --git a/ChangeLog b/ChangeLog index 389ce6244..ce2280236 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ Fix escaping of `\r` in built-in modules, fixed regression that stopped Espruino WiFi 2v25 from connecting to Wifi BLE: always return privacy info from NRF.getSecurityStatus(), regardless of connection state Linux SDL build: mouse events now create `E.on("touch"` events like on CYD + nRF52: Bootloader now doesn't reset RESETREAS + nRF52: If we reboot because of LOCKUP, don't enable DCDC converter + Bangle.js2: Test screen now fails if no DCDC enabled 2v25 : ESP32C3: Get analogRead working correctly Graphics: Adjust image alignment when rotating images to avoid cropping (fix #2535) diff --git a/libs/js/banglejs/Bangle_showTestScreen.js b/libs/js/banglejs/Bangle_showTestScreen.js index 32f6aa19d..651ce4736 100644 --- a/libs/js/banglejs/Bangle_showTestScreen.js +++ b/libs/js/banglejs/Bangle_showTestScreen.js @@ -34,7 +34,12 @@ var av = analogRead(D3), v=av*13.359; chg |= Bangle.isCharging(); if (av>mv) cup=1; - draw(8,'Chg',v.toFixed(2)+"v "+(Bangle.isCharging()?"charge":"discharge"),chg&&cup&&(v>2)&&(v<4.4)); + var ok = chg&&cup&&(v>2)&&(v<4.4), msg = v.toFixed(2)+"v "+(Bangle.isCharging()?"charge":"discharge"); + if (!peek32(0x40000578)) { // DCDCEN + msg = "NO DCDC"; + ok = false; + } + draw(8,'Chg',msg,ok); },500); },1000); Bangle.on('swipe', e => { diff --git a/libs/js/banglejs/Bangle_showTestScreen.min.js b/libs/js/banglejs/Bangle_showTestScreen.min.js index cae5ce65d..42e591d0e 100644 --- a/libs/js/banglejs/Bangle_showTestScreen.min.js +++ b/libs/js/banglejs/Bangle_showTestScreen.min.js @@ -1,2 +1,2 @@ -(ª(){ªc(a,b,e,d){k[a]=d;aš19;g.reset().clearRect(48,a,175,a+19).setFont(Ñ6x8:1x2);g.setBgColor(d?Ñ#0f0:Ñ#f00).clearRect(0,a,48,a+19);g.setFontAlign(0,0).drawString(b,24,a+10);g.setFontAlign(-1,0).drawString(e,52,a+10)}Bangle.setUI();clearInterval();clearWatch();g.clear(1);Bangle.removeAllListeners();E.removeAllListeners();Bangle.setBarometerPower(1,Ñapp);Bangle.setCompassPower(1,Ñapp);Bangle.setGPSPower(1,Ñapp);Bangle.setHRMPower(1,Ñapp);Bangle.setLCDPower(1);Bangle.setLocked(0);Bangle.setLCDTimeout(0);¬k=[];®f=Math.abs;Ñ"TS GPS HRM Baro Mag Acc Btn FW Chg.split(Ñ ).forEach((a,b)¢c(b,a,"",!1));Bangle.on(Ñtouch,(a,b)¢c(0,ÑTS,b.x+Ñ,+b.y,-25b.xž200>b.y));Bangle.on(ÑGPS,a¢c(1,ÑGPS,a.time?require(Ñlocale).time(a.time,1):Ñ--,!0));Bangle.on(ÑHRM-raw,a¢c(2,ÑHRM,a.vcPPG,0Ža.vcPPGž5E3‘a.vcPPG));Bangle.on(Ñpressure,a¢c(3,ÑBaro,Math.round(a.pressure),900a.pressure));Bangle.on(Ñmag,a¢c(4,ÑMag,a.x+Ñ,+a.y+Ñ,+a.z,5E3>f(a.x)ž5E3>Math.abs(a.y)ž5E3>Math.abs(a.z)));Bangle.on(Ñaccel,a¢c(5,ÑAcc,a.x.toFixed(1)+Ñ,+a.y.toFixed(1)+Ñ,+a.z.toFixed(1),.5>f(a.x)ž.5>f(a.y)ž-.8>a.z));setWatch(a¢c(6,ÑBtn,a.state?ÑPress:ÑReleased,!0),BTN,{edge:0,repeat:1});¬l=require(ÑStorage).read(Ñ.bootcde);c(7,ÑFW,Ñboot +(require(ÑStorage).readJSON(Ñ boot.info,1) {}).version ÑNONE,lžl.includes(ÑclockHasWidgets));setTimeout(ª(){¬a=(1E-4+analogRead(D3)+analogRead(D3)+analogRead(D3))/3,b=0,e=0;setInterval(ª(){¬d=analogRead(D3),h=13.359*d;eŸBangle.isCharging();d>až(b=1);c(8,ÑChg,h.toFixed(2)+Ñv +(Bangle.isCharging()?Ñcharge:Ñ discharge),ežbž2h)},500)},1E3);Bangle.on(Ñswipe,a¢{k.every(b¢b)ž(Bangle.removeAllListeners(),clearInterval(),clearWatch(),NRF.sleep(),Bangle.setBarometerPower(0,Ñapp),Bangle.setCompassPower(0,Ñapp),Bangle.setGPSPower(0,Ñapp),Bangle.setHRMPower(0,Ñapp),Bangle.setBacklight(0),Bangle.setLocked(1),g.clear(1).setFont(Ñ12x20:2).setFontAlign(0,0).drawString(Ñ TEST +(ª(){ªc(a,b,f,d){k[a]=d;aš19;g.reset().clearRect(48,a,175,a+19).setFont(Ñ6x8:1x2);g.setBgColor(d?Ñ#0f0:Ñ#f00).clearRect(0,a,48,a+19);g.setFontAlign(0,0).drawString(b,24,a+10);g.setFontAlign(-1,0).drawString(f,52,a+10)}Bangle.setUI();clearInterval();clearWatch();g.clear(1);Bangle.removeAllListeners();E.removeAllListeners();Bangle.setBarometerPower(1,Ñapp);Bangle.setCompassPower(1,Ñapp);Bangle.setGPSPower(1,Ñapp);Bangle.setHRMPower(1,Ñapp);Bangle.setLCDPower(1);Bangle.setLocked(0);Bangle.setLCDTimeout(0);¬k=[];®h=Math.abs;Ñ"TS GPS HRM Baro Mag Acc Btn FW Chg.split(Ñ ).forEach((a,b)¢c(b,a,"",!1));Bangle.on(Ñtouch,(a,b)¢c(0,ÑTS,b.x+Ñ,+b.y,-25b.xž200>b.y));Bangle.on(ÑGPS,a¢c(1,ÑGPS,a.time?require(Ñlocale).time(a.time,1):Ñ--,!0));Bangle.on(ÑHRM-raw,a¢c(2,ÑHRM,a.vcPPG,0Ža.vcPPGž5E3‘a.vcPPG));Bangle.on(Ñpressure,a¢c(3,ÑBaro,Math.round(a.pressure),900a.pressure));Bangle.on(Ñmag,a¢c(4,ÑMag,a.x+Ñ,+a.y+Ñ,+a.z,5E3>h(a.x)ž5E3>Math.abs(a.y)ž5E3>Math.abs(a.z)));Bangle.on(Ñaccel,a¢c(5,ÑAcc,a.x.toFixed(1)+Ñ,+a.y.toFixed(1)+Ñ,+a.z.toFixed(1),.5>h(a.x)ž.5>h(a.y)ž-.8>a.z));setWatch(a¢c(6,ÑBtn,a.state?ÑPress:ÑReleased,!0),BTN,{edge:0,repeat:1});¬l=require(ÑStorage).read(Ñ.bootcde);c(7,ÑFW,Ñboot +(require(ÑStorage).readJSON(Ñ boot.info,1) {}).version ÑNONE,lžl.includes(ÑclockHasWidgets));setTimeout(ª(){¬a=(1E-4+analogRead(D3)+analogRead(D3)+analogRead(D3))/3,b=0,f=0;setInterval(ª(){¬d=analogRead(D3),e=13.359*d;fŸBangle.isCharging();d>až(b=1);d=fžbž2e;e=e.toFixed(2)+Ñv +(Bangle.isCharging()?Ñcharge:Ñ discharge);peek32(1073743224) (e=ÑNO DCDC,d=!1);c(8,ÑChg,e,d)},500)},1E3);Bangle.on(Ñswipe,a¢{k.every(b¢b)ž(Bangle.removeAllListeners(),clearInterval(),clearWatch(),NRF.sleep(),Bangle.setBarometerPower(0,Ñapp),Bangle.setCompassPower(0,Ñapp),Bangle.setGPSPower(0,Ñapp),Bangle.setHRMPower(0,Ñapp),Bangle.setBacklight(0),Bangle.setLocked(1),g.clear(1).setFont(Ñ12x20:2).setFontAlign(0,0).drawString(Ñ TEST PASS,88,88),require(ÑStorage).writeJSON(Ñ welcome.json,{welcomed:!1}),Bangle.setPollInterval(800),setTimeout(ª(){Bangle.off()},36E5))})}) \ No newline at end of file diff --git a/targets/nrf5x/bluetooth.c b/targets/nrf5x/bluetooth.c index 6c96791ed..f10d0c52f 100644 --- a/targets/nrf5x/bluetooth.c +++ b/targets/nrf5x/bluetooth.c @@ -2636,10 +2636,14 @@ static void ble_stack_init() { NRF_SDH_SOC_OBSERVER(m_soc_observer, APP_SOC_OBSERVER_PRIO, soc_evt_handler, NULL); #endif -#if defined(PUCKJS) || defined(RUUVITAG) || defined(ESPR_DCDC_ENABLE) - // can only be enabled if we're sure we have a DC-DC - err_code = sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE); - APP_ERROR_CHECK(err_code); +#if defined(ESPR_DCDC_ENABLE) + if (!(NRF_POWER->RESETREAS & POWER_RESETREAS_LOCKUP_Msk)) { + /* If we previously booted and got a LOCKUP reset, this could well be due to a DCDC + converter issue, so don't enable DCDC if that's the case. */ + // can only be enabled if we're sure we have a DC-DC + err_code = sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE); + APP_ERROR_CHECK(err_code); + } #endif #if defined(ESPR_DCDC_HV_ENABLE) err_code = sd_power_dcdc0_mode_set(NRF_POWER_DCDC_ENABLE); diff --git a/targets/nrf5x_dfu/main.c b/targets/nrf5x_dfu/main.c index 8e5000a0f..e80367d17 100644 --- a/targets/nrf5x_dfu/main.c +++ b/targets/nrf5x_dfu/main.c @@ -396,8 +396,6 @@ int main(void) } else { // DICKENS: Enter bootloader only if BTN2 held as well if (!get_btn2_state()) { - // Clear reset reason flags - NRF_POWER->RESETREAS = 0xFFFFFFFF; #ifdef ESPR_BOOTLOADER_SPIFLASH lcd_init(); #ifndef DICKENS @@ -427,8 +425,6 @@ int main(void) while (*reasons) reasons++; reasons++; } - // Clear reset reason flags - NRF_POWER->RESETREAS = 0xFFFFFFFF; print_fw_version(); #ifdef ESPR_BOOTLOADER_SPIFLASH if (!get_btn1_state()) flashCheckAndRun();