From 44add51c80e1133ef5b467a84005d2c6e86bfb03 Mon Sep 17 00:00:00 2001 From: hughbarney Date: Thu, 18 Mar 2021 20:40:02 +0000 Subject: [PATCH] reduced arrayBuffer size in stepo to save memory --- apps.json | 2 +- apps/stepo/ChangeLog | 1 + apps/stepo/app.js | 16 ++++++++-------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apps.json b/apps.json index 97674717a..44a6c07f6 100644 --- a/apps.json +++ b/apps.json @@ -2962,7 +2962,7 @@ { "id": "stepo", "name": "Stepometer Clock", "icon": "stepo.png", - "version":"0.02", + "version":"0.03", "description": "A large font watch, displays step count in a doughnut guage and warns of low battery", "tags": "clock", "type":"clock", diff --git a/apps/stepo/ChangeLog b/apps/stepo/ChangeLog index c94954969..a28c163c7 100644 --- a/apps/stepo/ChangeLog +++ b/apps/stepo/ChangeLog @@ -1,2 +1,3 @@ 0.01: First version 0.02: Speeded up draw, start stop timer, long press BTN2 to switch to the launcher +0.03: Reduced buffer size, save on memory diff --git a/apps/stepo/app.js b/apps/stepo/app.js index e3f7092f1..b8a1ea8c9 100644 --- a/apps/stepo/app.js +++ b/apps/stepo/app.js @@ -1,15 +1,15 @@ var pal4color = new Uint16Array([0x0000,0xFFFF,0x7BEF,0xAFE5],0,2); // b,w,grey,greenyellow var pal4red = new Uint16Array([0x0000,0xFFFF,0xF800,0xAFE5],0,2); // b,w,red,greenyellow -var buf = Graphics.createArrayBuffer(160,160,2,{msb:true}); +var buf = Graphics.createArrayBuffer(120,120,2,{msb:true}); var intervalRefSec; function flip(x,y) { - g.drawImage({width:160,height:160,bpp:2,buffer:buf.buffer, palette:pal4color}, x, y); + g.drawImage({width:120,height:120,bpp:2,buffer:buf.buffer, palette:pal4color}, x, y); buf.clear(); } function flip_red(x,y) { - g.drawImage({width:160,height:160,bpp:2,buffer:buf.buffer, palette:pal4red}, x, y); + g.drawImage({width:120,height:120,bpp:2,buffer:buf.buffer, palette:pal4red}, x, y); buf.clear(); } @@ -19,8 +19,8 @@ function radians(a) { function drawSteps() { var i = 0; - var cx = 80; - var cy = 75; + var cx = 60; + var cy = 60; var r = 56; var steps = getSteps(); var percent = steps / 10000; @@ -53,13 +53,13 @@ function drawSteps() { buf.setColor(1); // white buf.setFont("Vector", 24); buf.setFontAlign(0,0); - buf.drawString(steps, 80, cy); + buf.drawString(steps, cx, cy); // change the remaining color to RED if battery is below 25% if (E.getBattery() > 25) - flip(40,100); + flip(60,115); else - flip_red(40,100); + flip_red(60,115); } function draw() {