Activities/Turtle Art/Programmable Brick: Difference between revisions

Tonyforster (talk | contribs)
Line 165: Line 165:
This Python block returns with the brightness sensor value in the heap.
This Python block returns with the brightness sensor value in the heap.
A range of parameters can be measured, for example, substitute any of
A range of parameters can be measured, for example, substitute any of
these strings for the string in the program below.
the path strings in the table for the 'device' in the program below.


* /sys/devices/platform/olpc-battery.0/power_supply/olpc-battery/current_now
 
* /sys/devices/platform/olpc-battery.0/power_supply/olpc-battery/voltage_now
{| border=1 cellpadding=3 style="border: 1px solid white; border-collapse: collapse; background: #e3e4e5;"
* /sys/devices/platform/dcon/backlight/dcon-bl/actual_brightness
|-style="background:#787878; color: white;"
! device !! path !! notes
|-
| battery current || /sys/devices/platform/olpc-battery.0/power_supply/olpc-battery/current_now || OLPC XO
|-
| battery voltage || /sys/devices/platform/olpc-battery.0/power_supply/olpc-battery/voltage_now || OLPC XO
|-
| screen brightness || /sys/devices/platform/dcon/backlight/dcon-bl/actual_brightness || OLPC XO
|-
| light sensor || /sys/devices/platform/olpc-ols.0/power_state || OLPC XO 1.75
|}




Line 182: Line 192:
         string = fh.read()
         string = fh.read()
         fh.close()
         fh.close()
         tw.lc.heap.append(int(string))  # append as integer value to heap
         tw.lc.heap.append(float(string))  # append as float value to heap
     else:
     else:
         tw.lc.heap.append(-1)
         tw.lc.heap.append(-1)