import { LCD } from '@sek1ro/i2c-lcd' import si from 'systeminformation' const lcd = new LCD(1, 0x27) await lcd.open() async function showSystemStats() { const [cpu, mem, temp] = await Promise.all([ si.currentLoad(), si.mem(), si.cpuTemperature(), ]); const cpuLoad = cpu.currentLoad.toFixed(1); const totalMem = (mem.total / 1024 ** 2).toFixed(0); const usedMem = ((mem.total - mem.available) / 1024 ** 2).toFixed(0); const tempC = temp.main?.toFixed(1) ?? 'N/A'; await lcd.send(LCD.ClearDisplay()) const hours = new Date().getHours() if (hours >= 23 || hours <= 7) { lcd.backlight = false } else { lcd.backlight = true } await lcd.jump(0, 0); await lcd.sendString(`${cpuLoad}%`); await lcd.jump(8, 0); await lcd.sendString(`${tempC}C`) await lcd.jump(0, 1); await lcd.sendString(`${usedMem}/${totalMem} MB`); } await showSystemStats() setInterval(showSystemStats, 1000)