remove current weather scroll canvas and almanac-outlook

This commit is contained in:
Matt Walsh
2022-08-05 14:34:00 -05:00
parent 80958226ce
commit eae3b321c7
4 changed files with 39 additions and 212 deletions

View File

@@ -1,4 +1,4 @@
/* globals draw, navigation, utils */
/* globals navigation, utils */
// eslint-disable-next-line no-unused-vars
const currentWeatherScroll = (() => {
@@ -6,23 +6,13 @@ const currentWeatherScroll = (() => {
const degree = String.fromCharCode(176);
// local variables
let context; // currently active context
let blankDrawArea; // original state of context
let interval;
let screenIndex = 0;
// start drawing conditions
// reset starts from the first item in the text scroll list
const start = (_context) => {
const start = () => {
// store see if the context is new
if (context && _context !== context) {
// clean the outgoing context
cleanLastContext();
// store the new blank context
blankDrawArea = _context.getImageData(0, 405, 640, 75);
}
// store the context locally
context = _context;
// set up the interval if needed
if (!interval) {
@@ -34,18 +24,10 @@ const currentWeatherScroll = (() => {
};
const stop = (reset) => {
cleanLastContext();
if (interval) interval = clearInterval(interval);
if (reset) screenIndex = 0;
};
const cleanLastContext = () => {
if (!context) return;
if (blankDrawArea) context.putImageData(blankDrawArea, 0, 405);
blankDrawArea = undefined;
context = undefined;
};
// increment interval, roll over
const incrementInterval = () => {
screenIndex = (screenIndex + 1) % (screens.length);
@@ -60,9 +42,6 @@ const currentWeatherScroll = (() => {
// nothing to do if there's no data yet
if (!data) return;
// clean up any old text
if (context && blankDrawArea) context.putImageData(blankDrawArea, 0, 405);
drawCondition(screens[screenIndex](data));
};
@@ -108,10 +87,6 @@ const currentWeatherScroll = (() => {
// internal draw function with preset parameters
const drawCondition = (text) => {
if (context) {
draw.text(context, 'Star4000', '24pt', '#ffffff', 70, 430, text, 2);
}
// update all html scroll elements
utils.elem.forEach('.weather-display .scroll .fixed', (elem) => {
elem.innerHTML = text;