def __init__(self): Screen.__init__(self) self.name = "F18 Hud Screen" # set name for this screen self.ahrs_bg = 0 self.show_debug = False # default off self.show_FPS = ( False ) # show screen refresh rate in frames per second for performance tuning self.line_mode = hud_utils.readConfigInt("HUD", "line_mode", 1) self.alt_box_mode = 1 # default on self.caged_mode = 1 # default on self.line_thickness = hud_utils.readConfigInt("HUD", "line_thickness", 2) self.center_circle_mode = hud_utils.readConfigInt( "HUD", "center_circle", 4) self.ahrs_line_deg = hud_utils.readConfigInt("HUD", "vertical_degrees", 5) print("ahrs_line_deg = %d" % self.ahrs_line_deg) self.MainColor = (0, 255, 0) # main color of hud graphics self.pxy_div = 30 # Y axis number of pixels per degree divisor self.readings = [] # Setup moving averages to smooth a bit self.max_samples = 20 # FPM smoothing self.readings1 = [] # Setup moving averages to smooth a bit self.max_samples1 = 20 # Caged FPM smoothing self.hsi_size = 360 self.roll_point_size = 20
def __init__(self): Screen.__init__(self) self.name = "Kivic Hud Screen" # set name for this screen self.ahrs_bg = 0 self.show_debug = False # default off self.show_FPS = ( False ) # show screen refresh rate in frames per second for performance tuning self.line_mode = hud_utils.readConfigInt("HUD", "line_mode", 0) self.alt_box_mode = 1 # default on self.line_thickness = hud_utils.readConfigInt("HUD", "line_thickness", 2) self.center_circle_mode = hud_utils.readConfigInt("HUD", "center_circle", 2) self.ahrs_line_deg = hud_utils.readConfigInt("HUD", "vertical_degrees", 10) print("ahrs_line_deg = %d" % self.ahrs_line_deg) self.MainColor = (0, 255, 0) # main color of hud graphics self.pxy_div = 60 # Y axis number of pixels per degree divisor
def initInput(self, aircraft): Input.initInput(self, aircraft) # call parent init Input. if aircraft.demoMode: # if in demo mode then load example data file. # get demo file to read from config. else default to.. if not len(aircraft.demoFile): defaultTo = "mgl_data1.bin" #defaultTo = "mgl_G430_v6_HSI_Nedl_2degsRtt_Vert_2Degs_Up.bin" #defaultTo = "mgl_G430_v7_Horz_Vert_Nedl_come to center.bin" aircraft.demoFile = hud_utils.readConfig( self.name, "demofile", defaultTo) self.ser = open( "lib/inputs/_example_data/%s" % (aircraft.demoFile), "r") else: self.efis_data_format = hud_utils.readConfig( "DataInput", "format", "none") self.efis_data_port = hud_utils.readConfig("DataInput", "port", "/dev/ttyS0") self.efis_data_baudrate = hud_utils.readConfigInt( "DataInput", "baudrate", 115200) # open serial connection. self.ser = serial.Serial( port=self.efis_data_port, baudrate=self.efis_data_baudrate, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1, )
def initInput(self,aircraft): Input.initInput( self, aircraft ) # call parent init Input. if aircraft.demoMode: # if in demo mode then load example data file. self.ser = open("lib/inputs/_example_data/flyonspeed2efisdata_data1.csv", "r") else: self.efis_data_format = hud_utils.readConfig("DataInput", "format", "none") self.efis_data_port = hud_utils.readConfig("DataInput", "port", "/dev/ttyS0") self.efis_data_baudrate = hud_utils.readConfigInt( "DataInput", "baudrate", 115200 ) # open serial connection. self.ser = serial.Serial( port=self.efis_data_port, baudrate=self.efis_data_baudrate, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1, )
def main_graphical(): global aircraft # init common things. maxframerate = hud_utils.readConfigInt("HUD", "maxframerate", 30) clock = pygame.time.Clock() pygame.time.set_timer(pygame.USEREVENT, 1000) # fire User events ever sec. ########################################## # Main graphics draw loop while not aircraft.errorFoundNeedToExit and not aircraft.textMode: clock.tick(maxframerate) for event in pygame.event.get( ): # check for event like keyboard input. if event.type == pygame.QUIT: aircraft.errorFoundNeedToExit = True # KEY MAPPINGS if event.type == pygame.KEYDOWN: if event.key == pygame.K_q: aircraft.errorFoundNeedToExit = True elif event.key == pygame.K_PAGEUP: loadScreen(hud_utils.findScreen("prev")) elif event.key == pygame.K_PAGEDOWN: loadScreen(hud_utils.findScreen("next")) elif event.key == pygame.K_HOME: loadScreen(hud_utils.findScreen("current")) elif event.key == pygame.K_t: aircraft.textMode = True # switch to text mode? elif event.key == pygame.K_m: pygame.mouse.set_visible(True) elif event.key == pygame.K_k: vkey = VirtualKeyboard( pygamescreen) # create a virtual keyboard #vkey.run("test") elif event.key == pygame.K_z: screenTimer.addNotice("hello", 1000) else: CurrentScreen.processEvent( event ) # send this key command to the hud screen object # Mouse Mappings (not droppings) if event.type == pygame.MOUSEBUTTONDOWN: mx, my = pygame.mouse.get_pos() #print("mouse %d x %d"%(mx,my)) drawTimer.addGrowlNotice("touch %dx%d" % (mx, my), 3000, drawTimer.blue, 6) drawTimer.addCustomDraw(drawMouseBox, 1000) # User event #if event.type == pygame.USEREVENT: #print("user event") # main draw loop.. clear screen then draw frame from current screen object. FPS = clock.get_fps() CurrentScreen.clearScreen() CurrentScreen.draw(aircraft, FPS) # draw method for current screen object drawTimer.processAllDrawTimers( pygamescreen) # process / remove / draw any active drawTimers... #now make pygame update display. pygame.display.update() # once exists main loop, close down pygame. and exit. pygame.quit() pygame.display.quit()