Commit from GitHub Actions
This commit is contained in:
parent
423717c29b
commit
2a48c5d3ba
161
docs/lvgl.html
161
docs/lvgl.html
@ -1299,87 +1299,118 @@
|
|||||||
</script>
|
</script>
|
||||||
<!-- Custom Script -->
|
<!-- Custom Script -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
/// In JavaScript: Render the C WebAssembly Display Buffer to the HTML Canvas
|
/// Rendering Parameters
|
||||||
function render_canvas() {
|
const DISPLAY_SCALE = 2; // Scale the canvas width and height
|
||||||
Module.print(`In JavaScript: render_canvas()`);
|
const DISPLAY_BYTES_PER_PIXEL = 4; // 4 bytes per pixel: RGBA
|
||||||
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
|
||||||
const DISPLAY_SCALE = 2; // Scale the canvas width and height
|
|
||||||
|
|
||||||
// Init LVGL Display
|
/// In JavaScript: Create the Watch Face in WebAssembly
|
||||||
Module._init_display();
|
function renderCanvas() {
|
||||||
|
Module.print(`In JavaScript: Rendering canvas...`);
|
||||||
|
|
||||||
// Set to true to see demo widget, false to see PineTime Watch Face
|
// Init LVGL Display in WebAssembly
|
||||||
const demo_mode = false;
|
Module._init_display();
|
||||||
if (demo_mode) {
|
|
||||||
// Construct the demo LVGL Widgets
|
|
||||||
Module._render_widgets();
|
|
||||||
} else {
|
|
||||||
// Create the LVGL Watch Face Widgets
|
|
||||||
Module._create_clock();
|
|
||||||
|
|
||||||
// Refresh the LVGL Watch Face Widgets
|
if (DEMO_MODE) {
|
||||||
Module._refresh_clock();
|
// 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
|
/// In JavaScript: Update the Watch Face time in WebAssembly and render the WebAssembly Display Buffer to the HTML Canvas
|
||||||
// Module._update_clock();
|
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
|
// Update the Watch Face time in WebAssembly
|
||||||
Module._render_display();
|
Module._refresh_clock();
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch the PineTime dimensions from WebAssembly Display Buffer
|
// Render Watch Face to the WebAssembly Display Buffer
|
||||||
var width = Module._get_display_width();
|
Module._render_display();
|
||||||
var height = Module._get_display_height();
|
|
||||||
|
|
||||||
// Resize the canvas to PineTime dimensions (240 x 240)
|
// Fetch the PineTime dimensions from WebAssembly Display Buffer
|
||||||
if (
|
var width = Module._get_display_width();
|
||||||
Module.canvas.width != width * DISPLAY_SCALE ||
|
var height = Module._get_display_height();
|
||||||
Module.canvas.height != height * DISPLAY_SCALE
|
|
||||||
) {
|
|
||||||
Module.canvas.width = width * DISPLAY_SCALE;
|
|
||||||
Module.canvas.height = height * DISPLAY_SCALE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch the canvas pixels
|
// Resize the canvas to PineTime dimensions (240 x 240)
|
||||||
var ctx = Module.canvas.getContext('2d');
|
if (
|
||||||
var imageData = ctx.getImageData(0, 0, width * DISPLAY_SCALE, height * DISPLAY_SCALE);
|
Module.canvas.width != width * DISPLAY_SCALE ||
|
||||||
var data = imageData.data;
|
Module.canvas.height != height * DISPLAY_SCALE
|
||||||
|
) {
|
||||||
|
Module.canvas.width = width * DISPLAY_SCALE;
|
||||||
|
Module.canvas.height = height * DISPLAY_SCALE;
|
||||||
|
}
|
||||||
|
|
||||||
// Copy the pixels from the WebAssembly Display Buffer to the canvas
|
// Fetch the canvas pixels
|
||||||
var addr = Module._get_display_buffer();
|
var ctx = Module.canvas.getContext('2d');
|
||||||
Module.print(`In JavaScript: get_display_buffer() returned ${toHex(addr)}`);
|
var imageData = ctx.getImageData(0, 0, width * DISPLAY_SCALE, height * DISPLAY_SCALE);
|
||||||
for (var y = 0; y < height; y++) {
|
var data = imageData.data;
|
||||||
// Scale the pixels vertically to fill the canvas
|
|
||||||
for (var ys = 0; ys < DISPLAY_SCALE; ys++) {
|
// Copy the pixels from the WebAssembly Display Buffer to the canvas
|
||||||
for (var x = 0; x < width; x++) {
|
var addr = Module._get_display_buffer();
|
||||||
// Copy from src to dest with scaling
|
Module.print(`In JavaScript: get_display_buffer() returned ${toHex(addr)}`);
|
||||||
const src = ((y * width) + x) * DISPLAY_BYTES_PER_PIXEL;
|
for (var y = 0; y < height; y++) {
|
||||||
const dest = ((((y * DISPLAY_SCALE + ys) * width) + x) * DISPLAY_BYTES_PER_PIXEL)
|
// Scale the pixels vertically to fill the canvas
|
||||||
* DISPLAY_SCALE;
|
for (var ys = 0; ys < DISPLAY_SCALE; ys++) {
|
||||||
// Scale the pixels horizontally to fill the canvas
|
for (var x = 0; x < width; x++) {
|
||||||
for (var xs = 0; xs < DISPLAY_SCALE; xs++) {
|
// Copy from src to dest with scaling
|
||||||
const dest2 = dest + xs * DISPLAY_BYTES_PER_PIXEL;
|
const src = ((y * width) + x) * DISPLAY_BYTES_PER_PIXEL;
|
||||||
// Copy 4 bytes: RGBA
|
const dest = ((((y * DISPLAY_SCALE + ys) * width) + x) * DISPLAY_BYTES_PER_PIXEL)
|
||||||
for (var b = 0; b < DISPLAY_BYTES_PER_PIXEL; b++) {
|
* DISPLAY_SCALE;
|
||||||
data[dest2 + b] = Module.HEAPU8[addr + src + b];
|
// 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
|
// Paint the canvas
|
||||||
Module.onRuntimeInitialized = function() {
|
ctx.putImageData(imageData, 0, 0);
|
||||||
// Render LVGL to HTML Canvas
|
|
||||||
render_canvas();
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Convert i to hexadecimal
|
// Update the Watch Face at the next minute
|
||||||
function toHex(i) { return "0x" + Number(i).toString(16); }
|
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>
|
</script>
|
||||||
<!-- End of Custom Script -->
|
<!-- End of Custom Script -->
|
||||||
|
84
docs/lvgl.js
84
docs/lvgl.js
@ -1292,11 +1292,11 @@ function updateGlobalBufferAndViews(buf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var STATIC_BASE = 1024,
|
var STATIC_BASE = 1024,
|
||||||
STACK_BASE = 5730896,
|
STACK_BASE = 5730928,
|
||||||
STACKTOP = STACK_BASE,
|
STACKTOP = STACK_BASE,
|
||||||
STACK_MAX = 488016,
|
STACK_MAX = 488048,
|
||||||
DYNAMIC_BASE = 5730896,
|
DYNAMIC_BASE = 5730928,
|
||||||
DYNAMICTOP_PTR = 487856;
|
DYNAMICTOP_PTR = 487888;
|
||||||
|
|
||||||
assert(STACK_BASE % 16 === 0, 'stack must start aligned');
|
assert(STACK_BASE % 16 === 0, 'stack must start aligned');
|
||||||
assert(DYNAMIC_BASE % 16 === 0, 'heap 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() } });
|
/* global initializers */ __ATINIT__.push({ func: function() { ___wasm_call_ctors() } });
|
||||||
|
|
||||||
|
|
||||||
@ -1946,7 +1946,7 @@ var ASM_CONSTS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _emscripten_get_sbrk_ptr() {
|
function _emscripten_get_sbrk_ptr() {
|
||||||
return 487856;
|
return 487888;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _emscripten_memcpy_big(dest, src, num) {
|
function _emscripten_memcpy_big(dest, src, num) {
|
||||||
@ -2076,6 +2076,76 @@ var ASM_CONSTS = {
|
|||||||
return 0;
|
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) {
|
function _setTempRet0($i) {
|
||||||
setTempRet0(($i) | 0);
|
setTempRet0(($i) | 0);
|
||||||
}
|
}
|
||||||
@ -2109,7 +2179,7 @@ function intArrayToString(array) {
|
|||||||
|
|
||||||
|
|
||||||
var asmGlobalArg = {};
|
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();
|
var asm = createWasm();
|
||||||
/** @type {function(...*):?} */
|
/** @type {function(...*):?} */
|
||||||
var ___wasm_call_ctors = Module["___wasm_call_ctors"] = createExportWrapper("__wasm_call_ctors");
|
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