def __init__(self, model, label_text, unit_text, initial='0', accept=None, cancel=None): """Create boolean dialog for provided model and with given label and unit text. Can provide an optional initial value (default to True), an accept callback function which is called when the user accepts the dialog (and the chosen value will be sent as a single parameter), a cancel callback which is called when the user cancels. """ self.value = str(initial) self.unit_text = unit_text self.model = model self.accept = accept self.cancel = cancel # Initialize button grid. self.buttons = ui.ButtonGrid(model.width, model.height, 4, 5) self.buttons.add(0, 1, 'False', font_size=freqshow.NUM_FONT, click=self.false_click) self.buttons.add(1, 1, 'True', font_size=freqshow.NUM_FONT, click=self.true_click) self.buttons.add(3, 3, 'CANCEL', click=self.cancel_click, bg_color=freqshow.CANCEL_BG) self.buttons.add(3, 4, 'ACCEPT', click=self.accept_click, bg_color=freqshow.ACCEPT_BG) # Build label text for faster rendering. self.input_rect = (0, 0, self.model.width, self.buttons.row_size) self.label = ui.render_text(label_text, size=freqshow.MAIN_FONT, fg=freqshow.INPUT_FG, bg=freqshow.INPUT_BG) self.label_pos = ui.align(self.label.get_rect(), self.input_rect, horizontal=ui.ALIGN_LEFT, hpad=2)
def render(self, screen): # Clear screen. screen.fill(freqshow.MAIN_BG) if self.overlay_enabled: # Draw shrunken spectrogram with overlaid buttons and axes values. spect_rect = (0, self.buttons.row_size, self.model.width, self.model.height-2*self.buttons.row_size) self.render_spectrogram(screen.subsurface(spect_rect)) # Draw hash marks. self.render_hash(screen, 0) self.render_hash(screen, self.model.width/2) self.render_hash(screen, self.model.width-1) # Draw frequencies in bottom row. bottom_row = (0, self.model.height-self.buttons.row_size, self.model.width, self.buttons.row_size) freq = self.model.get_center_freq() bandwidth = self.model.get_sample_rate() # Render minimum frequency on left. label = ui.render_text('{0:0.2f} Mhz'.format(freq-bandwidth/2.0), size=freqshow.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_LEFT)) # Render center frequency in center. label = ui.render_text('{0:0.2f} Mhz'.format(freq), size=freqshow.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_CENTER)) # Render maximum frequency on right. label = ui.render_text('{0:0.2f} Mhz'.format(freq+bandwidth/2.0), size=freqshow.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_RIGHT)) # Render min intensity in bottom left. label = ui.render_text('{0:0.0f} dB'.format(self.model.min_intensity), size=freqshow.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_LEFT, vertical=ui.ALIGN_BOTTOM)) # Render max intensity in top left. label = ui.render_text('{0:0.0f} dB'.format(self.model.max_intensity), size=freqshow.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_LEFT, vertical=ui.ALIGN_TOP)) # Draw the buttons. self.buttons.render(screen) else: # Draw fullscreen spectrogram. self.render_spectrogram(screen)
def __init__(self, model, label_text, unit_text, initial='0', accept=None, cancel=None, has_auto=False, allow_negative=False): """Create number dialog for provided model and with given label and unit text. Can provide an optional initial value (default to 0), an accept callback function which is called when the user accepts the dialog (and the chosen value will be sent as a single parameter), a cancel callback which is called when the user cancels, and a has_auto boolean if an 'AUTO' option should be given in addition to numbers. """ self.value = str(initial) self.unit_text = unit_text self.model = model self.accept = accept self.cancel = cancel # Initialize button grid. self.buttons = ui.ButtonGrid(model.width, model.height, 4, 5) self.buttons.add(0, 1, 'ENABLE', font_size=freqshow.NUM_FONT, click=self.enable_click, colspan=2) self.buttons.add(2, 1, 'DISABLE', font_size=freqshow.NUM_FONT, click=self.disable_click, colspan=2) self.buttons.add(0, 4, 'CANCEL', click=self.cancel_click, bg_color=freqshow.CANCEL_BG) self.buttons.add(3, 4, 'ACCEPT', click=self.accept_click, bg_color=freqshow.ACCEPT_BG) # Build label text for faster rendering. self.input_rect = (0, 0, self.model.width, self.buttons.row_size) self.label = ui.render_text(label_text, size=freqshow.MAIN_FONT, fg=freqshow.INPUT_FG, bg=freqshow.INPUT_BG) self.label_pos = ui.align(self.label.get_rect(), self.input_rect, horizontal=ui.ALIGN_LEFT, hpad=10)
def render(self, screen): screen.fill(freqshow.MAIN_BG) if self.overlay_enabled: spect_rect = (0, self.buttons.row_size, self.model.width, self.model.height-2*self.buttons.row_size) self.render_spectrogram(screen.subsurface(spect_rect)) self.render_hash(screen, 0) self.render_hash(screen, self.model.width/2) self.render_hash(screen, self.model.width-1) bottom_row = (0, self.model.height-self.buttons.row_size, self.model.width, self.buttons.row_size) freq = self.model.get_center_freq() bandwidth = self.model.get_sample_rate() label = ui.render_text('{0:0.2f} Mhz'.format(freq-bandwidth/2.0), size=freqshow.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_LEFT)) label = ui.render_text('{0:0.2f} Mhz'.format(freq), size=freqshow.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_CENTER)) label = ui.render_text('{0:0.2f} Mhz'.format(freq+bandwidth/2.0), size=freqshow.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_RIGHT)) label = ui.render_text('{0:0.0f} dB'.format(self.model.min_intensity), size=freqshow.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_LEFT, vertical=ui.ALIGN_BOTTOM)) label = ui.render_text('{0:0.0f} dB'.format(self.model.max_intensity), size=freqshow.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_LEFT, vertical=ui.ALIGN_TOP)) self.buttons.render(screen) else: self.render_spectrogram(screen)
def render(self, screen): screen.fill(freqshow.MAIN_BG) screen.fill(freqshow.INPUT_BG, self.input_rect) screen.blit(self.label, self.label_pos) value_label = ui.render_text('{0} {1}'.format(self.value, self.unit_text), size=freqshow.NUM_FONT, fg=freqshow.INPUT_FG, bg=freqshow.INPUT_BG) screen.blit(value_label, ui.align(value_label.get_rect(), self.input_rect, horizontal=ui.ALIGN_RIGHT, hpad=-10)) self.buttons.render(screen)
def __init__(self, model, text, accept, cancel=None): self.accept = accept self.cancel = cancel self.buttons = ui.ButtonGrid(model.width, model.height, 4, 5) self.buttons.add(0, 4, 'YA', click=self.accept_click, bg_color=spektrum.ACCEPT_BG) if cancel is not None: self.buttons.add(3, 4, 'BATAL', click=self.cancel_click, bg_color=spektrum.CANCEL_BG) self.label = ui.render_text(text, size=spektrum.NUM_FONT, fg=spektrum.TULISAN, bg=spektrum.MAIN_BG) self.label_rect = ui.align(self.label.get_rect(), (0, 0, model.width, model.height))
def __init__(self, model, text, accept, cancel=None): self.accept = accept self.cancel = cancel self.buttons = ui.ButtonGrid(model.width, model.height, 4, 5) self.buttons.add(3, 4, 'OK', click=self.accept_click, bg_color=freqshow.ACCEPT_BG) if cancel is not None: self.buttons.add(0, 4, 'CANCEL', click=self.cancel_click, bg_color=freqshow.CANCEL_BG) self.label = ui.render_text(text, size=freqshow.NUM_FONT, fg=freqshow.BUTTON_FG, bg=freqshow.MAIN_BG) self.label_rect = ui.align(self.label.get_rect(), (0, 0, model.width, model.height))
def render(self, screen): # Clear view and draw background. screen.fill(freqshow.MAIN_BG) # Draw input background at top of screen. screen.fill(freqshow.INPUT_BG, self.input_rect) # Render label and value text. screen.blit(self.label, self.label_pos) value_label = ui.render_text('{0} {1}'.format(self.value, self.unit_text), size=freqshow.NUM_FONT, fg=freqshow.INPUT_FG, bg=freqshow.INPUT_BG) screen.blit(value_label, ui.align(value_label.get_rect(), self.input_rect, horizontal=ui.ALIGN_RIGHT, hpad=-10)) # Render buttons. self.buttons.render(screen)
def __init__(self, model, label_text, unit_text, initial='0', accept=None, cancel=None, has_auto=False, allow_negative=False): """Create number dialog for provided model and with given label and unit text. Can provide an optional initial value (default to 0), an accept callback function which is called when the user accepts the dialog (and the chosen value will be sent as a single parameter), a cancel callback which is called when the user cancels, and a has_auto boolean if an 'AUTO' option should be given in addition to numbers. """ self.value = str(initial) self.unit_text = unit_text self.model = model self.accept = accept self.cancel = cancel # Initialize button grid. self.buttons = ui.ButtonGrid(model.width, model.height, 4, 5) self.buttons.add(0, 1, '1', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(1, 1, '2', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(2, 1, '3', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(0, 2, '4', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(1, 2, '5', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(2, 2, '6', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(0, 3, '7', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(1, 3, '8', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(2, 3, '9', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(1, 4, '0', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(2, 4, '.', font_size=freqshow.NUM_FONT, click=self.decimal_click) self.buttons.add(0, 4, 'DELETE', click=self.delete_click) if not allow_negative: # Render a clear button if only positive values are allowed. self.buttons.add(3, 1, 'CLEAR', click=self.clear_click) else: # Render a +/- toggle if negative values are allowed. self.buttons.add(3, 1, '+/-', click=self.posneg_click) self.buttons.add(3, 3, 'CANCEL', click=self.cancel_click, bg_color=freqshow.CANCEL_BG) self.buttons.add(3, 4, 'ACCEPT', click=self.accept_click, bg_color=freqshow.ACCEPT_BG) if has_auto: self.buttons.add(3, 2, 'AUTO', click=self.auto_click) # Build label text for faster rendering. self.input_rect = (0, 0, self.model.width, self.buttons.row_size) self.label = ui.render_text(label_text, size=freqshow.MAIN_FONT, fg=freqshow.INPUT_FG, bg=freqshow.INPUT_BG) self.label_pos = ui.align(self.label.get_rect(), self.input_rect, horizontal=ui.ALIGN_LEFT, hpad=10)
def run(): # Initialize pygame and SDL to use the PiTFT display and touchscreen. #os.putenv('SDL_VIDEODRIVER', 'fbcon') #os.putenv('SDL_FBDEV' , '/dev/fb1') #os.putenv('SDL_MOUSEDRV' , 'TSLIB') #os.putenv('SDL_MOUSEDEV' , '/dev/input/touchscreen') pygame.display.init() pygame.font.init() #pygame.mouse.set_visible(False) # Get size of screen and create main rendering surface. size = (pygame.display.Info().current_w, pygame.display.Info().current_h) print "w: " + str(size[0]) print "h: " + str(size[1]) screen = pygame.display.set_mode(size, pygame.RESIZABLE) # Display splash screen. splash = pygame.image.load('freqshow_splash.png') screen.fill(MAIN_BG) screen.blit(splash, ui.align(splash.get_rect(), (0, 0, size[0], size[1]))) pygame.display.update() # splash_start = time.time() # Create model and controller. print "build model with " + str(size[0]) + ", " + str(size[0]) fsmodel = model.FreqShowModel(size[0], size[1]) fscontroller = controller.FreqShowController(fsmodel) #time.sleep(2.0) # Main loop to process events and render current view. lastclick = 0 while True: # Process any events (only mouse events for now). for event in pygame.event.get(): if event.type is pygame.MOUSEBUTTONDOWN \ and (time.time() - lastclick) >= CLICK_DEBOUNCE: lastclick = time.time() fscontroller.current().click(pygame.mouse.get_pos()) # Update and render the current view. fscontroller.current().render(screen) #fscontroller.multiview().render(screen) #for x in fscontroller.both_views(): # x.render(screen) #views.WaterfallSpectrogram(model, fscontroller).render(screen) #views.InstantSpectrogram(model, fscontroller).render(screen) pygame.display.update()
def __init__(self, model, label_text, unit_text, initial='0', accept=None, cancel=None, has_auto=False, allow_negative=False): self.value = str(initial) self.unit_text = unit_text self.model = model self.accept = accept self.cancel = cancel self.buttons = ui.ButtonGrid(model.width, model.height, 4, 5) self.buttons.add(0, 1, '1', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(1, 1, '2', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(2, 1, '3', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(0, 2, '4', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(1, 2, '5', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(2, 2, '6', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(0, 3, '7', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(1, 3, '8', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(2, 3, '9', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(1, 4, '0', font_size=freqshow.NUM_FONT, click=self.number_click) self.buttons.add(2, 4, '.', font_size=freqshow.NUM_FONT, click=self.decimal_click) self.buttons.add(0, 4, 'Sil', click=self.delete_click) if not allow_negative: self.buttons.add(3, 1, 'Temizle', click=self.clear_click) else: self.buttons.add(3, 1, '+/-', click=self.posneg_click) self.buttons.add(3, 3, 'İptal', click=self.cancel_click, bg_color=freqshow.CANCEL_BG) self.buttons.add(3, 4, 'Kabul', click=self.accept_click, bg_color=freqshow.ACCEPT_BG) if has_auto: self.buttons.add(3, 2, 'Auto', click=self.auto_click) self.input_rect = (0, 0, self.model.width, self.buttons.row_size) self.label = ui.render_text(label_text, size=freqshow.MAIN_FONT, fg=freqshow.INPUT_FG, bg=freqshow.INPUT_BG) self.label_pos = ui.align(self.label.get_rect(), self.input_rect, horizontal=ui.ALIGN_LEFT, hpad=10)
def render(self, screen): # Clear screen. screen.fill(spektrum.MAIN_BG) if self.overlay_enabled: # Draw shrunken spectrogram with overlaid buttons and axes values. spect_rect = (0, self.buttons.row_size, self.model.width, self.model.height-2*self.buttons.row_size) self.render_spectrogram(screen.subsurface(spect_rect)) # Draw hash marks. self.render_hash(screen, 0) self.render_hash(screen, self.model.width/4) self.render_hash(screen, self.model.width/2) self.render_hash(screen, self.model.width*3/4) self.render_hash(screen, self.model.width-1) # Draw frequencies in bottom row. bottom_row = (0, (self.model.height-7)-self.buttons.row_size, self.model.width, self.buttons.row_size) bottom_mhz = (0, (self.model.height + 15)-self.buttons.row_size, self.model.width, self.buttons.row_size) freq = self.model.get_center_freq() bandwidth = self.model.get_sample_rate() # Render minimum frequency on left. label = ui.render_text('{0:0.2f}'.format(freq-bandwidth/2.0), size=spektrum.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_LEFT)) pygame.draw.line(screen, spektrum.PEMBATAS, [0, 256], [478, 256]) # Tengah2 top-center label = ui.render_text('{0:0.2f}'.format(freq-bandwidth/4.0), size=spektrum.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_LC)) pygame.draw.line(screen, spektrum.BATAS, [120, 256], [120, 64]) # Render center frequency in center. label = ui.render_text('{0:0.2f}'.format(freq), size=spektrum.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_CENTER)) pygame.draw.line(screen, spektrum.BATAS, [240, 256], [240, 64]) # Tulisan MHz label = ui.render_text('Frequency (Mhz)', size=spektrum.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), bottom_mhz, horizontal=ui.ALIGN_CENTER)) # Tengah2 Bot-center label = ui.render_text('{0:0.2f}'.format(freq+bandwidth/4.0), size=spektrum.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_RC)) pygame.draw.line(screen, spektrum.BATAS, [360, 256], [360, 64]) # Render maximum frequency on right. label = ui.render_text('{0:0.2f}'.format(freq+bandwidth/2.0), size=spektrum.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_RIGHT)) # Render min intensity in bottom left. label = ui.render_text('{0:0.1f} dBm'.format(self.model.min_intensity), size=spektrum.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_LEFT, vertical=ui.ALIGN_BOTTOM)) #Coba2 saja """label = ui.render_text('{0:0.0f} dBm'.format(self.model.max_intensity+self.model.min_intensity/2.0), size=spektrum.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_LEFT, vertical=ui.ALIGN_CENTER)) """ # Render max intensity in top left. label = ui.render_text('{0:0.2f} dBm'.format(self.model.max_intensity), size=spektrum.MAIN_FONT) screen.blit(label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_LEFT, vertical=ui.ALIGN_TOP)) pygame.draw.line(screen, spektrum.PEMBATAS, [0, 0], [0, 256]) # Draw the buttons. self.buttons.render(screen) else: # Draw fullscreen spectrogram. self.render_spectrogram(screen)
def render(self, screen): # Clear screen. screen.fill(freqshow.MAIN_BG) if self.overlay_enabled: # Draw shrunken spectrogram with overlaid buttons and axes values. spect_rect = (0, self.buttons.row_size, self.model.width, self.model.height - 2 * self.buttons.row_size) self.render_spectrogram(screen.subsurface(spect_rect)) # Draw hash marks. self.render_hash(screen, 0) self.render_hash(screen, self.model.width / 2) self.render_hash(screen, self.model.width - 1) # Draw frequencies in bottom row. bottom_row = (0, self.model.height - self.buttons.row_size, self.model.width, self.buttons.row_size) # freq = float(self.model.get_lo_freq()) - float(self.model.get_lo_offset()) freq = self.model.get_center_freq() bandwidth = self.model.get_zoom_fac() sig = (self.model.get_sig_strength() / 6) offset = self.model.get_lo_offset() beta = self.model.get_kaiser_beta() # Render minimum frequency on left. label = ui.render_text('- {0:0.4f} Mhz'.format(bandwidth / 2.0), size=freqshow.MAIN_FONT, bg=freqshow.MAIN_BG) screen.blit( label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_LEFT)) # Render center frequency in center. label = ui.render_text('{0:0.6f}'.format(freq), size=freqshow.MAIN_FONT, bg=freqshow.MAIN_BG) screen.blit( label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_CENTER)) # Render maximum frequency on right. label = ui.render_text('+ {0:0.4f} Mhz'.format(bandwidth / 2.0), size=freqshow.MAIN_FONT, bg=freqshow.MAIN_BG) screen.blit( label, ui.align(label.get_rect(), bottom_row, horizontal=ui.ALIGN_RIGHT)) # Render min intensity in bottom left. label = ui.render_text('{0:0.0f} dB'.format( self.model.min_intensity), size=freqshow.MAIN_FONT, bg=freqshow.GRID_BG) screen.blit( label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_LEFT, vertical=ui.ALIGN_BOTTOM)) # Render max intensity in top left. label = ui.render_text('{0:0.0f} dB'.format( self.model.max_intensity), size=freqshow.MAIN_FONT, bg=freqshow.GRID_BG) screen.blit( label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_LEFT, vertical=ui.ALIGN_TOP)) # Render FFT average in bottom right. if self.model.get_peak() == True: label = ui.render_text('fft pks = {0}'.format( self.model.fft_ave), size=freqshow.MAIN_FONT, bg=freqshow.GRID_BG) screen.blit( label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_RIGHT, vertical=ui.ALIGN_BOTTOM)) elif self.model.get_peak() == False: label = ui.render_text('fft ave = {0}'.format( self.model.fft_ave), size=freqshow.MAIN_FONT, bg=freqshow.GRID_BG) screen.blit( label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_RIGHT, vertical=ui.ALIGN_BOTTOM)) # Render Grid scale factor in upper right. label = ui.render_text('scale = {0:0.1f} dB'.format( (self.model.max_intensity - self.model.min_intensity) / 10), size=freqshow.MAIN_FONT, bg=freqshow.GRID_BG) screen.blit( label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_RIGHT, vertical=ui.ALIGN_TOP)) # Render Signal plus to Noise of Ceneter Frequency in center top. # label = ui.render_text('S units = {0:0.1f}' .format(sig), # size=freqshow.MAIN_FONT, bg=freqshow.GRID_BG) # screen.blit(label, ui.align(label.get_rect(), spect_rect, # horizontal=ui.ALIGN_CENTER, vertical=ui.ALIGN_TOP)) # Render windowing filter setting in center top. if self.model.filter == 'kaiser': label = ui.render_text('Kaiser beta = {0:0.1f}'.format(beta), size=freqshow.MAIN_FONT, bg=freqshow.GRID_BG) screen.blit( label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_CENTER, vertical=ui.ALIGN_TOP)) else: label = ui.render_text('{0}'.format(self.model.filter), size=freqshow.MAIN_FONT, bg=freqshow.GRID_BG) screen.blit( label, ui.align(label.get_rect(), spect_rect, horizontal=ui.ALIGN_CENTER, vertical=ui.ALIGN_TOP)) # Draw the buttons. self.buttons.render(screen) else: # Draw fullscreen spectrogram. self.render_spectrogram(screen)
ui.Button.padding_px = 2 ui.Button.border_px = 2 if __name__ == '__main__': pygame.display.init() pygame.font.init() pygame.mouse.set_visible(True) # Get size of screen and create main rendering surface. size = (pygame.display.Info().current_w, pygame.display.Info().current_h) screen = pygame.display.set_mode(size, pygame.FULLSCREEN) # Display splash screen. splash = pygame.image.load('spektrum_analizor.png') screen.fill(MAIN_BG) screen.blit(splash, ui.align(splash.get_rect(), (0, 0, size[0], size[1]))) pygame.display.update() splash_start = time.time() # Create model and controller. fsmodel = model.FreqShowModel(size[0], size[1]) fscontroller = controller.FreqShowController(fsmodel) time.sleep(2.0) # Main loop to process events and render current view. lastclick = 0 while True: # Process any events (only mouse events for now). for event in pygame.event.get(): if event.type is pygame.MOUSEBUTTONDOWN \ and (time.time() - lastclick) >= CLICK_DEBOUNCE: lastclick = time.time() fscontroller.current().click(pygame.mouse.get_pos())
if __name__ == '__main__': # Initialize pygame and SDL to use the PiTFT display and touchscreen. os.putenv('SDL_VIDEODRIVER', 'fbcon') os.putenv('SDL_FBDEV', '/dev/fb0') #os.putenv('SDL_MOUSEDRV' , 'TSLIB') #os.putenv('SDL_MOUSEDEV' , '/dev/input/touchscreen') pygame.display.init() pygame.font.init() pygame.mouse.set_visible(True) # Get size of screen and create main rendering surface. size = (pygame.display.Info().current_w, pygame.display.Info().current_h) screen = pygame.display.set_mode(size, pygame.FULLSCREEN) # Display splash screen. splash = pygame.image.load('freqshow_splash.png') screen.fill(MAIN_BG) screen.blit(splash, ui.align(splash.get_rect(), (0, 0, size[0], size[1]))) pygame.display.update() splash_start = time.time() # Create model and controller. fsmodel = model.FreqShowModel(size[0], size[1]) fscontroller = controller.FreqShowController(fsmodel) time.sleep(2.0) # Main loop to process events and render current view. lastclick = 0 while True: # Process any events (only mouse events for now). for event in pygame.event.get(): if event.type is pygame.MOUSEBUTTONDOWN \ and (time.time() - lastclick) >= CLICK_DEBOUNCE: lastclick = time.time() fscontroller.current().click(pygame.mouse.get_pos())
#os.putenv('SDL_MOUSEDEV' , '/dev/input/touchscreen') pygame.display.init() pygame.font.init() #pygame.mouse.set_visible(False) # Get size of screen and create main rendering surface. size = (pygame.display.Info().current_w, pygame.display.Info().current_h) print("w: " + str(size[0])) print("h: " + str(size[1])) screen = pygame.display.set_mode((1920, 1080), pygame.RESIZABLE) # Display splash screen. splash = pygame.image.load('freqshow_splash.png') screen.fill(MAIN_BG) screen.blit(splash, ui.align(splash.get_rect(), (0, 0, size[0], size[1]))) pygame.display.update() splash_start = time.time() # Create model and controller. fscontroller = controller.FreqShowController(fsmodel) # time.sleep(6.0) # Main loop to process events and render current view. lastclick = 0 ### lock2 = Lock() # if (not lock2.locked()): #lock2.acquire() #print ("unlocked running") #m.start()