warpdrive 0.04: Remove buffer finding code (which fails if screen rotated) and make dependent on fw 2v21's Bangle.getOptions().lcdBufferPtr (fix #3818)
Also adds check for non-contiguous memorymaster
parent
60d6742e41
commit
4b9fae3803
|
|
@ -1,3 +1,4 @@
|
|||
0.01: New app!
|
||||
0.02: Minor code improvements
|
||||
0.03: Minor code improvements
|
||||
0.04: Remove buffer finding code (which fails if screen rotated) and make dependent on fw 2v21's Bangle.getOptions().lcdBufferPtr (fix #3818)
|
||||
|
|
@ -480,7 +480,6 @@ void render(int* n, const unsigned char* m){
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
`);
|
||||
|
||||
const nodeCount = 4;
|
||||
|
|
@ -490,9 +489,7 @@ const translation = new Uint32Array(10);
|
|||
let bgColor = 0;
|
||||
const BLACK = g.setColor.bind(g, 0);
|
||||
const WHITE = g.setColor.bind(g, 0xFFFF);
|
||||
let lcdBuffer = 0,
|
||||
start = 0;
|
||||
|
||||
let lcdBuffer = 0;
|
||||
let locked = false;
|
||||
let charging = false;
|
||||
let stopped = true;
|
||||
|
|
@ -522,65 +519,6 @@ function test(addr, y) {
|
|||
return !peek8(addr);
|
||||
}
|
||||
|
||||
function probe() {
|
||||
if (!start) {
|
||||
start = 0x20000000;
|
||||
if (test(Bangle.getOptions().lcdBufferPtr, 0))
|
||||
start = Bangle.getOptions().lcdBufferPtr; // FW=2v21
|
||||
else if (test(0x2002d3fe, 0)) // try to skip loading if possible
|
||||
start = 0x2002d3fe; // FW=2v20
|
||||
}
|
||||
const end = Math.min(start + 0x800, 0x20038000);
|
||||
|
||||
if (start >= end) {
|
||||
print("Could not find framebuffer");
|
||||
return;
|
||||
}
|
||||
|
||||
BLACK().fillRect(0, 0, 176, 0);
|
||||
// sampling every 64 bytes since a 176-pixel row is 66 bytes at 3bpp
|
||||
for (; start < end; start += 64) {
|
||||
if (peek8(start)) continue;
|
||||
WHITE().fillRect(0, 0, 176, 0);
|
||||
let b = peek8(start);
|
||||
BLACK().fillRect(0, 0, 176, 0);
|
||||
if (!b) continue;
|
||||
if (!peek8(start)) break;
|
||||
}
|
||||
|
||||
if (start >= end) {
|
||||
setTimeout(probe, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// find the beginning of the row
|
||||
while (test(start - 1, 0))
|
||||
start--;
|
||||
|
||||
/*
|
||||
let stride = (176 * 3 + 7) >> 3,
|
||||
padding = 0;
|
||||
for (let i = 0; i < 20; ++i, ++padding) {
|
||||
if (test(start + stride + padding, 1)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
stride += padding;
|
||||
if (padding == 20) {
|
||||
print("Warning: Could not calculate padding");
|
||||
stride = 68;
|
||||
}
|
||||
*/
|
||||
let stride = 68;
|
||||
|
||||
lcdBuffer = start;
|
||||
print('Found lcdBuffer at ' + lcdBuffer.toString(16) + ' stride=' + stride);
|
||||
gfx.init(start, stride, E.getAddressOf(sintable, true));
|
||||
gfx.setCamera(0, 0, -300 << 8);
|
||||
setupInterval(true);
|
||||
}
|
||||
|
||||
function init() {
|
||||
bgColor = g.theme.bg & 0x8410;
|
||||
bgColor = ((bgColor >> 15) | (bgColor >> 9) | (bgColor >> 2));
|
||||
|
|
@ -612,7 +550,22 @@ function init() {
|
|||
c: i
|
||||
};
|
||||
}
|
||||
setTimeout(probe, 1);
|
||||
lcdBuffer = Bangle.getOptions().lcdBufferPtr;
|
||||
if (!lcdBuffer) {
|
||||
E.showMessage("Needs firmwave 2v21 or newer");
|
||||
return;
|
||||
}
|
||||
let stride = 68;
|
||||
//print('Found lcdBuffer at ' + lcdBuffer.toString(16) + ' stride=' + stride);
|
||||
var sintablePtr = E.getAddressOf(sintable, true);
|
||||
if (!sintablePtr) {
|
||||
lcdBuffer = 0;
|
||||
E.showMessage("Not enough memory");
|
||||
return;
|
||||
}
|
||||
gfx.init(lcdBuffer, stride, sintablePtr);
|
||||
gfx.setCamera(0, 0, -300 << 8);
|
||||
setupInterval(true);
|
||||
}
|
||||
|
||||
function updateNode(index) {
|
||||
|
|
@ -657,12 +610,17 @@ function drawNode(index) {
|
|||
translation[i++] = o.y * 256;
|
||||
translation[i++] = o.z * 256;
|
||||
translation[i++] = o.c;
|
||||
gfx.render(E.getAddressOf(translation, true));
|
||||
let translationPtr = E.getAddressOf(translation, true);
|
||||
if (!translationPtr) {
|
||||
lcdBuffer = 0;
|
||||
E.showMessage("Not enough memory");
|
||||
return;
|
||||
}
|
||||
gfx.render(translationPtr);
|
||||
}
|
||||
|
||||
function tick(locked) {
|
||||
g.reset();
|
||||
|
||||
if (lcdBuffer && !locked) {
|
||||
BLACK().drawRect(-1, -1, 0, 177); // dirty all the rows
|
||||
gfx.clear(bgColor);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "warpdrive",
|
||||
"name": "warpdrive clock",
|
||||
"version": "0.03",
|
||||
"version": "0.04",
|
||||
"description": "A watchface with an animated 3D scene.",
|
||||
"readme": "README.md",
|
||||
"icon": "app.png",
|
||||
|
|
|
|||
Loading…
Reference in New Issue