Daemon: compute_today_usage() sums today's Claude Code token usage across the local project transcripts (~/.claude/projects/**/*.jsonl), reading only files modified today so the scan stays cheap, and prices it with Anthropic list rates to show the equivalent API cost (the ccusage-style flex for subscription users). The compact fields tk (total tokens), tc (cost in cents) and tn (message count) piggyback onto the existing 60s BLE payload. Firmware: UsageData gains tokens_today (64-bit) / cost_cents_today / messages_today; parse_json reads tk/tc/tn; a new Session screen shows the cost as the hero with total tokens and message count below, refreshed from ui_update so it's current whenever opened. Wire SCREEN_SESSION to the real screen (was a stub). Verified end to end: daemon sends e.g. tk=105374109 tc=26838 tn=663. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
19 lines
846 B
C
19 lines
846 B
C
#pragma once
|
|
#include <Arduino.h>
|
|
|
|
struct UsageData {
|
|
float session_pct; // 5-hour window utilization (0-100)
|
|
int session_reset_mins; // minutes until session resets
|
|
float weekly_pct; // 7-day window utilization (0-100)
|
|
int weekly_reset_mins; // minutes until weekly resets
|
|
char status[16]; // "allowed" or "limited"
|
|
bool ok; // data parse succeeded
|
|
bool valid; // false until first successful parse
|
|
|
|
// Today's Claude Code usage (Phase 4 — computed by the daemon from local
|
|
// transcripts). Tokens can exceed 2^31 on a heavy day, so use 64-bit.
|
|
long long tokens_today; // total tokens today (input+output+cache)
|
|
int cost_cents_today; // equivalent API cost today, US cents
|
|
int messages_today; // assistant messages today
|
|
};
|