Skip to content

Commit d99a1d9

Browse files
committed
Refactor instruction display and note positioning
Updated instruction display and positioning for better ux
1 parent 9b4834d commit d99a1d9

1 file changed

Lines changed: 37 additions & 20 deletions

File tree

src/modules/others/BruceLM/bruce_lm.cpp

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,10 @@ void drawMessageScreen(const String &msg, const String &hint, const String &cent
341341

342342
if (centerNote.length() > 0) {
343343
int aboveFooterY = g.footerY - 4;
344-
int noteY = y + max(0, (aboveFooterY - y - g.lineH) / 2);
344+
// Biased toward the footer (rather than dead-centered in the gap) so
345+
// the note sits a bit further down the screen.
346+
int gapSpace = max(0, aboveFooterY - y - g.lineH);
347+
int noteY = y + (gapSpace * 2) / 3;
345348
tft.setTextColor(TFT_YELLOW, bruceConfig.bgColor);
346349
for (auto &line : wrapText(centerNote, g.maxChars)) {
347350
int nx = (tftWidth - (int)(line.length() * FP * LW)) / 2;
@@ -539,12 +542,21 @@ StartAction showStartScreen() {
539542
int cursor = 0;
540543
const char *labels[2] = {"Start", "Settings"};
541544
ChatGeometry g = computeGeometry();
542-
String instructions = "1. Get a model + tokenizer -\n"
543-
"e.g. stories260K.bin + tok512.bin\n"
544-
"from huggingface.co/karpathy/\n"
545-
"tinyllamas\n"
546-
"2. Copy both to BruceLM/models";
547-
std::vector<String> instructionLines = wrapText(instructions, g.maxChars);
545+
// Built as explicit (text, indented) rows rather than a single wrapped
546+
// string - wrapLine() treats runs of leading spaces as word breaks and
547+
// silently eats them, so indentation can't survive a plain "\n"-joined
548+
// string round-tripped through wrapText().
549+
struct InstructionRow {
550+
String text;
551+
bool indented;
552+
};
553+
std::vector<InstructionRow> instructionLines = {
554+
{"1. Download a model and tokenizer file.", false},
555+
{"E.g: stories260K.bin and tok512.bin from:", true },
556+
{"https://tinyurl.com/Stories260K", true },
557+
{"2. Copy both files to SD card: BruceLM/models", false},
558+
};
559+
int indentPx = FP * LW * 3;
548560

549561
int rowH = g.lineH + 6;
550562
// Centered in the gap between the end of the instructions text and the
@@ -553,20 +565,29 @@ StartAction showStartScreen() {
553565
int afterTextY = g.outputTop + (int)instructionLines.size() * g.lineH + 4;
554566
int aboveFooterY = g.footerY - 4;
555567
int rowsBlockH = rowH * 2;
556-
int row1Y = afterTextY + max(0, (aboveFooterY - afterTextY - rowsBlockH) / 2);
568+
// Biased toward the footer (rather than dead-centered in the gap) so the
569+
// buttons sit a bit further down the screen.
570+
int gapSpace = max(0, aboveFooterY - afterTextY - rowsBlockH);
571+
int row1Y = afterTextY + (gapSpace * 2) / 3;
557572
int row2Y = row1Y + rowH;
558573

559574
bool redraw = true;
560575
for (;;) {
561576
if (redraw) {
562577
drawMainBorderWithTitle("BruceLM");
563-
tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor);
564578
int y = g.outputTop;
565-
for (auto &line : instructionLines) {
566-
tft.setCursor(BORDER_PAD_X, y);
567-
tft.print(line);
579+
for (auto &row : instructionLines) {
580+
// Dim the URL line to secColor, the same tone used for AI
581+
// reply text, so it reads as secondary to the numbered steps.
582+
bool isUrlLine = row.text.indexOf("tinyurl.com") >= 0;
583+
tft.setTextColor(
584+
isUrlLine ? bruceConfig.secColor : bruceConfig.priColor, bruceConfig.bgColor
585+
);
586+
tft.setCursor(BORDER_PAD_X + (row.indented ? indentPx : 0), y);
587+
tft.print(row.text);
568588
y += g.lineH;
569589
}
590+
tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor);
570591

571592
for (int i = 0; i < 2; i++) {
572593
int rowY = (i == 0) ? row1Y : row2Y;
@@ -732,9 +753,7 @@ void bruceLM_setup() {
732753
if (!showConfirm(
733754
"Select a model checkpoint file.\n"
734755
"\n"
735-
"Recommended example:\n"
736-
"\n"
737-
"stories260K.bin",
756+
"(e.g. \"stories260K.bin\")",
738757
"OK: continue Esc: cancel",
739758
"Press OK to open the file picker"
740759
))
@@ -743,12 +762,10 @@ void bruceLM_setup() {
743762
if (checkpointPath.length() == 0) return; // user backed out of the picker
744763

745764
if (!showConfirm(
746-
"Now select the tokenizer file\n"
747-
"that matches your model.\n"
748-
"\n"
749-
"Recommended example:\n"
765+
"Select the tokenizer file that\n"
766+
"matches your model.\n"
750767
"\n"
751-
"tok512.bin",
768+
"(e.g. \"tok512.bin\")",
752769
"OK: continue Esc: cancel",
753770
"Press OK to open the file picker"
754771
))

0 commit comments

Comments
 (0)