From befe9f0a9ee86414edfc7d2b9ae5dcb30c6a90a6 Mon Sep 17 00:00:00 2001 From: Jannes Magnusson Date: Tue, 17 Mar 2026 08:38:34 +0100 Subject: [PATCH] switch save and cancel, make recipes available through menu, remove calibration tools in mock --- README.md | 21 +++++++++++++++------ frontend/__main__.py | 3 ++- frontend/views/main_view.py | 7 +++++-- frontend/views/menu.py | 3 +++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 040d407..23a3fb0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # Smaage Frontend Prototype +## TODO + +- [x] switch save and cancel -> in case save and not abort +- [x] make recipes available through menu +- [x] remove calibration tools button in mock + ## Install Requirements ```bash @@ -7,6 +13,7 @@ uv sync ``` ## Run + ```bash uv run -m frontend ``` @@ -39,6 +46,7 @@ stateDiagram-v2 Menu --> Main : LL [back] Menu --> BTPairing : RL [BT Pair] + Menu --> RecipeSelection : RL [Recipes] BTPairing --> Menu : LL [cancel] @@ -71,19 +79,20 @@ stateDiagram-v2 Renders the loading screen animation and exports every unique frame as both PNG files and a NumPy array. **Usage** + ```bash uv run export_loading_frames.py [--out-dir ] ``` -| Argument | Default | Description | -|---|---|---| +| Argument | Default | Description | +| ------------- | ----------- | ------------------------------------ | | `--out-dir` | `frames/` | Directory to write output files into | **Outputs** -| File | Description | -|---|---| -| `frames/frame_XXXX.png` | One PNG per unique frame, zero-padded index | -| `frames/frames.npy` | NumPy array of shape `(N, H, W)`, dtype `bool` | +| File | Description | +| ------------------------- | -------------------------------------------------- | +| `frames/frame_XXXX.png` | One PNG per unique frame, zero-padded index | +| `frames/frames.npy` | NumPy array of shape `(N, H, W)`, dtype `bool` | Consecutive duplicate frames are collapsed so only visually distinct frames are exported. The script prints the total number of frames rendered and the number of unique frames kept. diff --git a/frontend/__main__.py b/frontend/__main__.py index e5be5b6..04cb00f 100644 --- a/frontend/__main__.py +++ b/frontend/__main__.py @@ -147,7 +147,8 @@ class WeightApp(tk.Tk): if self.view is None: self.view = MainView(self, tare_command=self.weight_reader.tare, - calibrate_command=self.calibrate) + calibrate_command=self.calibrate, + is_mock=isinstance(self.weight_reader.serial, SerialMock)) self.view.update_views(selected_types) diff --git a/frontend/views/main_view.py b/frontend/views/main_view.py index 4b1df02..2238685 100644 --- a/frontend/views/main_view.py +++ b/frontend/views/main_view.py @@ -18,6 +18,7 @@ class MainView(tk.Frame, ButtonInterface): def __init__(self, parent, tare_command=None, calibrate_command=None, + is_mock=False, bt_connected_getter=None, bt_start_pairing_command=None, bt_stop_pairing_command=None, @@ -34,8 +35,9 @@ class MainView(tk.Frame, ButtonInterface): self.actions = Frame(self) self.actions.pack() - self.calibrate_button = ttk.Button(self.actions, text="Calibrate", command=calibrate_command) - self.calibrate_button.pack() + if not is_mock: + self.calibrate_button = ttk.Button(self.actions, text="Calibrate", command=calibrate_command) + self.calibrate_button.pack() self.im_size = (168, 144) self.center = (168 // 2, 144 // 2) @@ -133,6 +135,7 @@ class MainView(tk.Frame, ButtonInterface): self.buttons.current_view = MenuView(self, self.im_size, self.center, bluetooth_pair_command=self.start_bluetooth_pairing, + recipes_command=self.enter_recipe_selection, deactivate_command=self.enter_main_mode) self.refresh(0.0) diff --git a/frontend/views/menu.py b/frontend/views/menu.py index 3c2ecec..d6a510a 100644 --- a/frontend/views/menu.py +++ b/frontend/views/menu.py @@ -15,11 +15,14 @@ class MenuView(View, ButtonInterface): def __init__(self, parent, im_size, center, bluetooth_pair_command=None, + recipes_command=None, deactivate_command=None): self.deactivate_command = deactivate_command self.bluetooth_pair_command = bluetooth_pair_command + self.recipes_command = recipes_command self.item_list = CarouselView(render_height=124, large_font_size=20) self._actions = [ + ("Recipes", self.recipes_command), ("BT Pair", self.bluetooth_pair_command), ] self.item_list.items = [_make_text_item(label) for label, _ in self._actions]