Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
9 changes: 9 additions & 0 deletions ToasterOS/RemoteControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class RemoteControl {
CRGB OutputLEDData[OutputNumLEDs];

public:
// The combo pressed this loop, like "DC", for custom features. Empty if no combo was finished this loop
char JustPressedCombo[3] = "";

RemoteControl(ExpressionManager* expressionState, FaceRender* faceRenderer, BoopStateHandler* boopState) {
ExpressionState = expressionState;
FaceRenderer = faceRenderer;
Expand Down Expand Up @@ -53,6 +56,8 @@ class RemoteControl {

// Update state
void Update() {
JustPressedCombo[0] = 0;

int buttonsPressed = 0;
if (digitalRead(ProtoConfig.PinRemoteButtonA)) buttonsPressed += BUTTON_A;
if (digitalRead(ProtoConfig.PinRemoteButtonB)) buttonsPressed += BUTTON_B;
Expand Down Expand Up @@ -221,6 +226,10 @@ class RemoteControl {
// Wait for 2 button presses
if (NumPressedButtons < 2) return;

// Record the combo, for custom features
JustPressedCombo[0] = ButtonToLetter(PressedButtons[0]);
JustPressedCombo[1] = ButtonToLetter(PressedButtons[1]);

// Run the action for this combo, if there is one (RemoteControlActions in Protogen_Faces.h)
const RemoteControlActionConfig* action = FindAction(PressedButtons[0], PressedButtons[1]);
if (action != NULL) RunAction(action);
Expand Down
32 changes: 31 additions & 1 deletion toaster-oven/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ There's no test framework or linter. Prettier handles formatting only (`.prettie
```
src/
main.ts, App.vue App shell (nav + <main>). App.vue warns before leaving with undownloaded changes
router/index.ts / and /configure/{panels,expressions,features}
router/index.ts /, /configure/{panels,expressions,features}, /guides and /guides/<section>/<guide>
assets/
main.css Theme tokens + small component classes (.btn, .form-input, .kbd, .display-title)
Protogen_Faces.h COPY of ../ToasterOS/Protogen_Faces.h, plus OWO, Binary and UWU, parsed at build time for the preset expressions
Expand All @@ -52,17 +52,28 @@ src/
read-config.ts Config.h -> state. A list of readers per setting, newest format first
read-faces.ts Protogen_Faces.h -> expressions. Adds back missing required expressions
import-files.ts Detects each file's type, applies it in place, builds the import summary
guides/
<section>/*.md The guides, a folder per section (toaster-os/, later building/ ...).
A --- header with title, description, order and optional group, then Markdown
images/ Pictures for the guides, linked as images/name.png
sections.ts GUIDE_SECTIONS: each section's title, description, coming-soon topics and unnumbered groups
guides.ts Loads the guides (import.meta.glob) and their pictures
markdown.ts Small Markdown renderer. Code blocks are highlighted with highlight.js (only the languages it registers). See its header for what it supports
embeds.ts Parts of the site a guide can show with a `::name args` line, e.g. ::panel-layout 14-one
faces/
faces.ts Parses the presets from assets/Protogen_Faces.h. mirror(), expressionToPanels()
parse-faces.ts Regex parser for `struct FaceExpression Face_X = {...}` blocks and their animations
animation.ts Animation frames: frameView(), detachFrame(), pruneFrames(), frameIndexAt()
required-expressions.ts Expressions the firmware references by name (see below)
components/
VisorDisplay.vue SVG visor that draws panels as LED dots. Used on Home (hero), the panel map and the preview
PanelLayoutMap.vue The panel layout map for some connections: C1 #3 labels and wiring. Panels page and guides
expressions/ ExpressionCanvas (paint LEDs), ExpressionThumbnail, expression-layout.ts
form/ SettingsCard, FormField, ToggleSwitch
DownloadConfigButton.vue One button per file (kind="config" | "expressions")
views/
GuidesView.vue The guides by section and group, with each section's "coming soon" topics
GuideView.vue One guide, with "On this page" and previous/next links
HomeView.vue Hero visor (blinks; click to boop, using the boop expressions like the firmware)
ConfigureView.vue Heading, both download buttons, tabs, sticky "changed" reminder
configure/ PanelLayoutView, ExpressionsView, FeaturesView
Expand Down Expand Up @@ -104,6 +115,25 @@ src/

To check a generator, render the defaults and diff the output against the firmware file. Expect the panel layout to differ unless you pick the `14-two` preset first. `vite`'s `createServer` + `ssrLoadModule` can load the TS modules from a Node script.

## Guides

The Guides section (`/guides`) is Markdown in `src/guides/<section>/`. Sections are listed in `GUIDE_SECTIONS` in `sections.ts`, with a title, a description and the topics still to come (shown as "coming soon"). `toaster-os/` covers this software; `building/` (head, body and armour) has no guides yet. The owner's plan for both is `../guides-overview.md`.

To add a guide, add a `.md` file to its section's folder. Its path is its address: `toaster-os/side-lights.md` is `/guides/toaster-os/side-lights`. Each file starts with a header:

```
---
title: Side lights
description: One sentence, shown on the guides list.
order: 3
group: Enabling features
---
```

`order` sets its place in the section. `group` is optional: guides with the same group are listed under that heading, where the first of them comes in the order. Each list of guides (a group, or a run of guides without one) is numbered from 1, unless the group is in its section's `unnumberedGroups`. Previous/Next links stay within the section.

`markdown.ts` renders a small subset of Markdown, listed at the top of that file, including callouts (`> [!NOTE]`, `> [!TIP]`, `> [!WARNING]`). HTML in a guide is shown as text. Links to other pages start with `/` (e.g. `/guides/toaster-os/debugging#check-the-panels`); heading ids are the heading text in lowercase with dashes. Pictures are shared by all sections, in `src/guides/images/`, linked as `images/name.png`; keep them small, as they're bundled with the site. `power-splitting.svg` (the Power section of Setting up) is drawn by `scripts/power-splitting.py`: change the script and run it with `python scripts/power-splitting.py`, rather than editing the SVG. Add new guides to `public/sitemap.xml`. A line like `::panel-layout 14-one` shows a live part of the site (here the panel layout map for a preset) in place of a picture; `embeds.ts` lists what's available, and `GuideView.vue` mounts them. Styles are `.guide-content` in `main.css`. `> [!NOTE]` callouts starting with **To do:** mark parts the owner still needs to write. Toaster OS runs on an Arduino Nano Every or an ESP32, so guides say "microcontroller" (lowercase, except at the start of a sentence or heading), not "Arduino". Name a board only for something specific to it, such as the Nano Every's 6 KB of memory, or for the Arduino IDE. Pin numbers are examples, as people can use any free pins on their microcontroller: say "for example, pin 9" or label a table column "Example pin".

## State and downloads

- All state is in memory. **Nothing persists across a refresh yet.** Saving is planned as "projects" (multiple saved configurations to switch between). Keep state serialisable: plain objects, number bitmaps, and numeric ids on expressions.
Expand Down
2 changes: 1 addition & 1 deletion toaster-oven/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ In either the project root or the toaster-oven directory, create `.vscode/launch
"version": "0.2.0",
"configurations": [
{
"cwd": "${workspaceFolder}/toaster-oven",
"cwd": "${workspaceFolder}/toaster-oven", // This will need to change if you're running it from the sub-folder
"name": "Launch via NPM",
"request": "launch",
"runtimeArgs": ["start"],
Expand Down
10 changes: 10 additions & 0 deletions toaster-oven/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions toaster-oven/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"dependencies": {
"@fontsource-variable/atkinson-hyperlegible-next": "^5.3.0",
"@fontsource-variable/doto": "^5.3.0",
"highlight.js": "^11.12.0",
"vue": "^3.5.42",
"vue-router": "^5.3.1"
},
Expand Down
8 changes: 8 additions & 0 deletions toaster-oven/public/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@
<url><loc>https://toaster.badgercode.co.uk/configure/panels</loc></url>
<url><loc>https://toaster.badgercode.co.uk/configure/expressions</loc></url>
<url><loc>https://toaster.badgercode.co.uk/configure/features</loc></url>
<url><loc>https://toaster.badgercode.co.uk/guides</loc></url>
<url><loc>https://toaster.badgercode.co.uk/guides/toaster-os/setting-up</loc></url>
<url><loc>https://toaster.badgercode.co.uk/guides/toaster-os/debugging</loc></url>
<url><loc>https://toaster.badgercode.co.uk/guides/toaster-os/managing-expressions</loc></url>
<url><loc>https://toaster.badgercode.co.uk/guides/toaster-os/side-lights</loc></url>
<url><loc>https://toaster.badgercode.co.uk/guides/toaster-os/boop-sensor</loc></url>
<url><loc>https://toaster.badgercode.co.uk/guides/toaster-os/remote-control</loc></url>
<url><loc>https://toaster.badgercode.co.uk/guides/toaster-os/adding-custom-features</loc></url>
</urlset>
103 changes: 103 additions & 0 deletions toaster-oven/scripts/power-splitting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
"""Draws src/guides/images/power-splitting.svg, the power-splitting diagram in the
Toaster OS "Setting up" guide (Power section).

Run it from anywhere with `python scripts/power-splitting.py`. It needs only Python 3.
Change the parts list or the layout numbers below, then run it again.
"""
from pathlib import Path

OUTPUT = Path(__file__).resolve().parent.parent / 'src' / 'guides' / 'images' / 'power-splitting.svg'

W, H = 1000, 620
BG = '#120e1a'; SURFACE = '#1c1726'; BORDER = '#3f3a4d'; TEXT = '#f1f2f6'; MUTED = '#9a93aa'
RED = '#e5484d'; BLACK = '#111014'; CASING = '#7b748d'; ACCENT = '#3d8bff'
FONT = "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"
out = []
def add(s): out.append(s)
def text(x, y, s, size=15, fill=TEXT, weight=400, anchor='start'):
add(f'<text x="{x}" y="{y}" font-size="{size}" font-weight="{weight}" fill="{fill}" text-anchor="{anchor}">{s}</text>')
def box(x, y, w, h, r=10, fill=SURFACE, stroke=BORDER, sw=2):
add(f'<rect x="{x}" y="{y}" width="{w}" height="{h}" rx="{r}" fill="{fill}" stroke="{stroke}" stroke-width="{sw}"/>')
def wire(d, colour):
if colour == BLACK: # Ground: black, with a light casing so it shows on the dark background
add(f'<path d="{d}" fill="none" stroke="{CASING}" stroke-width="7" stroke-linecap="round"/>')
add(f'<path d="{d}" fill="none" stroke="{BLACK}" stroke-width="4" stroke-linecap="round"/>')
else:
add(f'<path d="{d}" fill="none" stroke="{colour}" stroke-width="5" stroke-linecap="round"/>')
def curve(x1, y1, x2, y2):
mx = (x1 + x2) / 2
return f'M {x1} {y1} C {mx} {y1}, {mx} {y2}, {x2} {y2}'

add(f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {W} {H}" font-family="{FONT}">')
add(f'<rect width="{W}" height="{H}" rx="16" fill="{BG}"/>')

# --- Power bank -------------------------------------------------------------
pbx, pby = 40, 230
box(pbx, pby, 130, 170, r=18)
add(f'<rect x="{pbx+40}" y="{pby+40}" width="50" height="80" rx="6" fill="none" stroke="{MUTED}" stroke-width="3"/>')
add(f'<rect x="{pbx+57}" y="{pby+33}" width="16" height="8" rx="2" fill="{MUTED}"/>')
for i in range(3):
add(f'<rect x="{pbx+46}" y="{pby+98 - i*22}" width="38" height="16" rx="3" fill="#2fcd03"/>')
text(pbx + 65, pby + 150, 'Power bank', 15, TEXT, 600, 'middle')
# USB port + plug
add(f'<rect x="{pbx+130}" y="{pby+75}" width="22" height="20" rx="3" fill="{MUTED}"/>')

# --- USB cable to the cut end ------------------------------------------------
cable_y = pby + 85
add(f'<path d="M {pbx+152} {cable_y} H 300" stroke="#4a4458" stroke-width="16" stroke-linecap="round" fill="none"/>')
add(f'<path d="M {pbx+152} {cable_y} H 300" stroke="#2b2735" stroke-width="10" stroke-linecap="round" fill="none"/>')
text(235, cable_y - 26, 'USB cable', 15, TEXT, 600, 'middle')
text(235, cable_y + 40, 'End cut off, or a', 13, MUTED, 400, 'middle')
text(235, cable_y + 58, 'cable with bare wires', 13, MUTED, 400, 'middle')

# Exposed wires from the cut end to the splitter
split_x = 420
v_in_y, g_in_y = 150, 430
wire(curve(300, cable_y - 6, split_x + 8, v_in_y - 38), RED)
wire(curve(300, cable_y + 6, split_x + 8, g_in_y - 38), BLACK)
text(352, 205, '5V (red)', 15, RED, 700, 'end')
text(385, 412, 'Ground (black)', 15, TEXT, 700, 'end')

# --- Splitter: two lever-connector blocks ----------------------------------
def splitter(y, label, colour):
box(split_x, y - 60, 70, 150, r=8, fill='#e8e6ee', stroke='#bdb7ca')
for i in range(5): # Five slots: one in, four out (like a WAGO 221-415)
ly = y - 48 + i * 28
add(f'<rect x="{split_x+44}" y="{ly}" width="18" height="20" rx="3" fill="{colour}"/>')
add(f'<rect x="{split_x+8}" y="{ly+6}" width="30" height="8" rx="2" fill="#bdb7ca"/>')
text(split_x + 35, y - 72, label, 14, TEXT, 700, 'middle')
text(split_x + 78, y - 33, 'in', 12, MUTED, 600)
splitter(v_in_y, '5V splitter', '#f3a5a7')
splitter(g_in_y, 'Ground splitter', '#5a546b')
text(split_x + 35, 560, 'Splitters, e.g. WAGO lever', 13, MUTED, 400, 'middle')
text(split_x + 35, 578, 'connectors or JST Y cables', 13, MUTED, 400, 'middle')

# --- Parts ------------------------------------------------------------------
parts = [
('Microcontroller', '5V and GND pins'),
('LED panels', 'VCC and GND of the first panel'),
('Side LED strips', '5V and GND of the strips'),
('Fan', 'Red and black wires'),
]
px, pw, ph, gap = 680, 280, 80, 36
top = (H - (len(parts) * ph + (len(parts) - 1) * gap)) / 2
for i, (name, pins) in enumerate(parts):
y = top + i * (ph + gap)
box(px, y, pw, ph)
text(px + 22, y + 34, name, 16, TEXT, 600)
text(px + 22, y + 56, pins, 13, MUTED)
vy, gy = y + 24, y + 56
# Two terminals on the left edge
add(f'<circle cx="{px}" cy="{vy}" r="5" fill="{RED}"/>')
add(f'<circle cx="{px}" cy="{gy}" r="5" fill="{CASING}"/>')
# Outputs from each splitter, spread over the blocks' slots
out_v = v_in_y - 10 + i * 28
out_g = g_in_y - 10 + i * 28
wire(curve(split_x + 70, out_v, px, vy), RED)
wire(curve(split_x + 70, out_g, px, gy), BLACK)

text(px + pw / 2, top - 18, 'Every part gets its own 5V and ground', 13, MUTED, 400, 'middle')
text(px + pw / 2, top + 4 * ph + 3 * gap + 30, 'Add more outputs for other parts', 13, MUTED, 400, 'middle')
add('</svg>')
OUTPUT.write_text('\n'.join(out) + '\n', encoding='utf-8')
print(f'Wrote {OUTPUT}')
2 changes: 2 additions & 0 deletions toaster-oven/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { onBeforeUnmount, onMounted } from 'vue'
import { RouterView } from 'vue-router'
import NavBar from '@/components/NavBar.vue'
import SiteFooter from '@/components/SiteFooter.vue'
import { hasUndownloadedChanges } from '@/state/config-download'

// Config isn't saved anywhere yet, so warn before a refresh/close loses changes
Expand All @@ -19,5 +20,6 @@ onBeforeUnmount(() => window.removeEventListener('beforeunload', warnAboutUndown
<main class="mx-auto w-full max-w-6xl flex-1 px-4 py-8 sm:px-6">
<RouterView />
</main>
<SiteFooter />
</div>
</template>
Loading
Loading