The code below is part of my sensor GUI display program, and it is "working", but I cannot get the values I really want to work in the graphs. I get a NameError: name 'result' is not defined
.
I want the value result
to display in the field rather than accel0.getAcceleration()
I can get it to print no problem, and tried global values, changing number format, etc to the best of my abilities, but just can't get it to work. Any help would be greatly appreciated!!!
def onAccelerationChange(self, acceleration, timestamp):
global result
xA = float(acceleration[0])
xZ = float(acceleration[2])
xAngle = xA / xZ
rads = (math.atan(xAngle))
result = math.degrees(rads) ***I want this value to go...***
def plot(self):
x = ["Load 0", "Load 1", "Load 2", "Load 3"]
h = [(load0.getVoltageRatio() * 1000), (load1.getVoltageRatio() * 1000), (load2.getVoltageRatio() * 1000), (load3.getVoltageRatio() * 1000)]
# adding the subplot
self.plot1.cla()
self.plot1.bar(x, h)
self.plot1.set_xlabel("Strain Gauges")
self.plot1.set_ylabel("PLI")
self.plot1.set_title("Blade Load")
Angle = "Angle: " + str***(accel0.getAcceleration())*** + "°"
self.text['text'] = Angle
self.canvas.draw()
self.canvas.get_tk_widget().pack()