Commit from GitHub Actions
This commit is contained in:
parent
423717c29b
commit
2a48c5d3ba
173
docs/lvgl.html
173
docs/lvgl.html
@ -1299,88 +1299,119 @@
|
||||
</script>
|
||||
<!-- Custom Script -->
|
||||
<script type="text/javascript">
|
||||
/// In JavaScript: Render the C WebAssembly Display Buffer to the HTML Canvas
|
||||
function render_canvas() {
|
||||
Module.print(`In JavaScript: render_canvas()`);
|
||||
const DISPLAY_BYTES_PER_PIXEL = 4; // 4 bytes per pixel: RGBA
|
||||
const DISPLAY_SCALE = 2; // Scale the canvas width and height
|
||||
/// Rendering Parameters
|
||||
const DISPLAY_SCALE = 2; // Scale the canvas width and height
|
||||
const DISPLAY_BYTES_PER_PIXEL = 4; // 4 bytes per pixel: RGBA
|
||||
const DEMO_MODE = false; // Set to true to see demo widget, false to see PineTime Watch Face
|
||||
|
||||
// Init LVGL Display
|
||||
Module._init_display();
|
||||
/// In JavaScript: Create the Watch Face in WebAssembly
|
||||
function renderCanvas() {
|
||||
Module.print(`In JavaScript: Rendering canvas...`);
|
||||
|
||||
// Set to true to see demo widget, false to see PineTime Watch Face
|
||||
const demo_mode = false;
|
||||
if (demo_mode) {
|
||||
// Construct the demo LVGL Widgets
|
||||
Module._render_widgets();
|
||||
} else {
|
||||
// Create the LVGL Watch Face Widgets
|
||||
Module._create_clock();
|
||||
// Init LVGL Display in WebAssembly
|
||||
Module._init_display();
|
||||
|
||||
// Refresh the LVGL Watch Face Widgets
|
||||
Module._refresh_clock();
|
||||
if (DEMO_MODE) {
|
||||
// Create the Demo Widgets in WebAssembly
|
||||
Module._render_widgets();
|
||||
} else {
|
||||
// Create the Watch Face in WebAssembly
|
||||
Module._create_clock();
|
||||
}
|
||||
// Draw the Watch Face
|
||||
updateCanvas();
|
||||
}
|
||||
|
||||
// Update the LVGL Watch Face Widgets
|
||||
// Module._update_clock();
|
||||
}
|
||||
/// In JavaScript: Update the Watch Face time in WebAssembly and render the WebAssembly Display Buffer to the HTML Canvas
|
||||
function updateCanvas() {
|
||||
Module.print(`In JavaScript: Updating canvas...`);
|
||||
if (!DEMO_MODE) {
|
||||
// Update the WebAssembly Date and Time: year, month, day, hour, minute, second
|
||||
const localTime = new Date();
|
||||
const timezoneOffset = localTime.getTimezoneOffset(); // In mins
|
||||
// Compensate for the time zone
|
||||
const now = new Date(
|
||||
localTime.valueOf() // Convert time to millisec
|
||||
- (timezoneOffset * 60 * 1000) // Convert mins to millisec
|
||||
);
|
||||
Module._update_clock(
|
||||
now.getFullYear(),
|
||||
now.getMonth() - 1, // getMonth() returns 1 to 12
|
||||
now.getDay(),
|
||||
now.getHours(),
|
||||
now.getMinutes(),
|
||||
now.getSeconds()
|
||||
);
|
||||
|
||||
// Render LVGL Widgets to the WebAssembly Display Buffer
|
||||
Module._render_display();
|
||||
|
||||
// Fetch the PineTime dimensions from WebAssembly Display Buffer
|
||||
var width = Module._get_display_width();
|
||||
var height = Module._get_display_height();
|
||||
// Update the Watch Face time in WebAssembly
|
||||
Module._refresh_clock();
|
||||
}
|
||||
|
||||
// Resize the canvas to PineTime dimensions (240 x 240)
|
||||
if (
|
||||
Module.canvas.width != width * DISPLAY_SCALE ||
|
||||
Module.canvas.height != height * DISPLAY_SCALE
|
||||
) {
|
||||
Module.canvas.width = width * DISPLAY_SCALE;
|
||||
Module.canvas.height = height * DISPLAY_SCALE;
|
||||
}
|
||||
|
||||
// Fetch the canvas pixels
|
||||
var ctx = Module.canvas.getContext('2d');
|
||||
var imageData = ctx.getImageData(0, 0, width * DISPLAY_SCALE, height * DISPLAY_SCALE);
|
||||
var data = imageData.data;
|
||||
|
||||
// Copy the pixels from the WebAssembly Display Buffer to the canvas
|
||||
var addr = Module._get_display_buffer();
|
||||
Module.print(`In JavaScript: get_display_buffer() returned ${toHex(addr)}`);
|
||||
for (var y = 0; y < height; y++) {
|
||||
// Scale the pixels vertically to fill the canvas
|
||||
for (var ys = 0; ys < DISPLAY_SCALE; ys++) {
|
||||
for (var x = 0; x < width; x++) {
|
||||
// Copy from src to dest with scaling
|
||||
const src = ((y * width) + x) * DISPLAY_BYTES_PER_PIXEL;
|
||||
const dest = ((((y * DISPLAY_SCALE + ys) * width) + x) * DISPLAY_BYTES_PER_PIXEL)
|
||||
* DISPLAY_SCALE;
|
||||
// Scale the pixels horizontally to fill the canvas
|
||||
for (var xs = 0; xs < DISPLAY_SCALE; xs++) {
|
||||
const dest2 = dest + xs * DISPLAY_BYTES_PER_PIXEL;
|
||||
// Copy 4 bytes: RGBA
|
||||
for (var b = 0; b < DISPLAY_BYTES_PER_PIXEL; b++) {
|
||||
data[dest2 + b] = Module.HEAPU8[addr + src + b];
|
||||
}
|
||||
// Render Watch Face to the WebAssembly Display Buffer
|
||||
Module._render_display();
|
||||
|
||||
// Fetch the PineTime dimensions from WebAssembly Display Buffer
|
||||
var width = Module._get_display_width();
|
||||
var height = Module._get_display_height();
|
||||
|
||||
// Resize the canvas to PineTime dimensions (240 x 240)
|
||||
if (
|
||||
Module.canvas.width != width * DISPLAY_SCALE ||
|
||||
Module.canvas.height != height * DISPLAY_SCALE
|
||||
) {
|
||||
Module.canvas.width = width * DISPLAY_SCALE;
|
||||
Module.canvas.height = height * DISPLAY_SCALE;
|
||||
}
|
||||
|
||||
// Fetch the canvas pixels
|
||||
var ctx = Module.canvas.getContext('2d');
|
||||
var imageData = ctx.getImageData(0, 0, width * DISPLAY_SCALE, height * DISPLAY_SCALE);
|
||||
var data = imageData.data;
|
||||
|
||||
// Copy the pixels from the WebAssembly Display Buffer to the canvas
|
||||
var addr = Module._get_display_buffer();
|
||||
Module.print(`In JavaScript: get_display_buffer() returned ${toHex(addr)}`);
|
||||
for (var y = 0; y < height; y++) {
|
||||
// Scale the pixels vertically to fill the canvas
|
||||
for (var ys = 0; ys < DISPLAY_SCALE; ys++) {
|
||||
for (var x = 0; x < width; x++) {
|
||||
// Copy from src to dest with scaling
|
||||
const src = ((y * width) + x) * DISPLAY_BYTES_PER_PIXEL;
|
||||
const dest = ((((y * DISPLAY_SCALE + ys) * width) + x) * DISPLAY_BYTES_PER_PIXEL)
|
||||
* DISPLAY_SCALE;
|
||||
// Scale the pixels horizontally to fill the canvas
|
||||
for (var xs = 0; xs < DISPLAY_SCALE; xs++) {
|
||||
const dest2 = dest + xs * DISPLAY_BYTES_PER_PIXEL;
|
||||
// Copy 4 bytes: RGBA
|
||||
for (var b = 0; b < DISPLAY_BYTES_PER_PIXEL; b++) {
|
||||
data[dest2 + b] = Module.HEAPU8[addr + src + b];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Paint the canvas
|
||||
ctx.putImageData(imageData, 0, 0);
|
||||
}
|
||||
|
||||
// In JavaScript: Wait for emscripten to be initialised
|
||||
Module.onRuntimeInitialized = function() {
|
||||
// Render LVGL to HTML Canvas
|
||||
render_canvas();
|
||||
};
|
||||
|
||||
/// Convert i to hexadecimal
|
||||
function toHex(i) { return "0x" + Number(i).toString(16); }
|
||||
|
||||
|
||||
// Paint the canvas
|
||||
ctx.putImageData(imageData, 0, 0);
|
||||
|
||||
// Update the Watch Face at the next minute
|
||||
const sleepSeconds = 60 - new Date().getSeconds();
|
||||
Module.print(`In JavaScript: Sleeping ${sleepSeconds} seconds...`);
|
||||
window.setTimeout(
|
||||
updateCanvas,
|
||||
sleepSeconds * 1000
|
||||
);
|
||||
}
|
||||
|
||||
/// Wait for emscripten to be initialised
|
||||
Module.onRuntimeInitialized = function() {
|
||||
// Render LVGL to HTML Canvas
|
||||
renderCanvas();
|
||||
};
|
||||
|
||||
/// Convert i to hexadecimal
|
||||
function toHex(i) { return "0x" + Number(i).toString(16); }
|
||||
|
||||
</script>
|
||||
<!-- End of Custom Script -->
|
||||
<script async type="text/javascript" src="lvgl.js"></script>
|
||||
|
84
docs/lvgl.js
84
docs/lvgl.js
@ -1292,11 +1292,11 @@ function updateGlobalBufferAndViews(buf) {
|
||||
}
|
||||
|
||||
var STATIC_BASE = 1024,
|
||||
STACK_BASE = 5730896,
|
||||
STACK_BASE = 5730928,
|
||||
STACKTOP = STACK_BASE,
|
||||
STACK_MAX = 488016,
|
||||
DYNAMIC_BASE = 5730896,
|
||||
DYNAMICTOP_PTR = 487856;
|
||||
STACK_MAX = 488048,
|
||||
DYNAMIC_BASE = 5730928,
|
||||
DYNAMICTOP_PTR = 487888;
|
||||
|
||||
assert(STACK_BASE % 16 === 0, 'stack must start aligned');
|
||||
assert(DYNAMIC_BASE % 16 === 0, 'heap must start aligned');
|
||||
@ -1881,7 +1881,7 @@ var ASM_CONSTS = {
|
||||
|
||||
|
||||
|
||||
// STATICTOP = STATIC_BASE + 486992;
|
||||
// STATICTOP = STATIC_BASE + 487024;
|
||||
/* global initializers */ __ATINIT__.push({ func: function() { ___wasm_call_ctors() } });
|
||||
|
||||
|
||||
@ -1946,7 +1946,7 @@ var ASM_CONSTS = {
|
||||
}
|
||||
|
||||
function _emscripten_get_sbrk_ptr() {
|
||||
return 487856;
|
||||
return 487888;
|
||||
}
|
||||
|
||||
function _emscripten_memcpy_big(dest, src, num) {
|
||||
@ -2076,6 +2076,76 @@ var ASM_CONSTS = {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function _tzset() {
|
||||
// TODO: Use (malleable) environment variables instead of system settings.
|
||||
if (_tzset.called) return;
|
||||
_tzset.called = true;
|
||||
|
||||
// timezone is specified as seconds west of UTC ("The external variable
|
||||
// `timezone` shall be set to the difference, in seconds, between
|
||||
// Coordinated Universal Time (UTC) and local standard time."), the same
|
||||
// as returned by getTimezoneOffset().
|
||||
// See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
|
||||
HEAP32[((__get_timezone())>>2)]=(new Date()).getTimezoneOffset() * 60;
|
||||
|
||||
var currentYear = new Date().getFullYear();
|
||||
var winter = new Date(currentYear, 0, 1);
|
||||
var summer = new Date(currentYear, 6, 1);
|
||||
HEAP32[((__get_daylight())>>2)]=Number(winter.getTimezoneOffset() != summer.getTimezoneOffset());
|
||||
|
||||
function extractZone(date) {
|
||||
var match = date.toTimeString().match(/\(([A-Za-z ]+)\)$/);
|
||||
return match ? match[1] : "GMT";
|
||||
};
|
||||
var winterName = extractZone(winter);
|
||||
var summerName = extractZone(summer);
|
||||
var winterNamePtr = allocateUTF8(winterName);
|
||||
var summerNamePtr = allocateUTF8(summerName);
|
||||
if (summer.getTimezoneOffset() < winter.getTimezoneOffset()) {
|
||||
// Northern hemisphere
|
||||
HEAP32[((__get_tzname())>>2)]=winterNamePtr;
|
||||
HEAP32[(((__get_tzname())+(4))>>2)]=summerNamePtr;
|
||||
} else {
|
||||
HEAP32[((__get_tzname())>>2)]=summerNamePtr;
|
||||
HEAP32[(((__get_tzname())+(4))>>2)]=winterNamePtr;
|
||||
}
|
||||
}function _mktime(tmPtr) {
|
||||
_tzset();
|
||||
var date = new Date(HEAP32[(((tmPtr)+(20))>>2)] + 1900,
|
||||
HEAP32[(((tmPtr)+(16))>>2)],
|
||||
HEAP32[(((tmPtr)+(12))>>2)],
|
||||
HEAP32[(((tmPtr)+(8))>>2)],
|
||||
HEAP32[(((tmPtr)+(4))>>2)],
|
||||
HEAP32[((tmPtr)>>2)],
|
||||
0);
|
||||
|
||||
// There's an ambiguous hour when the time goes back; the tm_isdst field is
|
||||
// used to disambiguate it. Date() basically guesses, so we fix it up if it
|
||||
// guessed wrong, or fill in tm_isdst with the guess if it's -1.
|
||||
var dst = HEAP32[(((tmPtr)+(32))>>2)];
|
||||
var guessedOffset = date.getTimezoneOffset();
|
||||
var start = new Date(date.getFullYear(), 0, 1);
|
||||
var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
|
||||
var winterOffset = start.getTimezoneOffset();
|
||||
var dstOffset = Math.min(winterOffset, summerOffset); // DST is in December in South
|
||||
if (dst < 0) {
|
||||
// Attention: some regions don't have DST at all.
|
||||
HEAP32[(((tmPtr)+(32))>>2)]=Number(summerOffset != winterOffset && dstOffset == guessedOffset);
|
||||
} else if ((dst > 0) != (dstOffset == guessedOffset)) {
|
||||
var nonDstOffset = Math.max(winterOffset, summerOffset);
|
||||
var trueOffset = dst > 0 ? dstOffset : nonDstOffset;
|
||||
// Don't try setMinutes(date.getMinutes() + ...) -- it's messed up.
|
||||
date.setTime(date.getTime() + (trueOffset - guessedOffset)*60000);
|
||||
}
|
||||
|
||||
HEAP32[(((tmPtr)+(24))>>2)]=date.getDay();
|
||||
var yday = ((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24))|0;
|
||||
HEAP32[(((tmPtr)+(28))>>2)]=yday;
|
||||
|
||||
return (date.getTime() / 1000)|0;
|
||||
}
|
||||
|
||||
function _setTempRet0($i) {
|
||||
setTempRet0(($i) | 0);
|
||||
}
|
||||
@ -2109,7 +2179,7 @@ function intArrayToString(array) {
|
||||
|
||||
|
||||
var asmGlobalArg = {};
|
||||
var asmLibraryArg = { "__assert_fail": ___assert_fail, "__handle_stack_overflow": ___handle_stack_overflow, "abort": _abort, "emscripten_get_sbrk_ptr": _emscripten_get_sbrk_ptr, "emscripten_memcpy_big": _emscripten_memcpy_big, "emscripten_resize_heap": _emscripten_resize_heap, "fd_write": _fd_write, "memory": wasmMemory, "setTempRet0": _setTempRet0, "table": wasmTable };
|
||||
var asmLibraryArg = { "__assert_fail": ___assert_fail, "__handle_stack_overflow": ___handle_stack_overflow, "abort": _abort, "emscripten_get_sbrk_ptr": _emscripten_get_sbrk_ptr, "emscripten_memcpy_big": _emscripten_memcpy_big, "emscripten_resize_heap": _emscripten_resize_heap, "fd_write": _fd_write, "memory": wasmMemory, "mktime": _mktime, "setTempRet0": _setTempRet0, "table": wasmTable };
|
||||
var asm = createWasm();
|
||||
/** @type {function(...*):?} */
|
||||
var ___wasm_call_ctors = Module["___wasm_call_ctors"] = createExportWrapper("__wasm_call_ctors");
|
||||
|
6628
docs/lvgl.txt
6628
docs/lvgl.txt
File diff suppressed because it is too large
Load Diff
BIN
docs/lvgl.wasm
BIN
docs/lvgl.wasm
Binary file not shown.
Loading…
Reference in New Issue
Block a user