Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.11 KB | None | 0 0
  1.  def exit(self):
  2.         print("PiCamera is closed.")
  3.         print("GPIO pins have been released")
  4.         self.destroy()
  5.  
  6.  
  7. class StartPage(tk.Frame):
  8.     def __init__(self, parent, controller):
  9.         """Initiate parent class"""
  10.         tk.Frame.__init__(self, parent)
  11.         self.configure(background="#0063FF")
  12.         self.controller = controller
  13.  
  14.         """Initializing scanning pattern variables"""
  15.         self.refresh_delay_milli = 1500
  16.         self.n_x_steps = 9
  17.         self.n_y_steps = 9
  18.         self.x_step_size = 2  # in cms
  19.         self.y_step_size = 2  # in cms
  20.         self.grid_panel = np.zeros((self.n_x_steps+1, self.n_y_steps+1))
  21.         self.target_list = [(i, j) for i in self.x_step_size*np.arange(self.n_x_steps+1)
  22.                             for j in self.y_step_size*np.arange(self.n_y_steps+1)]
  23.         self.refresh_timestamp = time()
  24.  
  25.         self.grid_panel[2][7] = 1
  26.         self.grid_panel[6][3] = 1
  27.         self.grid_panel[5][9] = 1
  28.         self.grid_panel[8][1] = 1
  29.  
  30.         """GPIO pins"""
  31.  
  32.         """Initialize Peripherals"""
  33.  
  34.         """Coordinate initialization"""
  35.         self.curr_x = 0
  36.         self.curr_y = 0
  37.         self.curr_z = 0
  38.         self.ysonic = ''    # Either LEFT or RIGHT
  39.         self.first_coord_fetch_flag = True  # The first fetched coordinates will be used for setting Origin
  40.  
  41.         """Origin"""
  42.         self.x_0 = 0
  43.         self.y_0 = 0
  44.         self.z_0 = 25
  45.  
  46.         """Target Coordinates"""
  47.         # self.x_target = 0
  48.         # self.y_target = 0
  49.         # self.z_target = 0
  50.         self.x_max = self.x_step_size * self.n_x_steps
  51.         self.x_min = 0
  52.         self.y_max = self.y_step_size * self.n_y_steps
  53.         self.y_min = 0
  54.         # self.target_update_flag_x = 0
  55.         # self.target_update_flag_y = 0
  56.         # self.top_to_bottom_flag = 0
  57.  
  58.         """Tolerance"""
  59.         self.tolerance = 1.5  # in cms
  60.         self.tolerance_z = 3  # in cms
  61.  
  62.         """Start and Stop Flags"""
  63.         self.start_instruction_flag = 1
  64.         self.stop_instruction_flag = 0
  65.         # self.held_timer_start_flag = 1
  66.         # self.held_start_time = 0
  67.         # self.total_time_held = 0
  68.         # self.hold_on_time_threshold = 3
  69.         self.scan_shot_time = 1  # Assuming scanning and storing takes 1 sec
  70.         # self.show_scanned_time_start = 0
  71.         # self.show_scanned_time = 2
  72.         self.calibration_flag = 1
  73.  
  74.         """Initialize Direction and Status Panel Frames"""
  75.         self.dir_panel = DirectionPanel(self, controller)
  76.         #self.dir_panel.grid(column=self.grid_panel.shape[0], rowspan = self.grid_panel.shape[1], padx = 50)
  77.         self.dir_panel.grid(columnspan = 20, rowspan = 15, padx = 100, pady= 130)
  78.  
  79.         #Manual Spacers#
  80.         tk.Label(self, text = " ", bg = "#0063FF").grid(column = 21, padx = 25)
  81.         tk.Label(self, text = " ", bg = "#0063FF").grid(row = 0,pady = 3)
  82.  
  83.         #self.numGrid = numGrid(self, controller)
  84.         #self.numGrid.grid()
  85.         for r in range(self.grid_panel.shape[1]):
  86.             for c in range(self.grid_panel.shape[0]):
  87.                 # if(int(self.grid_panel[c][r] == 0)):
  88.                 #     tk.Label(self, text=int(self.grid_panel[c][r]), font = ("Helvetica", fontsize), padx = 10, bg = "#8a0404",
  89.                 #     borderwidth=2 ).grid(row=r+1,column=c+22)
  90.                 # else:
  91.                 #     tk.Label(self, text=int(self.grid_panel[c][r]), font = ("Helvetica", fontsize), padx = 10, bg = "yellow",
  92.                 #     borderwidth=2 ).grid(row=r+1,column=c+22)
  93.                 if(int(self.grid_panel[c][r] == 0)):
  94.                     tk.Label(self, text="   ", font = ("Helvetica", fontsize), padx = 10, bg = "#8a0404",
  95.                     borderwidth=2, relief = "solid" ).grid(row=r+1,column=c+22)
  96.                 else:
  97.                     tk.Label(self, text="   ", font = ("Helvetica", fontsize), padx = 10, bg = "yellow",
  98.                     borderwidth=2, relief = "solid" ).grid(row=r+1,column=c+22)  
  99.  
  100.         # self.status_panel = ScanStatusPanel(self, controller)
  101.         # self.status_panel.pack(side="right", fill="both", expand=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement