With this code you will be able to blink LED1 when you push a graphical button. I use RPC and RTOS librairies on Mbed LPC1768. On python I use mbedRPC, and Tkinter.
Dependencies: mbed-rpc mbed-rtos mbed
Fork of Blinking_RPC by
GUI.py
00001 # coding: utf8 00002 00003 #linux command to execute the script : python 'path'/RPC_test_code/GUI.py 00004 00005 00006 from Tkinter import * #GUI Librairie 00007 from mbedrpc import * #Libraire to link serial communication mbed <=> PC, (serial or http) 00008 00009 mbed = SerialRPC('/dev/ttyACM0', 9600) #setup on the serial port ACM0. 00010 #You can check what port you are using with a linux shell command : ls /dev/ttyACM* 00011 #9600 : default baudrate 00012 00013 00014 00015 #------------RPCvariable 00016 00017 Blink = RPCVariable(mbed,"Blink_RPC") #Create a new variable : name= Blink_RPC, on the mbed setup before, link to the mbed variable Blink 00018 00019 00020 #--------------GUI display 00021 root = Tk() #creation a new window 00022 root.title('Blinking led') #display title 00023 root.geometry('150x50+200+200') #Set geometry of root window 00024 00025 00026 Area = LabelFrame(root,text = "Blinking mode : ") #area creation 00027 Area.pack(fill="x",expand="yes") 00028 00029 00030 #--update function 00031 def update(): 00032 00033 if(var.get() == 0): 00034 Blink.write(1) #change Blink_RPC value on mbed 00035 print 'Blinking' #Linux terminal output 00036 var.set(1) #change var value for the next clic 00037 00038 else: 00039 Blink.write(0) #change Blink_RPc value 00040 print 'No blink' 00041 var.set(0) 00042 00043 00044 #---------------------------create a simple button 00045 var = DoubleVar() 00046 var.set(0) 00047 Blink_button = Button(Area, text="Blink", command = update) #command = update => call function update() when you clic button 00048 Blink_button.pack() 00049 00050 root.mainloop()
Generated on Sat Jul 16 2022 01:57:01 by
1.7.2
