Skip to content

Commit 00e6ab7

Browse files
committed
color code chip text in sidebar
1 parent 2ff8e62 commit 00e6ab7

File tree

6 files changed

+49
-14
lines changed

6 files changed

+49
-14
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
55
## Demo
66

7-
![demo](./demo.png)
7+
### Temps
8+
9+
![demo](./demo_temp.png)
10+
11+
### Nonces
12+
13+
![demo](./demo_nonce.png)
814

915
## Analysis Modes
1016

demo.png

-699 KB
Binary file not shown.

demo_nonce.png

557 KB
Loading

demo_temp.png

670 KB
Loading

src/theme.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ pub fn color_for_board_temp(temp: f64) -> Color {
101101
gradient_text_color(t)
102102
}
103103

104+
/// Text color for nonce deficit display (gradient)
105+
/// deficit is percentage below slot average (0 = good, 50+ = bad)
106+
pub fn color_for_nonce_deficit(deficit: f32) -> Color {
107+
let t = normalize(deficit, NONCE_DEFICIT_RANGE.0, NONCE_DEFICIT_RANGE.1);
108+
gradient_text_color(t)
109+
}
110+
104111
/// Chip cell style with gradient coloring based on mode
105112
#[allow(clippy::cast_precision_loss)] // small integer values fit in f32
106113
pub fn chip_cell(

src/ui.rs

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ pub fn miner_view<'a>(
2222
dragging: bool,
2323
color_mode: ColorMode,
2424
) -> Element<'a, Message> {
25-
let sidebar = sidebar(data, system_info);
26-
2725
// Look up miner config based on model name for physical layout
2826
let miner_config = system_info.and_then(|info| config::lookup(&info.model));
2927

@@ -37,9 +35,11 @@ pub fn miner_view<'a>(
3735
.unwrap_or(3)
3836
});
3937

40-
// Compute cross-slot analysis for gradient/outlier modes
38+
// Compute cross-slot analysis for gradient/outlier/nonce modes
4139
let all_analysis = analysis::analyze_all_slots(&data.slots, chips_per_domain);
4240

41+
let sidebar = sidebar(data, system_info, &all_analysis);
42+
4343
let grids = data.slots.iter().zip(all_analysis.iter()).fold(
4444
Column::new().spacing(25).width(Length::Shrink),
4545
|col, (slot, slot_analysis)| {
@@ -86,7 +86,11 @@ pub fn miner_view<'a>(
8686
}
8787
}
8888

89-
fn sidebar<'a>(data: &'a MinerData, system_info: Option<&'a SystemInfo>) -> Column<'a, Message> {
89+
fn sidebar<'a>(
90+
data: &'a MinerData,
91+
system_info: Option<&'a SystemInfo>,
92+
all_analysis: &[Vec<ChipAnalysis>],
93+
) -> Column<'a, Message> {
9094
let mut col = Column::new().spacing(2).padding(5).width(Length::Fill);
9195

9296
// System info section
@@ -103,22 +107,40 @@ fn sidebar<'a>(data: &'a MinerData, system_info: Option<&'a SystemInfo>) -> Colu
103107
.push(Space::with_height(8)); // spacer
104108
}
105109

106-
for slot in &data.slots {
110+
for (slot_idx, slot) in data.slots.iter().enumerate() {
107111
col = col.push(
108112
text(format!("── Slot {} ──", slot.id))
109113
.size(13)
110114
.color(theme::BRAND_ORANGE),
111115
);
112116

113-
for chip in &slot.chips {
117+
let slot_analysis = all_analysis.get(slot_idx);
118+
119+
for (chip_idx, chip) in slot.chips.iter().enumerate() {
120+
let nonce_deficit = slot_analysis
121+
.and_then(|a| a.get(chip_idx))
122+
.map_or(0.0, |a| a.nonce_deficit);
123+
114124
col = col.push(
115-
text(format!(
116-
"C{:<3} freq:{:<3} vol:{:<3} temp:{:<2} nonce:{:<6} err:{} crc:{} x:{} repeat:{} pct:{:.1}%/{:.1}%",
117-
chip.id, chip.freq, chip.vol, chip.temp, chip.nonce,
118-
chip.errors, chip.crc, chip.x, chip.repeat, chip.pct1, chip.pct2,
119-
))
120-
.size(12)
121-
.color(theme::color_for_chip_temp(chip.temp)),
125+
row![
126+
text(format!("C{:<3}", chip.id)).size(12),
127+
text(format!("freq:{:<3}", chip.freq)).size(12),
128+
text(format!("vol:{:<3}", chip.vol)).size(12),
129+
text("temp:").size(12),
130+
text(format!("{:<2}", chip.temp))
131+
.size(12)
132+
.color(theme::color_for_chip_temp(chip.temp)),
133+
text("nonce:").size(12),
134+
text(format!("{:<6}", chip.nonce))
135+
.size(12)
136+
.color(theme::color_for_nonce_deficit(nonce_deficit)),
137+
text(format!(
138+
"errors:{} crc:{} x:{} repeat:{} pct:{:.0}%/{:.0}%",
139+
chip.errors, chip.crc, chip.x, chip.repeat, chip.pct1, chip.pct2,
140+
))
141+
.size(12),
142+
]
143+
.spacing(2),
122144
);
123145
}
124146
}

0 commit comments

Comments
 (0)