def ScanToOpen(self, controller): #to change the label ser = serial.Serial('/dev/ttyACM0', 9600) PurchasePage = controller.get_page('PurchaseMenu') timeout = time.time() + 6 flag = True while (time.time() < timeout): servo_locked() # print(time.time(), timeout) if b'METAL DETECTED\r\n' in ser: print('Metal Detected with Pi') servo_open() print("min(unlock)") sleep(10) servo_locked() print("max(lock)") sleep(1) if POS.DiscountEnabler == 1: POS.CanDiscountMethod(PurchasePage) self.Scanninglabel.config(text="Thank you for recycling!") ser.close() # self.update() # sleep(2) flag = False ser.close() POS.DiscountReturnMethod(self) # controller.show_frame("MainMenu") break elif POS.DiscountEnabler == 0: flag = False ser.close() POS.DiscountReturnMethod(self) break
def PlasticDoorOpen(self): servo_max() servo_min() print("min(unlock)") sleep(3) servo_max() print("max(lock)") self.OpeningDoorPromptlabel.config(text = "Thank you for recycling!") self.update() sleep(3) if POS.DiscountEnabler == 1: POS.WaterDiscountMethod(self) POS.DiscountReturnMethod(self) elif POS.DiscountEnabler == 0: POS.DiscountReturnMethod(self)
def PlasticDoorOpen(self, controller): PurchasePage = controller.get_page("PurchaseMenu") servo_max() servo_min() print("min(unlock)") sleep(10) servo_max() print("max(lock)") self.OpeningDoorPromptlabel.config(text="Thank you for recycling!") self.update() sleep(3) if POS.DiscountEnabler == 1: POS.WaterDiscountMethod(PurchasePage) POS.DiscountReturnMethod(self) elif POS.DiscountEnabler == 0: POS.DiscountReturnMethod(self)
def ScanToOpen(self, controller): #to change the label PurchasePage = controller.get_page('PurchaseMenu') while True: servo_max() if b'METAL DETECTED\r\n' in ser: print('Metal Detected with Pi') servo_min() print("min(unlock)") sleep(3) servo_max() print("max(lock)") sleep(1) if POS.DiscountEnabler == 1: POS.CanDiscountMethod(PurchasePage) POS.DiscountReturnMethod(self) self.Scanninglabel.config(text="Thank you for recycling!") break
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) self.controller = controller #This Creates the labels for the frame self.selectionlabel = tk.Label( self, bg='black', fg='white', text="Would you like to Recycle a Aluminum can or Plastic bottle?", font=controller.title_font) #This puts the label on the frame self.selectionlabel.pack(side="top", fill="x", pady=10) #This creates the buttons for the frame self.CanSelectionButton = tk.Button( self, text="", command=lambda: [ controller.show_frame("ScanningStage_OpenAlumDoor"), print("moving to ScanningStage_OpenAlumDoor") ]) self.BottleSelectionButton = tk.Button( self, text="", command=lambda: [ controller.show_frame("OpeningPlasticDoor"), print("opening plastic door") ]) self.ReturnSelectionButton = tk.Button( self, text="", command=lambda: [ controller.show_frame("MainMenu"), POS.ResetPrice(self), print("moving to main menu") ]) #This puts the buttons onto the frame self.CanSelectionButton.pack() self.BottleSelectionButton.pack() self.ReturnSelectionButton.pack() #This allows us to put images into the buttons self.AlumImageForButton = PhotoImage( file="Buttons_Pack//RecycleAluminum_image.gif") self.CanSelectionButton.config(image=self.AlumImageForButton, compound="bottom") self.CanSelectionButton.image = self.AlumImageForButton self.PlasticImageForButton = PhotoImage( file="Buttons_Pack//RecyclePlastic_image.gif") self.BottleSelectionButton.config(image=self.PlasticImageForButton, compound="bottom") self.BottleSelectionButton.image = self.PlasticImageForButton self.BackupImageForButton = PhotoImage( file="Buttons_Pack//BackupButton_image.gif") self.ReturnSelectionButton.config(image=self.BackupImageForButton, compound="bottom") self.ReturnSelectionButton.image = self.BackupImageForButton
def ActivateCoinAcceptor(self, controller): ser = serial.Serial('/dev/ttyACM1', 9600) PurchasePage = controller.get_page('PurchaseMenu') while True: #Converting the byte to string s = ser.readline() ss = np.fromstring(s, dtype=np.uint8) sss = "".join(map(chr, ss)) #Convert the string to integers total_amount = int(sss) self.Final_amount = POS.FinalPrice print(total_amount) if total_amount >= 25: self.coinlabeltest.config(text="You have deposited $0.25") self.Final_amount -= 25 self.FinalTotalLabel.config(text='$%.2f' % (self.Final_amount / 100)) self.update() if total_amount >= 50: self.coinlabeltest.config(text="You have deposited $0.50") self.Final_amount -= 25 self.FinalTotalLabel.config(text='$%.2f' % (self.Final_amount / 100)) self.update() if total_amount >= 75: self.coinlabeltest.config(text="You have deposited $0.75") self.Final_amount -= 25 self.FinalTotalLabel.config(text='$%.2f' % (self.Final_amount / 100)) self.update() if total_amount >= 100: self.coinlabeltest.config(text="You have deposited $1.00") self.Final_amount -= 25 self.FinalTotalLabel.config(text='$%.2f' % (self.Final_amount / 100)) self.update() if total_amount >= 125: self.coinlabeltest.config(text="You have deposited $1.25") self.Final_amount -= 25 self.FinalTotalLabel.config(text='$%.2f' % (self.Final_amount / 100)) self.update() if total_amount >= POS.FinalPrice: self.coinlabeltest.config(text="Thank you for choosing RVM") self.update() if POS.SodaSelected == 1: SM.Stepper1Forward(self) if POS.WaterSelected == 1: SM.Stepper2Forward(self) print(total_amount, POS.Price) POS.ResetPrice(PurchasePage, controller) ser.close() controller.show_frame("MainMenu") break
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) self.controller = controller checkOutFrame = controller.get_page('CheckoutMenu') #This Creates the labels for the frame self.selectionlabel = tk.Label( self, bg='black', fg='white', text="Would you like to buy a can of soda or bottle of water?", font=controller.title_font) self.TotalLabel = tk.Label( self, bg='black', fg='white', text="Your total will display here as you add items", font=controller.title_font) self.Cartlabel = tk.Label(self, bg='black', fg='white', text="Your Final value is " '$%.2f ' "Your discount was " '$%.2f' % ((POS.FinalPrice / 100), (POS.Discount / 100)), font=controller.title_font) #This puts the label on the frame self.selectionlabel.pack(side="top", fill="x", pady=10) self.Cartlabel.pack(side="top", fill="x", pady=10) self.TotalLabel.pack(side="top", fill="x", pady=10) #This creates the buttons for the frame self.AddSodaButton = tk.Button( self, text="", command=lambda: [POS.AddPriceOfSoda(self), POS.SodaSelectedMethod(self)]) self.AddWaterButton = tk.Button( self, text="", command=lambda: [POS.AddPriceOfWater(self), POS.WaterSelectedMethod(self)]) self.ReturnSelectionButton = tk.Button( self, text="", command=lambda: [ controller.show_frame("MainMenu"), POS.ResetPrice(self), print("moving to main menu") ]) self.CheckoutSelectionButton = tk.Button( self, text="", command=lambda: [ controller.show_frame("CheckoutMenu"), checkOutFrame.FinalTotalLabel.config(text=('$%.2f' % ( POS.FinalPrice / 100))), print("moving to checkout menu") ]) self.MinusSodaFromTotalButton = tk.Button( self, text="", command=lambda: [ POS.SubtractPriceOfSoda(self), print("Removing price of soda from total"), POS.SodaSelectedMethod(self) ]) self.MinusWaterFromTotalButton = tk.Button( self, text="", command=lambda: [ POS.SubtractPriceOfWater(self), print("Removing price of Water from total"), POS.WaterSelectedMethod(self) ]) self.RecycleOnPurchaseWindowButton = tk.Button( self, text="", command=lambda: [ POS.DiscountEnablerMethod(self), controller.show_frame("RecycleMenu"), print("Moving to recycle page") ]) #This puts the buttons onto the frame self.AddSodaButton.pack(side="left") self.MinusWaterFromTotalButton.pack(side="right") self.AddWaterButton.pack(side="right") self.MinusSodaFromTotalButton.pack(side="left") self.CheckoutSelectionButton.pack() self.ReturnSelectionButton.pack() self.RecycleOnPurchaseWindowButton.pack(side="bottom") #This puts images inside the buttons self.AddCanImageForButton = PhotoImage( file="Buttons_Pack//AddSodaButton_image.gif") self.AddBottleImageForButton = PhotoImage( file="Buttons_Pack//AddWaterButton_image.gif") self.RemoveCanImageForButton = PhotoImage( file="Buttons_Pack//RemoveSodaButton_image.gif") self.RemoveBottleImageForButton = PhotoImage( file="Buttons_Pack//RemoveWaterButton_image.gif") self.AddSodaButton.config(image=self.AddCanImageForButton, compound="bottom") self.AddSodaButton.image = self.AddCanImageForButton self.AddWaterButton.config(image=self.AddBottleImageForButton, compound="bottom") self.AddWaterButton.image = self.AddBottleImageForButton self.MinusSodaFromTotalButton.config( image=self.RemoveCanImageForButton, compound="bottom") self.MinusSodaFromTotalButton.image = self.RemoveCanImageForButton self.MinusWaterFromTotalButton.config( image=self.RemoveBottleImageForButton, compound="bottom") self.MinusWaterFromTotalButton.image = self.RemoveBottleImageForButton self.BackupImageForButton = PhotoImage( file="Buttons_Pack//BackupButton_image.gif") self.ReturnSelectionButton.config(image=self.BackupImageForButton, compound="bottom") self.ReturnSelectionButton.image = self.BackupImageForButton self.CheckoutImageForButton = PhotoImage( file="Buttons_Pack//Checkout_image.gif") self.CheckoutSelectionButton.config(image=self.CheckoutImageForButton, compound="bottom") self.CheckoutSelectionButton.image = self.CheckoutImageForButton self.RecycleOnPurchaseImageForButton = PhotoImage( file="Buttons_Pack//DiscountButton_image.gif") self.RecycleOnPurchaseWindowButton.config( image=self.RecycleOnPurchaseImageForButton, compound="bottom") self.RecycleOnPurchaseWindowButton.image = self.RecycleOnPurchaseImageForButton