def setUp(self): self.display = Display()
def __init__(self, platform, **kwargs): sys_clk_freq = int(100e6) SoCCore.__init__( self, platform, sys_clk_freq, cpu_type=None, csr_data_width=32, with_uart=False, with_timer=False, ident="My first System On Chip", ident_version=True, ) # Clock Reset Generation self.submodules.crg = CRG(platform.request("clk100"), ~platform.request("cpu_reset")) # No CPU, use Serial to control Wishbone bus self.add_cpu_or_bridge( UARTWishboneBridge(platform.request("serial"), sys_clk_freq, baudrate=115200)) self.add_wb_master(self.cpu_or_bridge.wishbone) # FPGA identification self.submodules.dna = dna.DNA() # FPGA Temperature/Voltage self.submodules.xadc = xadc.XADC() # Led user_leds = Cat(*[platform.request("user_led", i) for i in range(16)]) self.submodules.leds = Led(user_leds) #LCD D0~D7 byte # LCD_parallel = Cat(*[platform.request("LCD_parallel", i) for i in range(16)]) self.submodules.lcd_test = LCD(platform.request("LCD_Parallel", 0), platform.request("LCD_CS", 0), platform.request("LCD_RS", 0), platform.request("LCD_RD", 0), platform.request("LCD_WR", 0)) # Switches user_switches = Cat( *[platform.request("user_sw", i) for i in range(16)]) self.submodules.switches = Switch(user_switches) # Buttons user_buttons = Cat( *[platform.request("user_btn", i) for i in range(5)]) self.submodules.buttons = Button(user_buttons) # RGB Led self.submodules.rgbled = RGBLed(platform.request("user_rgb_led", 0)) # Accelerometer self.submodules.adxl362 = SPIMaster(platform.request("adxl362_spi")) # Display self.submodules.display = Display(sys_clk_freq) self.comb += [ platform.request("display_cs_n").eq(~self.display.cs), platform.request("display_abcdefg").eq(~self.display.abcdefg) ] # Probe PWM self.submodules.probe_PWM = PWM(platform.request("out_probe", 0)) # Probe SPI self.submodules.probeSPI = SPIMaster(platform.request("SPIprueba"))
WIDTH = 64 HEIGHT = 32 OFFSET = 0x200 SCALE = args.scale TIMER = pygame.USEREVENT + 1 TIMERS_UPDATE = config.timers_delay DEBUG = args.debug if not DEBUG: pygame.key.set_repeat(1, 17) else: # Pausing becomes impossible with 17 ms delay between keypresses. pygame.key.set_repeat(1, 100) # Initializing all the emulator objects display = Display(WIDTH, HEIGHT, SCALE, DEBUG) ram = RAM(MEM_SIZE, OFFSET) cpu = CPU(ram, display) keys = config.keys if not DEBUG: logger_cpu.propagate = False pause_toggle = True clock = pygame.time.Clock() def wait(): global pause_toggle while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit()
def graphics(ttk, window, root): eqn = StringVar() # Variable for interacting with the GUI stuff = ttk.Frame(window) stuff.grid(row=0, column=0, columnspan=3, sticky=E) ttk.Label(stuff, textvariable=eqn).grid(row=0, column=1) disp = Display() # Creating object to call get_eqn() # Creating the buttons on the interface ttk.Button(window, text='7', command=lambda: disp.get_eqn('7', eqn)).grid(row=1, column=0, sticky=(N, W, E, S)) ttk.Button(window, text='8', command=lambda: disp.get_eqn('8', eqn)).grid(row=1, column=1, sticky=(N, W, E, S)) ttk.Button(window, text='9', command=lambda: disp.get_eqn('9', eqn)).grid(row=1, column=2, sticky=(N, W, E, S)) ttk.Button(window, text='4', command=lambda: disp.get_eqn('4', eqn)).grid(row=2, column=0, sticky=(N, W, E, S)) ttk.Button(window, text='5', command=lambda: disp.get_eqn('5', eqn)).grid(row=2, column=1, sticky=(N, W, E, S)) ttk.Button(window, text='6', command=lambda: disp.get_eqn('6', eqn)).grid(row=2, column=2, sticky=(N, W, E, S)) ttk.Button(window, text='1', command=lambda: disp.get_eqn('1', eqn)).grid(row=3, column=0, sticky=(N, W, E, S)) ttk.Button(window, text='2', command=lambda: disp.get_eqn('2', eqn)).grid(row=3, column=1, sticky=(N, W, E, S)) ttk.Button(window, text='3', command=lambda: disp.get_eqn('3', eqn)).grid(row=3, column=2, sticky=(N, W, E, S)) ttk.Button(window, text='0', command=lambda: disp.get_eqn('0', eqn)).grid(row=4, column=0, sticky=(N, W, E, S)) ttk.Button(window, text='.', command=lambda: disp.get_eqn('.', eqn)).grid(row=4, column=1, sticky=(N, W, E, S)) ttk.Button(window, text='=', command=lambda: disp.get_eqn('=', eqn)).grid(row=4, column=2, sticky=(N, W, E, S)) ttk.Button(window, text='/', command=lambda: disp.get_eqn('/', eqn)).grid(row=1, column=3, sticky=(N, W, E, S)) ttk.Button(window, text='*', command=lambda: disp.get_eqn('*', eqn)).grid(row=2, column=3, sticky=(N, W, E, S)) ttk.Button(window, text='-', command=lambda: disp.get_eqn('-', eqn)).grid(row=3, column=3, sticky=(N, W, E, S)) ttk.Button(window, text='+', command=lambda: disp.get_eqn('+', eqn)).grid(row=4, column=3, sticky=(N, W, E, S)) ttk.Button(window, text='Del', command=lambda: disp.get_eqn('Del', eqn)).grid(row=1, column=4, sticky=(N, W, E, S)) ttk.Button(window, text='AC', command=lambda: disp.get_eqn('AC', eqn)).grid(row=2, column=4, sticky=(N, W, E, S)) ttk.Button(window, text='(', command=lambda: disp.get_eqn('(', eqn)).grid(row=3, column=4, sticky=(N, W, E, S)) ttk.Button(window, text=')', command=lambda: disp.get_eqn(')', eqn)).grid(row=4, column=4, sticky=(N, W, E, S)) # Resizing window and making it more responsive stuff.rowconfigure(0, weight=1) stuff.columnconfigure(0, weight=1) for i in range(5): window.rowconfigure(i, weight=1, pad='80') # newlines root.rowconfigure(i, weight=1, pad='80') for i in range(5): window.columnconfigure(i, weight=1, pad='80') root.columnconfigure(i, weight=1, pad='80') # Taking input from keyboard root.bind('7', lambda x: disp.get_eqn('7', eqn)) root.bind('8', lambda x: disp.get_eqn('8', eqn)) root.bind('9', lambda x: disp.get_eqn('9', eqn)) root.bind('4', lambda x: disp.get_eqn('4', eqn)) root.bind('5', lambda x: disp.get_eqn('5', eqn)) root.bind('6', lambda x: disp.get_eqn('6', eqn)) root.bind('1', lambda x: disp.get_eqn('1', eqn)) root.bind('2', lambda x: disp.get_eqn('2', eqn)) root.bind('3', lambda x: disp.get_eqn('3', eqn)) root.bind('0', lambda x: disp.get_eqn('0', eqn)) root.bind('.', lambda x: disp.get_eqn('.', eqn)) root.bind('/', lambda x: disp.get_eqn('/', eqn)) root.bind('*', lambda x: disp.get_eqn('*', eqn)) root.bind('-', lambda x: disp.get_eqn('-', eqn)) root.bind('+', lambda x: disp.get_eqn('+', eqn)) root.bind('=', lambda x: disp.get_eqn('=', eqn)) root.bind('(', lambda x: disp.get_eqn('(', eqn)) root.bind(')', lambda x: disp.get_eqn(')', eqn)) root.bind('<Return>', lambda x: disp.get_eqn('=', eqn)) root.bind('<BackSpace>', lambda x: disp.get_eqn('Del', eqn))
def __init__(self): self.display = Display(self.BOARD_SIZE) players = self.display.prompt_for_names() self.player1 = Player(players[0]) self.player2 = Player(players[1])
def new_display(name='Untitled', visible=True): display = Display(name, visible) __displays__.append(display) return display
# RELIES ON LITTLEVGL FIRMWARE BEING FLASHED ON ESP32 import lvgl as lv from main_menu import MainMenuApp from name import NameApp from pong import PongApp from display import Display import sensors import time from machine import Timer # Initialise LittlevGL -- for display lv.init() # Initialise and register the display disp = Display() buttons = sensors.Buttons(up=27, down=33, left=25, right=12, a=35, b=26, x=34, y=32) tim = Timer(-1) MainMenuApp(disp, buttons, tim)
def test_ask_for_new_url_with_jabber(self): jabber = Jabber(['whee.com']) new_display = Display(jabber) expected = new_display.ask_for_new_url() self.assertEqual(expected, 'whee.com')
def main(): tdl.set_font('arial12x12.png', greyscale=True, altLayout=True) display = Display() # missing game_map, has an empty log show_main_menu = True show_load_error = False player = None entities = [] state = GameStates.PLAYER_TURN game_map = None main_menu_background_image = image_load('a.png') while not tdl.event.is_window_closed(): for event in tdl.event.get(): if event.type == 'KEYDOWN': user_input = event break else: user_input = None if show_main_menu: main_menu(display, main_menu_background_image) if show_load_error: message_box(display, 'No save game to load', 50) tdl.flush() action = handle_main_menu(user_input) new = action.get('new') load = action.get('load') exit = action.get('exit') fullscreen = action.get('fullscreen') if fullscreen: tdl.set_fullscreen(not tdl.get_fullscreen()) if show_load_error and (new or load or exit): show_load_error = False elif new: player_name = player_name_select(display) if not player_name: continue player, entities, game_map, state = initialize( display, player_name) display.write(Message('Chop wood, carry water.')) show_main_menu = False elif load: try: player, entities, game_map, log, state = load_game() display.gmap = game_map display.log = log display.write(Message( 'Ah, {0} returns. Welcome back.'.format(player.name))) show_main_menu = False except FileNotFoundError: show_load_error = True elif exit: break else: play(player, entities, game_map, display, state) display.root_console.clear() display.con.clear() display.panel.clear() # need to reset message log, player inventory, etc # if exiting and returning to main menu show_main_menu = True show_load_error = False display = Display() player = None game_map = None entities = []
def test_ask_which_account_with_jabber(self): jabber = Jabber(['1300']) new_display = Display(jabber) account = Account('url', 'username', 'password') expected = new_display.ask_which_account([account], 17) self.assertEqual(expected, '1300')
def test_ask_for_title_with_jabber(self): jabber = Jabber(['Love Conquers All']) new_display = Display(jabber) expected = new_display.ask_for_title() self.assertEqual(expected, 'Love Conquers All')
def test_ask_for_new_username_with_jabber(self): jabber = Jabber(['microgasm']) new_display = Display(jabber) expected = new_display.ask_for_new_username() self.assertEqual(expected, 'microgasm')
def test_ask_for_temp_password_with_jabber(self): jabber = Jabber(['a temporary password']) new_display = Display(jabber) account = Account('hi', 'there', None) expected = new_display.ask_for_temp_password(account) self.assertEqual(expected, "a temporary password")
def test_ask_for_new_password_with_jabber(self): jabber = Jabber(['test']) new_display = Display(jabber) expected = new_display.ask_for_new_password() self.assertEqual(expected, "test")
def __init__(self, default_params_filename='params.yaml', *args, **kwargs): # Extend the dictionary with the values passed in arguments. # Call the Dictionary constructor once the parameters file is set. arguments = Arguments(args, kwargs) if arguments.args.config_file is not None: parameters_file = arguments.args.config_file[0] else: parameters_file = default_params_filename super().__init__(parameters_file, **kwargs) # Check that I've states and actions to start playing with. if not (self.action and self.state): raise AssertionError('No states or actions defined in config file.') # Override other potential parameters specified in command line. setattr(self, 'debug', arguments.args.debug is not None) setattr(self, 'log_level', arguments.args.debug[0] if arguments.args.debug else 3) # Interactive or Stepwise mode, overrides debug and log_level setattr(self, 'stepwise', arguments.args.stepwise) if self.stepwise is True: self.debug = True self.log_level = 4 # Start the logger if 'log_level' not in self: self.log_level = 3 # default value = INFO self.log = Logger(self.log_level) self.log.info( 'Using configuration parameters from: {}'.format(parameters_file)) # Define if acting in BULL or BEAR mode if arguments.args.trading_mode is None: setattr(self, 'mode', 'bull') else: setattr(self, 'mode', arguments.args.trading_mode[0]) self.log.info('Trading in {} mode'.format(self.mode)) # Define what to do setattr(self, 'possible_actions', arguments.possible_actions) setattr(self, 'what_to_do', arguments.args.action) self.log.info('{} mode'.format(self.what_to_do)) setattr(self, 'forecast_file', arguments.args.forecast[0]) # Load the NN model file, only if the action is not "train" if arguments.args.action != 'train' and arguments.args.model: setattr(self, 'model_file', arguments.args.model[0]) elif arguments.args.action != 'train': self.log.error('Model file must be specified with -m argument') raise ValueError('Model file must be specified with -m argument') setattr(self, 'no_dump', arguments.args.no_dump) setattr(self, 'do_plot', arguments.args.plot) setattr(self, 'save_model', arguments.args.save) setattr(self, 'totals', arguments.args.totals) setattr(self, 'short', arguments.args.short) if arguments.args.epochs is not None: setattr(self, 'num_episodes', int(arguments.args.epochs)) else: setattr(self, 'num_episodes', 1) if arguments.args.decay_factor is not None: setattr(self, 'decay_factor', float(arguments.args.decay_factor[0])) else: setattr(self, 'decay_factor', 0.996) self.log.info('Decay factor: {:.4f}'.format(self.decay_factor)) if arguments.args.initial_budget is not None: setattr(self, 'initial_budget', float(arguments.args.initial_budget[0])) else: setattr(self, 'initial_budget', self.initial_budget) self.log.info('Initial Budget: {:.0f}'.format(self.initial_budget)) # Init portfolio if arguments.args.init_portfolio is not None: setattr(self, 'init_portfolio', True) setattr(self, 'portfolio_name', arguments.args.init_portfolio[0]) else: setattr(self, 'init_portfolio', False) # Use portfolio if arguments.args.portfolio is not None: setattr(self, 'use_portfolio', True) setattr(self, 'portfolio_name', arguments.args.portfolio[0]) else: setattr(self, 'use_portfolio', False) # Check that if I want to predict, portfolio needs to be specified if self.what_to_do == 'predict' and 'portfolio_name' not in self: self.log.error( 'When calling `predict`, provide a portfolio filename.') self.log.error( 'To generate a portfolio, `simulate` with `--init-portfolio`') raise ValueError('wrong parameters') # Output filename specified. Save is implicit. if arguments.args.output is not None: setattr(self, 'output', arguments.args.output[0]) setattr(self, 'save_model', True) else: setattr(self, 'output', None) # # Extensions to the dictionary # # Build a self with a sequential number associated to each action setattr(self, 'action_id', MyDict()) for tup in zip(self.action, range(len(self.action))): self.action_id[tup[0]] = tup[1] # Build the reverse self for the actions self setattr(self, 'action_name', MyDict()) for tup in zip(range(len(self.action)), self.action): self.action_name[tup[0]] = tup[1] # Specific attributes to store number of actions and states. setattr(self, 'num_actions', len(self.action)) # Build a list of lists with the names of all possible states. setattr(self, 'states_list', list()) for state in self.state.keys(): self.states_list.append(self.state[state]) # Compute the total number of states as the multiplication of the # number of substates in each possible state-stack setattr(self, 'num_states', int) self.num_states = 1 for state in self.state.keys(): self.num_states = self.num_states * len(self.state[state]) self.log.info('{} possible states'.format(self.num_states)) # Set the number of substates (values inside each state) setattr(self, 'num_substates', int) self.num_substates = 0 for _, v in self.state.items(): if isinstance(v, list): self.num_substates += len(v) else: self.num_substates += 1 self.log.info('{} substates in all states'.format(self.num_substates)) # Create a display property to centralize all reporting activity into # a single function. That way I can store it all in a single dataframe # for later analysis. setattr(self, 'display', Display) self.display: Display = Display(self)
from display import Display if __name__ == '__main__': Display().start_engine()
def getScreen(self, playerId): player = self.getPlayer(playerId) display = Display(self.board, self.events) player = self.getPlayer(playerId) curScreen = display.getScreen(player) return curScreen
# Give external devs a way to start stuff early, but not before this point try: import boot2 except: pass import ckcc import uasyncio.core as asyncio loop = asyncio.get_event_loop() print("---\nColdcard Wallet from Coinkite Inc. (c) 2018.\n") # Setup OLED and get something onto it. from display import Display, FontFixed, FontSmall, FontLarge dis = Display() dis.splash() # Setup touch numpad from numpad import Numpad numpad = Numpad(loop) # Serial Flash memory from sflash import SPIFlash sf = SPIFlash() # NV settings from nvstore import SettingsObject settings = SettingsObject(loop)
def display_person(self): selected_item = self.listBox.curselection() person = self.listBox.get(selected_item) person_id = person.split(".")[0] displaypage = Display(person_id)
import time import cv2 from display import Display W = 1920 // 2 H = 1080 // 2 disp = Display(W, H) orb = cv2.ORB_create() print(dir(orb)) def process_frame(img): img = cv2.resize(img, (W, H)) kp, des = orb.detectAndCompute(img, None) for p in kp: u, v = map(lambda x: int(round(x)), p.pt) cv2.circle(img, (u, v), color=(0, 255, 0), radius=3) disp.paint(img) if __name__ == "__main__": cap = cv2.VideoCapture("test.mp4") while cap.isOpened(): ret, frame = cap.read() if ret == True: process_frame(frame)
from display import Display display = Display()
R = 1e14 P = np.load( '/Users/grays/Project/Data/finalData2/23-2-21-200p-Myr-position.npy') E = 0 M = 100 t = 100000 * 370 * 24 * 60 * 60 compressFactor = 100 dt = 10 * 24 * 60 * 60 * compressFactor t = len(P) * dt year = 365.25 * 24 * 60 * 60 def reshapeData(data): totalSteps = len(data) totalParticles = len(data[0]) Dimensions = len(data[0][0]) newData = np.full((totalParticles, Dimensions, totalSteps), 0.0) for i in tqdm(range(totalSteps)): for j in range(Dimensions): for k in range(totalParticles): newData[k][j][i] = data[i][k][j] return newData P = reshapeData(P) display = Display(P, E, t, dt, M, R) display.xyAnimation()
def __init__(self, debug: bool = False): self.display = Display(debug) self.left_click_time = None
def __init__(self, config): self.__data_source = DataSource(config) self.__display = Display() self.__running = False
def __init__(self): self.__display = Display(title='PyLife', grid_size=self.grid_size, width=800, height=800)
from persons.john_doe import JohnDoe from display import Display CONF = { 'tick_sleep_time': 5, 'persons': [JohnDoe()], 'displays': [Display()], }
else: env = Environment() env.load("env_1") eventFenetre = EventDisplay() eventFenetre.coefTime = 1 / 1000 simu = Simulator(env, eventFenetre) #affichage : ecran pygame.init() size = (1080, 720) #taille par défaut ecran = pygame.display.set_mode(size, pygame.RESIZABLE) #taille modifiable #creation de la fenetre active fenetre = Display(ecran, env, eventFenetre) continuer = True while continuer: size = ecran.get_size() ecran.fill((25, 25, 250)) #fond d'écran bleu police = pygame.font.Font(None, 50) texte = police.render("Press Enter", True, pygame.Color("#FFFF00")) #message texte a, b = texte.get_size() ecran.blit(texte, (size[0] / 2 - a / 2, (size[1] - b) / 3)) for event in pygame.event.get(): #ecoute les events de touche #arrete si on appuie sur la croix ou sur echap if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE): continuer = False
import numpy as np from frame import Frame, denormalize, match_frames, IRt import g2o from pointmap import Map, Point # camera intrinsics W = 3840 // 4 H = 2160 // 4 F = 270 # focal length K = np.array([[F, 0, W // 2], [0, F, H // 2], [0, 0, 1]]) Kinv = np.linalg.inv(K) # main classes mapp = Map() disp = Display(W, H) if os.getenv("D2D") is not None else None def triangulate(pose1, pose2, pts1, pts2): ret = np.zeros((pts1.shape[0], 4)) pose1 = np.linalg.inv(pose1) pose2 = np.linalg.inv(pose2) for i, p in enumerate(zip(pts1, pts2)): A = np.zeros((4, 4)) A[0] = p[0][0] * pose1[2] - pose1[0] A[1] = p[0][1] * pose1[2] - pose1[1] A[2] = p[1][0] * pose2[2] - pose2[0] A[3] = p[1][1] * pose2[2] - pose2[1] _, _, vt = np.linalg.svd(A) ret[i] = vt[3]
from pygame.locals import * pygame.init() fenetre = pygame.display.set_mode((1920,1080), pygame.FULLSCREEN) continuer= True hero = Personnage() degatsclic=1 #vpy=0 # INIT SALLE : display = Display(fenetre) #draw personnage display.drawHero(hero) pygame.display.flip() # TODO: listprojectile = [] # boucle principale while continuer: for event in pygame.event.get(): keys = pygame.key.get_pressed()
from physics import * from mymath import vec import random import theme import config #create world -> world l = config.WorldSize world = PhyWorld((-l, -l, -l, l, l, l), config.PhyFPS) #create viewport viewport = ViewPort(s=config.CameraPos, w=1024 / 2, h=768 / 2, d=400) #create display -> disp disp = Display(config.Resolution, world, viewport) theme.theme2(world, viewport) fps_timer = pg.time.Clock() quit = False delta_d = 0 delta_angle = 0 fff = 0 while not quit: for e in pg.event.get(): if e.type == pg.QUIT: quit = True elif e.type == pg.KEYDOWN: if e.key == pg.K_UP: delta_d = 5