-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add Conga vacuum support — bump to v0.3.0b2 #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
d6029aa
cdfdd59
3642f36
608af44
119c125
1ad1428
81286a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| """ | ||
| Image Draw Class for Conga Vacuums. | ||
| Extends HypferImageDraw to provide a Conga-specific drawing layer. | ||
| Pixel data is already normalised to compressedPixels by the time it reaches | ||
| this class, so all Hypfer drawing routines apply unchanged. | ||
| The canvas is rendered at CONGA_SCALE × the native Conga size so each | ||
| boundary pixel becomes a dense CONGA_SCALE×CONGA_SCALE block, producing | ||
| filled-looking rooms. Entity coordinates are pre-scaled in the handler. | ||
| Version: 0.1.2 | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from .hypfer_draw import ImageDraw as HypferImageDraw | ||
|
|
||
|
|
||
| # Scale factor: Conga pixelSize=1 vs standard pixelSize=5. | ||
| # The handler scales the canvas and all entity coordinates by this factor. | ||
| CONGA_SCALE = 5 | ||
|
|
||
|
|
||
| class CongaImageDraw(HypferImageDraw): | ||
| """Drawing handler for Conga vacuums. | ||
|
|
||
| Inherits all drawing logic from HypferImageDraw unchanged. | ||
| Coordinate scaling is handled entirely in CongaMapImageHandler so | ||
| the draw methods receive already-scaled values. | ||
| """ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| """ | ||
| Conga Image Handler Class. | ||
| Extends HypferMapImageHandler for Conga vacuums. | ||
| Conga maps have pixelSize=1 and canvas size 800×800. Before rendering we | ||
| deep-copy the JSON and multiply pixelSize, canvas size, and all entity | ||
| coordinates by CONGA_SCALE so that every map pixel becomes a CONGA_SCALE×CONGA_SCALE | ||
| block, producing solid filled rooms. Entity positions stay consistent with | ||
| the scaled map coordinate space, so no post-upscale is required. | ||
| Version: 0.1.4 | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import copy | ||
|
|
||
| from PIL import Image | ||
|
|
||
| from .config.shared import CameraShared | ||
| from .config.types import JsonType | ||
| from .conga_draw import CONGA_SCALE, CongaImageDraw | ||
| from .hypfer_handler import HypferMapImageHandler | ||
| from .map_data import HyperMapData | ||
|
|
||
|
|
||
| class CongaMapImageHandler(HypferMapImageHandler): | ||
| """Image Handler for Conga vacuums. | ||
|
|
||
| Scales pixelSize, canvas size, and all entity coordinates by CONGA_SCALE | ||
| before handing the JSON to the standard Hypfer render pipeline. | ||
| """ | ||
|
|
||
| def __init__(self, shared_data: CameraShared) -> None: | ||
| """Initialise the Conga image handler.""" | ||
| super().__init__(shared_data) | ||
| self.imd = CongaImageDraw(self) | ||
|
Comment on lines
+32
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Assignments and reads of is_conga:\n'
rg -n -C2 '\bis_conga\b'
printf '\nConga handler construction sites:\n'
rg -n -C2 '\bCongaMapImageHandler\s*\('Repository: sca075/Python-package-valetudo-map-parser Length of output: 925 Set
Suggested fix def __init__(self, shared_data: CameraShared) -> None:
"""Initialise the Conga image handler."""
super().__init__(shared_data)
+ self.shared.is_conga = True
self.imd = CongaImageDraw(self)🤖 Prompt for AI Agents |
||
|
|
||
| @staticmethod | ||
| def _scale_conga_json(m_json: JsonType, scale: int) -> JsonType: | ||
| """Return a deep copy of m_json with coordinates scaled by *scale*. | ||
|
|
||
| Patches: | ||
| - pixelSize → scale | ||
| - size.x / size.y → original × scale | ||
| - every entity's points list → each value × scale | ||
| """ | ||
| scaled = copy.deepcopy(m_json) | ||
| scaled["pixelSize"] = scale | ||
| size = scaled.get("size", {}) | ||
| scaled["size"] = { | ||
| "x": int(size.get("x", 800)) * scale, | ||
| "y": int(size.get("y", 800)) * scale, | ||
| } | ||
| for entity in scaled.get("entities", []): | ||
| pts = entity.get("points") | ||
| if isinstance(pts, list): | ||
| entity["points"] = [v * scale for v in pts] | ||
| return scaled | ||
|
|
||
| async def async_get_image_from_json( | ||
| self, m_json: JsonType | None | ||
| ) -> Image.Image | None: | ||
| """Scale Conga JSON to pixel_size=CONGA_SCALE, then render normally.""" | ||
| if m_json is None: | ||
| return None | ||
| scaled_json = self._scale_conga_json(m_json, CONGA_SCALE) | ||
| self.json_data = await HyperMapData.async_from_valetudo_json(scaled_json) | ||
| return await super().async_get_image_from_json(m_json=scaled_json) | ||
Uh oh!
There was an error while loading. Please reload this page.