switch save and cancel, make recipes available through menu, remove calibration tools in mock

This commit is contained in:
Jannes Magnusson
2026-03-17 08:38:34 +01:00
parent 74b1aa0706
commit befe9f0a9e
4 changed files with 25 additions and 9 deletions

View File

@@ -1,5 +1,11 @@
# Smaage Frontend Prototype # 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 ## Install Requirements
```bash ```bash
@@ -7,6 +13,7 @@ uv sync
``` ```
## Run ## Run
```bash ```bash
uv run -m frontend uv run -m frontend
``` ```
@@ -39,6 +46,7 @@ stateDiagram-v2
Menu --> Main : LL [back] Menu --> Main : LL [back]
Menu --> BTPairing : RL [BT Pair] Menu --> BTPairing : RL [BT Pair]
Menu --> RecipeSelection : RL [Recipes]
BTPairing --> Menu : LL [cancel] 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. Renders the loading screen animation and exports every unique frame as both PNG files and a NumPy array.
**Usage** **Usage**
```bash ```bash
uv run export_loading_frames.py [--out-dir <directory>] uv run export_loading_frames.py [--out-dir <directory>]
``` ```
| Argument | Default | Description | | Argument | Default | Description |
|---|---|---| | ------------- | ----------- | ------------------------------------ |
| `--out-dir` | `frames/` | Directory to write output files into | | `--out-dir` | `frames/` | Directory to write output files into |
**Outputs** **Outputs**
| File | Description | | File | Description |
|---|---| | ------------------------- | -------------------------------------------------- |
| `frames/frame_XXXX.png` | One PNG per unique frame, zero-padded index | | `frames/frame_XXXX.png` | One PNG per unique frame, zero-padded index |
| `frames/frames.npy` | NumPy array of shape `(N, H, W)`, dtype `bool` | | `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. 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.

View File

@@ -147,7 +147,8 @@ class WeightApp(tk.Tk):
if self.view is None: if self.view is None:
self.view = MainView(self, self.view = MainView(self,
tare_command=self.weight_reader.tare, 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) self.view.update_views(selected_types)

View File

@@ -18,6 +18,7 @@ class MainView(tk.Frame, ButtonInterface):
def __init__(self, parent, def __init__(self, parent,
tare_command=None, tare_command=None,
calibrate_command=None, calibrate_command=None,
is_mock=False,
bt_connected_getter=None, bt_connected_getter=None,
bt_start_pairing_command=None, bt_start_pairing_command=None,
bt_stop_pairing_command=None, bt_stop_pairing_command=None,
@@ -34,8 +35,9 @@ class MainView(tk.Frame, ButtonInterface):
self.actions = Frame(self) self.actions = Frame(self)
self.actions.pack() self.actions.pack()
self.calibrate_button = ttk.Button(self.actions, text="Calibrate", command=calibrate_command) if not is_mock:
self.calibrate_button.pack() self.calibrate_button = ttk.Button(self.actions, text="Calibrate", command=calibrate_command)
self.calibrate_button.pack()
self.im_size = (168, 144) self.im_size = (168, 144)
self.center = (168 // 2, 144 // 2) self.center = (168 // 2, 144 // 2)
@@ -133,6 +135,7 @@ class MainView(tk.Frame, ButtonInterface):
self.buttons.current_view = MenuView(self, self.buttons.current_view = MenuView(self,
self.im_size, self.center, self.im_size, self.center,
bluetooth_pair_command=self.start_bluetooth_pairing, bluetooth_pair_command=self.start_bluetooth_pairing,
recipes_command=self.enter_recipe_selection,
deactivate_command=self.enter_main_mode) deactivate_command=self.enter_main_mode)
self.refresh(0.0) self.refresh(0.0)

View File

@@ -15,11 +15,14 @@ class MenuView(View, ButtonInterface):
def __init__(self, parent, im_size, center, def __init__(self, parent, im_size, center,
bluetooth_pair_command=None, bluetooth_pair_command=None,
recipes_command=None,
deactivate_command=None): deactivate_command=None):
self.deactivate_command = deactivate_command self.deactivate_command = deactivate_command
self.bluetooth_pair_command = bluetooth_pair_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.item_list = CarouselView(render_height=124, large_font_size=20)
self._actions = [ self._actions = [
("Recipes", self.recipes_command),
("BT Pair", self.bluetooth_pair_command), ("BT Pair", self.bluetooth_pair_command),
] ]
self.item_list.items = [_make_text_item(label) for label, _ in self._actions] self.item_list.items = [_make_text_item(label) for label, _ in self._actions]