P5js get Battery Level
From Digipool-Wiki
Revision as of 12:17, 8 May 2021 by WikiSysop (Talk | contribs) (Created page with "<pre> // Get Battery Level // Read the current battery level with P5*js var bl; function setup() { frameRate(2); createCanvas(400, 400); fill(0); textAlign(CENTER);...")
// Get Battery Level // Read the current battery level with P5*js var bl; function setup() { frameRate(2); createCanvas(400, 400); fill(0); textAlign(CENTER); navigator.getBattery().then(function (battery) { bl = battery.level; }); } function draw() { background(255); textSize(24); text("Your current battery level is", width / 2 , height / 2 - 35); textSize(64); text(bl * 100 + " %", width / 2, height / 2 + 35); }