Activities/Turtle Art/Programmable Brick: Difference between revisions

Tonyforster (talk | contribs)
Tonyforster (talk | contribs)
Line 163: Line 163:


====Device I/O====
====Device I/O====
# 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.
these strings for the string 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/current_now
# /sys/devices/platform/olpc-battery.0/power_supply/olpc-battery/voltage_now
* /sys/devices/platform/olpc-battery.0/power_supply/olpc-battery/voltage_now
# /sys/devices/platform/dcon/backlight/dcon-bl/actual_brightness
* /sys/devices/platform/dcon/backlight/dcon-bl/actual_brightness




  def myblock(tw, x):  # ignores second argument
  def myblock(tw, x):  # ignores second argument
     import os
     import os
 
 
     # The light sensor is only available on the XO 1.75
     # The light sensor is only available on the XO 1.75
     device = '/sys/devices/platform/olpc-ols.0/power_state'
     device = '/sys/devices/platform/olpc-ols.0/power_state'
Line 185: Line 185:
     else:
     else:
         tw.lc.heap.append(-1)
         tw.lc.heap.append(-1)
 
 
# If you can work out how to use them...
If you can work out how to use them...
# accelerometer: /dev/input/event0 ???
* accelerometer: /dev/input/event0 ???
# power button: /dev/input/event1
* power button: /dev/input/event1
# lid switch: /dev/input/event2
* lid switch: /dev/input/event2
# ebook: /dev/input/event3
* ebook: /dev/input/event3
# headphone jack: /dev/input/event7
* headphone jack: /dev/input/event7
# microphone jack: /dev/input/event8
* microphone jack: /dev/input/event8
# rotate, cursor, and game pad keys: /dev/input/event10
* rotate, cursor, and game pad keys: /dev/input/event10


===Understanding the structure of the Turtle Art program===
===Understanding the structure of the Turtle Art program===