Skip to content

Commit

Permalink
Add flight mode display to HUD when not acro
Browse files Browse the repository at this point in the history
  • Loading branch information
Cykyrios committed Sep 6, 2020
1 parent 86502a5 commit ee201d7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
12 changes: 12 additions & 0 deletions HUD/HUD.gd
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ func update_data(dt: float, position: Vector3, angles: Vector3, velocity: Vector
hud_rpm[i] += dt * rpm[i]


func update_flight_mode(mode: int) -> void:
var text := ""
match mode:
FlightController.FlightMode.LEVEL:
text = "HORIZON"
FlightController.FlightMode.SPEED:
text = "SPEED"
FlightController.FlightMode.TRACK:
text = "POSITION"
$MarginContainer/FlightMode.text = text


func reset_data() -> void:
is_first = true
first_angles = Vector3.ZERO
Expand Down
28 changes: 28 additions & 0 deletions HUD/HUD.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,31 @@ script = ExtResource( 10 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="MarginContainer" type="MarginContainer" parent="."]
anchor_left = 1.0
anchor_right = 1.0
margin_left = -124.0
margin_bottom = 79.0
grow_horizontal = 0
size_flags_horizontal = 10
size_flags_vertical = 2
custom_constants/margin_right = 20
custom_constants/margin_top = 20
custom_constants/margin_left = 20
custom_constants/margin_bottom = 20
__meta__ = {
"_edit_use_anchors_": false
}

[node name="FlightMode" type="Label" parent="MarginContainer"]
margin_left = 20.0
margin_top = 20.0
margin_right = 104.0
margin_bottom = 59.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 10
size_flags_vertical = 2
custom_fonts/font = ExtResource( 9 )
text = "ACRO"
2 changes: 2 additions & 0 deletions drone/Drone.gd
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ func _on_flight_mode_changed(flight_mode: int) -> void:
elif flight_mode == FlightController.FlightMode.LAUNCH:
led.change_color(Color(1, 0, 0))
led.set_blink_pattern([Vector2(0.15, 0.15), Vector2(0.55, 0.15)])

hud.update_flight_mode(flight_mode)


func _on_quad_settings_updated() -> void:
Expand Down

0 comments on commit ee201d7

Please sign in to comment.