extends BaseWidgetNode
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
	var display_speed: int = 0
	if speed_mph >= 1:
		display_speed = int(round(speed_mph))
	label_node.text = str(display_speed)
