Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from Tkinter import *
- root = Tk()
- root.title("Elentirmo Observatory Controller v0.3")
- root.minsize(468, 85)
- root.maxsize(960, 85)
- dust_cover_text = StringVar()
- dust_cover_text.set('Cover Closed')
- usbport = 'COM9'
- import sys
- import time
- def dust_cover_open():
- print "Opening"
- ## Open a serial connection with Arduino.
- import time
- import serial
- ser = serial.Serial(usbport, 9600) # Open serial port that Arduino is using
- time.sleep(3) # Wait 3 seconds for Arduino to reset
- print ser # Print serial config
- print "Sending serial command to OPEN the dust cover to 180d."
- ser.write("O")
- print "Opening serial connection."
- ser.close()
- # Reminder to close the connection when finished
- if(ser.isOpen()):
- print "Serial connection is still open."
- dust_cover_label.config(bg="Green")
- dust_cover_text.set('Cover is Open')
- ##Tweet status
- tweet_text = "Dust cover opening."
- import os
- api.update_status(status=time.strftime("%Y.%m.%d-%H:%M:%S") + " - " + tweet_text)
- def dust_cover_close():
- print "Closing"
- ## Open a serial connection with Arduino.
- import time
- import serial
- ser = serial.Serial(usbport, 9600) # Open serial port that Arduino is using
- time.sleep(3) # Wait 3 seconds for Arduino to reset
- print ser # Print serial config
- print "Sending serial command to CLOSE the dust cover."
- ser.write("C")
- print "Closing serial connection."
- ser.close()
- # Reminder to close the connection when finished
- if(ser.isOpen()):
- print "Serial connection is still open."
- dust_cover_label.config(bg="red")
- dust_cover_text.set('Cover is closed')
- ##Tweet status
- tweet_text = "Dust cover closing."
- import os
- api.update_status(status=time.strftime("%Y.%m.%d-%H:%M:%S") + " - " + tweet_text)
- #Dust Cover Button
- open_dust_cover_btn = Button(text=" Open Cover ", width=15, command=dust_cover_open)
- open_dust_cover_btn.grid(row=0, column=0)
- close_dust_cover_btn = Button(text=" Close Cover ", width=15, command=dust_cover_close)
- close_dust_cover_btn.grid(row=1, column=0)
- #Dust Cover Label
- dust_cover_label = Label(root, textvariable=dust_cover_text, width=15, fg="Black", bg="Red")
- dust_cover_label.grid(row=2, column=0)
- #Current Status Label
- status_label = Label(root, text=("Current Status"), width=15, fg="Black")
- status_label.grid(row=2, column=1)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement