Files
venus/axiom-nmea/raymarine_nmea/nmea/sentences/depth.py
dev 9756538f16 Initial commit: Venus OS boat addons monorepo
Organizes 11 projects for Cerbo GX/Venus OS into a single repository:
- axiom-nmea: Raymarine LightHouse protocol decoder
- dbus-generator-ramp: Generator current ramp controller
- dbus-lightning: Blitzortung lightning monitor
- dbus-meteoblue-forecast: Meteoblue weather forecast
- dbus-no-foreign-land: noforeignland.com tracking
- dbus-tides: Tide prediction from depth + harmonics
- dbus-vrm-history: VRM cloud history proxy
- dbus-windy-station: Windy.com weather upload
- mfd-custom-app: MFD app deployment package
- venus-html5-app: Custom Victron HTML5 app fork
- watermaker: Watermaker PLC control UI

Adds root README, .gitignore, project template, and per-project
.gitignore files. Sensitive config files excluded via .gitignore
with .example templates provided.

Made-with: Cursor
2026-03-16 17:04:16 +00:00

114 lines
2.7 KiB
Python

"""
Depth-related NMEA sentences.
DPT - Depth
DBT - Depth Below Transducer
"""
from typing import Optional
from ..sentence import NMEASentence
class DPTSentence(NMEASentence):
"""DPT - Depth of Water.
Format:
$IIDPT,D.D,O.O,R.R*CC
Fields:
1. Depth in meters (relative to transducer)
2. Offset from transducer in meters
- Positive = distance from transducer to water line
- Negative = distance from transducer to keel
3. Maximum range scale in use (optional)
Example:
$IIDPT,12.5,0.5,100*4C
Note:
To get depth below keel: depth + offset (when offset is negative)
To get depth below surface: depth + offset (when offset is positive)
"""
talker_id = "II"
sentence_type = "DPT"
def __init__(
self,
depth_m: Optional[float] = None,
offset_m: float = 0.0,
max_range: Optional[float] = None,
):
"""Initialize DPT sentence.
Args:
depth_m: Depth in meters (relative to transducer)
offset_m: Offset from transducer in meters
max_range: Maximum range scale in meters
"""
self.depth_m = depth_m
self.offset_m = offset_m
self.max_range = max_range
def format_fields(self) -> Optional[str]:
"""Format DPT fields."""
if self.depth_m is None:
return None
range_str = f"{self.max_range:.0f}" if self.max_range is not None else ""
return f"{self.depth_m:.1f},{self.offset_m:.1f},{range_str}"
class DBTSentence(NMEASentence):
"""DBT - Depth Below Transducer.
Format:
$IIDBT,D.D,f,D.D,M,D.D,F*CC
Fields:
1. Depth in feet
2. f = Feet
3. Depth in meters
4. M = Meters
5. Depth in fathoms
6. F = Fathoms
Example:
$IIDBT,41.0,f,12.5,M,6.8,F*2B
Note:
Depth is measured from the transducer to the bottom.
Does not include offset to keel or waterline.
"""
talker_id = "II"
sentence_type = "DBT"
# Conversion constants
FEET_PER_METER = 3.28084
FATHOMS_PER_METER = 0.546807
def __init__(self, depth_m: Optional[float] = None):
"""Initialize DBT sentence.
Args:
depth_m: Depth in meters
"""
self.depth_m = depth_m
def format_fields(self) -> Optional[str]:
"""Format DBT fields."""
if self.depth_m is None:
return None
depth_ft = self.depth_m * self.FEET_PER_METER
depth_fathoms = self.depth_m * self.FATHOMS_PER_METER
return (
f"{depth_ft:.1f},f,"
f"{self.depth_m:.1f},M,"
f"{depth_fathoms:.1f},F"
)