@@ -29,6 +29,7 @@ def __init__(self, mpstate):
2929 self .present = False
3030 self .enabled = False
3131 self .healthy = True
32+ self .last_home_change = 0
3233
3334 def gui_menu_items (self ):
3435 ret = super (FenceModule , self ).gui_menu_items ()
@@ -77,6 +78,12 @@ def count(self):
7778 '''return number of waypoints'''
7879 return self .wploader .count ()
7980
81+ def last_change (self ):
82+ base_class_last_change = super ().last_change ()
83+ if self .last_home_change > base_class_last_change :
84+ return self .last_home_change
85+ return base_class_last_change
86+
8087 def circles_of_type (self , t ):
8188 '''return a list of Circle fences of a specific type - a single
8289 MISSION_ITEM'''
@@ -256,9 +263,15 @@ def handle_sys_status(self, m):
256263 elif self .enabled is True and self .healthy is False :
257264 self .console .set_status ('Fence' , 'FEN' , row = 0 , fg = 'red' )
258265
266+ def handle_home_position (self , m ):
267+ self .last_home_change = time .time () # see self.last_change in mavwp.py
268+
259269 def mavlink_packet (self , m ):
260- if m .get_type () == 'SYS_STATUS' and self .message_is_from_primary_vehicle (m ):
270+ m_type = m .get_type ()
271+ if m_type == 'SYS_STATUS' and self .message_is_from_primary_vehicle (m ):
261272 self .handle_sys_status (m )
273+ elif m_type == 'HOME_POSITION' :
274+ self .handle_home_position (m )
262275 super (FenceModule , self ).mavlink_packet (m )
263276
264277 def apply_function_to_points (self , function ):
0 commit comments