LingSys
↓ 0 downloadsYour machine's memory, GPU, motherboard and network, drawn and played in the Ling design system: LingSys, a small build for USB liquid-cooler displays, LingNet for IPv4/IPv6, DNS and packets, and a LingOS edition. 64-bit and 32-bit Windows builds included.
Keywords system-monitor, visualization, network, ipv6, gpu, lcd, lingos, ling
lingfu install LingSysCode / Files (48)
src/95_mini.ling
# ───────────────────────────── MINI ──────────────────────────────────────────
# A small build for a liquid-cooler LCD (or any small screen): four rings (memory, GPU, CPU, network)
# and four stat rows, nothing else. No menu, no sound. Same samplers, same design system.
# ling run --interp hatchmini.ling [WxH] [sim] [shot] e.g. 320x240, 240x320, 480x480
# Landscape (W >= H): rings on the left, rows down the right. Portrait: rings on top, rows in a 2 x 2 grid.
bind MINI_HM = [4, 3, 1, 6]
bind MINI_LET = "MGCN"
# [cx, cy, R, xs, ys, row w, row h]
fn mini_layout(W, H) {
if W >= H {
bind R = min(H * 0.5 - 6.0, W * 0.36)
bind cx = R + 6.0
bind x0 = cx + R + 10.0
bind rh = (H - 12.0) / 4.0
return [cx, H / 2.0, R, [x0, x0, x0, x0], [6.0, 6.0 + rh, 6.0 + 2.0 * rh, 6.0 + 3.0 * rh], W - x0 - 6.0, rh]
}
bind R = W * 0.5 - 6.0
bind cw = (W - 18.0) / 2.0
bind y1 = 2.0 * R + 18.0
bind rh = (H - y1 - 6.0) / 2.0
return [W / 2.0, R + 6.0, R, [6.0, 12.0 + cw, 6.0, 12.0 + cw], [y1, y1, y1 + rh, y1 + rh], cw, rh]
}
fn mini_row(i, x, y, w, h, val, sub, frac, k, sat, hs, e) {
bind ts = min(h * 0.46, w * 0.34)
tile(str_slice(MINI_LET, i, 1), x, y + h * 0.06, ts, 56.0 + 24.0 * e, k, sat, hs, 0.4 + e)
bind tw = w - ts - 6.0
bind vh = fit_h(val, tw, h * 0.32)
col(k, sat, 84.0, hs)
daemon_text(val, x + ts + 6.0, y + h * 0.06 + vh * 0.55, vh)
bind sh = fit_h(sub, tw, h * 0.17)
ink(60.0)
daemon_text(sub, x + ts + 6.0, y + h * 0.06 + vh * 1.4 + sh * 0.5, sh)
hbar(x, y + h * 0.82, w - 2.0, frac, k, sat, 58.0 + 22.0 * e, hs)
}
bind start = do {
bind args = get_args()
bind forceSim = 0
bind shot = 0
bind W = 320
bind H = 240
bind ai = 0
while ai < len(args) {
bind a = args[ai]
if a == "sim" { bind forceSim = 1 }
if a == "shot" { bind shot = 1 }
bind pr = split(a, "x")
if len(pr) == 2 {
if to_number(pr[0]) > 0 {
if to_number(pr[1]) > 0 {
bind W = floor(to_number(pr[0]))
bind H = floor(to_number(pr[1]))
}
}
}
bind ai = ai + 1
}
open_window(W, H, "LingSys Mini")
bind W = get_width()
bind H = get_height()
set_blend(1)
set_frame_blur(0.45)
bind lay = mini_layout(W, H)
bind t0 = time_now()
bind tprev = 0.0
bind lastRead = 0.0 - 10.0
bind shotN = 0
bind liveM = 0
bind liveG = 0
bind liveB = 0
bind liveN = 0
bind tsM = 0.0
bind tsG = 0.0
bind tsB = 0.0
bind tsN = 0.0
bind chgM = 0.0
bind chgG = 0.0
bind chgB = 0.0
bind chgN = 0.0
bind cats = sim_cats(0.0)
bind tgtCats = cats
bind total = 16384.0
bind rates = [0.0, 0.0, 0.0, 0.0]
bind tgtRates = rates
bind tgtGP = sim_gpu(0.0)
bind gpv = tgtGP[GP_VEC]
bind tgtBP = sim_board(0.0)
bind bvS = tgtBP[BP_BV]
bind tgtNP = sim_net(0.0)
bind nvS = tgtNP[NP_NV]
bind energy = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
bind rot = 0.0
bind act = 0.0
bind hueShift = 0.0
bind alBase = [0.0, 0.0, 0.0, 0.0]
bind alLast = [0.0 - 100.0, 0.0 - 100.0, 0.0 - 100.0, 0.0 - 100.0, 0.0 - 100.0, 0.0 - 100.0, 0.0 - 100.0, 0.0 - 100.0, 0.0 - 100.0]
bind alText = ""
bind alBorn = 0.0 - 100.0
while window_is_open() {
bind t = time_now() - t0
bind dt = clamp(t - tprev, 0.001, 0.1)
bind tprev = t
if key_pressed("escape") { close_window() }
if key_pressed("q") { close_window() }
if shot == 1 {
bind shotN = shotN + 1
if shotN == 240 {
screenshot("hatchmini_" + num_str(W) + "x" + num_str(H))
close_window()
}
}
# ---- data, about twice a second (same snapshots as the full program)
if t - lastRead > 0.5 {
bind lastRead = t
bind liveM = 0
bind liveG = 0
bind liveB = 0
bind liveN = 0
if forceSim == 0 {
if file_exists("mem.snap") {
bind snap = parse_snap(read_file("mem.snap"))
if snap[0] == 1 {
bind liveM = 1
bind g = snap[1]
bind r = snap[2]
bind total = g[0]
bind tgtCats = categories(g, snap[3])
bind tgtRates = [r[0], r[1] + r[3], r[2] + r[4] + r[7], r[5]]
if snap[9] != tsM {
bind tsM = snap[9]
bind chgM = t
}
if t - chgM > 8.0 { bind liveM = 2 }
}
}
if file_exists("gpu.snap") {
bind gn = parse_gpu(read_file("gpu.snap"))
if gn[0] == 1 {
bind tgtGP = gn
bind liveG = 1
if gn[8] != tsG {
bind tsG = gn[8]
bind chgG = t
}
if t - chgG > 8.0 { bind liveG = 2 }
}
}
if file_exists("board.snap") {
bind bn = parse_board(read_file("board.snap"))
if bn[0] == 1 {
bind tgtBP = bn
bind liveB = 1
if bn[9] != tsB {
bind tsB = bn[9]
bind chgB = t
}
if t - chgB > 8.0 { bind liveB = 2 }
}
}
if file_exists("net.snap") {
bind nn = parse_net(read_file("net.snap"))
if nn[0] == 1 {
bind tgtNP = nn
bind liveN = 1
if nn[5] != tsN {
bind tsN = nn[5]
bind chgN = t
}
if t - chgN > 8.0 { bind liveN = 2 }
}
}
}
if liveM == 0 {
bind total = 16384.0
bind tgtCats = sim_cats(t)
bind sr = sim_rates(t)
bind tgtRates = [sr[0], sr[1], sr[2], sr[0] * 0.2]
}
if liveG == 0 { bind tgtGP = sim_gpu(t) }
if liveB == 0 { bind tgtBP = sim_board(t) }
if liveN == 0 { bind tgtNP = sim_net(t) }
}
bind k = clamp(dt * 2.5, 0.0, 1.0)
bind cats = glide(cats, tgtCats, k)
bind rates = glide(rates, tgtRates, clamp(dt * 3.0, 0.0, 1.0))
bind gpv = glide_ll(gpv, tgtGP[GP_VEC], k)
bind bvS = glide(bvS, tgtBP[BP_BV], k)
bind nvS = glide(nvS, tgtNP[NP_NV], k)
# ---- the four numbers
bind usedM = clamp(1.0 - (cats[6] + cats[1]) / total, 0.0, 1.0)
bind gm = 0.0
bind gt = 0.0
bind gvu = 0.0
bind g = 0
while g < len(gpv) {
bind gm = max(gm, gpv[g][GV_UTIL])
bind gt = max(gt, gpv[g][GV_TEMP])
bind gvu = max(gvu, gpv[g][GV_VUSED] / max(gpv[g][GV_VTOTAL], 1.0))
bind g = g + 1
}
bind cpu = bvS[BV_UTIL]
bind netA = lg(nvS[NV_RX] + nvS[NV_TX], 9.0)
bind tmax = max(gt, bvS[BV_TEMP])
bind fr = [usedM, gm / 100.0, cpu / 100.0, netA, gvu, bvS[BV_DBUSY] / 100.0, clamp((tmax - 20.0) / 60.0, 0.0, 1.0)]
bind ne = []
bind i = 0
while i < 7 {
bind ne = list_push(ne, mix(energy[i], fr[i], clamp(dt * 3.0, 0.0, 1.0)))
bind i = i + 1
}
bind energy = ne
# ---- alerts: the same checks as the full program, shown as a banner (the display has no speaker)
bind alM = [cpu / 100.0, gm / 100.0, netA]
bind lives = [liveM, liveG, liveB, liveN]
if t > 12.0 {
bind code = alert_check(alM, alBase, bvS, gpv, lives, usedM, nvS)
if code >= 0 {
if t - alLast[code] > AL_COOL {
bind alLast = list_set(alLast, code, t)
bind alText = AL_TEXT[code]
bind alBorn = t
}
}
}
bind ar = clamp(dt * 0.15, 0.0, 1.0)
bind alBase = [mix(alBase[0], alM[0], ar), mix(alBase[1], alM[1], ar), mix(alBase[2], alM[2], ar), alBase[3]]
if nvS[NV_RTT] > 0.0 {
if alBase[3] <= 0.0 {
bind alBase = list_set(alBase, 3, nvS[NV_RTT])
} else {
bind alBase = list_set(alBase, 3, mix(alBase[3], nvS[NV_RTT], ar))
}
}
# ---- look
bind act = (usedM + cpu / 100.0 + gm / 100.0) / 3.0
bind rot = rot + dt * (0.06 + 0.9 * act)
bind hueShift = 10.0 * sin(t * 0.05)
bind sat = 52.0 + 40.0 * act
bind Z = [t, rot, hueShift, sat, W, H, [], 1.0, act, 0, 0, 0, [], [], [], [], [], [], [], act, energy, [], 1, H, [], "", 0, 0, 0, 0, fr, [], [alText, alBorn, 0]]
fill(0, 0, 0)
bind labels = ["MEMORY " + pct(usedM * 100.0) + " ", "GPU " + pct(gm) + " ", "CPU " + pct(cpu) + " ", "NET " + fmt_bytes(nvS[NV_RX] + nvS[NV_TX]) + " "]
ring_stack_at(Z, lay[0], lay[1], lay[2], 4, MINI_HM, labels, fr, pct(tmax) + "C", "HEAT", 1)
bind rs = "---"
if nvS[NV_RTT] > 0.0 { bind rs = num_str(round(nvS[NV_RTT])) + "MS" }
bind vals = [pct(usedM * 100.0) + "%", pct(gm) + "%", pct(cpu) + "%", fmt_bytes(nvS[NV_RX] + nvS[NV_TX])]
bind subs = [fmt_mb(usedM * total) + " OF " + fmt_mb(total), pct(gt) + "C " + fmt_mb(gvu * gpv[0][GV_VTOTAL]) + " V", num_str(round(bvS[BV_MHZ] / 100.0) / 10.0) + " GHZ", "PER S " + rs]
bind xs = lay[3]
bind ys = lay[4]
bind q = 0
while q < 4 {
mini_row(q, xs[q], ys[q], lay[5], lay[6], vals[q], subs[q], fr[q], MINI_HM[q], sat, hueShift, energy[q])
bind q = q + 1
}
alert_banner(Z)
present()
}
}