Trial and error - nightly check-in

master
Martin Zwigl 2025-03-16 20:12:42 +01:00
parent 1bdded1549
commit 4e99352c1e
3 changed files with 22 additions and 12 deletions

1
apps/coin_info/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/dummy.js

View File

@ -1,6 +1,8 @@
const settings = require("Storage").readJSON("coin_info.settings.json", 1) || {}; const settings = require("Storage").readJSON("coin_info.settings.json", 1) || {};
const db = require("Storage").readJSON("coin_info.cmc_key.json", 1) || {}; const db = require("Storage").readJSON("coin_info.cmc_key.json", 1) || {};
const csTokens = db.csTokens.split(','); const csTokens = db.csTokens.split(',');
var graph = require("graph");
//
var ticker = 0; var ticker = 0;
var currLoadMsg = "..."; var currLoadMsg = "...";
var timePeriod = "24h"; var timePeriod = "24h";
@ -9,10 +11,17 @@ var tknChrtData = [5,6,5,6,5,6,5,6,5,6,5,6,5,6,];
// //
function renderGraph(l) { function renderGraph(l) {
require("graph").drawLine(g, tknChrtData, { g.clearRect(l.x, l.y, l.w, l.h);
axes : true,
x:l.x, y:l.y, width:l.w, height:l.h if (tknChrtData.length > 0) {
}); graph.drawLine(g, tknChrtData, {
axes: true,
x: l.x, y: l.y, width: l.w, height: l.h,
miny: Math.min(...tknChrtData),
maxy: Math.max(...tknChrtData),
// gridy: 5
});
}
} }
var Layout = require("Layout"); var Layout = require("Layout");
@ -28,7 +37,7 @@ var layout = new Layout({
{type:"custom", render:renderGraph, id:"tknGraph", bgCol:g.theme.bg, fillx:1, filly:1 }, {type:"custom", render:renderGraph, id:"tknGraph", bgCol:g.theme.bg, fillx:1, filly:1 },
{type:"h", valign:1, {type:"h", valign:1,
c: [ c: [
{type:"btn", label:"24h", cb: d=>setLoadMsg("24 h")}, {type:"btn", label:"24h", cb: d=>getChart("24h")},
{type:"btn", label:"1w", cb: d=>setLoadMsg("1 w")}, {type:"btn", label:"1w", cb: d=>setLoadMsg("1 w")},
{type:"btn", label:"1m", cb: d=>setLoadMsg("1 m")}, {type:"btn", label:"1m", cb: d=>setLoadMsg("1 m")},
{type:"btn", label:"3m", cb: d=>setLoadMsg("3 m")} {type:"btn", label:"3m", cb: d=>setLoadMsg("3 m")}
@ -41,8 +50,8 @@ layout.update();
// //
function getChart(repeatable) { function getChart(period) {
const url = `https://openapiv1.coinstats.app/coins/bitcoin/charts?period=${timePeriod}`; const url = `https://openapiv1.coinstats.app/coins/${csTokens[ticker]}/charts?period=${period}`;
Bangle Bangle
.http(url, { .http(url, {
method: 'GET', method: 'GET',
@ -63,10 +72,10 @@ function getChart(repeatable) {
console.error("HTTP request failed:", err); console.error("HTTP request failed:", err);
}); });
if (repeatable == true) { // if (repeatable == true) {
if (httpTimeout) clearTimeout(httpTimeout); // if (httpTimeout) clearTimeout(httpTimeout);
httpTimeout = setTimeout(getChart, 300000); // Make HTTP request every 5 minutes // httpTimeout = setTimeout(getChart, 300000); // Make HTTP request every 5 minutes
} // }
} }
// //

View File

@ -1,7 +1,7 @@
{ "id": "coin_info", { "id": "coin_info",
"name": "Crypto-Coins Info", "name": "Crypto-Coins Info",
"shortName":"Coins Info", "shortName":"Coins Info",
"version": "0.06.33", "version": "0.06.34",
"description": "Crypto-Coins Infos with the help of the Binance API", "description": "Crypto-Coins Infos with the help of the Binance API",
"icon": "app.png", "icon": "app.png",
"tags": "clkinfo", "tags": "clkinfo",