def render(self, framebuffer, orientation): self.task_timer.start() speed_units = configuration.CONFIGURATION.__get_config_value__( configuration.Configuration.DISTANCE_UNITS_KEY, units.STATUTE) airspeed_text = None is_valid_airspeed = orientation.is_avionics_source and isinstance( orientation.airspeed, Number) is_valid_groundspeed = orientation.groundspeed is not None and isinstance( orientation.groundspeed, Number) airspeed_text = units.get_converted_units_string( speed_units, orientation.airspeed * units.feet_to_nm, unit_type=units.SPEED, decimal_places=False) if is_valid_airspeed else None groundspeed_text = units.get_converted_units_string( speed_units, (orientation.groundspeed * units.yards_to_nm), unit_type=units.SPEED, decimal_places=False ) if is_valid_groundspeed else orientation.groundspeed groundspeed_text += " GND" if airspeed_text is not None: airspeed_text += " IAS" ias_len = len(airspeed_text) gnd_len = len(groundspeed_text) max_len = gnd_len if ias_len < gnd_len else ias_len airspeed_text = airspeed_text.rjust(max_len) groundspeed_text = groundspeed_text.rjust(max_len) gs_display_color = display.WHITE if is_valid_groundspeed and orientation.gps_online else display.RED airspeed_color = display.WHITE if is_valid_airspeed else display.RED ias_texture = self.__font__.render( airspeed_text, True, airspeed_color, display.BLACK) if airspeed_text is not None else None gs_texture = self.__font__.render(groundspeed_text, True, gs_display_color, display.BLACK) gs_position_adj = self.__font_height__ if ias_texture is not None else 0 framebuffer.blit( gs_texture, (self.__left_x__, self.__text_y_pos__ + gs_position_adj)) if ias_texture is not None: framebuffer.blit(ias_texture, (self.__left_x__, self.__text_y_pos__)) self.task_timer.stop()
def __get_speed_string__(self, speed): """ Gets the string to display for the speed. Uses the units configured by the user. Arguments: speed {number} -- The raw speed from the sensor. Returns: string -- A string with the speed and the correct units. """ speed_units = configuration.CONFIGURATION.__get_config_value__( Configuration.DISTANCE_UNITS_KEY, units.STATUTE) return units.get_converted_units_string(speed_units, speed, units.SPEED)
def render(self, framebuffer, orientation): self.task_timer.start() speed_units = configuration.CONFIGURATION.__get_config_value__( configuration.Configuration.DISTANCE_UNITS_KEY, units.STATUTE) groundspeed_text = units.get_converted_units_string( speed_units, orientation.groundspeed * units.feet_to_nm, units.SPEED) texture = self.__font__.render( groundspeed_text, True, WHITE, BLACK) framebuffer.blit( texture, (self.__left_x__, self.__text_y_pos__)) self.task_timer.stop()
def __get_distance_string__(self, distance): """ Gets the distance string for display using the units from the configuration. Arguments: distance {float} -- The distance... straight from the GDL90 which means FEET Returns: string -- The distance in a handy string for display. """ display_units = configuration.CONFIGURATION.__get_config_value__( Configuration.DISTANCE_UNITS_KEY, units.STATUTE) return units.get_converted_units_string(display_units, distance)
def render(self, framebuffer, orientation): self.task_timer.start() speed_units = configuration.CONFIGURATION.__get_config_value__( configuration.Configuration.DISTANCE_UNITS_KEY, units.STATUTE) groundspeed_text = units.get_converted_units_string( speed_units, orientation.groundspeed * units.feet_to_nm, unit_type=units.SPEED, decimal_places=False ) if orientation.groundspeed is not None and isinstance( orientation.groundspeed, Number) else "INOP" display_color = display.WHITE if orientation is not None and orientation.groundspeed is not None and orientation.gps_online else display.RED texture = self.__font__.render(groundspeed_text, True, display_color, display.BLACK) framebuffer.blit(texture, (self.__left_x__, self.__text_y_pos__)) self.task_timer.stop()