Commit from GitHub Actions

This commit is contained in:
Lee Lup Yuen 2020-08-20 03:13:13 +00:00
parent 423717c29b
commit 2a48c5d3ba
4 changed files with 3525 additions and 3360 deletions

View File

@ -1299,32 +1299,55 @@
</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
/// 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
/// In JavaScript: Create the Watch Face in WebAssembly
function renderCanvas() {
Module.print(`In JavaScript: Rendering canvas...`);
// Init LVGL Display in WebAssembly
Module._init_display();
// 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
if (DEMO_MODE) {
// Create the Demo Widgets in WebAssembly
Module._render_widgets();
} else {
// Create the LVGL Watch Face Widgets
// Create the Watch Face in WebAssembly
Module._create_clock();
// Refresh the LVGL Watch Face Widgets
Module._refresh_clock();
// Update the LVGL Watch Face Widgets
// Module._update_clock();
}
// Draw the Watch Face
updateCanvas();
}
// Render LVGL Widgets to the WebAssembly Display Buffer
/// 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()
);
// Update the Watch Face time in WebAssembly
Module._refresh_clock();
}
// Render Watch Face to the WebAssembly Display Buffer
Module._render_display();
// Fetch the PineTime dimensions from WebAssembly Display Buffer
@ -1370,12 +1393,20 @@
// 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
);
}
// In JavaScript: Wait for emscripten to be initialised
/// Wait for emscripten to be initialised
Module.onRuntimeInitialized = function() {
// Render LVGL to HTML Canvas
render_canvas();
renderCanvas();
};
/// Convert i to hexadecimal

View File

@ -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");

File diff suppressed because it is too large Load Diff

Binary file not shown.