Adding readings to Web UI

Forums:

After manipulating a code I can read compass bearings and tilt/yaw angles from my Pimoroni ICM20948 9DoF Motion Sensor. I would like to add these readings to my Web UI dashboard.
I'm thinking I will need to do something along the lines of

http://forum.piborg.org/sites/default/files/forum_upload/piborg/metalWeb...

if getPath.startswith('/distances-once'):
# Ultrasonic distance readings
# Get the readings
distance1 = int(UB.GetDistance1())
distance2 = int(UB.GetDistance2())
distance3 = int(UB.GetDistance3())
distance4 = int(UB.GetDistance4())
# Build a table for the values
httpText = ''
if distance1 == 0:
httpText += 'None'
else:
httpText += '%04d' % (distance1)
if distance2 == 0:
httpText += 'None'
else:
httpText += '%04d' % (distance2)
if distance3 == 0:
httpText += 'None'
else:
httpText += '%04d' % (distance3)
if distance4 == 0:
httpText += 'None'
else:
httpText += '%04d' % (distance4)
httpText += ''
self.send(httpText)
would I replace the (/distances-once) in the if getPath with my compass file name and then replace the distances in the table with the desired readings?

As such?

if getPath.startswith('/IMU Readings'):
# IMU readings
# Get the readings
reading 1 = int(UB.GetDistance1())
reading2 = int(UB.GetDistance2())
reading 3 = int(UB.GetDistance3())
reading 4 = int(UB.GetDistance4())
# Build a table for the values
httpText = ''
if distance1 == 0:
httpText += 'None'
else:
httpText += '%04d' % (distance1)
if distance2 == 0:
httpText += 'None'
else:
httpText += '%04d' % (distance2)
if distance3 == 0:
httpText += 'None'
else:
httpText += '%04d' % (distance3)
if distance4 == 0:
httpText += 'None'
else:
httpText += '%04d' % (distance4)
httpText += ''
self.send(httpText)

Got a bit lost so I've included the amended compass code.

Hopefully you can understand my ramblings.

John

Attachments: 
Subscribe to Comments for "Adding readings to Web UI"