#!/usr/bin/env python3
import tkinter as tk
import gaugelib

win = tk.Tk()
#a5 = tk.PhotoImage(file="test1.jpg")
#win.tk.call('wm', 'iconphoto', win._w, a5)
win.title("Ardiotech Raspberry Pi Version 2.0")
#win.geometry("800x400+0+0")
win.resizable(width=True, height=True)
win.configure(bg='white')

gaugeTem = gaugelib.DrawGauge2(win,
                               max_value=100,
                               min_value=0,
                               size=300,
                               bg_col='red',
                               unit="°C",
                               bg_sel=2)
gaugeTem.pack(side=tk.LEFT)
gaugeTem.set_value(50)

from PIL import ImageTk, Image

canvas_width = 300
canvas_height = 300
#canvas = tk.Canvas(win,
#           width=canvas_width,
#           height=canvas_height)
#canvas.pack(side=tk.LEFT)
예제 #2
0
#             z = 0
#         win.after(100, read_serial_and_save)
#         p1.pack(side=BOTTOM)

if __name__ == '__main__':
    while True:
        if utils.is_arduino_connected():
            win = utils.create_win()
            port = utils.find_arduino_connected_port()
            # save_button =
            exit_btn = Button(win, text="Exit", command=exit)
            exit_btn.pack(side=BOTTOM)
            p1 = gaugelib.DrawGauge2(win,
                                     max_value=125.0,
                                     min_value=0.0,
                                     size=500,
                                     bg_col='black',
                                     unit="ADC value %",
                                     bg_sel=2)
            save_btn = Button(win,
                              text="Save",
                              command=lambda: utils.save_as_excel(store_data))
            save_btn.pack(side=TOP)
            p1.pack(side=BOTTOM, pady=20)
            read_serial_and_save()
            mainloop()
        else:
            if utils.is_arduino_connected():
                break

            root = Tk()
win.geometry("800x400+0+0")
win.resizable(width=True, height=True)
win.configure(bg='white')

g_value=0
x=0

def read_every_second():
    global x
    g_value=random.randint(0,30)
    p1.set_value(int(10))

    x+=1    
    if x>100:
#        graph1.draw_axes()
        x=0
    win.after(100, read_every_second)

p1 = gaugelib.DrawGauge2(
    win,
    max_value=300.0,
    min_value=0.0,
    size=300,
    bg_col='white',
    unit = "Temperature",bg_sel = 4)
p1.place(x=300,y=100)
#p1.pack()

read_every_second()
mainloop()
예제 #4
0
    print("Dec: " + str(current))
    response = sendCommand(current)
    updateRudder(response)


tk.Button(win,
          text="Increase",
          command=onClickInc,
          fg="dark green",
          bg="white").pack()
tk.Button(win,
          text="Decrease",
          command=onClickDec,
          fg="dark green",
          bg="white").pack()
tk.Label(win, textvariable=counter).pack()

p1 = gaugelib.DrawGauge2(win,
                         max_value=35.0,
                         min_value=-35.0,
                         size=200,
                         bg_col='black',
                         unit="Rudder Angle",
                         bg_sel=2)
p1.pack(side=LEFT)

g_value = 0
p1.set_value(int(g_value))

mainloop()
예제 #5
0
    g3_value = voltage
    p3.set_value(int(g3_value))
    #battery percentage
    g4_value = voltage
    p4.set_value(int(g4_value))
    x += 1
    if x > 100:
        #        graph1.draw_axes()
        x = 0
    win.after(100, read_every_second)


p1 = gaugelib.DrawGauge2(win,
                         max_value=100.0,
                         min_value=0.0,
                         size=200,
                         bg_col='black',
                         unit="Battery Temp. °C",
                         bg_sel=2)
p1.pack(side=LEFT)
p2 = gaugelib.DrawGauge2(win,
                         max_value=100.0,
                         min_value=0.0,
                         size=200,
                         bg_col='black',
                         unit="Motor Temp. °C",
                         bg_sel=2)
p2.pack(side=RIGHT)

p3 = gaugelib.DrawGauge3(win,
                         max_value=60.0,
예제 #6
0
    g_value=random.randint(0,100)
    p2.set_value(int(g_value))
    g_value=random.randint(0,100)
    p3.set_value(int(g_value))
    g_value=random.randint(0,100)
    p4.set_value(int(g_value))
    x+=1    
    if x>100:
#        graph1.draw_axes()
        x=0
    win.after(100, read_every_second)

p1 = gaugelib.DrawGauge2(
    win,
    max_value=70.0,
    min_value=-30.0,
    size=200,
    bg_col='black',
    unit = "Temp. °C",bg_sel = 2)
p1.pack(side=LEFT)
p2 = gaugelib.DrawGauge2(
    win,
    max_value=100.0,
    min_value= 0.0,
    size=200,
    bg_col='black',
    unit = "Humid %",bg_sel = 2)
p2.pack(side=RIGHT)

p3 = gaugelib.DrawGauge3(
    win,
예제 #7
0
    # Read the newest output from the Arduino
    dataPacket = ser.readline()
    dataPacket = str(dataPacket, 'utf-8')
    splitPacket = dataPacket.split(" ")
    q0 = float(splitPacket[0])
    q1 = float(splitPacket[1])
    p1.set_value(int(q0))
    p2.set_value(int(q1))
    # root.after(0,Packet)


root = Tk()
p1 = gaugelib.DrawGauge2(root,
                         max_value=1023,
                         min_value=0,
                         size=200,
                         bg_col='black',
                         unit="Temp. °C",
                         bg_sel=2)
p1.pack(side='left')

p2 = gaugelib.DrawGauge2(root,
                         max_value=1023,
                         min_value=0,
                         size=200,
                         bg_col='black',
                         unit="Humid %",
                         bg_sel=2)
p2.pack(side='right')

ser = serial.Serial('com3', 9600)
win = tk.Tk()
a5 = PhotoImage(file="g1.png")
win.tk.call('wm', 'iconphoto', win._w, a5)
win.title("Energy Produced by Bikes (Watts)")
win.geometry("200x200+0+0")
win.resizable(width=True, height=True)
win.configure(bg='black')
g_value = 0
x = 0


def read_every_second():
    if (ser.in_waiting > 0):
        line = ser.readline()
        p1.set_value(int(line))

    win.after(100, read_every_second)


p1 = gaugelib.DrawGauge2(win,
                         max_value=100.0,
                         min_value=0.0,
                         size=200,
                         bg_col='black',
                         unit="Energy (W)",
                         bg_sel=2)
p1.pack(side=LEFT)

read_every_second()
mainloop()
예제 #9
0
          londeg = int(longps/100)
          lonmin = longps - londeg*100
          lon = londeg+(lonmin/60)

          direction = data[8]
      
          with open("/media/usb/gps/gps-data-" + str(data[9]) + ".log", "a+") as pos: 
              pos.write("Lat: %s, Lon: %s, dt: %s\n" % (lat, lon, dateTime))
              if 'g_value_mph' in globals():
                  pos.write("mph: %.2f, Direction: %s\n" % (g_value_mph, direction))


    x+=1
    if x>100:
        #graph1.draw_axes()
        x=0
    win.after(100, read_every_second)

p1 = gaugelib.DrawGauge2(
    win,
    max_value=100.0,
    min_value=0.0,
    size=200,
    bg_col='black',
    unit = "SPEED", unit1="HEADING", bg_sel = 2)

p1.grid(row=0, columnspan=3)

read_every_second()
mainloop()