Changed to vehicle sensor instead of single sensor types

This commit is contained in:
2026-07-04 23:49:20 -06:00
parent 55522fc6fc
commit 10e9a0f5df
147 changed files with 523 additions and 8763 deletions
@@ -10,7 +10,8 @@ func _ready() -> void:
super._ready()
label_node = get_node("Label")
label_node.text = "0 ft"
Signals.altitude_updated.connect(_on_altitude_updated)
func _on_altitude_updated(sensor_ip: String, altitude_km: float):
label_node.text = 'Altitude: ' + str(int(round(altitude_km * Constants.M2FT * 1000))) + ' ft'
func _update_data():
if label_node == null:
return
label_node.text = 'Altitude: ' + str(int(round(host_vehicle.altitude_m * Constants.M2FT))) + ' ft'
+11
View File
@@ -6,16 +6,27 @@ var used_sensors: Dictionary = {}
var host_vehicle: VehicleNode
var timer: float = 0.
static var timer_1_60: float = 1/60
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
Signals.vehicle_added.connect(_on_vehicle_added)
Signals.requested_host_vehicle.emit(self)
func _process(delta: float):
timer += delta
if host_vehicle != null:
if timer < timer_1_60:
return
timer = 0
_update_data()
return
Signals.requested_host_vehicle.emit(self)
func _update_data():
pass
func _on_vehicle_added(new_vehicle):
host_vehicle = new_vehicle
@@ -12,10 +12,9 @@ func _ready() -> void:
if north_deg == null:
north_deg = 0.
north_rad = deg_to_rad(north_deg)
Signals.heading_updated.connect(_on_heading_updated)
indicator = get_node("CompassIndicator")
func _on_heading_updated(sensor_ip: String, heading_rad: float):
if not check_valid_sensor(sensor_ip, "MAG"):
func _update_data():
if indicator == null:
return
indicator.rotation = north_rad + heading_rad
indicator.rotation = host_vehicle.heading_rad
+10 -1
View File
@@ -1,6 +1,10 @@
extends BaseWidgetNode
class_name NetworkWidgetNode
var network_timer = 0.
static var timer_1 = 1.
var label: Node
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@@ -13,7 +17,12 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
var label = get_node("Label")
network_timer += delta
if network_timer < timer_1:
return
network_timer = 0
if label == null:
return
var label_text: String = ''
for address in IP.get_local_addresses():
label_text += address + '\n'
@@ -8,11 +8,12 @@ var label: Label
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
SensorSignals.pitch_updated.connect(_on_pitch_updated)
sprite = get_node("Sprite2D")
label = get_node("Label")
var label_size = label.size
func _on_pitch_updated(sensor_ip: String, pitch_rad: float):
sprite.rotation = pitch_rad
label.text = str(round(rad_to_deg(pitch_rad)*10)/10) + " \u00B0"
func _update_data():
if sprite == null or label == null:
return
sprite.rotation = host_vehicle.pitch_rad
label.text = str(round(rad_to_deg(host_vehicle.pitch_rad)*10)/10) + " \u00B0"
+5 -4
View File
@@ -7,11 +7,12 @@ var label: Label
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
SensorSignals.roll_updated.connect(_on_roll_updated)
sprite = get_node("Sprite2D")
label = get_node("Label")
var label_size = label.size
func _on_roll_updated(sensor_ip: String, roll_rad: float):
sprite.rotation = roll_rad
label.text = str(round(rad_to_deg(abs(roll_rad))*10)/10) + " \u00B0"
func _update_data():
if sprite == null or label == null:
return
sprite.rotation = host_vehicle.roll_rad
label.text = str(abs(round(rad_to_deg(host_vehicle.roll_rad)*10)/10)) + " \u00B0"
@@ -42,19 +42,6 @@ func set_host_vehicle(new_vehicle):
vehicle_3d_node = Node3D.new()
add_child(vehicle_3d_node)
func check_valid_sensor(sensor_ip: String, sensor_class: String):
if host_vehicle == null:
return false
if sensor_ip not in host_vehicle.sensors:
return false
if sensor_class == null:
return true
if sensor_class not in host_vehicle.sensor_classes:
return false
if sensor_ip not in host_vehicle.sensor_classes[sensor_class]:
return false
return true
func _on_sat_position_updated(sensor_ip: String, sat_position_data: Array):
if vehicle_3d_node == null:
return
+4 -6
View File
@@ -3,19 +3,17 @@ class_name SpeedWidgetNode
var K2MI = 0.6213712
var speed_kmh: float
var speed_mph: float
var label_node: Label
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
label_node = get_node("VBoxContainer/SpeedLabel")
SensorSignals.speed_updated.connect(_on_speed_updated)
func _on_speed_updated(ip_address: String, pnt_speed_kmh: float):
speed_kmh = pnt_speed_kmh
speed_mph = speed_kmh * K2MI
func _update_data():
if label_node == null:
return
var speed_mph = host_vehicle.speed_kmh * K2MI
var display_speed: int = 0
if speed_mph >= 1:
display_speed = int(round(speed_mph))