Merge pull request #695 from hughbarney/master

reduced arrayBuffer size in stepo to save memory
pull/698/head
Gordon Williams 2021-03-19 08:21:30 +00:00 committed by GitHub
commit e969ebf140
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 9 deletions

View File

@ -2962,7 +2962,7 @@
{ "id": "stepo", { "id": "stepo",
"name": "Stepometer Clock", "name": "Stepometer Clock",
"icon": "stepo.png", "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", "description": "A large font watch, displays step count in a doughnut guage and warns of low battery",
"tags": "clock", "tags": "clock",
"type":"clock", "type":"clock",

View File

@ -1,2 +1,3 @@
0.01: First version 0.01: First version
0.02: Speeded up draw, start stop timer, long press BTN2 to switch to the launcher 0.02: Speeded up draw, start stop timer, long press BTN2 to switch to the launcher
0.03: Reduced buffer size, save on memory

View File

@ -1,15 +1,15 @@
var pal4color = new Uint16Array([0x0000,0xFFFF,0x7BEF,0xAFE5],0,2); // b,w,grey,greenyellow 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 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; var intervalRefSec;
function flip(x,y) { 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(); buf.clear();
} }
function flip_red(x,y) { 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(); buf.clear();
} }
@ -19,8 +19,8 @@ function radians(a) {
function drawSteps() { function drawSteps() {
var i = 0; var i = 0;
var cx = 80; var cx = 60;
var cy = 75; var cy = 60;
var r = 56; var r = 56;
var steps = getSteps(); var steps = getSteps();
var percent = steps / 10000; var percent = steps / 10000;
@ -53,13 +53,13 @@ function drawSteps() {
buf.setColor(1); // white buf.setColor(1); // white
buf.setFont("Vector", 24); buf.setFont("Vector", 24);
buf.setFontAlign(0,0); 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% // change the remaining color to RED if battery is below 25%
if (E.getBattery() > 25) if (E.getBattery() > 25)
flip(40,100); flip(60,115);
else else
flip_red(40,100); flip_red(60,115);
} }
function draw() { function draw() {