Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--TurtleArt/taturtle.py18
-rw-r--r--TurtleArtActivity.py119
-rw-r--r--activity/activity-turtleart.svg95
-rw-r--r--activity/activity.info8
-rw-r--r--flags/Abkhazia.pngbin0 -> 1941 bytes
-rw-r--r--flags/Afghanistan.pngbin0 -> 5522 bytes
-rw-r--r--flags/Albania.pngbin0 -> 4683 bytes
-rw-r--r--flags/Algeria.pngbin0 -> 2190 bytes
-rw-r--r--flags/Andorra.pngbin0 -> 4446 bytes
-rw-r--r--flags/Angola.pngbin0 -> 3106 bytes
-rw-r--r--flags/Antigua_and_Barbuda.pngbin0 -> 2906 bytes
-rw-r--r--flags/Argentina.pngbin0 -> 2532 bytes
-rw-r--r--flags/Armenia.pngbin0 -> 394 bytes
-rw-r--r--flags/Australia.pngbin0 -> 3805 bytes
-rw-r--r--flags/Austria.pngbin0 -> 361 bytes
-rw-r--r--flags/Azerbaijan.pngbin0 -> 1690 bytes
-rw-r--r--flags/Bahamas.pngbin0 -> 844 bytes
-rw-r--r--flags/Bahrain.pngbin0 -> 963 bytes
-rw-r--r--flags/Bangladesh.pngbin0 -> 1791 bytes
-rw-r--r--flags/Barbados.pngbin0 -> 1838 bytes
-rw-r--r--flags/Belarus.pngbin0 -> 5759 bytes
-rw-r--r--flags/Belgium.pngbin0 -> 347 bytes
-rw-r--r--flags/Belize.pngbin0 -> 12938 bytes
-rw-r--r--flags/Benin.pngbin0 -> 404 bytes
-rw-r--r--flags/Bhutan.pngbin0 -> 9842 bytes
-rw-r--r--flags/Bolivia.pngbin0 -> 394 bytes
-rw-r--r--flags/Bosnia_and_Herzegovina.pngbin0 -> 1837 bytes
-rw-r--r--flags/Botswana.pngbin0 -> 415 bytes
-rw-r--r--flags/Brazil.pngbin0 -> 5002 bytes
-rw-r--r--flags/Brunei.pngbin0 -> 6511 bytes
-rw-r--r--flags/Bulgaria.pngbin0 -> 369 bytes
-rw-r--r--flags/Burkina_Faso.pngbin0 -> 1129 bytes
-rw-r--r--flags/Burundi.pngbin0 -> 5380 bytes
-rw-r--r--flags/Cambodia.pngbin0 -> 3373 bytes
-rw-r--r--flags/Cameroon.pngbin0 -> 1055 bytes
-rw-r--r--flags/Canada.pngbin0 -> 2272 bytes
-rw-r--r--flags/Cape_Verde.pngbin0 -> 2484 bytes
-rw-r--r--flags/Central_African_Republic.pngbin0 -> 1107 bytes
-rw-r--r--flags/Chad.pngbin0 -> 380 bytes
-rw-r--r--flags/Chile.pngbin0 -> 994 bytes
-rw-r--r--flags/Colombia.pngbin0 -> 381 bytes
-rw-r--r--flags/Comoros.pngbin0 -> 3640 bytes
-rw-r--r--flags/Cook_Islands.pngbin0 -> 6351 bytes
-rw-r--r--flags/Costa_Rica.pngbin0 -> 426 bytes
-rw-r--r--flags/Croatia.pngbin0 -> 3357 bytes
-rw-r--r--flags/Cuba.pngbin0 -> 2618 bytes
-rw-r--r--flags/Cyprus.pngbin0 -> 3250 bytes
-rw-r--r--flags/Czech_Republic.pngbin0 -> 828 bytes
-rw-r--r--flags/Côte_d'Ivoire.pngbin0 -> 349 bytes
-rw-r--r--flags/Democratic_Republic_of_the_Congo.pngbin0 -> 5072 bytes
-rw-r--r--flags/Denmark.pngbin0 -> 448 bytes
-rw-r--r--flags/Djibouti.pngbin0 -> 2348 bytes
-rw-r--r--flags/Dominica.pngbin0 -> 4153 bytes
-rw-r--r--flags/Dominican_Republic.pngbin0 -> 1537 bytes
-rw-r--r--flags/East_Timor.pngbin0 -> 2098 bytes
-rw-r--r--flags/Ecuador.pngbin0 -> 5116 bytes
-rw-r--r--flags/Egypt.pngbin0 -> 2311 bytes
-rw-r--r--flags/El_Salvador.pngbin0 -> 2643 bytes
-rw-r--r--flags/Equatorial_Guinea.pngbin0 -> 2484 bytes
-rw-r--r--flags/Eritrea.pngbin0 -> 5294 bytes
-rw-r--r--flags/Estonia.pngbin0 -> 385 bytes
-rw-r--r--flags/Ethiopia.pngbin0 -> 5066 bytes
-rw-r--r--flags/Federated_States_of_Micronesia.pngbin0 -> 2070 bytes
-rw-r--r--flags/Fiji.pngbin0 -> 6077 bytes
-rw-r--r--flags/Finland.pngbin0 -> 485 bytes
-rw-r--r--flags/France.pngbin0 -> 377 bytes
-rw-r--r--flags/Gabon.pngbin0 -> 363 bytes
-rw-r--r--flags/Gambia.pngbin0 -> 442 bytes
-rw-r--r--flags/Georgia.pngbin0 -> 1831 bytes
-rw-r--r--flags/Germany.pngbin0 -> 393 bytes
-rw-r--r--flags/Ghana.pngbin0 -> 1280 bytes
-rw-r--r--flags/Greece.pngbin0 -> 615 bytes
-rw-r--r--flags/Grenada.pngbin0 -> 5170 bytes
-rw-r--r--flags/Guatemala.pngbin0 -> 3283 bytes
-rw-r--r--flags/Guinea-Bissau.pngbin0 -> 1222 bytes
-rw-r--r--flags/Guinea.pngbin0 -> 400 bytes
-rw-r--r--flags/Guyana.pngbin0 -> 4067 bytes
-rw-r--r--flags/Haiti.pngbin0 -> 2295 bytes
-rw-r--r--flags/Honduras.pngbin0 -> 1675 bytes
-rw-r--r--flags/Hungary.pngbin0 -> 400 bytes
-rw-r--r--flags/Iceland.pngbin0 -> 585 bytes
-rw-r--r--flags/India.pngbin0 -> 2449 bytes
-rw-r--r--flags/Indonesia.pngbin0 -> 342 bytes
-rw-r--r--flags/Iran.pngbin0 -> 4308 bytes
-rw-r--r--flags/Iraq.pngbin0 -> 2026 bytes
-rw-r--r--flags/Ireland.pngbin0 -> 394 bytes
-rw-r--r--flags/Israel.pngbin0 -> 1963 bytes
-rw-r--r--flags/Italy.pngbin0 -> 377 bytes
-rw-r--r--flags/Jamaica.pngbin0 -> 1217 bytes
-rw-r--r--flags/Japan.pngbin0 -> 1767 bytes
-rw-r--r--flags/Jordan.pngbin0 -> 1245 bytes
-rw-r--r--flags/Kazakhstan.pngbin0 -> 7926 bytes
-rw-r--r--flags/Kenya.pngbin0 -> 2650 bytes
-rw-r--r--flags/Kiribati.pngbin0 -> 4205 bytes
-rw-r--r--flags/Kosovo.pngbin0 -> 3549 bytes
-rw-r--r--flags/Kuwait.pngbin0 -> 728 bytes
-rw-r--r--flags/Kyrgyzstan.pngbin0 -> 6718 bytes
-rw-r--r--flags/Laos.pngbin0 -> 1247 bytes
-rw-r--r--flags/Latvia.pngbin0 -> 373 bytes
-rw-r--r--flags/Lebanon.pngbin0 -> 3247 bytes
-rw-r--r--flags/Lesotho.pngbin0 -> 2072 bytes
-rw-r--r--flags/Liberia.pngbin0 -> 1298 bytes
-rw-r--r--flags/Libya.pngbin0 -> 1357 bytes
-rw-r--r--flags/Liechtenstein.pngbin0 -> 2656 bytes
-rw-r--r--flags/Lithuania.pngbin0 -> 410 bytes
-rw-r--r--flags/Luxembourg.pngbin0 -> 404 bytes
-rw-r--r--flags/Macedonia.pngbin0 -> 3976 bytes
-rw-r--r--flags/Madagascar.pngbin0 -> 380 bytes
-rw-r--r--flags/Malawi.pngbin0 -> 3340 bytes
-rw-r--r--flags/Malaysia.pngbin0 -> 3193 bytes
-rw-r--r--flags/Maldives.pngbin0 -> 1267 bytes
-rw-r--r--flags/Mali.pngbin0 -> 401 bytes
-rw-r--r--flags/Malta.pngbin0 -> 1279 bytes
-rw-r--r--flags/Marshall_Islands.pngbin0 -> 7117 bytes
-rw-r--r--flags/Mauritania.pngbin0 -> 2423 bytes
-rw-r--r--flags/Mauritius.pngbin0 -> 388 bytes
-rw-r--r--flags/Mexico.pngbin0 -> 4677 bytes
-rw-r--r--flags/Moldova.pngbin0 -> 5128 bytes
-rw-r--r--flags/Monaco.pngbin0 -> 343 bytes
-rw-r--r--flags/Mongolia.pngbin0 -> 2402 bytes
-rw-r--r--flags/Montenegro.pngbin0 -> 6440 bytes
-rw-r--r--flags/Morocco.pngbin0 -> 1477 bytes
-rw-r--r--flags/Mozambique.pngbin0 -> 3752 bytes
-rw-r--r--flags/Myanmar.pngbin0 -> 2058 bytes
-rw-r--r--flags/Nagorno-Karabakh.pngbin0 -> 791 bytes
-rw-r--r--flags/Namibia.pngbin0 -> 2712 bytes
-rw-r--r--flags/Nauru.pngbin0 -> 1889 bytes
-rw-r--r--flags/Nepal.pngbin0 -> 3868 bytes
-rw-r--r--flags/Netherlands.pngbin0 -> 394 bytes
-rw-r--r--flags/New_Zealand.pngbin0 -> 3425 bytes
-rw-r--r--flags/Nicaragua.pngbin0 -> 2069 bytes
-rw-r--r--flags/Niger.pngbin0 -> 939 bytes
-rw-r--r--flags/Nigeria.pngbin0 -> 392 bytes
-rw-r--r--flags/Niue.pngbin0 -> 2857 bytes
-rw-r--r--flags/North_Korea.pngbin0 -> 2399 bytes
-rw-r--r--flags/Norway.pngbin0 -> 606 bytes
-rw-r--r--flags/Oman.pngbin0 -> 2170 bytes
-rw-r--r--flags/Pakistan.pngbin0 -> 2380 bytes
-rw-r--r--flags/Palau.pngbin0 -> 1765 bytes
-rw-r--r--flags/Palestine.pngbin0 -> 988 bytes
-rw-r--r--flags/Panama.pngbin0 -> 1676 bytes
-rw-r--r--flags/Papua_New_Guinea.pngbin0 -> 4602 bytes
-rw-r--r--flags/Paraguay.pngbin0 -> 2495 bytes
-rw-r--r--flags/People's_Republic_of_China.pngbin0 -> 1728 bytes
-rw-r--r--flags/Peru.pngbin0 -> 379 bytes
-rw-r--r--flags/Philippines.pngbin0 -> 4264 bytes
-rw-r--r--flags/Poland.pngbin0 -> 366 bytes
-rw-r--r--flags/Portugal.pngbin0 -> 4496 bytes
-rw-r--r--flags/Qatar.pngbin0 -> 1609 bytes
-rw-r--r--flags/Republic_of_China.pngbin0 -> 2143 bytes
-rw-r--r--flags/Republic_of_the_Congo.pngbin0 -> 680 bytes
-rw-r--r--flags/Romania.pngbin0 -> 381 bytes
-rw-r--r--flags/Russia.pngbin0 -> 395 bytes
-rw-r--r--flags/Rwanda.pngbin0 -> 2588 bytes
-rw-r--r--flags/Sahrawi_Arab_Democratic_Republic.pngbin0 -> 2062 bytes
-rw-r--r--flags/Saint_Kitts_and_Nevis.pngbin0 -> 1907 bytes
-rw-r--r--flags/Saint_Lucia.pngbin0 -> 2791 bytes
-rw-r--r--flags/Saint_Vincent_and_the_Grenadines.pngbin0 -> 1167 bytes
-rw-r--r--flags/Samoa.pngbin0 -> 1710 bytes
-rw-r--r--flags/San_Marino.pngbin0 -> 6871 bytes
-rw-r--r--flags/Sao_Tome_and_Principe.pngbin0 -> 1465 bytes
-rw-r--r--flags/Saudi_Arabia.pngbin0 -> 6087 bytes
-rw-r--r--flags/Senegal.pngbin0 -> 1122 bytes
-rw-r--r--flags/Serbia.pngbin0 -> 6201 bytes
-rw-r--r--flags/Seychelles.pngbin0 -> 1406 bytes
-rw-r--r--flags/Sierra_Leone.pngbin0 -> 398 bytes
-rw-r--r--flags/Singapore.pngbin0 -> 2199 bytes
-rw-r--r--flags/Slovakia.pngbin0 -> 2536 bytes
-rw-r--r--flags/Slovenia.pngbin0 -> 1947 bytes
-rw-r--r--flags/Solomon_Islands.pngbin0 -> 3018 bytes
-rw-r--r--flags/Somalia.pngbin0 -> 1528 bytes
-rw-r--r--flags/Somaliland.pngbin0 -> 6301 bytes
-rw-r--r--flags/South_Africa.pngbin0 -> 1378 bytes
-rw-r--r--flags/South_Korea.pngbin0 -> 4883 bytes
-rw-r--r--flags/South_Ossetia.pngbin0 -> 381 bytes
-rw-r--r--flags/South_Sudan.pngbin0 -> 2582 bytes
-rw-r--r--flags/Spain.pngbin0 -> 3532 bytes
-rw-r--r--flags/Sri_Lanka.pngbin0 -> 8134 bytes
-rw-r--r--flags/Sudan.pngbin0 -> 1014 bytes
-rw-r--r--flags/Suriname.pngbin0 -> 1263 bytes
-rw-r--r--flags/Swaziland.pngbin0 -> 4747 bytes
-rw-r--r--flags/Sweden.pngbin0 -> 403 bytes
-rw-r--r--flags/Switzerland.pngbin0 -> 482 bytes
-rw-r--r--flags/Syria.pngbin0 -> 904 bytes
-rw-r--r--flags/Tajikistan.pngbin0 -> 2246 bytes
-rw-r--r--flags/Tanzania.pngbin0 -> 989 bytes
-rw-r--r--flags/Thailand.pngbin0 -> 412 bytes
-rw-r--r--flags/Togo.pngbin0 -> 1429 bytes
-rw-r--r--flags/Tonga.pngbin0 -> 605 bytes
-rw-r--r--flags/Transnistria.pngbin0 -> 413 bytes
-rw-r--r--flags/Trinidad_and_Tobago.pngbin0 -> 5611 bytes
-rw-r--r--flags/Tunisia.pngbin0 -> 2518 bytes
-rw-r--r--flags/Turkey.pngbin0 -> 2460 bytes
-rw-r--r--flags/Turkish_Republic_of_Northern_Cyprus.pngbin0 -> 2433 bytes
-rw-r--r--flags/Turkmenistan.pngbin0 -> 8447 bytes
-rw-r--r--flags/Tuvalu.pngbin0 -> 4660 bytes
-rw-r--r--flags/Uganda.pngbin0 -> 2183 bytes
-rw-r--r--flags/Ukraine.pngbin0 -> 368 bytes
-rw-r--r--flags/United_Arab_Emirates.pngbin0 -> 424 bytes
-rw-r--r--flags/United_Kingdom.pngbin0 -> 1558 bytes
-rw-r--r--flags/United_States.pngbin0 -> 5546 bytes
-rw-r--r--flags/Uruguay.pngbin0 -> 3984 bytes
-rw-r--r--flags/Uzbekistan.pngbin0 -> 1955 bytes
-rw-r--r--flags/Vanuatu.pngbin0 -> 4547 bytes
-rw-r--r--flags/Vatican_City.pngbin0 -> 2987 bytes
-rw-r--r--flags/Venezuela.pngbin0 -> 1766 bytes
-rw-r--r--flags/Vietnam.pngbin0 -> 1662 bytes
-rw-r--r--flags/Yemen.pngbin0 -> 389 bytes
-rw-r--r--flags/Zambia.pngbin0 -> 1820 bytes
-rw-r--r--flags/Zimbabwe.pngbin0 -> 3556 bytes
-rw-r--r--plugins/accelerometer/accelerometer.py91
-rw-r--r--plugins/accelerometer/icons/sensoroff.svg79
-rw-r--r--plugins/accelerometer/icons/sensoron.svg63
-rw-r--r--plugins/audio_sensors/audio_sensors.py468
-rw-r--r--plugins/audio_sensors/audiograb.py673
-rw-r--r--plugins/audio_sensors/icons/sensoroff.svg79
-rw-r--r--plugins/audio_sensors/icons/sensoron.svg63
-rw-r--r--plugins/audio_sensors/ringbuffer.py108
-rw-r--r--plugins/camera_sensor/camera_sensor.py308
-rw-r--r--plugins/camera_sensor/icons/sensoroff.svg79
-rw-r--r--plugins/camera_sensor/icons/sensoron.svg63
-rw-r--r--plugins/camera_sensor/images/camera1off.svg66
-rw-r--r--plugins/camera_sensor/images/camera1small.svg68
-rw-r--r--plugins/camera_sensor/images/cameraoff.svg15
-rw-r--r--plugins/camera_sensor/images/camerasmall.svg51
-rw-r--r--plugins/camera_sensor/tacamera.py69
-rw-r--r--plugins/camera_sensor/v4l2.py1914
-rw-r--r--plugins/light_sensor/icons/sensoroff.svg79
-rw-r--r--plugins/light_sensor/icons/sensoron.svg63
-rw-r--r--plugins/light_sensor/light_sensor.py87
-rw-r--r--plugins/rfid/device.py61
-rw-r--r--plugins/rfid/icons/sensoroff.svg79
-rw-r--r--plugins/rfid/icons/sensoron.svg63
-rw-r--r--plugins/rfid/rfid.py151
-rw-r--r--plugins/rfid/rfidrweusb.py200
-rw-r--r--plugins/rfid/rfidutils.py123
-rw-r--r--plugins/rfid/serial/__init__.py25
-rw-r--r--plugins/rfid/serial/serialposix.py492
-rw-r--r--plugins/rfid/serial/serialutil.py400
-rw-r--r--plugins/rfid/tis2000.py252
-rw-r--r--plugins/rfid/utils.py98
-rw-r--r--plugins/turtle_blocks_extras/turtle_blocks_extras.py84
-rw-r--r--samples/sensors-valentine.ta220
-rwxr-xr-xturtleflags.py (renamed from turtleblocks.py)52
245 files changed, 441 insertions, 6588 deletions
diff --git a/NEWS b/NEWS
index 73cbe42..2826a92 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@ ENHANCEMENTS:
* Added pen state boolean
* Added new sensor-record example (generates turtle art program from mouse movements)
+BUG FIX:
+* Fixed problem with load block introduced by turtle-centric rebase
+
184
ENHANCEMENTS:
diff --git a/TurtleArt/taturtle.py b/TurtleArt/taturtle.py
index 12882db..0ca6df6 100644
--- a/TurtleArt/taturtle.py
+++ b/TurtleArt/taturtle.py
@@ -322,7 +322,7 @@ class Turtle:
try:
self._heading = heading
except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
+ debug_output('set_heading: bad value sent to %s' % (__name__),
self._turtles.turtle_window.running_sugar)
return
self._heading %= 360
@@ -356,7 +356,7 @@ class Turtle:
try:
self._pen_color = color
except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
+ debug_output('set_color: bad value sent to %s' % (__name__),
self._turtles.turtle_window.running_sugar)
return
@@ -375,7 +375,7 @@ class Turtle:
try:
self._pen_gray = gray
except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
+ debug_output('set_gray: bad value sent to %s' % (__name__),
self._turtles.turtle_window.running_sugar)
return
@@ -399,7 +399,7 @@ class Turtle:
try:
self._pen_shade = shade
except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
+ debug_output('set_shade: bad value sent to %s' % (__name__),
self._turtles.turtle_window.running_sugar)
return
@@ -418,7 +418,7 @@ class Turtle:
try:
self._pen_size = max(0, pen_size)
except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
+ debug_output('set_pen_size: bad value sent to %s' % (__name__),
self._turtles.turtle_window.running_sugar)
return
@@ -513,7 +513,7 @@ class Turtle:
try:
self._heading += degrees
except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
+ debug_output('right: bad value sent to %s' % (__name__),
self._turtles.turtle_window.running_sugar)
return
self._heading %= 360
@@ -543,7 +543,7 @@ class Turtle:
xcor = old[0] + scaled_distance * sin(self._heading * DEGTOR)
ycor = old[1] + scaled_distance * cos(self._heading * DEGTOR)
except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
+ debug_output('forward: bad value sent to %s' % (__name__),
self._turtles.turtle_window.running_sugar)
return
@@ -562,7 +562,7 @@ class Turtle:
xcor = pos[0] * self._turtles.turtle_window.coord_scale
ycor = pos[1] * self._turtles.turtle_window.coord_scale
except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
+ debug_output('set_xy: bad value sent to %s' % (__name__),
self._turtles.turtle_window.running_sugar)
return
@@ -585,7 +585,7 @@ class Turtle:
else:
pos = self.rarc(a, r)
except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
+ debug_output('arc: bad value sent to %s' % (__name__),
self._turtles.turtle_window.running_sugar)
return
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index c8f9755..9add9bd 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -28,6 +28,7 @@ import gtk
import cairo
import gobject
import dbus
+import glob
import logging
_logger = logging.getLogger('turtleart-activity')
@@ -43,6 +44,10 @@ from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.radiotoolbutton import RadioToolButton
from sugar.graphics.alert import (ConfirmationAlert, NotifyAlert)
from sugar.graphics import style
+from sugar.graphics.combobox import ComboBox
+from sugar.graphics.toolcombobox import ToolComboBox
+from sugar.graphics.objectchooser import ObjectChooser
+from sugar import mime
from sugar.datastore import datastore
from sugar import profile
@@ -87,6 +92,7 @@ class TurtleArtActivity(activity.Activity):
self.tw = None
self.init_complete = False
+ self._stop_help = False
self.palette_buttons = []
self._palette_names = []
@@ -95,6 +101,9 @@ class TurtleArtActivity(activity.Activity):
self._check_ver_change(get_path(activity, 'data'))
self.connect("notify::active", self._notify_active_cb)
+ self._level = 0
+ self._custom_filepath = None
+
self.has_toolbarbox = HAS_TOOLBARBOX
_logger.debug('_setup_toolbar')
self._setup_toolbar()
@@ -132,6 +141,8 @@ class TurtleArtActivity(activity.Activity):
self._do_hover_help_toggle(None)
self.init_complete = True
+ self._load_level()
+
def check_buttons_for_fit(self):
''' Check to see which set of buttons to display '''
if not self.has_toolbarbox:
@@ -300,8 +311,10 @@ class TurtleArtActivity(activity.Activity):
return
if not self.has_toolbarbox:
self.palette_buttons[i].set_icon(palette_names[i] + 'on')
+ '''
else:
self._help_button.set_current_palette(palette_names[i])
+ '''
self.tw.show_palette(n=i)
self.do_showpalette()
@@ -348,8 +361,16 @@ class TurtleArtActivity(activity.Activity):
self.eraser_button.set_icon('eraseroff')
self.recenter()
self.tw.eraser_button()
+ self.restore_challenge()
gobject.timeout_add(250, self.eraser_button.set_icon, 'eraseron')
+ def restore_challenge(self):
+ ''' Restore the current challange after a clear screen '''
+ if self._custom_filepath is None:
+ self._load_level()
+ else:
+ self._load_level(custom=True)
+
def do_run_cb(self, button):
''' Callback for run button (rabbit) '''
self.run_button.set_icon('run-faston')
@@ -371,6 +392,13 @@ class TurtleArtActivity(activity.Activity):
def do_stop_cb(self, button):
''' Callback for stop button. '''
+ if not self._stop_help:
+ self._stop_help = True
+ self.tw.showblocks()
+ self.stop_turtle_button.set_icon('hideshowoff')
+ self.stop_turtle_button.set_tooltip(_('Hide blocks'))
+ return
+
# Auto show blocks after stop
if not self.tw.hide and not self.tw.running_blocks:
self.tw.hideblocks()
@@ -509,6 +537,14 @@ class TurtleArtActivity(activity.Activity):
# Given the change in how overlays are handled (v123), there is no way
# to erase and then redraw the overlays.
+ def _do_help_cb(self, button):
+ if os.path.exists(os.path.join(
+ activity.get_bundle_path(), 'challenges',
+ 'help-' + str(self._level + 1) + '.ta')):
+ self.read_file(os.path.join(
+ activity.get_bundle_path(), 'challenges',
+ 'help-' + str(self._level + 1) + '.ta'))
+
def get_document_path(self, async_cb, async_err_cb):
''' View TA code as part of view source. '''
ta_code_path = self._dump_ta_code()
@@ -606,7 +642,11 @@ class TurtleArtActivity(activity.Activity):
self.palette_toolbar_button = ToolbarButton(
page=self._palette_toolbar, icon_name='palette')
- self._help_button = HelpButton(self)
+ self._help_button = self._add_button('help-toolbar',
+ _('Help'),
+ self._do_help_cb,
+ None)
+ # self._help_button = HelpButton(self)
self._make_load_save_buttons(self.activity_toolbar_button)
@@ -876,6 +916,8 @@ class TurtleArtActivity(activity.Activity):
if self.tw.hw in [XO1, XO15, XO175, XO4]:
self._make_palette_buttons(self._palette_toolbar)
'''
+ self._make_confusion_combo(self._palette_toolbar)
+
self._palette_toolbar.show()
self._overflow_box.show_all()
self._overflow_palette.set_content(self._overflow_sw)
@@ -889,6 +931,9 @@ class TurtleArtActivity(activity.Activity):
self._overflow_box.remove(button)
if self._overflow_palette_button in self._palette_toolbar:
self._palette_toolbar.remove(self._overflow_palette_button)
+ if hasattr(self, '_levels_combo') and \
+ self._levels_tool in self._palette_toolbar:
+ self._palette_toolbar.remove(self._levels_tool)
def _generate_palette_buttons(self, add_buttons=False):
''' Create a radio button and a normal button for each palette '''
@@ -1016,6 +1061,20 @@ class TurtleArtActivity(activity.Activity):
self._palette.popdown(immediate=True)
return
+ def _make_confusion_combo(self, toolbar):
+ if hasattr(self, '_levels_tools'):
+ toolbar.insert(self._levels_tools, -1)
+ else:
+ self._levels = self._get_levels(activity.get_bundle_path())
+ level_names = []
+ for level in self._levels:
+ level_names.append(_(os.path.basename(level)))
+ self._levels_combo, self._levels_tool = \
+ self._combo_factory(level_names,
+ _('Select a challenge'),
+ toolbar,
+ self._levels_cb)
+
def _make_palette_buttons(self, toolbar, palette_button=False):
''' Creates the palette and block buttons for both toolbar types'''
if palette_button: # old-style toolbars need this button
@@ -1534,6 +1593,64 @@ in order to use the plugin.'))
help_strings[name] = tooltip
return button
+ def _combo_factory(self, options, tooltip, toolbar, callback, default=0):
+ ''' Combo box factory '''
+ combo = ComboBox()
+ if hasattr(combo, 'set_tooltip_text'):
+ combo.set_tooltip_text(tooltip)
+ combo.connect('changed', callback)
+ for i, option in enumerate(options):
+ combo.append_item(i, option.replace('-', ' '), None)
+ combo.set_active(default)
+ combo.show()
+ tool = ToolComboBox(combo)
+ tool.show()
+ if hasattr(toolbar, 'insert'):
+ toolbar.insert(tool, -1)
+ else:
+ toolbar.props.page.insert(tool, -1)
+ return combo, tool
+
+ def _get_levels(self, path):
+ ''' Look for level files in lessons directory. '''
+ levels = glob.glob(os.path.join(activity.get_bundle_path(),
+ 'flags', '*.png'))
+
+ level_files = []
+ for level in levels:
+ level_files.append(level[:-4])
+
+ return level_files
+
+ def _levels_cb(self, combobox=None):
+ ''' The combo box has changed. '''
+ if hasattr(self, '_levels_combo'):
+ i = self._levels_combo.get_active()
+ if i != -1: # and i != self._level:
+ self._level = i
+ self._load_level()
+ self._custom_filepath = None
+
+ def _load_level(self, custom=False):
+ self.tw.canvas.clearscreen()
+ if custom:
+ self.tw.turtles.get_active_turtle().set_xy((0, 0), pendown=False)
+ self.tw.lc.insert_image(center=True,
+ filepath=self._custom_filepath,
+ resize=True, offset=False)
+ else:
+ xoffset = 0
+ yoffset = 0
+ self.tw.turtles.get_active_turtle().set_xy((0, 0), pendown=False)
+ self.tw.lc.insert_image(center=False,
+ filepath=os.path.join
+ (activity.get_bundle_path(),
+ 'flags',
+ self._levels[self._level] + '.png'),
+ resize=True,
+ offset=True)
+ self.tw.turtles.get_active_turtle().set_xy((0, 0), pendown=False)
+
def _radio_button_factory(self, button_name, toolbar, cb, arg, tooltip,
group, position=-1):
''' Add a radio button to a toolbar '''
diff --git a/activity/activity-turtleart.svg b/activity/activity-turtleart.svg
index 9c2147f..5a99ac6 100644
--- a/activity/activity-turtleart.svg
+++ b/activity/activity-turtleart.svg
@@ -2,25 +2,80 @@
<!ENTITY stroke_color "#000">
<!ENTITY fill_color "#eee">
]><svg height="55px" viewBox="0 0 55 55" width="55px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.5" stroke="&stroke_color;" fill="&fill_color;">
- <g>
- <path d="M 27.497 48.279 C 26.944 48.279 26.398 48.244 25.86 48.179 L 27.248 50.528 L 28.616 48.215 C 28.245 48.245 27.875 48.279 27.497 48.279 Z " fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/>
- <g>
- <path d="M 40.16 11.726 C 37.996 11.726 36.202 13.281 35.817 15.333 C 37.676 16.678 39.274 18.448 40.492 20.541 C 42.777 20.369 44.586 18.48 44.586 16.151 C 44.586 13.707 42.604 11.726 40.16 11.726 Z " fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/>
- <path d="M 40.713 39.887 C 39.489 42.119 37.853 44.018 35.916 45.443 C 36.437 47.307 38.129 48.682 40.16 48.682 C 42.603 48.682 44.586 46.702 44.586 44.258 C 44.586 42.003 42.893 40.162 40.713 39.887 Z " fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/>
- <path d="M 14.273 39.871 C 12.02 40.077 10.249 41.95 10.249 44.258 C 10.249 46.701 12.229 48.682 14.673 48.682 C 16.737 48.682 18.457 47.262 18.945 45.35 C 17.062 43.934 15.47 42.061 14.273 39.871 Z " fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/>
- <path d="M 19.026 15.437 C 18.683 13.334 16.872 11.726 14.673 11.726 C 12.229 11.726 10.249 13.707 10.249 16.15 C 10.249 18.532 12.135 20.46 14.494 20.556 C 15.68 18.513 17.226 16.772 19.026 15.437 Z " fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/>
+ <path
+ d="m 7.6154267,52.249623 0,-49.2348876"
+ style="fill:none;stroke:&stroke_color;;stroke-width:4.12671185;stroke-linecap:round" />
+ <path
+ d="M 8.8769179,5.1948598 C 24.839408,12.267252 32.592618,11.795759 49.467251,5.6663527 c -4.788747,9.9013483 -4.788747,17.4452323 0,27.3465813 -16.418561,5.893661 -23.031594,5.893661 -40.5903331,0 l 0,-27.8180742 z"
+ id="path2440"
+ style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:2.31858921;stroke-linejoin:round" />
+ <g
+ transform="matrix(0.29395519,0.36988804,-0.36988804,0.29395519,32.356828,4.6563038)"
+ id="g3197"
+ style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round">
+ <g
+ id="g3157">
+ <path
+ d="m 27.497,48.279 c -0.553,0 -1.099,-0.035 -1.637,-0.1 l 1.388,2.349 1.368,-2.313 c -0.371,0.03 -0.741,0.064 -1.119,0.064 z"
+ id="path3159"
+ style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:3.5" />
+ <g
+ id="g3161">
+ <path
+ d="m 40.16,11.726 c -2.164,0 -3.958,1.555 -4.343,3.607 1.859,1.345 3.457,3.115 4.675,5.208 2.285,-0.172 4.094,-2.061 4.094,-4.39 0,-2.444 -1.982,-4.425 -4.426,-4.425 z"
+ id="path3163"
+ style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:3.5" />
+ <path
+ d="m 40.713,39.887 c -1.224,2.232 -2.86,4.131 -4.797,5.556 0.521,1.864 2.213,3.239 4.244,3.239 2.443,0 4.426,-1.98 4.426,-4.424 0,-2.255 -1.693,-4.096 -3.873,-4.371 z"
+ id="path3165"
+ style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:3.5" />
+ <path
+ d="m 14.273,39.871 c -2.253,0.206 -4.024,2.079 -4.024,4.387 0,2.443 1.98,4.424 4.424,4.424 2.064,0 3.784,-1.42 4.272,-3.332 -1.883,-1.416 -3.475,-3.289 -4.672,-5.479 z"
+ id="path3167"
+ style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:3.5" />
+ <path
+ d="m 19.026,15.437 c -0.343,-2.103 -2.154,-3.711 -4.353,-3.711 -2.444,0 -4.424,1.981 -4.424,4.424 0,2.382 1.886,4.31 4.245,4.406 1.186,-2.043 2.732,-3.784 4.532,-5.119 z"
+ id="path3169"
+ style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:3.5" />
+ </g>
+ <path
+ d="m 27.497,12.563 c 1.908,0 3.728,0.411 5.418,1.128 0.741,-1.076 1.178,-2.377 1.178,-3.783 0,-3.687 -2.989,-6.677 -6.677,-6.677 -3.687,0 -6.676,2.99 -6.676,6.677 0,1.428 0.452,2.749 1.216,3.834 1.724,-0.749 3.587,-1.179 5.541,-1.179 z"
+ id="path3171"
+ style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:3.5" />
+ <g
+ id="g3173">
+ <path
+ d="m 43.102,30.421 c 0,4.7344 -1.6452,9.2798 -4.5706,12.6275 -2.9254,3.3478 -6.8973,5.2305 -11.0344,5.2305 -4.1371,0 -8.109,-1.8827 -11.0344,-5.2305 -2.9254,-3.3477 -4.5706,-7.8931 -4.5706,-12.6275 0,-9.7966 7.0444,-17.858 15.605,-17.858 8.5606,0 15.605,8.0614 15.605,17.858 z"
+ id="path3175"
+ style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:3.5" />
+ </g>
+ <g
+ id="g3177">
+ <path
+ d="m 25.875,33.75 -1.542,-4.625 3.164,-2.587 3.615,2.626 -1.487,4.669 z"
+ id="path3179"
+ style="fill:&stroke_color;;stroke:none" />
+ <path
+ d="m 27.501,41.551 c -3.968,-0.16 -5.543,-2.009 -5.543,-2.009 l 3.57,-4.163 4.465,0.168 3.132,4.12 c 0,0 -2.89,1.994 -5.624,1.884 z"
+ id="path3181"
+ style="fill:&stroke_color;;stroke:none" />
+ <path
+ d="m 18.453,33.843 c -0.849,-2.968 0.172,-6.884 0.172,-6.884 l 4,2.167 1.493,4.629 -3.582,4.233 c 0,-10e-4 -1.465,-1.99 -2.083,-4.145 z"
+ id="path3183"
+ style="fill:&stroke_color;;stroke:none" />
+ <path
+ d="m 19.458,25.125 c 0,0 0.5,-1.958 3.039,-3.822 2.237,-1.643 4.465,-1.72 4.465,-1.72 l -0.037,4.981 -3.521,2.75 -3.946,-2.189 z"
+ id="path3185"
+ style="fill:&stroke_color;;stroke:none" />
+ <path
+ d="M 32.084,27.834 28.625,24.959 29,19.75 c 0,0 1.834,-0.042 3.959,1.667 2.228,1.791 3.362,4.983 3.362,4.983 l -4.237,1.434 z"
+ id="path3187"
+ style="fill:&stroke_color;;stroke:none" />
+ <path
+ d="m 31.292,34.042 1.313,-4.464 4.187,-1.536 c 0,0 0.677,2.663 -0.042,5.667 -0.54,2.256 -2.084,4.361 -2.084,4.361 l -3.374,-4.028 z"
+ id="path3189"
+ style="fill:&stroke_color;;stroke:none" />
+ </g>
+ </g>
</g>
- <path d="M 27.497 12.563 C 29.405 12.563 31.225 12.974 32.915 13.691 C 33.656 12.615 34.093 11.314 34.093 9.908 C 34.093 6.221 31.104 3.231 27.416 3.231 C 23.729 3.231 20.74 6.221 20.74 9.908 C 20.74 11.336 21.192 12.657 21.956 13.742 C 23.68 12.993 25.543 12.563 27.497 12.563 Z " fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/>
- <g>
- <path d="M 43.102 30.421 C 43.102 35.1554 41.4568 39.7008 38.5314 43.0485 C 35.606 46.3963 31.6341 48.279 27.497 48.279 C 23.3599 48.279 19.388 46.3963 16.4626 43.0485 C 13.5372 39.7008 11.892 35.1554 11.892 30.421 C 11.892 20.6244 18.9364 12.563 27.497 12.563 C 36.0576 12.563 43.102 20.6244 43.102 30.421 Z " fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/>
- </g>
- <g>
- <path d="M 25.875 33.75 L 24.333 29.125 L 27.497 26.538 L 31.112 29.164 L 29.625 33.833 Z " fill="&stroke_color;" stroke="none" stroke-width="3.5"/>
- <path d="M 27.501 41.551 C 23.533 41.391 21.958 39.542 21.958 39.542 L 25.528 35.379 L 29.993 35.547 L 33.125 39.667 C 33.125 39.667 30.235 41.661 27.501 41.551 Z " fill="&stroke_color;" stroke="none" />
- <path d="M 18.453 33.843 C 17.604 30.875 18.625 26.959 18.625 26.959 L 22.625 29.126 L 24.118 33.755 L 20.536 37.988 C 20.536 37.987 19.071 35.998 18.453 33.843 Z " fill="&stroke_color;" stroke="none" />
- <path d="M 19.458 25.125 C 19.458 25.125 19.958 23.167 22.497 21.303 C 24.734 19.66 26.962 19.583 26.962 19.583 L 26.925 24.564 L 23.404 27.314 L 19.458 25.125 Z " fill="&stroke_color;" stroke="none" />
- <path d="M 32.084 27.834 L 28.625 24.959 L 29 19.75 C 29 19.75 30.834 19.708 32.959 21.417 C 35.187 23.208 36.321 26.4 36.321 26.4 L 32.084 27.834 Z " fill="&stroke_color;" stroke="none" />
- <path d="M 31.292 34.042 L 32.605 29.578 L 36.792 28.042 C 36.792 28.042 37.469 30.705 36.75 33.709 C 36.21 35.965 34.666 38.07 34.666 38.07 L 31.292 34.042 Z " fill="&stroke_color;" stroke="none" />
- </g>
- </g>
</svg>
diff --git a/activity/activity.info b/activity/activity.info
index 503a5b5..77b99f7 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -1,11 +1,11 @@
[Activity]
-name = TurtleBlocks
-activity_version = 184
+name = TurtleFlags
+activity_version = 185
license = MIT
-bundle_id = org.laptop.TurtleArtActivity
+bundle_id = org.laptop.TurtleFlags
exec = sugar-activity TurtleArtActivity.TurtleArtActivity
icon = activity-turtleart
show_launcher = yes
website = http://wiki.sugarlabs.org/go/Activities/Turtle_Art
mime_types = application/x-turtle-art;application/vnd.turtleblocks
-summary = A Logo-inspired turtle that draws colorful pictures with snap-together visual programming blocks
+summary = Use the turtle to draw country flags
diff --git a/flags/Abkhazia.png b/flags/Abkhazia.png
new file mode 100644
index 0000000..330792d
--- /dev/null
+++ b/flags/Abkhazia.png
Binary files differ
diff --git a/flags/Afghanistan.png b/flags/Afghanistan.png
new file mode 100644
index 0000000..ef46370
--- /dev/null
+++ b/flags/Afghanistan.png
Binary files differ
diff --git a/flags/Albania.png b/flags/Albania.png
new file mode 100644
index 0000000..b9d0251
--- /dev/null
+++ b/flags/Albania.png
Binary files differ
diff --git a/flags/Algeria.png b/flags/Algeria.png
new file mode 100644
index 0000000..556e47d
--- /dev/null
+++ b/flags/Algeria.png
Binary files differ
diff --git a/flags/Andorra.png b/flags/Andorra.png
new file mode 100644
index 0000000..337dbc2
--- /dev/null
+++ b/flags/Andorra.png
Binary files differ
diff --git a/flags/Angola.png b/flags/Angola.png
new file mode 100644
index 0000000..0bc80fa
--- /dev/null
+++ b/flags/Angola.png
Binary files differ
diff --git a/flags/Antigua_and_Barbuda.png b/flags/Antigua_and_Barbuda.png
new file mode 100644
index 0000000..56852a0
--- /dev/null
+++ b/flags/Antigua_and_Barbuda.png
Binary files differ
diff --git a/flags/Argentina.png b/flags/Argentina.png
new file mode 100644
index 0000000..9226a0d
--- /dev/null
+++ b/flags/Argentina.png
Binary files differ
diff --git a/flags/Armenia.png b/flags/Armenia.png
new file mode 100644
index 0000000..c954104
--- /dev/null
+++ b/flags/Armenia.png
Binary files differ
diff --git a/flags/Australia.png b/flags/Australia.png
new file mode 100644
index 0000000..4d97b2a
--- /dev/null
+++ b/flags/Australia.png
Binary files differ
diff --git a/flags/Austria.png b/flags/Austria.png
new file mode 100644
index 0000000..8a5d562
--- /dev/null
+++ b/flags/Austria.png
Binary files differ
diff --git a/flags/Azerbaijan.png b/flags/Azerbaijan.png
new file mode 100644
index 0000000..4b6ae60
--- /dev/null
+++ b/flags/Azerbaijan.png
Binary files differ
diff --git a/flags/Bahamas.png b/flags/Bahamas.png
new file mode 100644
index 0000000..a6f77a0
--- /dev/null
+++ b/flags/Bahamas.png
Binary files differ
diff --git a/flags/Bahrain.png b/flags/Bahrain.png
new file mode 100644
index 0000000..7f5e870
--- /dev/null
+++ b/flags/Bahrain.png
Binary files differ
diff --git a/flags/Bangladesh.png b/flags/Bangladesh.png
new file mode 100644
index 0000000..b08ae80
--- /dev/null
+++ b/flags/Bangladesh.png
Binary files differ
diff --git a/flags/Barbados.png b/flags/Barbados.png
new file mode 100644
index 0000000..ea08f68
--- /dev/null
+++ b/flags/Barbados.png
Binary files differ
diff --git a/flags/Belarus.png b/flags/Belarus.png
new file mode 100644
index 0000000..9092bf0
--- /dev/null
+++ b/flags/Belarus.png
Binary files differ
diff --git a/flags/Belgium.png b/flags/Belgium.png
new file mode 100644
index 0000000..bce69c3
--- /dev/null
+++ b/flags/Belgium.png
Binary files differ
diff --git a/flags/Belize.png b/flags/Belize.png
new file mode 100644
index 0000000..cdc7ac5
--- /dev/null
+++ b/flags/Belize.png
Binary files differ
diff --git a/flags/Benin.png b/flags/Benin.png
new file mode 100644
index 0000000..5ab3bb6
--- /dev/null
+++ b/flags/Benin.png
Binary files differ
diff --git a/flags/Bhutan.png b/flags/Bhutan.png
new file mode 100644
index 0000000..18c24b8
--- /dev/null
+++ b/flags/Bhutan.png
Binary files differ
diff --git a/flags/Bolivia.png b/flags/Bolivia.png
new file mode 100644
index 0000000..681ac9f
--- /dev/null
+++ b/flags/Bolivia.png
Binary files differ
diff --git a/flags/Bosnia_and_Herzegovina.png b/flags/Bosnia_and_Herzegovina.png
new file mode 100644
index 0000000..faa840f
--- /dev/null
+++ b/flags/Bosnia_and_Herzegovina.png
Binary files differ
diff --git a/flags/Botswana.png b/flags/Botswana.png
new file mode 100644
index 0000000..8605af9
--- /dev/null
+++ b/flags/Botswana.png
Binary files differ
diff --git a/flags/Brazil.png b/flags/Brazil.png
new file mode 100644
index 0000000..95cace4
--- /dev/null
+++ b/flags/Brazil.png
Binary files differ
diff --git a/flags/Brunei.png b/flags/Brunei.png
new file mode 100644
index 0000000..6a7c96a
--- /dev/null
+++ b/flags/Brunei.png
Binary files differ
diff --git a/flags/Bulgaria.png b/flags/Bulgaria.png
new file mode 100644
index 0000000..c533850
--- /dev/null
+++ b/flags/Bulgaria.png
Binary files differ
diff --git a/flags/Burkina_Faso.png b/flags/Burkina_Faso.png
new file mode 100644
index 0000000..bf8fb3a
--- /dev/null
+++ b/flags/Burkina_Faso.png
Binary files differ
diff --git a/flags/Burundi.png b/flags/Burundi.png
new file mode 100644
index 0000000..32b7441
--- /dev/null
+++ b/flags/Burundi.png
Binary files differ
diff --git a/flags/Cambodia.png b/flags/Cambodia.png
new file mode 100644
index 0000000..bca3cad
--- /dev/null
+++ b/flags/Cambodia.png
Binary files differ
diff --git a/flags/Cameroon.png b/flags/Cameroon.png
new file mode 100644
index 0000000..acda3d6
--- /dev/null
+++ b/flags/Cameroon.png
Binary files differ
diff --git a/flags/Canada.png b/flags/Canada.png
new file mode 100644
index 0000000..6e3f34d
--- /dev/null
+++ b/flags/Canada.png
Binary files differ
diff --git a/flags/Cape_Verde.png b/flags/Cape_Verde.png
new file mode 100644
index 0000000..1dabdd6
--- /dev/null
+++ b/flags/Cape_Verde.png
Binary files differ
diff --git a/flags/Central_African_Republic.png b/flags/Central_African_Republic.png
new file mode 100644
index 0000000..183df1f
--- /dev/null
+++ b/flags/Central_African_Republic.png
Binary files differ
diff --git a/flags/Chad.png b/flags/Chad.png
new file mode 100644
index 0000000..41e3f4b
--- /dev/null
+++ b/flags/Chad.png
Binary files differ
diff --git a/flags/Chile.png b/flags/Chile.png
new file mode 100644
index 0000000..bc88017
--- /dev/null
+++ b/flags/Chile.png
Binary files differ
diff --git a/flags/Colombia.png b/flags/Colombia.png
new file mode 100644
index 0000000..e5adb61
--- /dev/null
+++ b/flags/Colombia.png
Binary files differ
diff --git a/flags/Comoros.png b/flags/Comoros.png
new file mode 100644
index 0000000..dc47d07
--- /dev/null
+++ b/flags/Comoros.png
Binary files differ
diff --git a/flags/Cook_Islands.png b/flags/Cook_Islands.png
new file mode 100644
index 0000000..c0c0567
--- /dev/null
+++ b/flags/Cook_Islands.png
Binary files differ
diff --git a/flags/Costa_Rica.png b/flags/Costa_Rica.png
new file mode 100644
index 0000000..547c46e
--- /dev/null
+++ b/flags/Costa_Rica.png
Binary files differ
diff --git a/flags/Croatia.png b/flags/Croatia.png
new file mode 100644
index 0000000..6b0ae99
--- /dev/null
+++ b/flags/Croatia.png
Binary files differ
diff --git a/flags/Cuba.png b/flags/Cuba.png
new file mode 100644
index 0000000..f832074
--- /dev/null
+++ b/flags/Cuba.png
Binary files differ
diff --git a/flags/Cyprus.png b/flags/Cyprus.png
new file mode 100644
index 0000000..f49a3f6
--- /dev/null
+++ b/flags/Cyprus.png
Binary files differ
diff --git a/flags/Czech_Republic.png b/flags/Czech_Republic.png
new file mode 100644
index 0000000..b248ae9
--- /dev/null
+++ b/flags/Czech_Republic.png
Binary files differ
diff --git a/flags/Côte_d'Ivoire.png b/flags/Côte_d'Ivoire.png
new file mode 100644
index 0000000..d57a928
--- /dev/null
+++ b/flags/Côte_d'Ivoire.png
Binary files differ
diff --git a/flags/Democratic_Republic_of_the_Congo.png b/flags/Democratic_Republic_of_the_Congo.png
new file mode 100644
index 0000000..39b6597
--- /dev/null
+++ b/flags/Democratic_Republic_of_the_Congo.png
Binary files differ
diff --git a/flags/Denmark.png b/flags/Denmark.png
new file mode 100644
index 0000000..76c34ac
--- /dev/null
+++ b/flags/Denmark.png
Binary files differ
diff --git a/flags/Djibouti.png b/flags/Djibouti.png
new file mode 100644
index 0000000..879d83c
--- /dev/null
+++ b/flags/Djibouti.png
Binary files differ
diff --git a/flags/Dominica.png b/flags/Dominica.png
new file mode 100644
index 0000000..cec98f8
--- /dev/null
+++ b/flags/Dominica.png
Binary files differ
diff --git a/flags/Dominican_Republic.png b/flags/Dominican_Republic.png
new file mode 100644
index 0000000..a1d4225
--- /dev/null
+++ b/flags/Dominican_Republic.png
Binary files differ
diff --git a/flags/East_Timor.png b/flags/East_Timor.png
new file mode 100644
index 0000000..aba1e40
--- /dev/null
+++ b/flags/East_Timor.png
Binary files differ
diff --git a/flags/Ecuador.png b/flags/Ecuador.png
new file mode 100644
index 0000000..ad405dd
--- /dev/null
+++ b/flags/Ecuador.png
Binary files differ
diff --git a/flags/Egypt.png b/flags/Egypt.png
new file mode 100644
index 0000000..64a8844
--- /dev/null
+++ b/flags/Egypt.png
Binary files differ
diff --git a/flags/El_Salvador.png b/flags/El_Salvador.png
new file mode 100644
index 0000000..22a480d
--- /dev/null
+++ b/flags/El_Salvador.png
Binary files differ
diff --git a/flags/Equatorial_Guinea.png b/flags/Equatorial_Guinea.png
new file mode 100644
index 0000000..3b85669
--- /dev/null
+++ b/flags/Equatorial_Guinea.png
Binary files differ
diff --git a/flags/Eritrea.png b/flags/Eritrea.png
new file mode 100644
index 0000000..4ff1954
--- /dev/null
+++ b/flags/Eritrea.png
Binary files differ
diff --git a/flags/Estonia.png b/flags/Estonia.png
new file mode 100644
index 0000000..0e41fdc
--- /dev/null
+++ b/flags/Estonia.png
Binary files differ
diff --git a/flags/Ethiopia.png b/flags/Ethiopia.png
new file mode 100644
index 0000000..d0fc714
--- /dev/null
+++ b/flags/Ethiopia.png
Binary files differ
diff --git a/flags/Federated_States_of_Micronesia.png b/flags/Federated_States_of_Micronesia.png
new file mode 100644
index 0000000..9477419
--- /dev/null
+++ b/flags/Federated_States_of_Micronesia.png
Binary files differ
diff --git a/flags/Fiji.png b/flags/Fiji.png
new file mode 100644
index 0000000..3b7d02f
--- /dev/null
+++ b/flags/Fiji.png
Binary files differ
diff --git a/flags/Finland.png b/flags/Finland.png
new file mode 100644
index 0000000..71fc4e0
--- /dev/null
+++ b/flags/Finland.png
Binary files differ
diff --git a/flags/France.png b/flags/France.png
new file mode 100644
index 0000000..e8c83f5
--- /dev/null
+++ b/flags/France.png
Binary files differ
diff --git a/flags/Gabon.png b/flags/Gabon.png
new file mode 100644
index 0000000..2fd5f5d
--- /dev/null
+++ b/flags/Gabon.png
Binary files differ
diff --git a/flags/Gambia.png b/flags/Gambia.png
new file mode 100644
index 0000000..64f4fe1
--- /dev/null
+++ b/flags/Gambia.png
Binary files differ
diff --git a/flags/Georgia.png b/flags/Georgia.png
new file mode 100644
index 0000000..acd3b3f
--- /dev/null
+++ b/flags/Georgia.png
Binary files differ
diff --git a/flags/Germany.png b/flags/Germany.png
new file mode 100644
index 0000000..e4112c9
--- /dev/null
+++ b/flags/Germany.png
Binary files differ
diff --git a/flags/Ghana.png b/flags/Ghana.png
new file mode 100644
index 0000000..8e9d77e
--- /dev/null
+++ b/flags/Ghana.png
Binary files differ
diff --git a/flags/Greece.png b/flags/Greece.png
new file mode 100644
index 0000000..c8dd2d1
--- /dev/null
+++ b/flags/Greece.png
Binary files differ
diff --git a/flags/Grenada.png b/flags/Grenada.png
new file mode 100644
index 0000000..4d26cec
--- /dev/null
+++ b/flags/Grenada.png
Binary files differ
diff --git a/flags/Guatemala.png b/flags/Guatemala.png
new file mode 100644
index 0000000..107a371
--- /dev/null
+++ b/flags/Guatemala.png
Binary files differ
diff --git a/flags/Guinea-Bissau.png b/flags/Guinea-Bissau.png
new file mode 100644
index 0000000..4b2e621
--- /dev/null
+++ b/flags/Guinea-Bissau.png
Binary files differ
diff --git a/flags/Guinea.png b/flags/Guinea.png
new file mode 100644
index 0000000..b0e836b
--- /dev/null
+++ b/flags/Guinea.png
Binary files differ
diff --git a/flags/Guyana.png b/flags/Guyana.png
new file mode 100644
index 0000000..b9d4fa3
--- /dev/null
+++ b/flags/Guyana.png
Binary files differ
diff --git a/flags/Haiti.png b/flags/Haiti.png
new file mode 100644
index 0000000..3e9c24c
--- /dev/null
+++ b/flags/Haiti.png
Binary files differ
diff --git a/flags/Honduras.png b/flags/Honduras.png
new file mode 100644
index 0000000..5b92421
--- /dev/null
+++ b/flags/Honduras.png
Binary files differ
diff --git a/flags/Hungary.png b/flags/Hungary.png
new file mode 100644
index 0000000..74a641d
--- /dev/null
+++ b/flags/Hungary.png
Binary files differ
diff --git a/flags/Iceland.png b/flags/Iceland.png
new file mode 100644
index 0000000..ad1d6ad
--- /dev/null
+++ b/flags/Iceland.png
Binary files differ
diff --git a/flags/India.png b/flags/India.png
new file mode 100644
index 0000000..cae78b8
--- /dev/null
+++ b/flags/India.png
Binary files differ
diff --git a/flags/Indonesia.png b/flags/Indonesia.png
new file mode 100644
index 0000000..8ba3eb9
--- /dev/null
+++ b/flags/Indonesia.png
Binary files differ
diff --git a/flags/Iran.png b/flags/Iran.png
new file mode 100644
index 0000000..ac0b5ac
--- /dev/null
+++ b/flags/Iran.png
Binary files differ
diff --git a/flags/Iraq.png b/flags/Iraq.png
new file mode 100644
index 0000000..78068c8
--- /dev/null
+++ b/flags/Iraq.png
Binary files differ
diff --git a/flags/Ireland.png b/flags/Ireland.png
new file mode 100644
index 0000000..babba27
--- /dev/null
+++ b/flags/Ireland.png
Binary files differ
diff --git a/flags/Israel.png b/flags/Israel.png
new file mode 100644
index 0000000..32f54b7
--- /dev/null
+++ b/flags/Israel.png
Binary files differ
diff --git a/flags/Italy.png b/flags/Italy.png
new file mode 100644
index 0000000..e3ddf00
--- /dev/null
+++ b/flags/Italy.png
Binary files differ
diff --git a/flags/Jamaica.png b/flags/Jamaica.png
new file mode 100644
index 0000000..9114e79
--- /dev/null
+++ b/flags/Jamaica.png
Binary files differ
diff --git a/flags/Japan.png b/flags/Japan.png
new file mode 100644
index 0000000..90fe80e
--- /dev/null
+++ b/flags/Japan.png
Binary files differ
diff --git a/flags/Jordan.png b/flags/Jordan.png
new file mode 100644
index 0000000..fc32e4b
--- /dev/null
+++ b/flags/Jordan.png
Binary files differ
diff --git a/flags/Kazakhstan.png b/flags/Kazakhstan.png
new file mode 100644
index 0000000..66fb583
--- /dev/null
+++ b/flags/Kazakhstan.png
Binary files differ
diff --git a/flags/Kenya.png b/flags/Kenya.png
new file mode 100644
index 0000000..38833a0
--- /dev/null
+++ b/flags/Kenya.png
Binary files differ
diff --git a/flags/Kiribati.png b/flags/Kiribati.png
new file mode 100644
index 0000000..95e6c21
--- /dev/null
+++ b/flags/Kiribati.png
Binary files differ
diff --git a/flags/Kosovo.png b/flags/Kosovo.png
new file mode 100644
index 0000000..8021182
--- /dev/null
+++ b/flags/Kosovo.png
Binary files differ
diff --git a/flags/Kuwait.png b/flags/Kuwait.png
new file mode 100644
index 0000000..11fa31d
--- /dev/null
+++ b/flags/Kuwait.png
Binary files differ
diff --git a/flags/Kyrgyzstan.png b/flags/Kyrgyzstan.png
new file mode 100644
index 0000000..28229be
--- /dev/null
+++ b/flags/Kyrgyzstan.png
Binary files differ
diff --git a/flags/Laos.png b/flags/Laos.png
new file mode 100644
index 0000000..5c9e0fd
--- /dev/null
+++ b/flags/Laos.png
Binary files differ
diff --git a/flags/Latvia.png b/flags/Latvia.png
new file mode 100644
index 0000000..859191c
--- /dev/null
+++ b/flags/Latvia.png
Binary files differ
diff --git a/flags/Lebanon.png b/flags/Lebanon.png
new file mode 100644
index 0000000..d8caedf
--- /dev/null
+++ b/flags/Lebanon.png
Binary files differ
diff --git a/flags/Lesotho.png b/flags/Lesotho.png
new file mode 100644
index 0000000..4d5b398
--- /dev/null
+++ b/flags/Lesotho.png
Binary files differ
diff --git a/flags/Liberia.png b/flags/Liberia.png
new file mode 100644
index 0000000..2bdf99e
--- /dev/null
+++ b/flags/Liberia.png
Binary files differ
diff --git a/flags/Libya.png b/flags/Libya.png
new file mode 100644
index 0000000..0c4287a
--- /dev/null
+++ b/flags/Libya.png
Binary files differ
diff --git a/flags/Liechtenstein.png b/flags/Liechtenstein.png
new file mode 100644
index 0000000..b0c5461
--- /dev/null
+++ b/flags/Liechtenstein.png
Binary files differ
diff --git a/flags/Lithuania.png b/flags/Lithuania.png
new file mode 100644
index 0000000..aed7aab
--- /dev/null
+++ b/flags/Lithuania.png
Binary files differ
diff --git a/flags/Luxembourg.png b/flags/Luxembourg.png
new file mode 100644
index 0000000..68a7c47
--- /dev/null
+++ b/flags/Luxembourg.png
Binary files differ
diff --git a/flags/Macedonia.png b/flags/Macedonia.png
new file mode 100644
index 0000000..bc39dc1
--- /dev/null
+++ b/flags/Macedonia.png
Binary files differ
diff --git a/flags/Madagascar.png b/flags/Madagascar.png
new file mode 100644
index 0000000..1fd41b4
--- /dev/null
+++ b/flags/Madagascar.png
Binary files differ
diff --git a/flags/Malawi.png b/flags/Malawi.png
new file mode 100644
index 0000000..1974b78
--- /dev/null
+++ b/flags/Malawi.png
Binary files differ
diff --git a/flags/Malaysia.png b/flags/Malaysia.png
new file mode 100644
index 0000000..04fce2a
--- /dev/null
+++ b/flags/Malaysia.png
Binary files differ
diff --git a/flags/Maldives.png b/flags/Maldives.png
new file mode 100644
index 0000000..459cd0d
--- /dev/null
+++ b/flags/Maldives.png
Binary files differ
diff --git a/flags/Mali.png b/flags/Mali.png
new file mode 100644
index 0000000..c856816
--- /dev/null
+++ b/flags/Mali.png
Binary files differ
diff --git a/flags/Malta.png b/flags/Malta.png
new file mode 100644
index 0000000..5ce1a07
--- /dev/null
+++ b/flags/Malta.png
Binary files differ
diff --git a/flags/Marshall_Islands.png b/flags/Marshall_Islands.png
new file mode 100644
index 0000000..b22990f
--- /dev/null
+++ b/flags/Marshall_Islands.png
Binary files differ
diff --git a/flags/Mauritania.png b/flags/Mauritania.png
new file mode 100644
index 0000000..36d160b
--- /dev/null
+++ b/flags/Mauritania.png
Binary files differ
diff --git a/flags/Mauritius.png b/flags/Mauritius.png
new file mode 100644
index 0000000..be8e271
--- /dev/null
+++ b/flags/Mauritius.png
Binary files differ
diff --git a/flags/Mexico.png b/flags/Mexico.png
new file mode 100644
index 0000000..c29f735
--- /dev/null
+++ b/flags/Mexico.png
Binary files differ
diff --git a/flags/Moldova.png b/flags/Moldova.png
new file mode 100644
index 0000000..db16eb5
--- /dev/null
+++ b/flags/Moldova.png
Binary files differ
diff --git a/flags/Monaco.png b/flags/Monaco.png
new file mode 100644
index 0000000..f684ff1
--- /dev/null
+++ b/flags/Monaco.png
Binary files differ
diff --git a/flags/Mongolia.png b/flags/Mongolia.png
new file mode 100644
index 0000000..0a4a5d1
--- /dev/null
+++ b/flags/Mongolia.png
Binary files differ
diff --git a/flags/Montenegro.png b/flags/Montenegro.png
new file mode 100644
index 0000000..d135925
--- /dev/null
+++ b/flags/Montenegro.png
Binary files differ
diff --git a/flags/Morocco.png b/flags/Morocco.png
new file mode 100644
index 0000000..911a66f
--- /dev/null
+++ b/flags/Morocco.png
Binary files differ
diff --git a/flags/Mozambique.png b/flags/Mozambique.png
new file mode 100644
index 0000000..f1d0d75
--- /dev/null
+++ b/flags/Mozambique.png
Binary files differ
diff --git a/flags/Myanmar.png b/flags/Myanmar.png
new file mode 100644
index 0000000..53b9303
--- /dev/null
+++ b/flags/Myanmar.png
Binary files differ
diff --git a/flags/Nagorno-Karabakh.png b/flags/Nagorno-Karabakh.png
new file mode 100644
index 0000000..9aae6b1
--- /dev/null
+++ b/flags/Nagorno-Karabakh.png
Binary files differ
diff --git a/flags/Namibia.png b/flags/Namibia.png
new file mode 100644
index 0000000..9c225c5
--- /dev/null
+++ b/flags/Namibia.png
Binary files differ
diff --git a/flags/Nauru.png b/flags/Nauru.png
new file mode 100644
index 0000000..b9fca38
--- /dev/null
+++ b/flags/Nauru.png
Binary files differ
diff --git a/flags/Nepal.png b/flags/Nepal.png
new file mode 100644
index 0000000..a383de2
--- /dev/null
+++ b/flags/Nepal.png
Binary files differ
diff --git a/flags/Netherlands.png b/flags/Netherlands.png
new file mode 100644
index 0000000..c3f5426
--- /dev/null
+++ b/flags/Netherlands.png
Binary files differ
diff --git a/flags/New_Zealand.png b/flags/New_Zealand.png
new file mode 100644
index 0000000..76d1a84
--- /dev/null
+++ b/flags/New_Zealand.png
Binary files differ
diff --git a/flags/Nicaragua.png b/flags/Nicaragua.png
new file mode 100644
index 0000000..d4a254c
--- /dev/null
+++ b/flags/Nicaragua.png
Binary files differ
diff --git a/flags/Niger.png b/flags/Niger.png
new file mode 100644
index 0000000..2f4740c
--- /dev/null
+++ b/flags/Niger.png
Binary files differ
diff --git a/flags/Nigeria.png b/flags/Nigeria.png
new file mode 100644
index 0000000..1ee9ed4
--- /dev/null
+++ b/flags/Nigeria.png
Binary files differ
diff --git a/flags/Niue.png b/flags/Niue.png
new file mode 100644
index 0000000..1114724
--- /dev/null
+++ b/flags/Niue.png
Binary files differ
diff --git a/flags/North_Korea.png b/flags/North_Korea.png
new file mode 100644
index 0000000..1fe6b9c
--- /dev/null
+++ b/flags/North_Korea.png
Binary files differ
diff --git a/flags/Norway.png b/flags/Norway.png
new file mode 100644
index 0000000..0915a21
--- /dev/null
+++ b/flags/Norway.png
Binary files differ
diff --git a/flags/Oman.png b/flags/Oman.png
new file mode 100644
index 0000000..cf1d253
--- /dev/null
+++ b/flags/Oman.png
Binary files differ
diff --git a/flags/Pakistan.png b/flags/Pakistan.png
new file mode 100644
index 0000000..cd7ed89
--- /dev/null
+++ b/flags/Pakistan.png
Binary files differ
diff --git a/flags/Palau.png b/flags/Palau.png
new file mode 100644
index 0000000..fbd7791
--- /dev/null
+++ b/flags/Palau.png
Binary files differ
diff --git a/flags/Palestine.png b/flags/Palestine.png
new file mode 100644
index 0000000..e5e7b0f
--- /dev/null
+++ b/flags/Palestine.png
Binary files differ
diff --git a/flags/Panama.png b/flags/Panama.png
new file mode 100644
index 0000000..3427141
--- /dev/null
+++ b/flags/Panama.png
Binary files differ
diff --git a/flags/Papua_New_Guinea.png b/flags/Papua_New_Guinea.png
new file mode 100644
index 0000000..968bea1
--- /dev/null
+++ b/flags/Papua_New_Guinea.png
Binary files differ
diff --git a/flags/Paraguay.png b/flags/Paraguay.png
new file mode 100644
index 0000000..b998624
--- /dev/null
+++ b/flags/Paraguay.png
Binary files differ
diff --git a/flags/People's_Republic_of_China.png b/flags/People's_Republic_of_China.png
new file mode 100644
index 0000000..9893c3d
--- /dev/null
+++ b/flags/People's_Republic_of_China.png
Binary files differ
diff --git a/flags/Peru.png b/flags/Peru.png
new file mode 100644
index 0000000..17f6155
--- /dev/null
+++ b/flags/Peru.png
Binary files differ
diff --git a/flags/Philippines.png b/flags/Philippines.png
new file mode 100644
index 0000000..0f82ee7
--- /dev/null
+++ b/flags/Philippines.png
Binary files differ
diff --git a/flags/Poland.png b/flags/Poland.png
new file mode 100644
index 0000000..eb867c4
--- /dev/null
+++ b/flags/Poland.png
Binary files differ
diff --git a/flags/Portugal.png b/flags/Portugal.png
new file mode 100644
index 0000000..a2e645b
--- /dev/null
+++ b/flags/Portugal.png
Binary files differ
diff --git a/flags/Qatar.png b/flags/Qatar.png
new file mode 100644
index 0000000..c7cddb8
--- /dev/null
+++ b/flags/Qatar.png
Binary files differ
diff --git a/flags/Republic_of_China.png b/flags/Republic_of_China.png
new file mode 100644
index 0000000..973d894
--- /dev/null
+++ b/flags/Republic_of_China.png
Binary files differ
diff --git a/flags/Republic_of_the_Congo.png b/flags/Republic_of_the_Congo.png
new file mode 100644
index 0000000..aa43389
--- /dev/null
+++ b/flags/Republic_of_the_Congo.png
Binary files differ
diff --git a/flags/Romania.png b/flags/Romania.png
new file mode 100644
index 0000000..1727fa9
--- /dev/null
+++ b/flags/Romania.png
Binary files differ
diff --git a/flags/Russia.png b/flags/Russia.png
new file mode 100644
index 0000000..6c179b2
--- /dev/null
+++ b/flags/Russia.png
Binary files differ
diff --git a/flags/Rwanda.png b/flags/Rwanda.png
new file mode 100644
index 0000000..45cc220
--- /dev/null
+++ b/flags/Rwanda.png
Binary files differ
diff --git a/flags/Sahrawi_Arab_Democratic_Republic.png b/flags/Sahrawi_Arab_Democratic_Republic.png
new file mode 100644
index 0000000..5f77d93
--- /dev/null
+++ b/flags/Sahrawi_Arab_Democratic_Republic.png
Binary files differ
diff --git a/flags/Saint_Kitts_and_Nevis.png b/flags/Saint_Kitts_and_Nevis.png
new file mode 100644
index 0000000..299f924
--- /dev/null
+++ b/flags/Saint_Kitts_and_Nevis.png
Binary files differ
diff --git a/flags/Saint_Lucia.png b/flags/Saint_Lucia.png
new file mode 100644
index 0000000..f3ddbd0
--- /dev/null
+++ b/flags/Saint_Lucia.png
Binary files differ
diff --git a/flags/Saint_Vincent_and_the_Grenadines.png b/flags/Saint_Vincent_and_the_Grenadines.png
new file mode 100644
index 0000000..06cacca
--- /dev/null
+++ b/flags/Saint_Vincent_and_the_Grenadines.png
Binary files differ
diff --git a/flags/Samoa.png b/flags/Samoa.png
new file mode 100644
index 0000000..6ef2a27
--- /dev/null
+++ b/flags/Samoa.png
Binary files differ
diff --git a/flags/San_Marino.png b/flags/San_Marino.png
new file mode 100644
index 0000000..b9449c4
--- /dev/null
+++ b/flags/San_Marino.png
Binary files differ
diff --git a/flags/Sao_Tome_and_Principe.png b/flags/Sao_Tome_and_Principe.png
new file mode 100644
index 0000000..8491fb1
--- /dev/null
+++ b/flags/Sao_Tome_and_Principe.png
Binary files differ
diff --git a/flags/Saudi_Arabia.png b/flags/Saudi_Arabia.png
new file mode 100644
index 0000000..37a4ea7
--- /dev/null
+++ b/flags/Saudi_Arabia.png
Binary files differ
diff --git a/flags/Senegal.png b/flags/Senegal.png
new file mode 100644
index 0000000..2dfcd70
--- /dev/null
+++ b/flags/Senegal.png
Binary files differ
diff --git a/flags/Serbia.png b/flags/Serbia.png
new file mode 100644
index 0000000..1c66732
--- /dev/null
+++ b/flags/Serbia.png
Binary files differ
diff --git a/flags/Seychelles.png b/flags/Seychelles.png
new file mode 100644
index 0000000..bb04b89
--- /dev/null
+++ b/flags/Seychelles.png
Binary files differ
diff --git a/flags/Sierra_Leone.png b/flags/Sierra_Leone.png
new file mode 100644
index 0000000..d6a02c3
--- /dev/null
+++ b/flags/Sierra_Leone.png
Binary files differ
diff --git a/flags/Singapore.png b/flags/Singapore.png
new file mode 100644
index 0000000..2ac1526
--- /dev/null
+++ b/flags/Singapore.png
Binary files differ
diff --git a/flags/Slovakia.png b/flags/Slovakia.png
new file mode 100644
index 0000000..92bb7a6
--- /dev/null
+++ b/flags/Slovakia.png
Binary files differ
diff --git a/flags/Slovenia.png b/flags/Slovenia.png
new file mode 100644
index 0000000..8e00ff0
--- /dev/null
+++ b/flags/Slovenia.png
Binary files differ
diff --git a/flags/Solomon_Islands.png b/flags/Solomon_Islands.png
new file mode 100644
index 0000000..e237ccd
--- /dev/null
+++ b/flags/Solomon_Islands.png
Binary files differ
diff --git a/flags/Somalia.png b/flags/Somalia.png
new file mode 100644
index 0000000..b2a5883
--- /dev/null
+++ b/flags/Somalia.png
Binary files differ
diff --git a/flags/Somaliland.png b/flags/Somaliland.png
new file mode 100644
index 0000000..9df5ae0
--- /dev/null
+++ b/flags/Somaliland.png
Binary files differ
diff --git a/flags/South_Africa.png b/flags/South_Africa.png
new file mode 100644
index 0000000..6bdec48
--- /dev/null
+++ b/flags/South_Africa.png
Binary files differ
diff --git a/flags/South_Korea.png b/flags/South_Korea.png
new file mode 100644
index 0000000..c8c0eeb
--- /dev/null
+++ b/flags/South_Korea.png
Binary files differ
diff --git a/flags/South_Ossetia.png b/flags/South_Ossetia.png
new file mode 100644
index 0000000..9003533
--- /dev/null
+++ b/flags/South_Ossetia.png
Binary files differ
diff --git a/flags/South_Sudan.png b/flags/South_Sudan.png
new file mode 100644
index 0000000..7c3965f
--- /dev/null
+++ b/flags/South_Sudan.png
Binary files differ
diff --git a/flags/Spain.png b/flags/Spain.png
new file mode 100644
index 0000000..a175acf
--- /dev/null
+++ b/flags/Spain.png
Binary files differ
diff --git a/flags/Sri_Lanka.png b/flags/Sri_Lanka.png
new file mode 100644
index 0000000..7f2b0d7
--- /dev/null
+++ b/flags/Sri_Lanka.png
Binary files differ
diff --git a/flags/Sudan.png b/flags/Sudan.png
new file mode 100644
index 0000000..ea5fdfe
--- /dev/null
+++ b/flags/Sudan.png
Binary files differ
diff --git a/flags/Suriname.png b/flags/Suriname.png
new file mode 100644
index 0000000..69134d4
--- /dev/null
+++ b/flags/Suriname.png
Binary files differ
diff --git a/flags/Swaziland.png b/flags/Swaziland.png
new file mode 100644
index 0000000..f650471
--- /dev/null
+++ b/flags/Swaziland.png
Binary files differ
diff --git a/flags/Sweden.png b/flags/Sweden.png
new file mode 100644
index 0000000..b594a8c
--- /dev/null
+++ b/flags/Sweden.png
Binary files differ
diff --git a/flags/Switzerland.png b/flags/Switzerland.png
new file mode 100644
index 0000000..94e82ba
--- /dev/null
+++ b/flags/Switzerland.png
Binary files differ
diff --git a/flags/Syria.png b/flags/Syria.png
new file mode 100644
index 0000000..1df63a6
--- /dev/null
+++ b/flags/Syria.png
Binary files differ
diff --git a/flags/Tajikistan.png b/flags/Tajikistan.png
new file mode 100644
index 0000000..eed5a1d
--- /dev/null
+++ b/flags/Tajikistan.png
Binary files differ
diff --git a/flags/Tanzania.png b/flags/Tanzania.png
new file mode 100644
index 0000000..6c17955
--- /dev/null
+++ b/flags/Tanzania.png
Binary files differ
diff --git a/flags/Thailand.png b/flags/Thailand.png
new file mode 100644
index 0000000..6718345
--- /dev/null
+++ b/flags/Thailand.png
Binary files differ
diff --git a/flags/Togo.png b/flags/Togo.png
new file mode 100644
index 0000000..c013d22
--- /dev/null
+++ b/flags/Togo.png
Binary files differ
diff --git a/flags/Tonga.png b/flags/Tonga.png
new file mode 100644
index 0000000..5e19635
--- /dev/null
+++ b/flags/Tonga.png
Binary files differ
diff --git a/flags/Transnistria.png b/flags/Transnistria.png
new file mode 100644
index 0000000..40c3b59
--- /dev/null
+++ b/flags/Transnistria.png
Binary files differ
diff --git a/flags/Trinidad_and_Tobago.png b/flags/Trinidad_and_Tobago.png
new file mode 100644
index 0000000..c580a5d
--- /dev/null
+++ b/flags/Trinidad_and_Tobago.png
Binary files differ
diff --git a/flags/Tunisia.png b/flags/Tunisia.png
new file mode 100644
index 0000000..b31135c
--- /dev/null
+++ b/flags/Tunisia.png
Binary files differ
diff --git a/flags/Turkey.png b/flags/Turkey.png
new file mode 100644
index 0000000..38818c9
--- /dev/null
+++ b/flags/Turkey.png
Binary files differ
diff --git a/flags/Turkish_Republic_of_Northern_Cyprus.png b/flags/Turkish_Republic_of_Northern_Cyprus.png
new file mode 100644
index 0000000..f7a7a1e
--- /dev/null
+++ b/flags/Turkish_Republic_of_Northern_Cyprus.png
Binary files differ
diff --git a/flags/Turkmenistan.png b/flags/Turkmenistan.png
new file mode 100644
index 0000000..c18cc7b
--- /dev/null
+++ b/flags/Turkmenistan.png
Binary files differ
diff --git a/flags/Tuvalu.png b/flags/Tuvalu.png
new file mode 100644
index 0000000..e322957
--- /dev/null
+++ b/flags/Tuvalu.png
Binary files differ
diff --git a/flags/Uganda.png b/flags/Uganda.png
new file mode 100644
index 0000000..035f769
--- /dev/null
+++ b/flags/Uganda.png
Binary files differ
diff --git a/flags/Ukraine.png b/flags/Ukraine.png
new file mode 100644
index 0000000..5fb2802
--- /dev/null
+++ b/flags/Ukraine.png
Binary files differ
diff --git a/flags/United_Arab_Emirates.png b/flags/United_Arab_Emirates.png
new file mode 100644
index 0000000..24545ca
--- /dev/null
+++ b/flags/United_Arab_Emirates.png
Binary files differ
diff --git a/flags/United_Kingdom.png b/flags/United_Kingdom.png
new file mode 100644
index 0000000..1e0d8f3
--- /dev/null
+++ b/flags/United_Kingdom.png
Binary files differ
diff --git a/flags/United_States.png b/flags/United_States.png
new file mode 100644
index 0000000..64159fc
--- /dev/null
+++ b/flags/United_States.png
Binary files differ
diff --git a/flags/Uruguay.png b/flags/Uruguay.png
new file mode 100644
index 0000000..443c4d1
--- /dev/null
+++ b/flags/Uruguay.png
Binary files differ
diff --git a/flags/Uzbekistan.png b/flags/Uzbekistan.png
new file mode 100644
index 0000000..f61ec9e
--- /dev/null
+++ b/flags/Uzbekistan.png
Binary files differ
diff --git a/flags/Vanuatu.png b/flags/Vanuatu.png
new file mode 100644
index 0000000..1893314
--- /dev/null
+++ b/flags/Vanuatu.png
Binary files differ
diff --git a/flags/Vatican_City.png b/flags/Vatican_City.png
new file mode 100644
index 0000000..3d148e9
--- /dev/null
+++ b/flags/Vatican_City.png
Binary files differ
diff --git a/flags/Venezuela.png b/flags/Venezuela.png
new file mode 100644
index 0000000..07620b1
--- /dev/null
+++ b/flags/Venezuela.png
Binary files differ
diff --git a/flags/Vietnam.png b/flags/Vietnam.png
new file mode 100644
index 0000000..ca29158
--- /dev/null
+++ b/flags/Vietnam.png
Binary files differ
diff --git a/flags/Yemen.png b/flags/Yemen.png
new file mode 100644
index 0000000..a0d30dd
--- /dev/null
+++ b/flags/Yemen.png
Binary files differ
diff --git a/flags/Zambia.png b/flags/Zambia.png
new file mode 100644
index 0000000..dcda5d0
--- /dev/null
+++ b/flags/Zambia.png
Binary files differ
diff --git a/flags/Zimbabwe.png b/flags/Zimbabwe.png
new file mode 100644
index 0000000..4fed175
--- /dev/null
+++ b/flags/Zimbabwe.png
Binary files differ
diff --git a/plugins/accelerometer/accelerometer.py b/plugins/accelerometer/accelerometer.py
deleted file mode 100644
index 26aefd4..0000000
--- a/plugins/accelerometer/accelerometer.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/env python
-#Copyright (c) 2011 Walter Bender
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import os
-
-from gettext import gettext as _
-
-from plugins.plugin import Plugin
-
-from TurtleArt.tapalette import make_palette
-from TurtleArt.talogo import primitive_dictionary
-from TurtleArt.tautils import debug_output
-
-import logging
-_logger = logging.getLogger('turtleart-activity accelerometer plugin')
-
-
-ACCELEROMETER_DEVICE = '/sys/devices/platform/lis3lv02d/position'
-
-
-class Accelerometer(Plugin):
-
- def __init__(self, parent):
- self._parent = parent
- if os.path.exists(ACCELEROMETER_DEVICE):
- self._status = True
- else:
- self._status = False
- self.running_sugar = self._parent.running_sugar
-
- def setup(self):
- # set up accelerometer specific blocks
- palette = make_palette('sensor',
- colors=["#FF6060", "#A06060"],
- help_string=_('Palette of sensor blocks'),
- position=6)
-
- primitive_dictionary['xyz'] = self.prim_xyz
- if self._status:
- palette.add_block('xyz',
- style='basic-style-extended-vertical',
- label=_('acceleration'),
- help_string=\
- _('push acceleration in x, y, z to heap'),
- prim_name='xyz')
- else:
- palette.add_block('xyz',
- style='basic-style-extended-vertical',
- label=_('acceleration'),
- help_string=\
- _('push acceleration in x, y, z to heap'),
- hidden=True,
- prim_name='xyz')
-
- self._parent.lc.def_prim(
- 'xyz', 0, lambda self: primitive_dictionary['xyz']())
-
- def _status_report(self):
- debug_output('Reporting accelerator status: %s' % (str(self._status)))
- return self._status
-
- # Block primitives used in talogo
-
- def prim_xyz(self):
- ''' push accelerometer xyz to stack '''
- if not self._status:
- self._parent.lc.heap.append(0)
- self._parent.lc.heap.append(0)
- self._parent.lc.heap.append(0)
- else:
- fh = open(ACCELEROMETER_DEVICE)
- string = fh.read()
- xyz = string[1:-2].split(',')
- self._parent.lc.heap.append(float(xyz[2]) / 18)
- self._parent.lc.heap.append(float(xyz[1]) / 18)
- self._parent.lc.heap.append(float(xyz[0]) / 18)
- fh.close()
diff --git a/plugins/accelerometer/icons/sensoroff.svg b/plugins/accelerometer/icons/sensoroff.svg
deleted file mode 100644
index 0a16670..0000000
--- a/plugins/accelerometer/icons/sensoroff.svg
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="55"
- height="55"
- viewBox="0 0 55 55"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata15"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs13" />
-<rect
- width="42.763924"
- height="42.763924"
- x="6.1180382"
- y="6.1180382"
- id="rect2986"
- style="fill:#282828;fill-opacity:1;stroke:#282828;stroke-width:2.23607516;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><g
- transform="matrix(0.87078705,0,0,0.87078705,3.2821055,2.9298726)"
- id="network-wired_1_"
- style="display:block">
- <g
- id="network-wired">
- <line
- id="line3076"
- y2="23.993"
- y1="32.438999"
- x2="16.966999"
- x1="16.966999"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round" />
- <line
- id="line3078"
- y2="28.215"
- y1="28.215"
- x2="34.938"
- x1="29.636999"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round" />
-
- <rect
- width="9.7939997"
- height="7.599"
- x="42.157001"
- y="24.312"
- id="rect3080"
- style="fill:#ffffff;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round" />
- <path
- d="m 16.967,23.993 c 0,-2.334 -1.892,-4.224 -4.224,-4.224 -2.332,0 -4.223,1.889 -4.223,4.224"
- id="path3082"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 25.413,32.439 c 0,2.334 -1.891,4.224 -4.224,4.224 -2.332,0 -4.223,-1.89 -4.223,-4.224"
- id="path3084"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 25.413,32.439 c 0,-2.332 1.893,-4.226 4.224,-4.226"
- id="path3086"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 8.52,23.993 c 0,2.332 -1.892,4.222 -4.223,4.222"
- id="path3088"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
-
- <rect
- width="14.477"
- height="11.35"
- x="31.945"
- y="22.438"
- id="rect3090"
- style="fill:#ffffff;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- </g>
-</g></svg> \ No newline at end of file
diff --git a/plugins/accelerometer/icons/sensoron.svg b/plugins/accelerometer/icons/sensoron.svg
deleted file mode 100644
index d756860..0000000
--- a/plugins/accelerometer/icons/sensoron.svg
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="55"
- height="55"
- viewBox="0 0 55 55"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata15"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs13" /><rect
- width="55"
- height="55"
- x="0"
- y="0"
- id="rect3269"
- style="fill:#ffd200;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
- transform="translate(0.27777716,18.796296)"
- id="g4054"><line
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-opacity:1"
- x1="17.778971"
- x2="17.778971"
- y1="12.381037"
- y2="5.0263696"
- id="line3076" /><line
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-opacity:1"
- x1="28.811842"
- x2="33.427887"
- y1="8.7028332"
- y2="8.7028332"
- id="line3078" /><rect
- width="8.5284882"
- height="6.6171107"
- x="39.7141"
- y="5.3041511"
- id="rect3080"
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:1.95927083;stroke-linecap:round;stroke-opacity:1" /><path
- d="m 17.778971,5.0263697 c 0,-2.032417 -1.647529,-3.6782045 -3.678204,-3.6782045 -2.030675,0 -3.677334,1.6449167 -3.677334,3.6782045"
- id="path3082"
- style="fill:none;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 25.133639,12.381037 c 0,2.032417 -1.646658,3.678205 -3.678205,3.678205 -2.030675,0 -3.677333,-1.645788 -3.677333,-3.678205"
- id="path3084"
- style="fill:none;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 25.133639,12.381037 c 0,-2.030675 1.6484,-3.679946 3.678204,-3.679946"
- id="path3086"
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 10.423433,5.0263697 c 0,2.0306754 -1.6475288,3.6764629 -3.6773334,3.6764629"
- id="path3088"
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><rect
- width="12.606384"
- height="9.8834333"
- x="30.821619"
- y="3.6722956"
- id="rect3090"
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /></g></svg> \ No newline at end of file
diff --git a/plugins/audio_sensors/audio_sensors.py b/plugins/audio_sensors/audio_sensors.py
deleted file mode 100644
index 8d45395..0000000
--- a/plugins/audio_sensors/audio_sensors.py
+++ /dev/null
@@ -1,468 +0,0 @@
-#!/usr/bin/env python
-#Copyright (c) 2011, 2012 Walter Bender
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-from gettext import gettext as _
-
-try:
- from numpy import append
- from numpy.fft import rfft
- PITCH_AVAILABLE = True
-except:
- PITCH_AVAILABLE = False
-
-from plugins.plugin import Plugin
-
-from plugins.audio_sensors.audiograb import (AudioGrab,
- SENSOR_DC_NO_BIAS, SENSOR_DC_BIAS, SENSOR_AC_BIAS)
-
-from plugins.audio_sensors.ringbuffer import RingBuffer1d
-
-from TurtleArt.tapalette import make_palette
-from TurtleArt.taconstants import XO1, XO15, XO175, XO30, XO4
-from TurtleArt.talogo import primitive_dictionary
-from TurtleArt.tautils import debug_output
-
-import logging
-_logger = logging.getLogger('turtleart-activity audio sensors plugin')
-
-
-def _avg(array, abs_value=False):
- ''' Calc. the average value of an array '''
- if len(array) == 0:
- return 0
- array_sum = 0
- if abs_value:
- for a in array:
- array_sum += abs(a)
- else:
- for a in array:
- array_sum += a
- return float(array_sum) / len(array)
-
-
-class Audio_sensors(Plugin):
-
- def __init__(self, parent):
- self._parent = parent
- self._status = True # TODO: test for audio device
- # These flags are referenced by audiograb
- self.hw = self._parent.hw
- self.running_sugar = self._parent.running_sugar
-
- def setup(self):
- ''' set up audio-sensor-specific blocks '''
- self.max_samples = 1500
- self.input_step = 1
-
- self.ringbuffer = []
-
- palette = make_palette('sensor',
- colors=["#FF6060", "#A06060"],
- help_string=_('Palette of sensor blocks'),
- position=6)
-
- primitive_dictionary['sound'] = self.prim_sound
- primitive_dictionary['volume'] = self.prim_volume
- if self._status:
- palette.add_block('sound',
- style='box-style',
- label=_('sound'),
- help_string=_('raw microphone input signal'),
- value_block=True,
- prim_name='sound')
-
- palette.add_block('volume',
- style='box-style',
- label=_('loudness'),
- help_string=_('microphone input volume'),
- value_block=True,
- prim_name='volume')
- else:
- palette.add_block('sound',
- hidden=True,
- style='box-style',
- label=_('sound'),
- help_string=_('raw microphone input signal'),
- value_block=True,
- prim_name='sound')
- palette.add_block('volume',
- hidden=True,
- style='box-style',
- label=_('loudness'),
- help_string=_('microphone input volume'),
- value_block=True,
- prim_name='volume')
-
- self._parent.lc.def_prim(
- 'sound', 0, lambda self: primitive_dictionary['sound'](0))
- self._parent.lc.def_prim(
- 'volume', 0, lambda self: primitive_dictionary['volume'](0))
-
- primitive_dictionary['pitch'] = self.prim_pitch
- if PITCH_AVAILABLE and self._status:
- palette.add_block('pitch',
- style='box-style',
- label=_('pitch'),
- help_string=_('microphone input pitch'),
- value_block=True,
- prim_name='pitch')
- else:
- palette.add_block('pitch',
- hidden=True,
- style='box-style',
- label=_('pitch'),
- help_string=_('microphone input pitch'),
- value_block=True,
- prim_name='pitch')
- self._parent.lc.def_prim('pitch', 0,
- lambda self: primitive_dictionary['pitch'](0))
-
- primitive_dictionary['resistance'] = self.prim_resistance
- primitive_dictionary['voltage'] = self.prim_voltage
- if self.hw in [XO1, XO15, XO175, XO4, XO30] and self._status:
- if self.hw == XO1:
- self.voltage_gain = 0.000022
- self.voltage_bias = 1.14
- elif self.hw == XO15:
- self.voltage_gain = -0.00015
- self.voltage_bias = 1.70
- elif self.hw in [XO175, XO4]: # recalibrate in light of #3675?
- self.voltage_gain = 0.000071
- self.voltage_bias = 0.55
- else: # XO 3.0
- self.voltage_gain = 0.000077
- self.voltage_bias = 0.72
- palette.add_block('resistance',
- style='box-style',
- label=_('resistance'),
- help_string=_('microphone input resistance'),
- value_block=True,
- prim_name='resistance')
- palette.add_block('voltage',
- style='box-style',
- label=_('voltage'),
- help_string=_('microphone input voltage'),
- value_block=True,
- prim_name='voltage')
- else:
- palette.add_block('resistance',
- hidden=True,
- style='box-style',
- label=_('resistance'),
- help_string=_('microphone input resistance'),
- prim_name='resistance')
- palette.add_block('voltage',
- hidden=True,
- style='box-style',
- label=_('voltage'),
- help_string=_('microphone input voltage'),
- prim_name='voltage')
-
- # FIXME: Only add stereo capture for XO15 (broken on ARM #3675)
- if self.hw in [XO15] and self._status:
- palette.add_block('resistance2',
- style='box-style',
- label=_('resistance') + '2',
- help_string=_('microphone input resistance'),
- value_block=True,
- prim_name='resistance2')
- palette.add_block('voltage2',
- style='box-style',
- label=_('voltage') + '2',
- help_string=_('microphone input voltage'),
- value_block=True,
- prim_name='voltage2')
- else:
- palette.add_block('resistance2',
- hidden=True,
- style='box-style',
- label=_('resistance') + '2',
- help_string=_('microphone input resistance'),
- prim_name='resistance2')
- palette.add_block('voltage2',
- hidden=True,
- style='box-style',
- label=_('voltage') + '2',
- help_string=_('microphone input voltage'),
- prim_name='voltage2')
- self._parent.lc.def_prim(
- 'resistance', 0,
- lambda self: primitive_dictionary['resistance'](0))
- self._parent.lc.def_prim(
- 'voltage', 0, lambda self: primitive_dictionary['voltage'](0))
- self._parent.lc.def_prim(
- 'resistance2', 0,
- lambda self: primitive_dictionary['resistance'](1))
- self._parent.lc.def_prim(
- 'voltage2', 0, lambda self: primitive_dictionary['voltage'](1))
-
- self.audio_started = False
- if self.hw in [XO175, XO30, XO4]:
- self.PARAMETERS = {
- SENSOR_AC_BIAS: (False, True, 80, True),
- SENSOR_DC_NO_BIAS: (True, False, 80, False),
- SENSOR_DC_BIAS: (True, True, 90, False)
- }
- elif self.hw == XO15:
- self.PARAMETERS = {
- SENSOR_AC_BIAS: (False, True, 80, True),
- SENSOR_DC_NO_BIAS: (True, False, 80, False),
- SENSOR_DC_BIAS: (True, True, 90, False)
- }
- elif self.hw == XO1:
- self.PARAMETERS = {
- SENSOR_AC_BIAS: (False, True, 40, True),
- SENSOR_DC_NO_BIAS: (True, False, 0, False),
- SENSOR_DC_BIAS: (True, True, 0, False)
- }
- else:
- self.PARAMETERS = {
- SENSOR_AC_BIAS: (None, True, 40, True),
- SENSOR_DC_NO_BIAS: (True, False, 80, False),
- SENSOR_DC_BIAS: (True, True, 90, False)
- }
-
- def start(self):
- ''' Start grabbing audio if there is an audio block in use '''
- if not self._status:
- return
- if self.audio_started:
- self.audiograb.stop_grabbing()
- if len(self._parent.block_list.get_similar_blocks(
- 'block', ['volume', 'sound', 'pitch'])) > 0:
- mode, bias, gain, boost = self.PARAMETERS[SENSOR_AC_BIAS]
- elif len(self._parent.block_list.get_similar_blocks(
- 'block', ['resistance', 'resistance2'])) > 0:
- mode, bias, gain, boost = self.PARAMETERS[SENSOR_DC_BIAS]
- elif len(self._parent.block_list.get_similar_blocks(
- 'block', ['voltage', 'voltage2'])) > 0:
- mode, bias, gain, boost = self.PARAMETERS[SENSOR_DC_NO_BIAS]
- else:
- return # No audio blocks in use.
- self.audiograb = AudioGrab(self.new_buffer, self,
- mode, bias, gain, boost)
- self._channels = self.audiograb.channels
- for i in range(self._channels):
- self.ringbuffer.append(RingBuffer1d(self.max_samples,
- dtype='int16'))
- self.audiograb.start_grabbing()
- self.audio_started = True
-
- def new_buffer(self, buf, channel=0):
- ''' Append a new buffer to the ringbuffer '''
- self.ringbuffer[channel].append(buf)
- return True
-
- def stop(self):
- ''' This gets called by the stop button '''
- if self._status and self.audio_started:
- self.audiograb.on_activity_quit() # reset all setting
- self.audio_started = False
-
- def goto_background(self):
- ''' This gets called when your process is sent to the background '''
- pass
-
- def return_to_foreground(self):
- ''' This gets called when your process returns from the background '''
- pass
-
- def quit(self):
- ''' This gets called by the quit button '''
- if self._status and self.audio_started:
- self.audiograb.on_activity_quit()
-
- def _status_report(self):
- debug_output(
- 'Reporting audio sensor status: %s' % (str(self._status)),
- self._parent.running_sugar)
- return self._status
-
- # Block primitives used in talogo
-
- def prim_volume(self, channel):
- if not self._status:
- return 0
- # Return average of both channels if sampling in stereo
- if self._channels == 2:
- chan0 = self._prim_volume(0)
- chan1 = self._prim_volume(1)
- return (chan0 + chan1) / 2
- else:
- return self._prim_volume(0)
-
- def _prim_volume(self, channel):
- ''' return mic in value '''
- buf = self.ringbuffer[channel].read(None, self.input_step)
- if len(buf) > 0:
- volume = float(_avg(buf, abs_value=True))
- self._parent.lc.update_label_value('volume', volume)
- return volume
- else:
- return 0
-
- def prim_sound(self, channel):
- if not self._status:
- return 0
- # Return average of both channels if sampling in stereo
- if self._channels == 2:
- chan0 = self._prim_sound(0)
- chan1 = self._prim_sound(1)
- return (chan0 + chan1) / 2
- else:
- return self._prim_sound(0)
-
- def _prim_sound(self, channel):
- ''' return raw mic in value '''
- buf = self.ringbuffer[channel].read(None, self.input_step)
- if len(buf) > 0:
- sound = float(buf[0])
- if self._parent.lc.update_values:
- self._parent.lc.update_label_value('sound', sound)
- return sound
- else:
- return 0
-
- def prim_pitch(self, channel):
- if not PITCH_AVAILABLE or not self._status:
- return 0
- # Return average of both channels if sampling in stereo
- if self._channels == 2:
- chan0 = self._prim_pitch(0)
- chan1 = self._prim_pitch(1)
- return (chan0 + chan1) / 2
- else:
- return self._prim_pitch(0)
-
- def _prim_pitch(self, channel):
- ''' return index of max value in fft of mic in values '''
- buf = self.ringbuffer[channel].read(None, self.input_step)
- if len(buf) > 0:
- buf = rfft(buf)
- buf = abs(buf)
- maxi = buf.argmax()
- if maxi == 0:
- pitch = 0
- else: # Simple interpolation
- a, b, c = buf[maxi - 1], buf[maxi], buf[maxi + 1]
- maxi -= a / float(a + b + c)
- maxi += c / float(a + b + c)
- pitch = maxi * 48000 / (len(buf) * 2)
-
- if self._parent.lc.update_values:
- self._parent.lc.update_label_value('pitch', pitch)
- return pitch
- else:
- return 0
-
- def prim_resistance(self, channel):
- if not self.hw in [XO1, XO15, XO175, XO30, XO4] or not self._status:
- return 0
- if self.hw in [XO1, XO4]:
- resistance = self._prim_resistance(0)
- if self._parent.lc.update_values:
- self._update_resistance_labels(0, resistance)
- return resistance
- elif self.hw == XO15:
- resistance = self._prim_resistance(channel)
- if self._parent.lc.update_values:
- self._update_resistance_labels(channel, resistance)
- return resistance
- # FIXME: For XO175: channel assignment is seemingly random
- # (#3675), so sum both channels (one of them will be 0)
- else:
- chan0 = self._prim_resistance(0)
- chan1 = self._prim_resistance(1)
- resistance = chan0 + chan1
- if self._parent.lc.update_values:
- self._update_resistance_labels(0, resistance)
- return resistance
-
- def _prim_resistance(self, channel):
- ''' return resistance sensor value '''
- buf = self.ringbuffer[channel].read(None, self.input_step)
- if len(buf) > 0:
- # See <http://bugs.sugarlabs.org/ticket/552#comment:7>
- # TODO: test this calibration on XO 1.5, XO 1.75
- avg_buf = float(_avg(buf))
- if self.hw == XO1:
- resistance = 2.718 ** ((avg_buf * 0.000045788) + 8.0531)
- elif self.hw == XO15:
- if avg_buf > 0:
- resistance = (420000000 / avg_buf) - 13500
- else:
- resistance = 420000000
- elif self.hw in [XO175, XO4]:
- if avg_buf < 30700:
- resistance = .12 * ((180000000 / (30700 - avg_buf)) - 3150)
- else:
- resistance = 999999999
- else: # XO 3.0
- if avg_buf < 30514:
- resistance = (46000000 / (30514 - avg_buf)) - 1150
- else:
- resistance = 999999999
- if resistance < 0:
- resistance = 0
- return resistance
- else:
- return 0
-
- def _update_resistance_labels(self, channel, resistance):
- if channel == 0:
- self._parent.lc.update_label_value('resistance', resistance)
- else:
- self._parent.lc.update_label_value('resistance2', resistance)
-
- def prim_voltage(self, channel):
- if not self.hw in [XO1, XO15, XO175, XO30, XO4] or not self._status:
- return 0
- if self.hw in [XO1, XO4]:
- voltage = self._prim_voltage(0)
- if self._parent.lc.update_values:
- self._update_voltage_labels(0, voltage)
- return voltage
- elif self.hw == XO15:
- voltage = self._prim_voltage(channel)
- if self._parent.lc.update_values:
- self._update_voltage_labels(channel, voltage)
- return voltage
- # FIXME: For XO175: channel assignment is seemingly random
- # (#3675), so sum both channels (one of them will be 0)
- else:
- chan0 = self._prim_voltage(0)
- chan1 = self._prim_voltage(1)
- voltage = chan0 + chan1
- if self._parent.lc.update_values:
- self._update_voltage_labels(0, voltage)
- return voltage
-
- def _prim_voltage(self, channel):
- ''' return voltage sensor value '''
- buf = self.ringbuffer[channel].read(None, self.input_step)
- if len(buf) > 0:
- # See <http://bugs.sugarlabs.org/ticket/552#comment:7>
- voltage = float(_avg(buf)) * self.voltage_gain + self.voltage_bias
- return voltage
- else:
- return 0
-
- def _update_voltage_labels(self, channel, voltage):
- if channel == 0:
- self._parent.lc.update_label_value('voltage', voltage)
- else:
- self._parent.lc.update_label_value('voltage2', voltage)
diff --git a/plugins/audio_sensors/audiograb.py b/plugins/audio_sensors/audiograb.py
deleted file mode 100644
index 228e4c2..0000000
--- a/plugins/audio_sensors/audiograb.py
+++ /dev/null
@@ -1,673 +0,0 @@
-#! /usr/bin/python
-#
-# Author: Arjun Sarwal arjun@laptop.org
-# Copyright (C) 2007, Arjun Sarwal
-# Copyright (C) 2009-12 Walter Bender
-# Copyright (C) 2009, Benjamin Berg, Sebastian Berg
-# Copyright (C) 2009, Sayamindu Dasgupta
-# Copyright (C) 2010, Sascha Silbe
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# You should have received a copy of the GNU General Public License
-# along with this library; if not, write to the Free Software
-# Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
-
-import pygst
-import gst
-import gst.interfaces
-from numpy import fromstring
-import subprocess
-import traceback
-from string import find
-from threading import Timer
-
-from TurtleArt.taconstants import XO1, XO4
-from TurtleArt.tautils import debug_output
-
-# Initial device settings
-RATE = 48000
-MIC_BOOST = True
-DC_MODE_ENABLE = False
-CAPTURE_GAIN = 50
-BIAS = True
-
-# Setting on quit
-QUIT_MIC_BOOST = False
-QUIT_DC_MODE_ENABLE = False
-QUIT_CAPTURE_GAIN = 100
-QUIT_BIAS = True
-
-# Capture modes
-SENSOR_AC_NO_BIAS = 'external'
-SENSOR_AC_BIAS = 'sound'
-SENSOR_DC_NO_BIAS = 'voltage'
-SENSOR_DC_BIAS = 'resistance'
-
-
-class AudioGrab():
- """ The interface between measure and the audio device """
-
- def __init__(self, callable1, parent,
- mode=None, bias=None, gain=None, boost=None):
- """ Initialize the class: callable1 is a data buffer;
- parent is the parent class"""
-
- self.callable1 = callable1
- self.parent = parent
- self.sensor = None
-
- self.temp_buffer = [0]
-
- self.rate = RATE
- # Force XO1 and XO4 to use just 1 channel
- if self.parent.hw in [XO1, XO4]:
- self.channels = 1
- else:
- self.channels = None
-
- self._dc_control = None
- self._mic_bias_control = None
- self._capture_control = None
- self._mic_boost_control = None
- self._labels_available = True # Query controls for device names
-
- self._query_mixer()
- # If Channels was not found in the Capture controller, guess.
- if self.channels is None:
- debug_output('Guessing there are 2 channels',
- self.parent.running_sugar)
- self.channels = 2
-
- # Set mixer to known state
- self.set_dc_mode(DC_MODE_ENABLE)
- self.set_bias(BIAS)
- self.set_capture_gain(CAPTURE_GAIN)
- self.set_mic_boost(MIC_BOOST)
-
- self.master = self.get_master()
- self.dc_mode = self.get_dc_mode()
- self.bias = self.get_bias()
- self.capture_gain = self.get_capture_gain()
- self.mic_boost = self.get_mic_boost()
-
- # Set mixer to desired state
- self._set_sensor_type(mode, bias, gain, boost)
- self.dc_mode = self.get_dc_mode()
- self.bias = self.get_bias()
- self.capture_gain = self.get_capture_gain()
- self.mic_boost = self.get_mic_boost()
-
- # Set up gstreamer pipeline
- self._pad_count = 0
- self.pads = []
- self.queue = []
- self.fakesink = []
- self.pipeline = gst.Pipeline('pipeline')
- self.alsasrc = gst.element_factory_make('alsasrc', 'alsa-source')
- self.pipeline.add(self.alsasrc)
- self.caps1 = gst.element_factory_make('capsfilter', 'caps1')
- self.pipeline.add(self.caps1)
- caps_str = 'audio/x-raw-int,rate=%d,channels=%d,depth=16' % (
- RATE, self.channels)
- self.caps1.set_property('caps', gst.caps_from_string(caps_str))
- if self.channels == 1:
- self.fakesink.append(gst.element_factory_make('fakesink', 'fsink'))
- self.pipeline.add(self.fakesink[0])
- self.fakesink[0].connect('handoff', self.on_buffer, 0)
- self.fakesink[0].set_property('signal-handoffs', True)
- gst.element_link_many(self.alsasrc, self.caps1, self.fakesink[0])
- else:
- if not hasattr(self, 'splitter'):
- self.splitter = gst.element_factory_make('deinterleave')
- self.pipeline.add(self.splitter)
- self.splitter.set_properties('keep-positions=true', 'name=d')
- self.splitter.connect('pad-added', self._splitter_pad_added)
- gst.element_link_many(self.alsasrc, self.caps1, self.splitter)
- for i in range(self.channels):
- self.queue.append(gst.element_factory_make('queue'))
- self.pipeline.add(self.queue[i])
- self.fakesink.append(gst.element_factory_make('fakesink'))
- self.pipeline.add(self.fakesink[i])
- self.fakesink[i].connect('handoff', self.on_buffer, i)
- self.fakesink[i].set_property('signal-handoffs', True)
-
- self.dont_queue_the_buffer = False
-
- # Timer for interval sampling and switch to indicate when to capture
- self.capture_timer = None
- self.capture_interval_sample = False
-
- def _query_mixer(self):
- self._mixer = gst.element_factory_make('alsamixer')
- rc = self._mixer.set_state(gst.STATE_PAUSED)
- assert rc == gst.STATE_CHANGE_SUCCESS
-
- # Query the available controls
- tracks_list = self._mixer.list_tracks()
- if hasattr(tracks_list[0].props, 'untranslated_label'):
- self._capture_control = self._find_control(['capture', 'axi'])
- self._dc_control = self._find_control(['dc mode'])
- self._mic_bias_control = self._find_control(['mic bias',
- 'dc input bias',
- 'v_refout'])
- self._mic_boost_control = self._find_control(['mic boost',
- 'mic1 boost',
- 'mic boost (+20db)',
- 'internal mic boost',
- 'analog mic boost'])
- self._mic_gain_control = self._find_control(['mic'])
- self._master_control = self._find_control(['master'])
- else: # Use hardwired values
- self._labels_available = False
-
- def _unlink_sink_queues(self):
- ''' Build the sink pipelines '''
-
- # If there were existing pipelines, unlink them
- for i in range(self._pad_count):
- try:
- self.splitter.unlink(self.queue[i])
- self.queue[i].unlink(self.fakesink[i])
- except:
- traceback.print_exc()
-
- # Build the new pipelines
- self._pad_count = 0
- self.pads = []
-
- def _splitter_pad_added(self, element, pad):
- ''' Seems to be the case that ring is right channel 0,
- tip is left channel 1'''
- '''
- debug_output('splitter pad %d added' % (self._pad_count),
- self.parent.running_sugar)
- '''
- self.pads.append(pad)
- if self._pad_count < self.channels:
- pad.link(self.queue[self._pad_count].get_pad('sink'))
- self.queue[self._pad_count].get_pad('src').link(
- self.fakesink[self._pad_count].get_pad('sink'))
- self._pad_count += 1
- else:
- debug_output('ignoring channels > %d' % (self.channels),
- self.parent.running_sugar)
-
- def set_handoff_signal(self, handoff_state):
- '''Sets whether the handoff signal would generate an interrupt
- or not'''
- for i in range(len(self.fakesink)):
- self.fakesink[i].set_property('signal-handoffs', handoff_state)
-
- def _new_buffer(self, buf, channel):
- ''' Use a new buffer '''
- if not self.dont_queue_the_buffer:
- self.temp_buffer = buf
- self.callable1(buf, channel=channel)
- else:
- pass
-
- def on_buffer(self, element, data_buffer, pad, channel):
- '''The function that is called whenever new data is available
- This is the signal handler for the handoff signal'''
- temp_buffer = fromstring(data_buffer, 'int16')
- if not self.dont_queue_the_buffer:
- self._new_buffer(temp_buffer, channel=channel)
- return False
-
- def start_sound_device(self):
- '''Start or Restart grabbing data from the audio capture'''
- gst.event_new_flush_start()
- self.pipeline.set_state(gst.STATE_PLAYING)
-
- def stop_sound_device(self):
- '''Stop grabbing data from capture device'''
- gst.event_new_flush_stop()
- self.pipeline.set_state(gst.STATE_NULL)
-
- def sample_now(self):
- ''' Log the current sample now. This method is called from the
- capture_timer object when the interval expires. '''
- self.capture_interval_sample = True
- self.make_timer()
-
- def set_buffer_interval_logging(self, interval=0):
- '''Sets the number of buffers after which a buffer needs to be
- emitted'''
- self.buffer_interval_logging = interval
-
- def set_sampling_rate(self, sr):
- '''Sets the sampling rate of the capture device
- Sampling rate must be given as an integer for example 16000 for
- setting 16Khz sampling rate
- The sampling rate would be set in the device to the nearest available'''
- self.pause_grabbing()
- caps_str = 'audio/x-raw-int,rate=%d,channels=%d,depth=16' % (
- sr, self.channels)
- self.caps1.set_property('caps', gst.caps_from_string(caps_str))
- self.resume_grabbing()
-
- def get_sampling_rate(self):
- '''Gets the sampling rate of the capture device'''
- return int(self.caps1.get_property('caps')[0]['rate'])
-
- def set_callable1(self, callable1):
- '''Sets the callable to the drawing function for giving the
- data at the end of idle-add'''
- self.callable1 = callable1
-
- def start_grabbing(self):
- '''Called right at the start of the Activity'''
- self.start_sound_device()
- self.set_handoff_signal(True)
-
- def pause_grabbing(self):
- '''When Activity goes into background'''
- self.save_state()
- self.stop_sound_device()
-
- def resume_grabbing(self):
- '''When Activity becomes active after going to background'''
- self.start_sound_device()
- self.resume_state()
- self.set_handoff_signal(True)
-
- def stop_grabbing(self):
- '''Not used ???'''
- self.stop_sound_device()
- self.set_handoff_signal(False)
-
- def _find_control(self, prefixes):
- '''Try to find a mixer control matching one of the prefixes.
-
- The control with the best match (smallest difference in length
- between label and prefix) will be returned. If no match is found,
- None is returned.
- '''
- def best_prefix(label, prefixes):
- matches =\
- [len(label) - len(p) for p in prefixes if label.startswith(p)]
- if not matches:
- return None
-
- matches.sort()
- return matches[0]
-
- controls = []
- for track in self._mixer.list_tracks():
- label = track.props.untranslated_label.lower()
- diff = best_prefix(label, prefixes)
- if diff is not None:
- controls.append((track, diff))
-
- controls.sort(key=lambda e: e[1])
- if controls:
- '''
- debug_output('Found control: %s' %\
- (str(controls[0][0].props.untranslated_label)),
- self.parent.running_sugar)
- '''
- if self.channels is None:
- if hasattr(controls[0][0], 'num_channels'):
- channels = controls[0][0].num_channels
- if channels > 0:
- self.channels = channels
- '''
- debug_output('setting channels to %d' % (self.channels),
- self.parent.running_sugar)
- '''
-
- return controls[0][0]
-
- return None
-
- def save_state(self):
- '''Saves the state of all audio controls'''
- self.master = self.get_master()
- self.bias = self.get_bias()
- self.dc_mode = self.get_dc_mode()
- self.capture_gain = self.get_capture_gain()
- self.mic_boost = self.get_mic_boost()
-
- def resume_state(self):
- '''Put back all audio control settings from the saved state'''
- self.set_master(self.master)
- self.set_bias(self.bias)
- self.set_dc_mode(self.dc_mode)
- self.set_capture_gain(self.capture_gain)
- self.set_mic_boost(self.mic_boost)
-
- def _get_mute(self, control, name, default):
- '''Get mute status of a control'''
- if not control:
- return default
- return bool(control.flags & gst.interfaces.MIXER_TRACK_MUTE)
-
- def _set_mute(self, control, name, value):
- '''Mute a control'''
- if not control:
- return
- self._mixer.set_mute(control, value)
-
- def _get_volume(self, control, name):
- '''Get volume of a control and convert to a scale of 0-100'''
- if not control:
- return 100
- volume = self._mixer.get_volume(control)
- if type(volume) == tuple:
- hw_volume = volume[0]
- else:
- hw_volume = volume
- min_vol = control.min_volume
- max_vol = control.max_volume
- if max_vol == min_vol:
- percent = 100
- else:
- percent = (hw_volume - min_vol) * 100 // (max_vol - min_vol)
- return percent
-
- def _set_volume(self, control, name, value):
- '''Sets the level of a control on a scale of 0-100'''
- if not control:
- return
- # convert value to scale of control
- min_vol = control.min_volume
- max_vol = control.max_volume
- if min_vol != max_vol:
- hw_volume = value * (max_vol - min_vol) // 100 + min_vol
- self._mixer.set_volume(control,
- (hw_volume,) * control.num_channels)
-
- def amixer_set(self, control, state):
- ''' Direct call to amixer for old systems. '''
- if state:
- output = check_output(
- ['amixer', 'set', "%s" % (control), 'unmute'],
- 'Problem with amixer set "%s" unmute' % (control),
- self.parent.running_sugar)
- else:
- output = check_output(
- ['amixer', 'set', "%s" % (control), 'mute'],
- 'Problem with amixer set "%s" mute' % (control),
- self.parent.running_sugar)
-
- def mute_master(self):
- '''Mutes the Master Control'''
- if self._labels_available and self.parent.hw != XO1:
- self._set_mute(self._master_control, 'Master', True)
- else:
- self.amixer_set('Master', False)
-
- def unmute_master(self):
- '''Unmutes the Master Control'''
- if self._labels_available and self.parent.hw != XO1:
- self._set_mute(self._master_control, 'Master', True)
- else:
- self.amixer_set('Master', True)
-
- def set_master(self, master_val):
- '''Sets the Master gain slider settings
- master_val must be given as an integer between 0 and 100 indicating the
- percentage of the slider to be set'''
- if self._labels_available:
- self._set_volume(self._master_control, 'Master', master_val)
- else:
- output = check_output(
- ['amixer', 'set', 'Master', "%d%s" % (master_val, '%')],
- 'Problem with amixer set Master',
- self.parent.running_sugar)
-
- def get_master(self):
- '''Gets the MIC gain slider settings. The value returned is an
- integer between 0-100 and is an indicative of the percentage 0 - 100%'''
- if self._labels_available:
- return self._get_volume(self._master_control, 'master')
- else:
- output = check_output(['amixer', 'get', 'Master'],
- 'amixer: Could not get Master volume',
- self.parent.running_sugar)
- if output is None:
- return 100
- else:
- output = output[find(output, 'Front Left:'):]
- output = output[find(output, '[') + 1:]
- output = output[:find(output, '%]')]
- return int(output)
-
- def set_bias(self, bias_state=False):
- '''Enables / disables bias voltage.'''
- if self._labels_available and self.parent.hw != XO1:
- if self._mic_bias_control is None:
- return
- # If there is a flag property, use set_mute
- if self._mic_bias_control not in self._mixer.list_tracks() or \
- hasattr(self._mic_bias_control.props, 'flags'):
- self._set_mute(
- self._mic_bias_control, 'Mic Bias', not bias_state)
- # We assume that values are sorted from lowest (=off) to highest.
- # Since they are mixed strings ('Off', '50%', etc.), we cannot
- # easily ensure this by sorting with the default sort order.
- elif bias_state: # Otherwise, set with volume
- self._mixer.set_volume(self._mic_bias_control,
- self._mic_bias_control.max_volume)
- else:
- self._mixer.set_volume(self._mic_bias_control,
- self._mic_bias_control.min_volume)
- elif not self._labels_available:
- self.amixer_set('V_REFOUT Enable', bias_state)
- else:
- self.amixer_set('MIC Bias Enable', bias_state)
-
- def get_bias(self):
- '''Check whether bias voltage is enabled.'''
- if self._labels_available:
- if self._mic_bias_control is None:
- return False
- if self._mic_bias_control not in self._mixer.list_tracks() or \
- hasattr(self._mic_bias_control.props, 'flags'):
- return not self._get_mute(
- self._mic_bias_control, 'Mic Bias', False)
- value = self._mixer.get_volume(self._mic_bias_control)
- if value == self._mic_bias_control.min_volume:
- return False
- return True
- else:
- output = check_output(['amixer', 'get', "V_REFOUT Enable"],
- 'amixer: Could not get mic bias voltage',
- self.parent.running_sugar)
- if output is None:
- return False
- else:
- output = output[find(output, 'Mono:'):]
- output = output[find(output, '[') + 1:]
- output = output[:find(output, ']')]
- if output == 'on':
- return True
- return False
-
- def set_dc_mode(self, dc_mode=False):
- '''Sets the DC Mode Enable control
- pass False to mute and True to unmute'''
- if self._labels_available and self.parent.hw != XO1:
- if self._dc_control is not None:
- self._set_mute(self._dc_control, 'DC mode', not dc_mode)
- else:
- self.amixer_set('DC Mode Enable', dc_mode)
-
- def get_dc_mode(self):
- '''Returns the setting of DC Mode Enable control
- i.e. True: Unmuted and False: Muted'''
- if self._labels_available and self.parent.hw != XO1:
- if self._dc_control is not None:
- return not self._get_mute(self._dc_control, 'DC mode', False)
- else:
- return False
- else:
- output = check_output(['amixer', 'get', "DC Mode Enable"],
- 'amixer: Could not get DC Mode',
- self.parent.running_sugar)
- if output is None:
- return False
- else:
- output = output[find(output, 'Mono:'):]
- output = output[find(output, '[') + 1:]
- output = output[:find(output, ']')]
- if output == 'on':
- return True
- return False
-
- def set_mic_boost(self, mic_boost=False):
- '''Set Mic Boost.
- True = +20dB, False = 0dB'''
- if self._labels_available:
- if self._mic_boost_control is None:
- return
- # If there is a volume, use set volume
- if hasattr(self._mic_boost_control, 'min_volume'):
- if mic_boost:
- self._set_volume(self._mic_boost_control, 'boost', 100)
- else:
- self._set_volume(self._mic_boost_control, 'boost', 0)
- # Else if there is a flag property, use set_mute
- elif self._mic_boost_control not in self._mixer.list_tracks() or \
- hasattr(self._mic_boost_control.props, 'flags'):
- self._set_mute(
- self._mic_boost_control, 'Mic Boost', not mic_boost)
- else:
- self.amixer_set('Mic Boost (+20dB)', mic_boost)
-
- def get_mic_boost(self):
- '''Return Mic Boost setting.
- True = +20dB, False = 0dB'''
- if self._labels_available:
- if self._mic_boost_control is None:
- return False
- if self._mic_boost_control not in self._mixer.list_tracks() or \
- hasattr(self._mic_boost_control.props, 'flags'):
- return not self._get_mute(
- self._mic_boost_control, 'Mic Boost', False)
- else: # Compare to min value
- value = self._mixer.get_volume(self._mic_boost_control)
- if value != self._mic_boost_control.min_volume:
- return True
- return False
- else:
- output = check_output(['amixer', 'get', "Mic Boost (+20dB)"],
- 'amixer: Could not get mic boost',
- self.parent.running_sugar)
- if output is None:
- return False
- else:
- output = output[find(output, 'Mono:'):]
- output = output[find(output, '[') + 1:]
- output = output[:find(output, ']')]
- if output == 'on':
- return True
- return False
-
- def set_capture_gain(self, capture_val):
- '''Sets the Capture gain slider settings
- capture_val must be given as an integer between 0 and 100 indicating the
- percentage of the slider to be set'''
- if self._labels_available and self.parent.hw != XO1:
- if self._capture_control is not None:
- self._set_volume(self._capture_control, 'Capture', capture_val)
- else:
- output = check_output(
- ['amixer', 'set', 'Capture', "%d%s" % (capture_val, '%')],
- 'Problem with amixer set Capture',
- self.parent.running_sugar)
-
- def get_capture_gain(self):
- '''Gets the Capture gain slider settings. The value returned is an
- integer between 0-100 and is an indicative of the percentage 0 - 100%'''
- if self._labels_available:
- if self._capture_control is not None:
- return self._get_volume(self._capture_control, 'Capture')
- else:
- return 0
- else:
- output = check_output(['amixer', 'get', 'Capture'],
- 'amixer: Could not get Capture level',
- self.parent.running_sugar)
- if output is None:
- return 100
- else:
- output = output[find(output, 'Front Left:'):]
- output = output[find(output, '[') + 1:]
- output = output[:find(output, '%]')]
- return int(output)
-
- def set_mic_gain(self, mic_val):
- '''Sets the MIC gain slider settings
- mic_val must be given as an integer between 0 and 100 indicating the
- percentage of the slider to be set'''
- if self._labels_available and self.parent.hw != XO1:
- self._set_volume(self._mic_gain_control, 'Mic', mic_val)
- else:
- output = check_output(
- ['amixer', 'set', 'Mic', "%d%s" % (mic_val, '%')],
- 'Problem with amixer set Mic',
- self.parent.running_sugar)
-
- def get_mic_gain(self):
- '''Gets the MIC gain slider settings. The value returned is an
- integer between 0-100 and is an indicative of the percentage 0 - 100%'''
- if self._labels_available and self.parent.hw != XO1:
- return self._get_volume(self._mic_gain_control, 'Mic')
- else:
- output = check_output(['amixer', 'get', 'Mic'],
- 'amixer: Could not get mic gain level',
- self.parent.running_sugar)
- if output is None:
- return 100
- else:
- output = output[find(output, 'Mono:'):]
- output = output[find(output, '[') + 1:]
- output = output[:find(output, '%]')]
- return int(output)
-
- def _set_sensor_type(self, mode=None, bias=None, gain=None, boost=None):
- '''Helper to modify (some) of the sensor settings.'''
- if mode is not None:
- self.set_dc_mode(mode)
- if bias is not None:
- self.set_bias(bias)
- if gain is not None:
- self.set_capture_gain(gain)
- if boost is not None:
- self.set_mic_boost(boost)
- self.save_state()
-
- def on_activity_quit(self):
- '''When Activity quits'''
- self.set_mic_boost(QUIT_MIC_BOOST)
- self.set_dc_mode(QUIT_DC_MODE_ENABLE)
- self.set_capture_gain(QUIT_CAPTURE_GAIN)
- self.set_bias(QUIT_BIAS)
- self.stop_sound_device()
-
-
-def check_output(command, warning, running_sugar=True):
- ''' Workaround for old systems without subprocess.check_output'''
- if hasattr(subprocess, 'check_output'):
- try:
- output = subprocess.check_output(command)
- except subprocess.CalledProcessError:
- debug_output(warning, running_sugar)
- return None
- else:
- import commands
-
- cmd = ''
- for c in command:
- cmd += c
- cmd += ' '
- (status, output) = commands.getstatusoutput(cmd)
- if status != 0:
- debug_output(warning, running_sugar)
- return None
- return output
diff --git a/plugins/audio_sensors/icons/sensoroff.svg b/plugins/audio_sensors/icons/sensoroff.svg
deleted file mode 100644
index 0a16670..0000000
--- a/plugins/audio_sensors/icons/sensoroff.svg
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="55"
- height="55"
- viewBox="0 0 55 55"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata15"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs13" />
-<rect
- width="42.763924"
- height="42.763924"
- x="6.1180382"
- y="6.1180382"
- id="rect2986"
- style="fill:#282828;fill-opacity:1;stroke:#282828;stroke-width:2.23607516;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><g
- transform="matrix(0.87078705,0,0,0.87078705,3.2821055,2.9298726)"
- id="network-wired_1_"
- style="display:block">
- <g
- id="network-wired">
- <line
- id="line3076"
- y2="23.993"
- y1="32.438999"
- x2="16.966999"
- x1="16.966999"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round" />
- <line
- id="line3078"
- y2="28.215"
- y1="28.215"
- x2="34.938"
- x1="29.636999"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round" />
-
- <rect
- width="9.7939997"
- height="7.599"
- x="42.157001"
- y="24.312"
- id="rect3080"
- style="fill:#ffffff;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round" />
- <path
- d="m 16.967,23.993 c 0,-2.334 -1.892,-4.224 -4.224,-4.224 -2.332,0 -4.223,1.889 -4.223,4.224"
- id="path3082"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 25.413,32.439 c 0,2.334 -1.891,4.224 -4.224,4.224 -2.332,0 -4.223,-1.89 -4.223,-4.224"
- id="path3084"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 25.413,32.439 c 0,-2.332 1.893,-4.226 4.224,-4.226"
- id="path3086"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 8.52,23.993 c 0,2.332 -1.892,4.222 -4.223,4.222"
- id="path3088"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
-
- <rect
- width="14.477"
- height="11.35"
- x="31.945"
- y="22.438"
- id="rect3090"
- style="fill:#ffffff;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- </g>
-</g></svg> \ No newline at end of file
diff --git a/plugins/audio_sensors/icons/sensoron.svg b/plugins/audio_sensors/icons/sensoron.svg
deleted file mode 100644
index d756860..0000000
--- a/plugins/audio_sensors/icons/sensoron.svg
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="55"
- height="55"
- viewBox="0 0 55 55"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata15"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs13" /><rect
- width="55"
- height="55"
- x="0"
- y="0"
- id="rect3269"
- style="fill:#ffd200;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
- transform="translate(0.27777716,18.796296)"
- id="g4054"><line
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-opacity:1"
- x1="17.778971"
- x2="17.778971"
- y1="12.381037"
- y2="5.0263696"
- id="line3076" /><line
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-opacity:1"
- x1="28.811842"
- x2="33.427887"
- y1="8.7028332"
- y2="8.7028332"
- id="line3078" /><rect
- width="8.5284882"
- height="6.6171107"
- x="39.7141"
- y="5.3041511"
- id="rect3080"
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:1.95927083;stroke-linecap:round;stroke-opacity:1" /><path
- d="m 17.778971,5.0263697 c 0,-2.032417 -1.647529,-3.6782045 -3.678204,-3.6782045 -2.030675,0 -3.677334,1.6449167 -3.677334,3.6782045"
- id="path3082"
- style="fill:none;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 25.133639,12.381037 c 0,2.032417 -1.646658,3.678205 -3.678205,3.678205 -2.030675,0 -3.677333,-1.645788 -3.677333,-3.678205"
- id="path3084"
- style="fill:none;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 25.133639,12.381037 c 0,-2.030675 1.6484,-3.679946 3.678204,-3.679946"
- id="path3086"
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 10.423433,5.0263697 c 0,2.0306754 -1.6475288,3.6764629 -3.6773334,3.6764629"
- id="path3088"
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><rect
- width="12.606384"
- height="9.8834333"
- x="30.821619"
- y="3.6722956"
- id="rect3090"
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /></g></svg> \ No newline at end of file
diff --git a/plugins/audio_sensors/ringbuffer.py b/plugins/audio_sensors/ringbuffer.py
deleted file mode 100644
index 2afb5c9..0000000
--- a/plugins/audio_sensors/ringbuffer.py
+++ /dev/null
@@ -1,108 +0,0 @@
-# Copyright (C) 2009, Benjamin Berg, Sebastian Berg
-# Copyright (C) 2010, Walter Bender
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-import numpy as np
-
-
-class RingBuffer1d(object):
- """This class implements an array being written in as a ring and that can
- be read from continuously ending with the newest data or starting with the
- oldest. It returns a numpy array copy of the data;
- """
-
- def __init__(self, length, dtype=None):
- """Initialize the 1 dimensional ring buffer with the given lengths.
- The initial values are all 0s
- """
- self.offset = 0
-
- self._data = np.zeros(length, dtype=dtype)
-
- self.stored = 0
-
- def fill(self, number):
- self._data.fill(number)
- self.offset = 0
-
- def append(self, data):
- """Append to the ring buffer (and overwrite old data). If len(data)
- is greater then the ring buffers length, the newest data takes
- precedence.
- """
- data = np.asarray(data)
-
- if len(self._data) == 0:
- return
-
- if len(data) >= len(self._data):
- self._data[:] = data[-len(self._data):]
- self.offset = 0
- self.stored = len(self._data)
-
- elif len(self._data) - self.offset >= len(data):
- self._data[self.offset: self.offset + len(data)] = data
- self.offset = self.offset + len(data)
- self.stored += len(data)
- else:
- self._data[self.offset:] = data[:len(self._data) - self.offset]
- self._data[:len(data) - (len(self._data) - self.offset)] = \
- data[-len(data) + (len(self._data) - self.offset):]
- self.offset = len(data) - (len(self._data) - self.offset)
- self.stored += len(data)
-
- if len(self._data) <= self.stored:
- self.read = self._read
-
- def read(self, number=None, step=1):
- """Read the ring Buffer. Number can be positive or negative.
- Positive values will give the latest information, negative values will
- give the newest added information from the buffer. (in normal order)
-
- Before the buffer is filled once: This returns just None
- """
- return np.array([])
-
- def _read(self, number=None, step=1):
- """Read the ring Buffer. Number can be positive or negative.
- Positive values will give the latest information, negative values will
- give the newest added information from the buffer. (in normal order)
- """
- if number == None:
- number = len(self._data) // step
-
- number *= step
- assert abs(number) <= len(self._data), \
- 'Number to read*step must be smaller then length'
-
- if number < 0:
- if abs(number) <= self.offset:
- return self._data[self.offset + number:self.offset:step]
-
- spam = (self.offset - 1) % step
-
- return np.concatenate(
- (self._data[step - spam - 1 + self.offset + number::step],
- self._data[spam:self.offset:step]))
-
- if number - (len(self._data) - self.offset) > 0:
- spam = ((self.offset + number) - self.offset - 1) % step
- return np.concatenate(
- (self._data[self.offset:self.offset + number:step],
- self._data[spam:number -
- (len(self._data) - self.offset):step]))
-
- return self._data[self.offset:self.offset + number:step].copy()
diff --git a/plugins/camera_sensor/camera_sensor.py b/plugins/camera_sensor/camera_sensor.py
deleted file mode 100644
index 6509a88..0000000
--- a/plugins/camera_sensor/camera_sensor.py
+++ /dev/null
@@ -1,308 +0,0 @@
-#!/usr/bin/env python
-#Copyright (c) 2011, 2012 Walter Bender
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import gst
-import gtk
-from fcntl import ioctl
-import os
-from time import time
-
-from gettext import gettext as _
-
-from plugins.camera_sensor.tacamera import Camera
-from plugins.camera_sensor.v4l2 import v4l2_control, V4L2_CID_AUTOGAIN, \
- VIDIOC_G_CTRL, VIDIOC_S_CTRL
-
-from plugins.plugin import Plugin
-
-from TurtleArt.tapalette import make_palette
-from TurtleArt.talogo import media_blocks_dictionary, primitive_dictionary
-from TurtleArt.tautils import get_path, debug_output
-from TurtleArt.taconstants import MEDIA_SHAPES, NO_IMPORT, SKIN_PATHS, \
- BLOCKS_WITH_SKIN
-
-
-class Camera_sensor(Plugin):
-
- def __init__(self, parent):
- ''' Make sure there is a camera device '''
- self._parent = parent
- self._status = False
- self._ag_control = None
- self.devices = []
- self.cameras = []
-
- if os.path.exists('/dev/video0'):
- self.devices.append('/dev/video0')
- if os.path.exists('/dev/video1'):
- self.devices.append('/dev/video1')
- if len(self.devices) > 0:
- self._status = True
- else:
- self._status = False
-
- def setup(self):
- ''' Set up the palettes '''
- sensors_palette = make_palette('sensor',
- colors=["#FF6060", "#A06060"],
- help_string=_(
- 'Palette of sensor blocks'),
- position=6)
- media_palette = make_palette('media',
- colors=["#A0FF00", "#80A000"],
- help_string=_('Palette of media objects'),
- position=7)
-
- # set up camera-specific blocks
- primitive_dictionary['read_camera'] = self.prim_read_camera
- media_blocks_dictionary['camera'] = self.prim_take_picture0
- media_blocks_dictionary['camera1'] = self.prim_take_picture1
-
- SKIN_PATHS.append('plugins/camera_sensor/images')
-
- if self._status:
- sensors_palette.add_block('luminance',
- style='box-style',
- label=_('brightness'),
- help_string=_(
- 'light level detected by camera'),
- value_block=True,
- prim_name='luminance')
- self._parent.lc.def_prim('luminance', 0,
- lambda self: primitive_dictionary['read_camera'](
- luminance_only=True))
-
- # Depreciated block
- sensors_palette.add_block('read_camera',
- hidden=True,
- style='box-style',
- label=_('brightness'),
- help_string=_(
- 'Average RGB color from camera \
-is pushed to the stack'),
- value_block=True,
- prim_name='read_camera')
- self._parent.lc.def_prim('read_camera', 0,
- lambda self: primitive_dictionary['read_camera']())
-
- media_palette.add_block('camera',
- style='box-style-media',
- label=' ',
- default='CAMERA',
- help_string=_('camera output'),
- content_block=True)
- if len(self.devices) > 1:
- media_palette.add_block('camera1',
- style='box-style-media',
- label=' ',
- default='CAMERA',
- help_string=_('camera output'),
- content_block=True)
- else:
- media_palette.add_block('camera1',
- hidden=True,
- style='box-style-media',
- label=' ',
- default='CAMERA',
- help_string=_('camera output'),
- content_block=True)
-
- else: # No camera, so blocks should do nothing
- sensors_palette.add_block('luminance',
- hidden=True,
- style='box-style',
- label=_('brightness'),
- help_string=\
- _('light level detected by camera'),
- value_block=True,
- prim_name='read_camera')
- self._parent.lc.def_prim('luminance', 0,
- lambda self: primitive_dictionary['read_camera'](
- luminance_only=True))
-
- # Depreciated block
- sensors_palette.add_block('read_camera',
- hidden=True,
- style='box-style',
- label=_('brightness'),
- help_string=_(
- 'Average RGB color from camera \
-is pushed to the stack'),
- value_block=True,
- prim_name='read_camera')
- self._parent.lc.def_prim('read_camera', 0,
- lambda self: primitive_dictionary['read_camera']())
-
- media_palette.add_block('camera',
- hidden=True,
- style='box-style-media',
- label=' ',
- default='CAMERA',
- help_string=_('camera output'),
- content_block=True)
-
- media_palette.add_block('camera1',
- hidden=True,
- style='box-style-media',
- label=' ',
- default='CAMERA',
- help_string=_('camera output'),
- content_block=True)
-
- NO_IMPORT.append('camera')
- BLOCKS_WITH_SKIN.append('camera')
- NO_IMPORT.append('camera1')
- BLOCKS_WITH_SKIN.append('camera1')
- MEDIA_SHAPES.append('camerasmall')
- MEDIA_SHAPES.append('cameraoff')
- MEDIA_SHAPES.append('camera1small')
- MEDIA_SHAPES.append('camera1off')
-
- def start(self):
- ''' Initialize the camera if there is an camera block in use '''
- if len(self._parent.block_list.get_similar_blocks('block',
- ['camera', 'camera1', 'read_camera', 'luminance'])) > 0:
- if self._status and len(self.cameras) == 0:
- for device in self.devices:
- self.cameras.append(Camera(device))
-
- def quit(self):
- ''' This gets called when the activity quits '''
- self._reset_the_camera()
-
- def stop(self):
- ''' This gets called by the stop button '''
- self._reset_the_camera()
-
- def clear(self):
- ''' This gets called by the clean button and erase button '''
- self._reset_the_camera()
-
- def _reset_the_camera(self):
- if self._status and len(self.cameras) > 0:
- for i, camera in enumerate(self.cameras):
- camera.stop_camera_input()
- self._set_autogain(1, camera=i) # enable AUTOGAIN
-
- def _status_report(self):
- debug_output('Reporting camera status: %s' % (str(self._status)),
- self._parent.running_sugar)
- return self._status
-
- # Block primitives used in talogo
-
- def prim_take_picture0(self):
- self._take_picture(camera=0)
-
- def prim_take_picture1(self):
- self._take_picture(camera=1)
-
- def _take_picture(self, camera=0):
- ''' method called by media block '''
- self._set_autogain(1, camera) # enable AUTOGAIN
- self._get_pixbuf_from_camera(camera)
- self._parent.lc.pixbuf = self.cameras[camera].pixbuf
-
- def prim_read_camera(self, luminance_only=False, camera=0):
- """ Read average pixel from camera and push b, g, r to the stack """
- self.luminance_only = luminance_only
- if not self._status:
- if self.luminance_only:
- return -1
- else:
- self._parent.lc.heap.append(-1)
- self._parent.lc.heap.append(-1)
- self._parent.lc.heap.append(-1)
- return
-
- array = None
- self._set_autogain(0, camera=camera) # disable AUTOGAIN
- self._get_pixbuf_from_camera(camera=camera)
- self.calc_luminance(camera=camera)
- if self.luminance_only:
- self._parent.lc.update_label_value('luminance', self.luminance)
- return self.luminance
- else:
- self._parent.lc.heap.append(self.b)
- self._parent.lc.heap.append(self.g)
- self._parent.lc.heap.append(self.r)
-
- def calc_luminance(self, camera=0):
- array = self.cameras[camera].pixbuf.get_pixels()
- width = self.cameras[camera].pixbuf.get_width()
- height = self.cameras[camera].pixbuf.get_height()
-
- if array is not None:
- length = int(len(array) / 3)
- if length != width * height:
- debug_output('array length != width x height (%d != %dx%d)' % \
- (length, width, height),
- self._parent.running_sugar)
-
- # Average the 100 pixels in the center of the screen
- r, g, b = 0, 0, 0
- row_offset = int((height / 2 - 5) * width * 3)
- column_offset = int(width / 2 - 5) * 3
- for y in range(10):
- i = row_offset + column_offset
- for x in range(10):
- r += ord(array[i])
- i += 1
- g += ord(array[i])
- i += 1
- b += ord(array[i])
- i += 1
- row_offset += width * 3
- if self.luminance_only:
- self.luminance = int((r * 0.3 + g * 0.6 + b * 0.1) / 100)
- else:
- self.r = int(r / 100)
- self.g = int(g / 100)
- self.b = int(b / 100)
- else:
- if self.luminance_only:
- self.luminance = -1
- else:
- self.r = -1
- self.g = -1
- self.b = -1
-
- def _set_autogain(self, state, camera=0):
- ''' 0 is off; 1 is on '''
- if self._ag_control is not None and self._ag_control.value == state:
- return
- try:
- video_capture_device = open(self.devices[camera], 'rw')
- except:
- video_capture_device = None
- debug_output('video capture device not available',
- self._parent.running_sugar)
- return
- self._ag_control = v4l2_control(V4L2_CID_AUTOGAIN)
- try:
- ioctl(video_capture_device, VIDIOC_G_CTRL, self._ag_control)
- self._ag_control.value = state
- ioctl(video_capture_device, VIDIOC_S_CTRL, self._ag_control)
- except:
- pass
- video_capture_device.close()
-
- def _get_pixbuf_from_camera(self, camera):
- ''' Regardless of how we get it, we want to return a pixbuf '''
- self._parent.lc.pixbuf = None
- if self._status:
- self.cameras[camera].start_camera_input()
diff --git a/plugins/camera_sensor/icons/sensoroff.svg b/plugins/camera_sensor/icons/sensoroff.svg
deleted file mode 100644
index 0a16670..0000000
--- a/plugins/camera_sensor/icons/sensoroff.svg
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="55"
- height="55"
- viewBox="0 0 55 55"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata15"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs13" />
-<rect
- width="42.763924"
- height="42.763924"
- x="6.1180382"
- y="6.1180382"
- id="rect2986"
- style="fill:#282828;fill-opacity:1;stroke:#282828;stroke-width:2.23607516;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><g
- transform="matrix(0.87078705,0,0,0.87078705,3.2821055,2.9298726)"
- id="network-wired_1_"
- style="display:block">
- <g
- id="network-wired">
- <line
- id="line3076"
- y2="23.993"
- y1="32.438999"
- x2="16.966999"
- x1="16.966999"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round" />
- <line
- id="line3078"
- y2="28.215"
- y1="28.215"
- x2="34.938"
- x1="29.636999"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round" />
-
- <rect
- width="9.7939997"
- height="7.599"
- x="42.157001"
- y="24.312"
- id="rect3080"
- style="fill:#ffffff;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round" />
- <path
- d="m 16.967,23.993 c 0,-2.334 -1.892,-4.224 -4.224,-4.224 -2.332,0 -4.223,1.889 -4.223,4.224"
- id="path3082"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 25.413,32.439 c 0,2.334 -1.891,4.224 -4.224,4.224 -2.332,0 -4.223,-1.89 -4.223,-4.224"
- id="path3084"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 25.413,32.439 c 0,-2.332 1.893,-4.226 4.224,-4.226"
- id="path3086"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 8.52,23.993 c 0,2.332 -1.892,4.222 -4.223,4.222"
- id="path3088"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
-
- <rect
- width="14.477"
- height="11.35"
- x="31.945"
- y="22.438"
- id="rect3090"
- style="fill:#ffffff;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- </g>
-</g></svg> \ No newline at end of file
diff --git a/plugins/camera_sensor/icons/sensoron.svg b/plugins/camera_sensor/icons/sensoron.svg
deleted file mode 100644
index d756860..0000000
--- a/plugins/camera_sensor/icons/sensoron.svg
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="55"
- height="55"
- viewBox="0 0 55 55"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata15"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs13" /><rect
- width="55"
- height="55"
- x="0"
- y="0"
- id="rect3269"
- style="fill:#ffd200;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
- transform="translate(0.27777716,18.796296)"
- id="g4054"><line
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-opacity:1"
- x1="17.778971"
- x2="17.778971"
- y1="12.381037"
- y2="5.0263696"
- id="line3076" /><line
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-opacity:1"
- x1="28.811842"
- x2="33.427887"
- y1="8.7028332"
- y2="8.7028332"
- id="line3078" /><rect
- width="8.5284882"
- height="6.6171107"
- x="39.7141"
- y="5.3041511"
- id="rect3080"
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:1.95927083;stroke-linecap:round;stroke-opacity:1" /><path
- d="m 17.778971,5.0263697 c 0,-2.032417 -1.647529,-3.6782045 -3.678204,-3.6782045 -2.030675,0 -3.677334,1.6449167 -3.677334,3.6782045"
- id="path3082"
- style="fill:none;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 25.133639,12.381037 c 0,2.032417 -1.646658,3.678205 -3.678205,3.678205 -2.030675,0 -3.677333,-1.645788 -3.677333,-3.678205"
- id="path3084"
- style="fill:none;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 25.133639,12.381037 c 0,-2.030675 1.6484,-3.679946 3.678204,-3.679946"
- id="path3086"
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 10.423433,5.0263697 c 0,2.0306754 -1.6475288,3.6764629 -3.6773334,3.6764629"
- id="path3088"
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><rect
- width="12.606384"
- height="9.8834333"
- x="30.821619"
- y="3.6722956"
- id="rect3090"
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /></g></svg> \ No newline at end of file
diff --git a/plugins/camera_sensor/images/camera1off.svg b/plugins/camera_sensor/images/camera1off.svg
deleted file mode 100644
index 2abf8d2..0000000
--- a/plugins/camera_sensor/images/camera1off.svg
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="55"
- height="55"
- viewBox="0 0 55 55"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata29"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs27">
-
-
-
-
-
-
-
-
-
- </defs><g
- transform="matrix(1.0741382,0,0,1.0741382,-2.9531883,-3.3782508)"
- id="media-flash-usb"
- style="stroke-width:2.20384002;stroke-miterlimit:4;stroke-dasharray:none;display:block"><g
- id="g3115"
- style="stroke-width:2.20384002;stroke-miterlimit:4;stroke-dasharray:none;display:inline"><path
- d="m 15.885,16.723 c -6.641,0 -12.023,5.385 -12.023,12.025 0,6.639 5.383,12.023 12.023,12.023 h 0.014 27.259 V 16.723 H 15.899"
- id="path3117"
- style="fill:#ffffff;stroke:#010101;stroke-width:2.20384002;stroke-miterlimit:4;stroke-dasharray:none" /><rect
- width="9.1400003"
- height="14.182"
- x="43.722"
- y="21.731001"
- id="rect3119"
- style="fill:#ffffff;stroke:#010101;stroke-width:2.20384002;stroke-miterlimit:4;stroke-dasharray:none" /></g></g><g
- transform="matrix(0.57244766,0,0,0.57244766,11.646526,13.522259)"
- id="camera-external"
- style="display:block"><g
- id="g5"
- style="display:inline"><g
- id="g7"><polygon
- points="48.209,38.973 48.209,14.52 38.532,14.52 34.904,9.862 18.783,9.862 15.155,14.52 6.29,14.52 6.29,38.973 "
- id="polygon9"
- style="fill:#ffffff" /></g><g
- id="g11"><polygon
- points="48.209,38.973 48.209,14.52 38.532,14.52 34.904,9.862 18.783,9.862 15.155,14.52 6.29,14.52 6.29,38.973 "
- id="polygon13"
- style="fill:none;stroke:#010101;stroke-width:3.5" /></g></g><path
- d="m 20.601,26.441 c 0,3.67 2.979,6.648 6.65,6.648 3.667,0 6.646,-2.979 6.646,-6.648 0,-3.668 -2.979,-6.652 -6.646,-6.652 -3.67,0 -6.65,2.986 -6.65,6.652 z"
- id="path15"
- style="fill:#ffffff;stroke:#010101;stroke-width:3.5;display:inline" /><rect
- width="6.2870002"
- height="4.1929998"
- x="38.098999"
- y="18.417999"
- id="rect17"
- style="fill:#010101;display:inline" /></g>
-</svg> \ No newline at end of file
diff --git a/plugins/camera_sensor/images/camera1small.svg b/plugins/camera_sensor/images/camera1small.svg
deleted file mode 100644
index 4d7f756..0000000
--- a/plugins/camera_sensor/images/camera1small.svg
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="29"
- height="15"
- viewBox="0 0 29 15"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata29"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs27">
-
-
-
-
-
-
-
-
-
- </defs><g
- transform="matrix(0.49560305,0,0,0.51274162,-0.00570885,-0.18882692)"
- id="g2994"><g
- transform="matrix(1.142777,0,0,1.142777,-3.1426369,-17.855891)"
- id="media-flash-usb"
- style="stroke-width:2.20384002;stroke-miterlimit:4;stroke-dasharray:none;display:block"><g
- id="g3115"
- style="stroke-width:2.20384002;stroke-miterlimit:4;stroke-dasharray:none;display:inline"><path
- d="m 15.885,16.723 c -6.641,0 -12.023,5.385 -12.023,12.025 0,6.639 5.383,12.023 12.023,12.023 h 0.014 27.259 V 16.723 H 15.899"
- id="path3117"
- style="fill:#ffffff;stroke:#010101;stroke-width:2.20384002;stroke-miterlimit:4;stroke-dasharray:none" /><rect
- width="9.1400003"
- height="14.182"
- x="43.722"
- y="21.731001"
- id="rect3119"
- style="fill:#ffffff;stroke:#010101;stroke-width:2.20384002;stroke-miterlimit:4;stroke-dasharray:none" /></g></g><g
- transform="matrix(0.57244766,0,0,0.57244766,11.646526,1.105918)"
- id="camera-external"
- style="display:block"><g
- id="g5"
- style="display:inline"><g
- id="g7"><polygon
- points="34.904,9.862 18.783,9.862 15.155,14.52 6.29,14.52 6.29,38.973 48.209,38.973 48.209,14.52 38.532,14.52 "
- id="polygon9"
- style="fill:#ffffff" /></g><g
- id="g11"><polygon
- points="34.904,9.862 18.783,9.862 15.155,14.52 6.29,14.52 6.29,38.973 48.209,38.973 48.209,14.52 38.532,14.52 "
- id="polygon13"
- style="fill:none;stroke:#010101;stroke-width:3.5" /></g></g><path
- d="m 20.601,26.441 c 0,3.67 2.979,6.648 6.65,6.648 3.667,0 6.646,-2.979 6.646,-6.648 0,-3.668 -2.979,-6.652 -6.646,-6.652 -3.67,0 -6.65,2.986 -6.65,6.652 z"
- id="path15"
- style="fill:#ffffff;stroke:#010101;stroke-width:3.5;display:inline" /><rect
- width="6.2870002"
- height="4.1929998"
- x="38.098999"
- y="18.417999"
- id="rect17"
- style="fill:#010101;display:inline" /></g></g>
-</svg> \ No newline at end of file
diff --git a/plugins/camera_sensor/images/cameraoff.svg b/plugins/camera_sensor/images/cameraoff.svg
deleted file mode 100644
index 54d9c86..0000000
--- a/plugins/camera_sensor/images/cameraoff.svg
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [
- <!ENTITY stroke_color "#010101">
- <!ENTITY fill_color "#ffffff">
-]><svg enable-background="new 0 0 55 55" height="55px" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="camera-external">
- <g display="inline">
- <g>
- <polygon fill="&fill_color;" points="38.532,14.52 34.904,9.862 18.783,9.862 15.155,14.52 6.29,14.52 6.29,38.973 48.209,38.973 48.209,14.52 "/>
- </g>
- <g>
- <polygon fill="none" points="38.532,14.52 34.904,9.862 18.783,9.862 15.155,14.52 6.29,14.52 6.29,38.973 48.209,38.973 48.209,14.52 " stroke="&stroke_color;" stroke-width="3.5"/>
- </g>
- </g>
- <path d="M20.601,26.441c0,3.67,2.979,6.648,6.65,6.648 c3.667,0,6.646-2.979,6.646-6.648c0-3.668-2.979-6.652-6.646-6.652C23.581,19.789,20.601,22.775,20.601,26.441z" display="inline" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/>
- <rect display="inline" fill="&stroke_color;" height="4.193" width="6.287" x="38.099" y="18.418"/>
-</g></svg> \ No newline at end of file
diff --git a/plugins/camera_sensor/images/camerasmall.svg b/plugins/camera_sensor/images/camerasmall.svg
deleted file mode 100644
index 690e940..0000000
--- a/plugins/camera_sensor/images/camerasmall.svg
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="26"
- height="18.668091"
- viewBox="0 0 26 18.668091"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata29"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs27">
-
-
-
-
-
-
-
-
-
- </defs><g
- transform="matrix(0.57244766,0,0,0.57244766,-2.5989125,-4.6436954)"
- id="camera-external"
- style="display:block"><g
- id="g5"
- style="display:inline"><g
- id="g7"><polygon
- points="48.209,14.52 38.532,14.52 34.904,9.862 18.783,9.862 15.155,14.52 6.29,14.52 6.29,38.973 48.209,38.973 "
- id="polygon9"
- style="fill:#ffffff" /></g><g
- id="g11"><polygon
- points="48.209,14.52 38.532,14.52 34.904,9.862 18.783,9.862 15.155,14.52 6.29,14.52 6.29,38.973 48.209,38.973 "
- id="polygon13"
- style="fill:none;stroke:#010101;stroke-width:3.5" /></g></g><path
- d="m 20.601,26.441 c 0,3.67 2.979,6.648 6.65,6.648 3.667,0 6.646,-2.979 6.646,-6.648 0,-3.668 -2.979,-6.652 -6.646,-6.652 -3.67,0 -6.65,2.986 -6.65,6.652 z"
- id="path15"
- style="fill:#ffffff;stroke:#010101;stroke-width:3.5;display:inline" /><rect
- width="6.2870002"
- height="4.1929998"
- x="38.098999"
- y="18.417999"
- id="rect17"
- style="fill:#010101;display:inline" /></g></svg> \ No newline at end of file
diff --git a/plugins/camera_sensor/tacamera.py b/plugins/camera_sensor/tacamera.py
deleted file mode 100644
index fc0804d..0000000
--- a/plugins/camera_sensor/tacamera.py
+++ /dev/null
@@ -1,69 +0,0 @@
-# -*- coding: utf-8 -*-
-#Copyright (c) 2010, Walter Bender
-#Copyright (c) 2010, Tony Forster
-
-#Permission is hereby granted, free of charge, to any person obtaining a copy
-#of this software and associated documentation files (the "Software"), to deal
-#in the Software without restriction, including without limitation the rights
-#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-#copies of the Software, and to permit persons to whom the Software is
-#furnished to do so, subject to the following conditions:
-
-#The above copyright notice and this permission notice shall be included in
-#all copies or substantial portions of the Software.
-
-#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-#THE SOFTWARE.
-
-import gst, time
-import gobject
-
-from TurtleArt.tautils import debug_output
-
-
-class Camera():
- ''' Sets up a pipe from the camera to a pixbuf and emits a signal
- when the image is ready. '''
-
- def __init__(self, device='/dev/video0'):
- ''' Prepare camera pipeline to pixbuf and signal watch '''
- self.pipe = gst.Pipeline('pipeline')
- v4l2src = gst.element_factory_make('v4l2src', None)
- v4l2src.props.device = device
- self.pipe.add(v4l2src)
- ffmpegcolorspace = gst.element_factory_make('ffmpegcolorspace', None)
- self.pipe.add(ffmpegcolorspace)
- gdkpixbufsink = gst.element_factory_make('gdkpixbufsink', None)
- self.pipe.add(gdkpixbufsink)
- gst.element_link_many(v4l2src, ffmpegcolorspace, gdkpixbufsink)
- if self.pipe is not None:
- self.bus = self.pipe.get_bus()
- self.bus.add_signal_watch()
- self.bus.connect('message', self._on_message)
- status = True
- else:
- status = False
-
- def _on_message(self, bus, message):
- ''' We get a message if a pixbuf is available '''
- if message.structure is not None:
- if message.structure.get_name() == 'pixbuf':
- self.pixbuf = message.structure['pixbuf']
- self.image_ready = True
-
- def start_camera_input(self):
- ''' Start grabbing '''
- self.pixbuf = None
- self.image_ready = False
- self.pipe.set_state(gst.STATE_PLAYING)
- while not self.image_ready:
- self.bus.poll(gst.MESSAGE_ANY, -1)
-
- def stop_camera_input(self):
- ''' Stop grabbing '''
- self.pipe.set_state(gst.STATE_NULL)
diff --git a/plugins/camera_sensor/v4l2.py b/plugins/camera_sensor/v4l2.py
deleted file mode 100644
index 9c052fd..0000000
--- a/plugins/camera_sensor/v4l2.py
+++ /dev/null
@@ -1,1914 +0,0 @@
-# Python bindings for the v4l2 userspace api
-
-# Copyright (C) 1999-2009 the contributors
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# Alternatively you can redistribute this file under the terms of the
-# BSD license as stated below:
-
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-# 3. The names of its contributors may not be used to endorse or promote
-# products derived from this software without specific prior written
-# permission.
-
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-"""
-Python bindings for the v4l2 userspace api in Linux 2.6.34
-"""
-
-# see linux/videodev2.h
-
-import ctypes
-
-
-_IOC_NRBITS = 8
-_IOC_TYPEBITS = 8
-_IOC_SIZEBITS = 14
-_IOC_DIRBITS = 2
-
-_IOC_NRSHIFT = 0
-_IOC_TYPESHIFT = _IOC_NRSHIFT + _IOC_NRBITS
-_IOC_SIZESHIFT = _IOC_TYPESHIFT + _IOC_TYPEBITS
-_IOC_DIRSHIFT = _IOC_SIZESHIFT + _IOC_SIZEBITS
-
-_IOC_NONE = 0
-_IOC_WRITE = 1
-_IOC_READ = 2
-
-
-def _IOC(dir_, type_, nr, size):
- return (
- ctypes.c_int32(dir_ << _IOC_DIRSHIFT).value |
- ctypes.c_int32(ord(type_) << _IOC_TYPESHIFT).value |
- ctypes.c_int32(nr << _IOC_NRSHIFT).value |
- ctypes.c_int32(size << _IOC_SIZESHIFT).value)
-
-
-def _IOC_TYPECHECK(t):
- return ctypes.sizeof(t)
-
-
-def _IO(type_, nr):
- return _IOC(_IOC_NONE, type_, nr, 0)
-
-
-def _IOW(type_, nr, size):
- return _IOC(_IOC_WRITE, type_, nr, _IOC_TYPECHECK(size))
-
-
-def _IOR(type_, nr, size):
- return _IOC(_IOC_READ, type_, nr, _IOC_TYPECHECK(size))
-
-
-def _IOWR(type_, nr, size):
- return _IOC(_IOC_READ | _IOC_WRITE, type_, nr, _IOC_TYPECHECK(size))
-
-
-#
-# type alias
-#
-
-enum = ctypes.c_uint
-c_int = ctypes.c_int
-
-
-#
-# time
-#
-
-class timeval(ctypes.Structure):
- _fields_ = [
- ('secs', ctypes.c_long),
- ('usecs', ctypes.c_long),
- ]
-
-
-#
-# v4l2
-#
-
-
-VIDEO_MAX_FRAME = 32
-
-
-VID_TYPE_CAPTURE = 1
-VID_TYPE_TUNER = 2
-VID_TYPE_TELETEXT = 4
-VID_TYPE_OVERLAY = 8
-VID_TYPE_CHROMAKEY = 16
-VID_TYPE_CLIPPING = 32
-VID_TYPE_FRAMERAM = 64
-VID_TYPE_SCALES = 128
-VID_TYPE_MONOCHROME = 256
-VID_TYPE_SUBCAPTURE = 512
-VID_TYPE_MPEG_DECODER = 1024
-VID_TYPE_MPEG_ENCODER = 2048
-VID_TYPE_MJPEG_DECODER = 4096
-VID_TYPE_MJPEG_ENCODER = 8192
-
-
-def v4l2_fourcc(a, b, c, d):
- return ord(a) | (ord(b) << 8) | (ord(c) << 16) | (ord(d) << 24)
-
-
-v4l2_field = enum
-(
- V4L2_FIELD_ANY,
- V4L2_FIELD_NONE,
- V4L2_FIELD_TOP,
- V4L2_FIELD_BOTTOM,
- V4L2_FIELD_INTERLACED,
- V4L2_FIELD_SEQ_TB,
- V4L2_FIELD_SEQ_BT,
- V4L2_FIELD_ALTERNATE,
- V4L2_FIELD_INTERLACED_TB,
- V4L2_FIELD_INTERLACED_BT,
-) = range(10)
-
-
-def V4L2_FIELD_HAS_TOP(field):
- return (
- field == V4L2_FIELD_TOP or
- field == V4L2_FIELD_INTERLACED or
- field == V4L2_FIELD_INTERLACED_TB or
- field == V4L2_FIELD_INTERLACED_BT or
- field == V4L2_FIELD_SEQ_TB or
- field == V4L2_FIELD_SEQ_BT)
-
-
-def V4L2_FIELD_HAS_BOTTOM(field):
- return (
- field == V4L2_FIELD_BOTTOM or
- field == V4L2_FIELD_INTERLACED or
- field == V4L2_FIELD_INTERLACED_TB or
- field == V4L2_FIELD_INTERLACED_BT or
- field == V4L2_FIELD_SEQ_TB or
- field == V4L2_FIELD_SEQ_BT)
-
-
-def V4L2_FIELD_HAS_BOTH(field):
- return (
- field == V4L2_FIELD_INTERLACED or
- field == V4L2_FIELD_INTERLACED_TB or
- field == V4L2_FIELD_INTERLACED_BT or
- field == V4L2_FIELD_SEQ_TB or
- field == V4L2_FIELD_SEQ_BT)
-
-
-v4l2_buf_type = enum
-(
- V4L2_BUF_TYPE_VIDEO_CAPTURE,
- V4L2_BUF_TYPE_VIDEO_OUTPUT,
- V4L2_BUF_TYPE_VIDEO_OVERLAY,
- V4L2_BUF_TYPE_VBI_CAPTURE,
- V4L2_BUF_TYPE_VBI_OUTPUT,
- V4L2_BUF_TYPE_SLICED_VBI_CAPTURE,
- V4L2_BUF_TYPE_SLICED_VBI_OUTPUT,
- V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY,
- V4L2_BUF_TYPE_PRIVATE,
-) = range(1, 9) + [0x80]
-
-
-v4l2_ctrl_type = enum
-(
- V4L2_CTRL_TYPE_INTEGER,
- V4L2_CTRL_TYPE_BOOLEAN,
- V4L2_CTRL_TYPE_MENU,
- V4L2_CTRL_TYPE_BUTTON,
- V4L2_CTRL_TYPE_INTEGER64,
- V4L2_CTRL_TYPE_CTRL_CLASS,
- V4L2_CTRL_TYPE_STRING,
-) = range(1, 8)
-
-
-v4l2_tuner_type = enum
-(
- V4L2_TUNER_RADIO,
- V4L2_TUNER_ANALOG_TV,
- V4L2_TUNER_DIGITAL_TV,
-) = range(1, 4)
-
-
-v4l2_memory = enum
-(
- V4L2_MEMORY_MMAP,
- V4L2_MEMORY_USERPTR,
- V4L2_MEMORY_OVERLAY,
-) = range(1, 4)
-
-
-v4l2_colorspace = enum
-(
- V4L2_COLORSPACE_SMPTE170M,
- V4L2_COLORSPACE_SMPTE240M,
- V4L2_COLORSPACE_REC709,
- V4L2_COLORSPACE_BT878,
- V4L2_COLORSPACE_470_SYSTEM_M,
- V4L2_COLORSPACE_470_SYSTEM_BG,
- V4L2_COLORSPACE_JPEG,
- V4L2_COLORSPACE_SRGB,
-) = range(1, 9)
-
-
-v4l2_priority = enum
-(
- V4L2_PRIORITY_UNSET,
- V4L2_PRIORITY_BACKGROUND,
- V4L2_PRIORITY_INTERACTIVE,
- V4L2_PRIORITY_RECORD,
- V4L2_PRIORITY_DEFAULT,
-) = range(0, 4) + [2]
-
-
-class v4l2_rect(ctypes.Structure):
- _fields_ = [
- ('left', ctypes.c_int32),
- ('top', ctypes.c_int32),
- ('width', ctypes.c_int32),
- ('height', ctypes.c_int32),
- ]
-
-
-class v4l2_fract(ctypes.Structure):
- _fields_ = [
- ('numerator', ctypes.c_uint32),
- ('denominator', ctypes.c_uint32),
- ]
-
-
-#
-# Driver capabilities
-#
-
-class v4l2_capability(ctypes.Structure):
- _fields_ = [
- ('driver', ctypes.c_char * 16),
- ('card', ctypes.c_char * 32),
- ('bus_info', ctypes.c_char * 32),
- ('version', ctypes.c_uint32),
- ('capabilities', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 4),
- ]
-
-
-#
-# Values for 'capabilities' field
-#
-
-V4L2_CAP_VIDEO_CAPTURE = 0x00000001
-V4L2_CAP_VIDEO_OUTPUT = 0x00000002
-V4L2_CAP_VIDEO_OVERLAY = 0x00000004
-V4L2_CAP_VBI_CAPTURE = 0x00000010
-V4L2_CAP_VBI_OUTPUT = 0x00000020
-V4L2_CAP_SLICED_VBI_CAPTURE = 0x00000040
-V4L2_CAP_SLICED_VBI_OUTPUT = 0x00000080
-V4L2_CAP_RDS_CAPTURE = 0x00000100
-V4L2_CAP_VIDEO_OUTPUT_OVERLAY = 0x00000200
-V4L2_CAP_HW_FREQ_SEEK = 0x00000400
-V4L2_CAP_RDS_OUTPUT = 0x00000800
-
-V4L2_CAP_TUNER = 0x00010000
-V4L2_CAP_AUDIO = 0x00020000
-V4L2_CAP_RADIO = 0x00040000
-V4L2_CAP_MODULATOR = 0x00080000
-
-V4L2_CAP_READWRITE = 0x01000000
-V4L2_CAP_ASYNCIO = 0x02000000
-V4L2_CAP_STREAMING = 0x04000000
-
-
-#
-# Video image format
-#
-
-class v4l2_pix_format(ctypes.Structure):
- _fields_ = [
- ('width', ctypes.c_uint32),
- ('height', ctypes.c_uint32),
- ('pixelformat', ctypes.c_uint32),
- ('field', v4l2_field),
- ('bytesperline', ctypes.c_uint32),
- ('sizeimage', ctypes.c_uint32),
- ('colorspace', v4l2_colorspace),
- ('priv', ctypes.c_uint32),
- ]
-
-# RGB formats
-V4L2_PIX_FMT_RGB332 = v4l2_fourcc('R', 'G', 'B', '1')
-V4L2_PIX_FMT_RGB444 = v4l2_fourcc('R', '4', '4', '4')
-V4L2_PIX_FMT_RGB555 = v4l2_fourcc('R', 'G', 'B', 'O')
-V4L2_PIX_FMT_RGB565 = v4l2_fourcc('R', 'G', 'B', 'P')
-V4L2_PIX_FMT_RGB555X = v4l2_fourcc('R', 'G', 'B', 'Q')
-V4L2_PIX_FMT_RGB565X = v4l2_fourcc('R', 'G', 'B', 'R')
-V4L2_PIX_FMT_BGR24 = v4l2_fourcc('B', 'G', 'R', '3')
-V4L2_PIX_FMT_RGB24 = v4l2_fourcc('R', 'G', 'B', '3')
-V4L2_PIX_FMT_BGR32 = v4l2_fourcc('B', 'G', 'R', '4')
-V4L2_PIX_FMT_RGB32 = v4l2_fourcc('R', 'G', 'B', '4')
-
-# Grey formats
-V4L2_PIX_FMT_GREY = v4l2_fourcc('G', 'R', 'E', 'Y')
-V4L2_PIX_FMT_Y10 = v4l2_fourcc('Y', '1', '0', ' ')
-V4L2_PIX_FMT_Y16 = v4l2_fourcc('Y', '1', '6', ' ')
-
-# Palette formats
-V4L2_PIX_FMT_PAL8 = v4l2_fourcc('P', 'A', 'L', '8')
-
-# Luminance+Chrominance formats
-V4L2_PIX_FMT_YVU410 = v4l2_fourcc('Y', 'V', 'U', '9')
-V4L2_PIX_FMT_YVU420 = v4l2_fourcc('Y', 'V', '1', '2')
-V4L2_PIX_FMT_YUYV = v4l2_fourcc('Y', 'U', 'Y', 'V')
-V4L2_PIX_FMT_YYUV = v4l2_fourcc('Y', 'Y', 'U', 'V')
-V4L2_PIX_FMT_YVYU = v4l2_fourcc('Y', 'V', 'Y', 'U')
-V4L2_PIX_FMT_UYVY = v4l2_fourcc('U', 'Y', 'V', 'Y')
-V4L2_PIX_FMT_VYUY = v4l2_fourcc('V', 'Y', 'U', 'Y')
-V4L2_PIX_FMT_YUV422P = v4l2_fourcc('4', '2', '2', 'P')
-V4L2_PIX_FMT_YUV411P = v4l2_fourcc('4', '1', '1', 'P')
-V4L2_PIX_FMT_Y41P = v4l2_fourcc('Y', '4', '1', 'P')
-V4L2_PIX_FMT_YUV444 = v4l2_fourcc('Y', '4', '4', '4')
-V4L2_PIX_FMT_YUV555 = v4l2_fourcc('Y', 'U', 'V', 'O')
-V4L2_PIX_FMT_YUV565 = v4l2_fourcc('Y', 'U', 'V', 'P')
-V4L2_PIX_FMT_YUV32 = v4l2_fourcc('Y', 'U', 'V', '4')
-V4L2_PIX_FMT_YUV410 = v4l2_fourcc('Y', 'U', 'V', '9')
-V4L2_PIX_FMT_YUV420 = v4l2_fourcc('Y', 'U', '1', '2')
-V4L2_PIX_FMT_HI240 = v4l2_fourcc('H', 'I', '2', '4')
-V4L2_PIX_FMT_HM12 = v4l2_fourcc('H', 'M', '1', '2')
-
-# two planes -- one Y, one Cr + Cb interleaved
-V4L2_PIX_FMT_NV12 = v4l2_fourcc('N', 'V', '1', '2')
-V4L2_PIX_FMT_NV21 = v4l2_fourcc('N', 'V', '2', '1')
-V4L2_PIX_FMT_NV16 = v4l2_fourcc('N', 'V', '1', '6')
-V4L2_PIX_FMT_NV61 = v4l2_fourcc('N', 'V', '6', '1')
-
-# Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm
-V4L2_PIX_FMT_SBGGR8 = v4l2_fourcc('B', 'A', '8', '1')
-V4L2_PIX_FMT_SGBRG8 = v4l2_fourcc('G', 'B', 'R', 'G')
-V4L2_PIX_FMT_SGRBG8 = v4l2_fourcc('G', 'R', 'B', 'G')
-V4L2_PIX_FMT_SRGGB8 = v4l2_fourcc('R', 'G', 'G', 'B')
-V4L2_PIX_FMT_SBGGR10 = v4l2_fourcc('B', 'G', '1', '0')
-V4L2_PIX_FMT_SGBRG10 = v4l2_fourcc('G', 'B', '1', '0')
-V4L2_PIX_FMT_SGRBG10 = v4l2_fourcc('B', 'A', '1', '0')
-V4L2_PIX_FMT_SRGGB10 = v4l2_fourcc('R', 'G', '1', '0')
-V4L2_PIX_FMT_SGRBG10DPCM8 = v4l2_fourcc('B', 'D', '1', '0')
-V4L2_PIX_FMT_SBGGR16 = v4l2_fourcc('B', 'Y', 'R', '2')
-
-# compressed formats
-V4L2_PIX_FMT_MJPEG = v4l2_fourcc('M', 'J', 'P', 'G')
-V4L2_PIX_FMT_JPEG = v4l2_fourcc('J', 'P', 'E', 'G')
-V4L2_PIX_FMT_DV = v4l2_fourcc('d', 'v', 's', 'd')
-V4L2_PIX_FMT_MPEG = v4l2_fourcc('M', 'P', 'E', 'G')
-
-# Vendor-specific formats
-V4L2_PIX_FMT_CPIA1 = v4l2_fourcc('C', 'P', 'I', 'A')
-V4L2_PIX_FMT_WNVA = v4l2_fourcc('W', 'N', 'V', 'A')
-V4L2_PIX_FMT_SN9C10X = v4l2_fourcc('S', '9', '1', '0')
-V4L2_PIX_FMT_SN9C20X_I420 = v4l2_fourcc('S', '9', '2', '0')
-V4L2_PIX_FMT_PWC1 = v4l2_fourcc('P', 'W', 'C', '1')
-V4L2_PIX_FMT_PWC2 = v4l2_fourcc('P', 'W', 'C', '2')
-V4L2_PIX_FMT_ET61X251 = v4l2_fourcc('E', '6', '2', '5')
-V4L2_PIX_FMT_SPCA501 = v4l2_fourcc('S', '5', '0', '1')
-V4L2_PIX_FMT_SPCA505 = v4l2_fourcc('S', '5', '0', '5')
-V4L2_PIX_FMT_SPCA508 = v4l2_fourcc('S', '5', '0', '8')
-V4L2_PIX_FMT_SPCA561 = v4l2_fourcc('S', '5', '6', '1')
-V4L2_PIX_FMT_PAC207 = v4l2_fourcc('P', '2', '0', '7')
-V4L2_PIX_FMT_MR97310A = v4l2_fourcc('M', '3', '1', '0')
-V4L2_PIX_FMT_SN9C2028 = v4l2_fourcc('S', 'O', 'N', 'X')
-V4L2_PIX_FMT_SQ905C = v4l2_fourcc('9', '0', '5', 'C')
-V4L2_PIX_FMT_PJPG = v4l2_fourcc('P', 'J', 'P', 'G')
-V4L2_PIX_FMT_OV511 = v4l2_fourcc('O', '5', '1', '1')
-V4L2_PIX_FMT_OV518 = v4l2_fourcc('O', '5', '1', '8')
-V4L2_PIX_FMT_STV0680 = v4l2_fourcc('S', '6', '8', '0')
-
-
-#
-# Format enumeration
-#
-
-class v4l2_fmtdesc(ctypes.Structure):
- _fields_ = [
- ('index', ctypes.c_uint32),
- ('type', ctypes.c_int),
- ('flags', ctypes.c_uint32),
- ('description', ctypes.c_char * 32),
- ('pixelformat', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 4),
- ]
-
-V4L2_FMT_FLAG_COMPRESSED = 0x0001
-V4L2_FMT_FLAG_EMULATED = 0x0002
-
-
-#
-# Experimental frame size and frame rate enumeration
-#
-
-v4l2_frmsizetypes = enum
-(
- V4L2_FRMSIZE_TYPE_DISCRETE,
- V4L2_FRMSIZE_TYPE_CONTINUOUS,
- V4L2_FRMSIZE_TYPE_STEPWISE,
-) = range(1, 4)
-
-
-class v4l2_frmsize_discrete(ctypes.Structure):
- _fields_ = [
- ('width', ctypes.c_uint32),
- ('height', ctypes.c_uint32),
- ]
-
-
-class v4l2_frmsize_stepwise(ctypes.Structure):
- _fields_ = [
- ('min_width', ctypes.c_uint32),
- ('min_height', ctypes.c_uint32),
- ('step_width', ctypes.c_uint32),
- ('min_height', ctypes.c_uint32),
- ('max_height', ctypes.c_uint32),
- ('step_height', ctypes.c_uint32),
- ]
-
-
-class v4l2_frmsizeenum(ctypes.Structure):
- class _u(ctypes.Union):
- _fields_ = [
- ('discrete', v4l2_frmsize_discrete),
- ('stepwise', v4l2_frmsize_stepwise),
- ]
-
- _fields_ = [
- ('index', ctypes.c_uint32),
- ('pixel_format', ctypes.c_uint32),
- ('type', ctypes.c_uint32),
- ('_u', _u),
- ('reserved', ctypes.c_uint32 * 2)
- ]
-
- _anonymous_ = ('_u',)
-
-
-#
-# Frame rate enumeration
-#
-
-v4l2_frmivaltypes = enum
-(
- V4L2_FRMIVAL_TYPE_DISCRETE,
- V4L2_FRMIVAL_TYPE_CONTINUOUS,
- V4L2_FRMIVAL_TYPE_STEPWISE,
-) = range(1, 4)
-
-
-class v4l2_frmival_stepwise(ctypes.Structure):
- _fields_ = [
- ('min', v4l2_fract),
- ('max', v4l2_fract),
- ('step', v4l2_fract),
- ]
-
-
-class v4l2_frmivalenum(ctypes.Structure):
- class _u(ctypes.Union):
- _fields_ = [
- ('discrete', v4l2_fract),
- ('stepwise', v4l2_frmival_stepwise),
- ]
-
- _fields_ = [
- ('index', ctypes.c_uint32),
- ('pixel_format', ctypes.c_uint32),
- ('width', ctypes.c_uint32),
- ('height', ctypes.c_uint32),
- ('type', ctypes.c_uint32),
- ('_u', _u),
- ('reserved', ctypes.c_uint32 * 2),
- ]
-
- _anonymous_ = ('_u',)
-
-
-#
-# Timecode
-#
-
-class v4l2_timecode(ctypes.Structure):
- _fields_ = [
- ('type', ctypes.c_uint32),
- ('flags', ctypes.c_uint32),
- ('frames', ctypes.c_uint8),
- ('seconds', ctypes.c_uint8),
- ('minutes', ctypes.c_uint8),
- ('hours', ctypes.c_uint8),
- ('userbits', ctypes.c_uint8 * 4),
- ]
-
-
-V4L2_TC_TYPE_24FPS = 1
-V4L2_TC_TYPE_25FPS = 2
-V4L2_TC_TYPE_30FPS = 3
-V4L2_TC_TYPE_50FPS = 4
-V4L2_TC_TYPE_60FPS = 5
-
-V4L2_TC_FLAG_DROPFRAME = 0x0001
-V4L2_TC_FLAG_COLORFRAME = 0x0002
-V4L2_TC_USERBITS_field = 0x000C
-V4L2_TC_USERBITS_USERDEFINED = 0x0000
-V4L2_TC_USERBITS_8BITCHARS = 0x0008
-
-
-class v4l2_jpegcompression(ctypes.Structure):
- _fields_ = [
- ('quality', ctypes.c_int),
- ('APPn', ctypes.c_int),
- ('APP_len', ctypes.c_int),
- ('APP_data', ctypes.c_char * 60),
- ('COM_len', ctypes.c_int),
- ('COM_data', ctypes.c_char * 60),
- ('jpeg_markers', ctypes.c_uint32),
- ]
-
-
-V4L2_JPEG_MARKER_DHT = 1 << 3
-V4L2_JPEG_MARKER_DQT = 1 << 4
-V4L2_JPEG_MARKER_DRI = 1 << 5
-V4L2_JPEG_MARKER_COM = 1 << 6
-V4L2_JPEG_MARKER_APP = 1 << 7
-
-
-#
-# Memory-mapping buffers
-#
-
-class v4l2_requestbuffers(ctypes.Structure):
- _fields_ = [
- ('count', ctypes.c_uint32),
- ('type', v4l2_buf_type),
- ('memory', v4l2_memory),
- ('reserved', ctypes.c_uint32 * 2),
- ]
-
-
-class v4l2_buffer(ctypes.Structure):
- class _u(ctypes.Union):
- _fields_ = [
- ('offset', ctypes.c_uint32),
- ('userptr', ctypes.c_ulong),
- ]
-
- _fields_ = [
- ('index', ctypes.c_uint32),
- ('type', v4l2_buf_type),
- ('bytesused', ctypes.c_uint32),
- ('flags', ctypes.c_uint32),
- ('field', v4l2_field),
- ('timestamp', timeval),
- ('timecode', v4l2_timecode),
- ('sequence', ctypes.c_uint32),
- ('memory', v4l2_memory),
- ('m', _u),
- ('length', ctypes.c_uint32),
- ('input', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32),
- ]
-
-
-V4L2_BUF_FLAG_MAPPED = 0x0001
-V4L2_BUF_FLAG_QUEUED = 0x0002
-V4L2_BUF_FLAG_DONE = 0x0004
-V4L2_BUF_FLAG_KEYFRAME = 0x0008
-V4L2_BUF_FLAG_PFRAME = 0x0010
-V4L2_BUF_FLAG_BFRAME = 0x0020
-V4L2_BUF_FLAG_TIMECODE = 0x0100
-V4L2_BUF_FLAG_INPUT = 0x0200
-
-
-#
-# Overlay preview
-#
-
-class v4l2_framebuffer(ctypes.Structure):
- _fields_ = [
- ('capability', ctypes.c_uint32),
- ('flags', ctypes.c_uint32),
- ('base', ctypes.c_void_p),
- ('fmt', v4l2_pix_format),
- ]
-
-V4L2_FBUF_CAP_EXTERNOVERLAY = 0x0001
-V4L2_FBUF_CAP_CHROMAKEY = 0x0002
-V4L2_FBUF_CAP_LIST_CLIPPING = 0x0004
-V4L2_FBUF_CAP_BITMAP_CLIPPING = 0x0008
-V4L2_FBUF_CAP_LOCAL_ALPHA = 0x0010
-V4L2_FBUF_CAP_GLOBAL_ALPHA = 0x0020
-V4L2_FBUF_CAP_LOCAL_INV_ALPHA = 0x0040
-V4L2_FBUF_CAP_SRC_CHROMAKEY = 0x0080
-
-V4L2_FBUF_FLAG_PRIMARY = 0x0001
-V4L2_FBUF_FLAG_OVERLAY = 0x0002
-V4L2_FBUF_FLAG_CHROMAKEY = 0x0004
-V4L2_FBUF_FLAG_LOCAL_ALPHA = 0x0008
-V4L2_FBUF_FLAG_GLOBAL_ALPHA = 0x0010
-V4L2_FBUF_FLAG_LOCAL_INV_ALPHA = 0x0020
-V4L2_FBUF_FLAG_SRC_CHROMAKEY = 0x0040
-
-
-class v4l2_clip(ctypes.Structure):
- pass
-v4l2_clip._fields_ = [
- ('c', v4l2_rect),
- ('next', ctypes.POINTER(v4l2_clip)),
-]
-
-
-class v4l2_window(ctypes.Structure):
- _fields_ = [
- ('w', v4l2_rect),
- ('field', v4l2_field),
- ('chromakey', ctypes.c_uint32),
- ('clips', ctypes.POINTER(v4l2_clip)),
- ('clipcount', ctypes.c_uint32),
- ('bitmap', ctypes.c_void_p),
- ('global_alpha', ctypes.c_uint8),
- ]
-
-
-#
-# Capture parameters
-#
-
-class v4l2_captureparm(ctypes.Structure):
- _fields_ = [
- ('capability', ctypes.c_uint32),
- ('capturemode', ctypes.c_uint32),
- ('timeperframe', v4l2_fract),
- ('extendedmode', ctypes.c_uint32),
- ('readbuffers', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 4),
- ]
-
-
-V4L2_MODE_HIGHQUALITY = 0x0001
-V4L2_CAP_TIMEPERFRAME = 0x1000
-
-
-class v4l2_outputparm(ctypes.Structure):
- _fields_ = [
- ('capability', ctypes.c_uint32),
- ('outputmode', ctypes.c_uint32),
- ('timeperframe', v4l2_fract),
- ('extendedmode', ctypes.c_uint32),
- ('writebuffers', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 4),
- ]
-
-
-#
-# Input image cropping
-#
-
-class v4l2_cropcap(ctypes.Structure):
- _fields_ = [
- ('type', v4l2_buf_type),
- ('bounds', v4l2_rect),
- ('defrect', v4l2_rect),
- ('pixelaspect', v4l2_fract),
- ]
-
-
-class v4l2_crop(ctypes.Structure):
- _fields_ = [
- ('type', ctypes.c_int),
- ('c', v4l2_rect),
- ]
-
-
-#
-# Analog video standard
-#
-
-v4l2_std_id = ctypes.c_uint64
-
-
-V4L2_STD_PAL_B = 0x00000001
-V4L2_STD_PAL_B1 = 0x00000002
-V4L2_STD_PAL_G = 0x00000004
-V4L2_STD_PAL_H = 0x00000008
-V4L2_STD_PAL_I = 0x00000010
-V4L2_STD_PAL_D = 0x00000020
-V4L2_STD_PAL_D1 = 0x00000040
-V4L2_STD_PAL_K = 0x00000080
-
-V4L2_STD_PAL_M = 0x00000100
-V4L2_STD_PAL_N = 0x00000200
-V4L2_STD_PAL_Nc = 0x00000400
-V4L2_STD_PAL_60 = 0x00000800
-
-V4L2_STD_NTSC_M = 0x00001000
-V4L2_STD_NTSC_M_JP = 0x00002000
-V4L2_STD_NTSC_443 = 0x00004000
-V4L2_STD_NTSC_M_KR = 0x00008000
-
-V4L2_STD_SECAM_B = 0x00010000
-V4L2_STD_SECAM_D = 0x00020000
-V4L2_STD_SECAM_G = 0x00040000
-V4L2_STD_SECAM_H = 0x00080000
-V4L2_STD_SECAM_K = 0x00100000
-V4L2_STD_SECAM_K1 = 0x00200000
-V4L2_STD_SECAM_L = 0x00400000
-V4L2_STD_SECAM_LC = 0x00800000
-
-V4L2_STD_ATSC_8_VSB = 0x01000000
-V4L2_STD_ATSC_16_VSB = 0x02000000
-
-
-# some common needed stuff
-V4L2_STD_PAL_BG = (V4L2_STD_PAL_B | V4L2_STD_PAL_B1 | V4L2_STD_PAL_G)
-V4L2_STD_PAL_DK = (V4L2_STD_PAL_D | V4L2_STD_PAL_D1 | V4L2_STD_PAL_K)
-V4L2_STD_PAL = (V4L2_STD_PAL_BG | V4L2_STD_PAL_DK | V4L2_STD_PAL_H | V4L2_STD_PAL_I)
-V4L2_STD_NTSC = (V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_M_KR)
-V4L2_STD_SECAM_DK = (V4L2_STD_SECAM_D | V4L2_STD_SECAM_K | V4L2_STD_SECAM_K1)
-V4L2_STD_SECAM = (V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H | V4L2_STD_SECAM_DK | V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)
-
-V4L2_STD_525_60 = (V4L2_STD_PAL_M | V4L2_STD_PAL_60 | V4L2_STD_NTSC | V4L2_STD_NTSC_443)
-V4L2_STD_625_50 = (V4L2_STD_PAL | V4L2_STD_PAL_N | V4L2_STD_PAL_Nc | V4L2_STD_SECAM)
-V4L2_STD_ATSC = (V4L2_STD_ATSC_8_VSB | V4L2_STD_ATSC_16_VSB)
-
-V4L2_STD_UNKNOWN = 0
-V4L2_STD_ALL = (V4L2_STD_525_60 | V4L2_STD_625_50)
-
-# some merged standards
-V4L2_STD_MN = (V4L2_STD_PAL_M | V4L2_STD_PAL_N | V4L2_STD_PAL_Nc | V4L2_STD_NTSC)
-V4L2_STD_B = (V4L2_STD_PAL_B | V4L2_STD_PAL_B1 | V4L2_STD_SECAM_B)
-V4L2_STD_GH = (V4L2_STD_PAL_G | V4L2_STD_PAL_H|V4L2_STD_SECAM_G | V4L2_STD_SECAM_H)
-V4L2_STD_DK = (V4L2_STD_PAL_DK | V4L2_STD_SECAM_DK)
-
-
-class v4l2_standard(ctypes.Structure):
- _fields_ = [
- ('index', ctypes.c_uint32),
- ('id', v4l2_std_id),
- ('name', ctypes.c_char * 24),
- ('frameperiod', v4l2_fract),
- ('framelines', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 4),
- ]
-
-
-#
-# Video timings dv preset
-#
-
-class v4l2_dv_preset(ctypes.Structure):
- _fields_ = [
- ('preset', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 4)
- ]
-
-
-#
-# DV preset enumeration
-#
-
-class v4l2_dv_enum_preset(ctypes.Structure):
- _fields_ = [
- ('index', ctypes.c_uint32),
- ('preset', ctypes.c_uint32),
- ('name', ctypes.c_char * 32),
- ('width', ctypes.c_uint32),
- ('height', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 4),
- ]
-
-#
-# DV preset values
-#
-
-V4L2_DV_INVALID = 0
-V4L2_DV_480P59_94 = 1
-V4L2_DV_576P50 = 2
-V4L2_DV_720P24 = 3
-V4L2_DV_720P25 = 4
-V4L2_DV_720P30 = 5
-V4L2_DV_720P50 = 6
-V4L2_DV_720P59_94 = 7
-V4L2_DV_720P60 = 8
-V4L2_DV_1080I29_97 = 9
-V4L2_DV_1080I30 = 10
-V4L2_DV_1080I25 = 11
-V4L2_DV_1080I50 = 12
-V4L2_DV_1080I60 = 13
-V4L2_DV_1080P24 = 14
-V4L2_DV_1080P25 = 15
-V4L2_DV_1080P30 = 16
-V4L2_DV_1080P50 = 17
-V4L2_DV_1080P60 = 18
-
-
-#
-# DV BT timings
-#
-
-class v4l2_bt_timings(ctypes.Structure):
- _fields_ = [
- ('width', ctypes.c_uint32),
- ('height', ctypes.c_uint32),
- ('interlaced', ctypes.c_uint32),
- ('polarities', ctypes.c_uint32),
- ('pixelclock', ctypes.c_uint64),
- ('hfrontporch', ctypes.c_uint32),
- ('hsync', ctypes.c_uint32),
- ('hbackporch', ctypes.c_uint32),
- ('vfrontporch', ctypes.c_uint32),
- ('vsync', ctypes.c_uint32),
- ('vbackporch', ctypes.c_uint32),
- ('il_vfrontporch', ctypes.c_uint32),
- ('il_vsync', ctypes.c_uint32),
- ('il_vbackporch', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 16),
- ]
-
- _pack_ = True
-
-# Interlaced or progressive format
-V4L2_DV_PROGRESSIVE = 0
-V4L2_DV_INTERLACED = 1
-
-# Polarities. If bit is not set, it is assumed to be negative polarity
-V4L2_DV_VSYNC_POS_POL = 0x00000001
-V4L2_DV_HSYNC_POS_POL = 0x00000002
-
-
-class v4l2_dv_timings(ctypes.Structure):
- class _u(ctypes.Union):
- _fields_ = [
- ('bt', v4l2_bt_timings),
- ('reserved', ctypes.c_uint32 * 32),
- ]
-
- _fields_ = [
- ('type', ctypes.c_uint32),
- ('_u', _u),
- ]
-
- _anonymous_ = ('_u',)
- _pack_ = True
-
-
-# Values for the type field
-V4L2_DV_BT_656_1120 = 0
-
-
-#
-# Video inputs
-#
-
-class v4l2_input(ctypes.Structure):
- _fields_ = [
- ('index', ctypes.c_uint32),
- ('name', ctypes.c_char * 32),
- ('type', ctypes.c_uint32),
- ('audioset', ctypes.c_uint32),
- ('tuner', ctypes.c_uint32),
- ('std', v4l2_std_id),
- ('status', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 4),
- ]
-
-
-V4L2_INPUT_TYPE_TUNER = 1
-V4L2_INPUT_TYPE_CAMERA = 2
-
-V4L2_IN_ST_NO_POWER = 0x00000001
-V4L2_IN_ST_NO_SIGNAL = 0x00000002
-V4L2_IN_ST_NO_COLOR = 0x00000004
-
-V4L2_IN_ST_HFLIP = 0x00000010
-V4L2_IN_ST_VFLIP = 0x00000020
-
-V4L2_IN_ST_NO_H_LOCK = 0x00000100
-V4L2_IN_ST_COLOR_KILL = 0x00000200
-
-V4L2_IN_ST_NO_SYNC = 0x00010000
-V4L2_IN_ST_NO_EQU = 0x00020000
-V4L2_IN_ST_NO_CARRIER = 0x00040000
-
-V4L2_IN_ST_MACROVISION = 0x01000000
-V4L2_IN_ST_NO_ACCESS = 0x02000000
-V4L2_IN_ST_VTR = 0x04000000
-
-V4L2_IN_CAP_PRESETS = 0x00000001
-V4L2_IN_CAP_CUSTOM_TIMINGS = 0x00000002
-V4L2_IN_CAP_STD = 0x00000004
-
-#
-# Video outputs
-#
-
-class v4l2_output(ctypes.Structure):
- _fields_ = [
- ('index', ctypes.c_uint32),
- ('name', ctypes.c_char * 32),
- ('type', ctypes.c_uint32),
- ('audioset', ctypes.c_uint32),
- ('modulator', ctypes.c_uint32),
- ('std', v4l2_std_id),
- ('reserved', ctypes.c_uint32 * 4),
- ]
-
-
-V4L2_OUTPUT_TYPE_MODULATOR = 1
-V4L2_OUTPUT_TYPE_ANALOG = 2
-V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY = 3
-
-V4L2_OUT_CAP_PRESETS = 0x00000001
-V4L2_OUT_CAP_CUSTOM_TIMINGS = 0x00000002
-V4L2_OUT_CAP_STD = 0x00000004
-
-#
-# Controls
-#
-
-class v4l2_control(ctypes.Structure):
- _fields_ = [
- ('id', ctypes.c_uint32),
- ('value', ctypes.c_int32),
- ]
-
-
-class v4l2_ext_control(ctypes.Structure):
- class _u(ctypes.Union):
- _fields_ = [
- ('value', ctypes.c_int32),
- ('value64', ctypes.c_int64),
- ('reserved', ctypes.c_void_p),
- ]
-
- _fields_ = [
- ('id', ctypes.c_uint32),
- ('reserved2', ctypes.c_uint32 * 2),
- ('_u', _u)
- ]
-
- _anonymous_ = ('_u',)
- _pack_ = True
-
-
-class v4l2_ext_controls(ctypes.Structure):
- _fields_ = [
- ('ctrl_class', ctypes.c_uint32),
- ('count', ctypes.c_uint32),
- ('error_idx', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 2),
- ('controls', ctypes.POINTER(v4l2_ext_control)),
- ]
-
-
-V4L2_CTRL_CLASS_USER = 0x00980000
-V4L2_CTRL_CLASS_MPEG = 0x00990000
-V4L2_CTRL_CLASS_CAMERA = 0x009a0000
-V4L2_CTRL_CLASS_FM_TX = 0x009b0000
-
-
-def V4L2_CTRL_ID_MASK():
- return 0x0fffffff
-
-
-def V4L2_CTRL_ID2CLASS(id_):
- return id_ & 0x0fff0000 # unsigned long
-
-
-def V4L2_CTRL_DRIVER_PRIV(id_):
- return (id_ & 0xffff) >= 0x1000
-
-
-class v4l2_queryctrl(ctypes.Structure):
- _fields_ = [
- ('id', ctypes.c_uint32),
- ('type', v4l2_ctrl_type),
- ('name', ctypes.c_char * 32),
- ('minimum', ctypes.c_int32),
- ('maximum', ctypes.c_int32),
- ('step', ctypes.c_int32),
- ('default', ctypes.c_int32),
- ('flags', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 2),
- ]
-
-
-class v4l2_querymenu(ctypes.Structure):
- _fields_ = [
- ('id', ctypes.c_uint32),
- ('index', ctypes.c_uint32),
- ('name', ctypes.c_char * 32),
- ('reserved', ctypes.c_uint32),
- ]
-
-
-V4L2_CTRL_FLAG_DISABLED = 0x0001
-V4L2_CTRL_FLAG_GRABBED = 0x0002
-V4L2_CTRL_FLAG_READ_ONLY = 0x0004
-V4L2_CTRL_FLAG_UPDATE = 0x0008
-V4L2_CTRL_FLAG_INACTIVE = 0x0010
-V4L2_CTRL_FLAG_SLIDER = 0x0020
-V4L2_CTRL_FLAG_WRITE_ONLY = 0x0040
-
-V4L2_CTRL_FLAG_NEXT_CTRL = 0x80000000
-
-V4L2_CID_BASE = V4L2_CTRL_CLASS_USER | 0x900
-V4L2_CID_USER_BASE = V4L2_CID_BASE
-V4L2_CID_PRIVATE_BASE = 0x08000000
-
-V4L2_CID_USER_CLASS = V4L2_CTRL_CLASS_USER | 1
-V4L2_CID_BRIGHTNESS = V4L2_CID_BASE + 0
-V4L2_CID_CONTRAST = V4L2_CID_BASE + 1
-V4L2_CID_SATURATION = V4L2_CID_BASE + 2
-V4L2_CID_HUE = V4L2_CID_BASE + 3
-V4L2_CID_AUDIO_VOLUME = V4L2_CID_BASE + 5
-V4L2_CID_AUDIO_BALANCE = V4L2_CID_BASE + 6
-V4L2_CID_AUDIO_BASS = V4L2_CID_BASE + 7
-V4L2_CID_AUDIO_TREBLE = V4L2_CID_BASE + 8
-V4L2_CID_AUDIO_MUTE = V4L2_CID_BASE + 9
-V4L2_CID_AUDIO_LOUDNESS = V4L2_CID_BASE + 10
-V4L2_CID_BLACK_LEVEL = V4L2_CID_BASE + 11 # Deprecated
-V4L2_CID_AUTO_WHITE_BALANCE = V4L2_CID_BASE + 12
-V4L2_CID_DO_WHITE_BALANCE = V4L2_CID_BASE + 13
-V4L2_CID_RED_BALANCE = V4L2_CID_BASE + 14
-V4L2_CID_BLUE_BALANCE = V4L2_CID_BASE + 15
-V4L2_CID_GAMMA = V4L2_CID_BASE + 16
-V4L2_CID_WHITENESS = V4L2_CID_GAMMA # Deprecated
-V4L2_CID_EXPOSURE = V4L2_CID_BASE + 17
-V4L2_CID_AUTOGAIN = V4L2_CID_BASE + 18
-V4L2_CID_GAIN = V4L2_CID_BASE + 19
-V4L2_CID_HFLIP = V4L2_CID_BASE + 20
-V4L2_CID_VFLIP = V4L2_CID_BASE + 21
-
-# Deprecated; use V4L2_CID_PAN_RESET and V4L2_CID_TILT_RESET
-V4L2_CID_HCENTER = V4L2_CID_BASE + 22
-V4L2_CID_VCENTER = V4L2_CID_BASE + 23
-
-V4L2_CID_POWER_LINE_FREQUENCY = V4L2_CID_BASE + 24
-
-v4l2_power_line_frequency = enum
-(
- V4L2_CID_POWER_LINE_FREQUENCY_DISABLED,
- V4L2_CID_POWER_LINE_FREQUENCY_50HZ,
- V4L2_CID_POWER_LINE_FREQUENCY_60HZ,
-) = range(3)
-
-V4L2_CID_HUE_AUTO = V4L2_CID_BASE + 25
-V4L2_CID_WHITE_BALANCE_TEMPERATURE = V4L2_CID_BASE + 26
-V4L2_CID_SHARPNESS = V4L2_CID_BASE + 27
-V4L2_CID_BACKLIGHT_COMPENSATION = V4L2_CID_BASE + 28
-V4L2_CID_CHROMA_AGC = V4L2_CID_BASE + 29
-V4L2_CID_COLOR_KILLER = V4L2_CID_BASE + 30
-V4L2_CID_COLORFX = V4L2_CID_BASE + 31
-
-v4l2_colorfx = enum
-(
- V4L2_COLORFX_NONE,
- V4L2_COLORFX_BW,
- V4L2_COLORFX_SEPIA,
-) = range(3)
-
-V4L2_CID_AUTOBRIGHTNESS = V4L2_CID_BASE + 32
-V4L2_CID_BAND_STOP_FILTER = V4L2_CID_BASE + 33
-
-V4L2_CID_ROTATE = V4L2_CID_BASE + 34
-V4L2_CID_BG_COLOR = V4L2_CID_BASE + 35
-V4L2_CID_LASTP1 = V4L2_CID_BASE + 36
-
-V4L2_CID_MPEG_BASE = V4L2_CTRL_CLASS_MPEG | 0x900
-V4L2_CID_MPEG_CLASS = V4L2_CTRL_CLASS_MPEG | 1
-
-# MPEG streams
-V4L2_CID_MPEG_STREAM_TYPE = V4L2_CID_MPEG_BASE + 0
-
-v4l2_mpeg_stream_type = enum
-(
- V4L2_MPEG_STREAM_TYPE_MPEG2_PS,
- V4L2_MPEG_STREAM_TYPE_MPEG2_TS,
- V4L2_MPEG_STREAM_TYPE_MPEG1_SS,
- V4L2_MPEG_STREAM_TYPE_MPEG2_DVD,
- V4L2_MPEG_STREAM_TYPE_MPEG1_VCD,
- V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD,
-) = range(6)
-
-V4L2_CID_MPEG_STREAM_PID_PMT = V4L2_CID_MPEG_BASE + 1
-V4L2_CID_MPEG_STREAM_PID_AUDIO = V4L2_CID_MPEG_BASE + 2
-V4L2_CID_MPEG_STREAM_PID_VIDEO = V4L2_CID_MPEG_BASE + 3
-V4L2_CID_MPEG_STREAM_PID_PCR = V4L2_CID_MPEG_BASE + 4
-V4L2_CID_MPEG_STREAM_PES_ID_AUDIO = V4L2_CID_MPEG_BASE + 5
-V4L2_CID_MPEG_STREAM_PES_ID_VIDEO = V4L2_CID_MPEG_BASE + 6
-V4L2_CID_MPEG_STREAM_VBI_FMT = V4L2_CID_MPEG_BASE + 7
-
-v4l2_mpeg_stream_vbi_fmt = enum
-(
- V4L2_MPEG_STREAM_VBI_FMT_NONE,
- V4L2_MPEG_STREAM_VBI_FMT_IVTV,
-) = range(2)
-
-V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ = V4L2_CID_MPEG_BASE + 100
-
-v4l2_mpeg_audio_sampling_freq = enum
-(
- V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100,
- V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000,
- V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000,
-) = range(3)
-
-V4L2_CID_MPEG_AUDIO_ENCODING = V4L2_CID_MPEG_BASE + 101
-
-v4l2_mpeg_audio_encoding = enum
-(
- V4L2_MPEG_AUDIO_ENCODING_LAYER_1,
- V4L2_MPEG_AUDIO_ENCODING_LAYER_2,
- V4L2_MPEG_AUDIO_ENCODING_LAYER_3,
- V4L2_MPEG_AUDIO_ENCODING_AAC,
- V4L2_MPEG_AUDIO_ENCODING_AC3,
-) = range(5)
-
-V4L2_CID_MPEG_AUDIO_L1_BITRATE = V4L2_CID_MPEG_BASE + 102
-
-v4l2_mpeg_audio_l1_bitrate = enum
-(
- V4L2_MPEG_AUDIO_L1_BITRATE_32K,
- V4L2_MPEG_AUDIO_L1_BITRATE_64K,
- V4L2_MPEG_AUDIO_L1_BITRATE_96K,
- V4L2_MPEG_AUDIO_L1_BITRATE_128K,
- V4L2_MPEG_AUDIO_L1_BITRATE_160K,
- V4L2_MPEG_AUDIO_L1_BITRATE_192K,
- V4L2_MPEG_AUDIO_L1_BITRATE_224K,
- V4L2_MPEG_AUDIO_L1_BITRATE_256K,
- V4L2_MPEG_AUDIO_L1_BITRATE_288K,
- V4L2_MPEG_AUDIO_L1_BITRATE_320K,
- V4L2_MPEG_AUDIO_L1_BITRATE_352K,
- V4L2_MPEG_AUDIO_L1_BITRATE_384K,
- V4L2_MPEG_AUDIO_L1_BITRATE_416K,
- V4L2_MPEG_AUDIO_L1_BITRATE_448K,
-) = range(14)
-
-V4L2_CID_MPEG_AUDIO_L2_BITRATE = V4L2_CID_MPEG_BASE + 103
-
-v4l2_mpeg_audio_l2_bitrate = enum
-(
- V4L2_MPEG_AUDIO_L2_BITRATE_32K,
- V4L2_MPEG_AUDIO_L2_BITRATE_48K,
- V4L2_MPEG_AUDIO_L2_BITRATE_56K,
- V4L2_MPEG_AUDIO_L2_BITRATE_64K,
- V4L2_MPEG_AUDIO_L2_BITRATE_80K,
- V4L2_MPEG_AUDIO_L2_BITRATE_96K,
- V4L2_MPEG_AUDIO_L2_BITRATE_112K,
- V4L2_MPEG_AUDIO_L2_BITRATE_128K,
- V4L2_MPEG_AUDIO_L2_BITRATE_160K,
- V4L2_MPEG_AUDIO_L2_BITRATE_192K,
- V4L2_MPEG_AUDIO_L2_BITRATE_224K,
- V4L2_MPEG_AUDIO_L2_BITRATE_256K,
- V4L2_MPEG_AUDIO_L2_BITRATE_320K,
- V4L2_MPEG_AUDIO_L2_BITRATE_384K,
-) = range(14)
-
-V4L2_CID_MPEG_AUDIO_L3_BITRATE = V4L2_CID_MPEG_BASE + 104
-
-v4l2_mpeg_audio_l3_bitrate = enum
-(
- V4L2_MPEG_AUDIO_L3_BITRATE_32K,
- V4L2_MPEG_AUDIO_L3_BITRATE_40K,
- V4L2_MPEG_AUDIO_L3_BITRATE_48K,
- V4L2_MPEG_AUDIO_L3_BITRATE_56K,
- V4L2_MPEG_AUDIO_L3_BITRATE_64K,
- V4L2_MPEG_AUDIO_L3_BITRATE_80K,
- V4L2_MPEG_AUDIO_L3_BITRATE_96K,
- V4L2_MPEG_AUDIO_L3_BITRATE_112K,
- V4L2_MPEG_AUDIO_L3_BITRATE_128K,
- V4L2_MPEG_AUDIO_L3_BITRATE_160K,
- V4L2_MPEG_AUDIO_L3_BITRATE_192K,
- V4L2_MPEG_AUDIO_L3_BITRATE_224K,
- V4L2_MPEG_AUDIO_L3_BITRATE_256K,
- V4L2_MPEG_AUDIO_L3_BITRATE_320K,
-) = range(14)
-
-V4L2_CID_MPEG_AUDIO_MODE = V4L2_CID_MPEG_BASE + 105
-
-v4l2_mpeg_audio_mode = enum
-(
- V4L2_MPEG_AUDIO_MODE_STEREO,
- V4L2_MPEG_AUDIO_MODE_JOINT_STEREO,
- V4L2_MPEG_AUDIO_MODE_DUAL,
- V4L2_MPEG_AUDIO_MODE_MONO,
-) = range(4)
-
-V4L2_CID_MPEG_AUDIO_MODE_EXTENSION = V4L2_CID_MPEG_BASE + 106
-
-v4l2_mpeg_audio_mode_extension = enum
-(
- V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4,
- V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_8,
- V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_12,
- V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16,
-) = range(4)
-
-V4L2_CID_MPEG_AUDIO_EMPHASIS = V4L2_CID_MPEG_BASE + 107
-
-v4l2_mpeg_audio_emphasis = enum
-(
- V4L2_MPEG_AUDIO_EMPHASIS_NONE,
- V4L2_MPEG_AUDIO_EMPHASIS_50_DIV_15_uS,
- V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17,
-) = range(3)
-
-V4L2_CID_MPEG_AUDIO_CRC = V4L2_CID_MPEG_BASE + 108
-
-v4l2_mpeg_audio_crc = enum
-(
- V4L2_MPEG_AUDIO_CRC_NONE,
- V4L2_MPEG_AUDIO_CRC_CRC16,
-) = range(2)
-
-V4L2_CID_MPEG_AUDIO_MUTE = V4L2_CID_MPEG_BASE + 109
-V4L2_CID_MPEG_AUDIO_AAC_BITRATE = V4L2_CID_MPEG_BASE + 110
-V4L2_CID_MPEG_AUDIO_AC3_BITRATE = V4L2_CID_MPEG_BASE + 111
-
-v4l2_mpeg_audio_ac3_bitrate = enum
-(
- V4L2_MPEG_AUDIO_AC3_BITRATE_32K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_40K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_48K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_56K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_64K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_80K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_96K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_112K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_128K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_160K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_192K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_224K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_256K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_320K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_384K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_448K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_512K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_576K,
- V4L2_MPEG_AUDIO_AC3_BITRATE_640K,
-) = range(19)
-
-V4L2_CID_MPEG_VIDEO_ENCODING = V4L2_CID_MPEG_BASE + 200
-
-v4l2_mpeg_video_encoding = enum
-(
- V4L2_MPEG_VIDEO_ENCODING_MPEG_1,
- V4L2_MPEG_VIDEO_ENCODING_MPEG_2,
- V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC,
-) = range(3)
-
-V4L2_CID_MPEG_VIDEO_ASPECT = V4L2_CID_MPEG_BASE + 201
-
-v4l2_mpeg_video_aspect = enum
-(
- V4L2_MPEG_VIDEO_ASPECT_1x1,
- V4L2_MPEG_VIDEO_ASPECT_4x3,
- V4L2_MPEG_VIDEO_ASPECT_16x9,
- V4L2_MPEG_VIDEO_ASPECT_221x100,
-) = range(4)
-
-V4L2_CID_MPEG_VIDEO_B_FRAMES = V4L2_CID_MPEG_BASE + 202
-V4L2_CID_MPEG_VIDEO_GOP_SIZE = V4L2_CID_MPEG_BASE + 203
-V4L2_CID_MPEG_VIDEO_GOP_CLOSURE = V4L2_CID_MPEG_BASE + 204
-V4L2_CID_MPEG_VIDEO_PULLDOWN = V4L2_CID_MPEG_BASE + 205
-V4L2_CID_MPEG_VIDEO_BITRATE_MODE = V4L2_CID_MPEG_BASE + 206
-
-v4l2_mpeg_video_bitrate_mode = enum
-(
- V4L2_MPEG_VIDEO_BITRATE_MODE_VBR,
- V4L2_MPEG_VIDEO_BITRATE_MODE_CBR,
-) = range(2)
-
-V4L2_CID_MPEG_VIDEO_BITRATE = V4L2_CID_MPEG_BASE + 207
-V4L2_CID_MPEG_VIDEO_BITRATE_PEAK = V4L2_CID_MPEG_BASE + 208
-V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION = V4L2_CID_MPEG_BASE + 209
-V4L2_CID_MPEG_VIDEO_MUTE = V4L2_CID_MPEG_BASE + 210
-V4L2_CID_MPEG_VIDEO_MUTE_YUV = V4L2_CID_MPEG_BASE + 211
-
-V4L2_CID_MPEG_CX2341X_BASE = V4L2_CTRL_CLASS_MPEG | 0x1000
-V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE = V4L2_CID_MPEG_CX2341X_BASE + 0
-
-v4l2_mpeg_cx2341x_video_spatial_filter_mode = enum
-(
- V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL,
- V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO,
-) = range(2)
-
-V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER = V4L2_CID_MPEG_CX2341X_BASE + 1
-V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE = V4L2_CID_MPEG_CX2341X_BASE + 2
-
-v4l2_mpeg_cx2341x_video_luma_spatial_filter_type = enum
-(
- V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF,
- V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR,
- V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_VERT,
- V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_HV_SEPARABLE,
- V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE,
-) = range(5)
-
-V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE = V4L2_CID_MPEG_CX2341X_BASE + 3
-
-v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type = enum
-(
- V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF,
- V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR,
-) = range(2)
-
-V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE = V4L2_CID_MPEG_CX2341X_BASE + 4
-
-v4l2_mpeg_cx2341x_video_temporal_filter_mode = enum
-(
- V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL,
- V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO,
-) = range(2)
-
-V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER = V4L2_CID_MPEG_CX2341X_BASE + 5
-V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE = V4L2_CID_MPEG_CX2341X_BASE + 6
-
-v4l2_mpeg_cx2341x_video_median_filter_type = enum
-(
- V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF,
- V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR,
- V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_VERT,
- V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_HOR_VERT,
- V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG,
-) = range(5)
-
-V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM = V4L2_CID_MPEG_CX2341X_BASE + 7
-V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP = V4L2_CID_MPEG_CX2341X_BASE + 8
-V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM = V4L2_CID_MPEG_CX2341X_BASE + 9
-V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP = V4L2_CID_MPEG_CX2341X_BASE + 10
-V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS = V4L2_CID_MPEG_CX2341X_BASE + 11
-
-V4L2_CID_CAMERA_CLASS_BASE = V4L2_CTRL_CLASS_CAMERA | 0x900
-V4L2_CID_CAMERA_CLASS = V4L2_CTRL_CLASS_CAMERA | 1
-
-V4L2_CID_EXPOSURE_AUTO = V4L2_CID_CAMERA_CLASS_BASE + 1
-
-v4l2_exposure_auto_type = enum
-(
- V4L2_EXPOSURE_AUTO,
- V4L2_EXPOSURE_MANUAL,
- V4L2_EXPOSURE_SHUTTER_PRIORITY,
- V4L2_EXPOSURE_APERTURE_PRIORITY,
-) = range(4)
-
-V4L2_CID_EXPOSURE_ABSOLUTE = V4L2_CID_CAMERA_CLASS_BASE + 2
-V4L2_CID_EXPOSURE_AUTO_PRIORITY = V4L2_CID_CAMERA_CLASS_BASE + 3
-
-V4L2_CID_PAN_RELATIVE = V4L2_CID_CAMERA_CLASS_BASE + 4
-V4L2_CID_TILT_RELATIVE = V4L2_CID_CAMERA_CLASS_BASE + 5
-V4L2_CID_PAN_RESET = V4L2_CID_CAMERA_CLASS_BASE + 6
-V4L2_CID_TILT_RESET = V4L2_CID_CAMERA_CLASS_BASE + 7
-
-V4L2_CID_PAN_ABSOLUTE = V4L2_CID_CAMERA_CLASS_BASE + 8
-V4L2_CID_TILT_ABSOLUTE = V4L2_CID_CAMERA_CLASS_BASE + 9
-
-V4L2_CID_FOCUS_ABSOLUTE = V4L2_CID_CAMERA_CLASS_BASE + 10
-V4L2_CID_FOCUS_RELATIVE = V4L2_CID_CAMERA_CLASS_BASE + 11
-V4L2_CID_FOCUS_AUTO = V4L2_CID_CAMERA_CLASS_BASE + 12
-
-V4L2_CID_ZOOM_ABSOLUTE = V4L2_CID_CAMERA_CLASS_BASE + 13
-V4L2_CID_ZOOM_RELATIVE = V4L2_CID_CAMERA_CLASS_BASE + 14
-V4L2_CID_ZOOM_CONTINUOUS = V4L2_CID_CAMERA_CLASS_BASE + 15
-
-V4L2_CID_PRIVACY = V4L2_CID_CAMERA_CLASS_BASE + 16
-
-V4L2_CID_FM_TX_CLASS_BASE = V4L2_CTRL_CLASS_FM_TX | 0x900
-V4L2_CID_FM_TX_CLASS = V4L2_CTRL_CLASS_FM_TX | 1
-
-V4L2_CID_RDS_TX_DEVIATION = V4L2_CID_FM_TX_CLASS_BASE + 1
-V4L2_CID_RDS_TX_PI = V4L2_CID_FM_TX_CLASS_BASE + 2
-V4L2_CID_RDS_TX_PTY = V4L2_CID_FM_TX_CLASS_BASE + 3
-V4L2_CID_RDS_TX_PS_NAME = V4L2_CID_FM_TX_CLASS_BASE + 5
-V4L2_CID_RDS_TX_RADIO_TEXT = V4L2_CID_FM_TX_CLASS_BASE + 6
-
-V4L2_CID_AUDIO_LIMITER_ENABLED = V4L2_CID_FM_TX_CLASS_BASE + 64
-V4L2_CID_AUDIO_LIMITER_RELEASE_TIME = V4L2_CID_FM_TX_CLASS_BASE + 65
-V4L2_CID_AUDIO_LIMITER_DEVIATION = V4L2_CID_FM_TX_CLASS_BASE + 66
-
-V4L2_CID_AUDIO_COMPRESSION_ENABLED = V4L2_CID_FM_TX_CLASS_BASE + 80
-V4L2_CID_AUDIO_COMPRESSION_GAIN = V4L2_CID_FM_TX_CLASS_BASE + 81
-V4L2_CID_AUDIO_COMPRESSION_THRESHOLD = V4L2_CID_FM_TX_CLASS_BASE + 82
-V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME = V4L2_CID_FM_TX_CLASS_BASE + 83
-V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME = V4L2_CID_FM_TX_CLASS_BASE + 84
-
-V4L2_CID_PILOT_TONE_ENABLED = V4L2_CID_FM_TX_CLASS_BASE + 96
-V4L2_CID_PILOT_TONE_DEVIATION = V4L2_CID_FM_TX_CLASS_BASE + 97
-V4L2_CID_PILOT_TONE_FREQUENCY = V4L2_CID_FM_TX_CLASS_BASE + 98
-
-V4L2_CID_TUNE_PREEMPHASIS = V4L2_CID_FM_TX_CLASS_BASE + 112
-
-v4l2_preemphasis = enum
-(
- V4L2_PREEMPHASIS_DISABLED,
- V4L2_PREEMPHASIS_50_uS,
- V4L2_PREEMPHASIS_75_uS,
-) = range(3)
-
-V4L2_CID_TUNE_POWER_LEVEL = V4L2_CID_FM_TX_CLASS_BASE + 113
-V4L2_CID_TUNE_ANTENNA_CAPACITOR = V4L2_CID_FM_TX_CLASS_BASE + 114
-
-
-#
-# Tuning
-#
-
-class v4l2_tuner(ctypes.Structure):
- _fields_ = [
- ('index', ctypes.c_uint32),
- ('name', ctypes.c_char * 32),
- ('type', v4l2_tuner_type),
- ('capability', ctypes.c_uint32),
- ('rangelow', ctypes.c_uint32),
- ('rangehigh', ctypes.c_uint32),
- ('rxsubchans', ctypes.c_uint32),
- ('audmode', ctypes.c_uint32),
- ('signal', ctypes.c_int32),
- ('afc', ctypes.c_int32),
- ('reserved', ctypes.c_uint32 * 4),
- ]
-
-
-class v4l2_modulator(ctypes.Structure):
- _fields_ = [
- ('index', ctypes.c_uint32),
- ('name', ctypes.c_char * 32),
- ('capability', ctypes.c_uint32),
- ('rangelow', ctypes.c_uint32),
- ('rangehigh', ctypes.c_uint32),
- ('txsubchans', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 4),
- ]
-
-
-V4L2_TUNER_CAP_LOW = 0x0001
-V4L2_TUNER_CAP_NORM = 0x0002
-V4L2_TUNER_CAP_STEREO = 0x0010
-V4L2_TUNER_CAP_LANG2 = 0x0020
-V4L2_TUNER_CAP_SAP = 0x0020
-V4L2_TUNER_CAP_LANG1 = 0x0040
-V4L2_TUNER_CAP_RDS = 0x0080
-
-V4L2_TUNER_SUB_MONO = 0x0001
-V4L2_TUNER_SUB_STEREO = 0x0002
-V4L2_TUNER_SUB_LANG2 = 0x0004
-V4L2_TUNER_SUB_SAP = 0x0004
-V4L2_TUNER_SUB_LANG1 = 0x0008
-V4L2_TUNER_SUB_RDS = 0x0010
-
-V4L2_TUNER_MODE_MONO = 0x0000
-V4L2_TUNER_MODE_STEREO = 0x0001
-V4L2_TUNER_MODE_LANG2 = 0x0002
-V4L2_TUNER_MODE_SAP = 0x0002
-V4L2_TUNER_MODE_LANG1 = 0x0003
-V4L2_TUNER_MODE_LANG1_LANG2 = 0x0004
-
-
-class v4l2_frequency(ctypes.Structure):
- _fields_ = [
- ('tuner', ctypes.c_uint32),
- ('type', v4l2_tuner_type),
- ('frequency', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 8),
- ]
-
-
-class v4l2_hw_freq_seek(ctypes.Structure):
- _fields_ = [
- ('tuner', ctypes.c_uint32),
- ('type', v4l2_tuner_type),
- ('seek_upward', ctypes.c_uint32),
- ('wrap_around', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 8),
- ]
-
-
-#
-# RDS
-#
-
-class v4l2_rds_data(ctypes.Structure):
- _fields_ = [
- ('lsb', ctypes.c_char),
- ('msb', ctypes.c_char),
- ('block', ctypes.c_char),
- ]
-
- _pack_ = True
-
-
-V4L2_RDS_BLOCK_MSK = 0x7
-V4L2_RDS_BLOCK_A = 0
-V4L2_RDS_BLOCK_B = 1
-V4L2_RDS_BLOCK_C = 2
-V4L2_RDS_BLOCK_D = 3
-V4L2_RDS_BLOCK_C_ALT = 4
-V4L2_RDS_BLOCK_INVALID = 7
-
-V4L2_RDS_BLOCK_CORRECTED = 0x40
-V4L2_RDS_BLOCK_ERROR = 0x80
-
-
-#
-# Audio
-#
-
-class v4l2_audio(ctypes.Structure):
- _fields_ = [
- ('index', ctypes.c_uint32),
- ('name', ctypes.c_char * 32),
- ('capability', ctypes.c_uint32),
- ('mode', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 2),
- ]
-
-
-V4L2_AUDCAP_STEREO = 0x00001
-V4L2_AUDCAP_AVL = 0x00002
-
-V4L2_AUDMODE_AVL = 0x00001
-
-
-class v4l2_audioout(ctypes.Structure):
- _fields_ = [
- ('index', ctypes.c_uint32),
- ('name', ctypes.c_char * 32),
- ('capability', ctypes.c_uint32),
- ('mode', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 2),
- ]
-
-
-#
-# Mpeg services (experimental)
-#
-
-V4L2_ENC_IDX_FRAME_I = 0
-V4L2_ENC_IDX_FRAME_P = 1
-V4L2_ENC_IDX_FRAME_B = 2
-V4L2_ENC_IDX_FRAME_MASK = 0xf
-
-
-class v4l2_enc_idx_entry(ctypes.Structure):
- _fields_ = [
- ('offset', ctypes.c_uint64),
- ('pts', ctypes.c_uint64),
- ('length', ctypes.c_uint32),
- ('flags', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 2),
- ]
-
-
-V4L2_ENC_IDX_ENTRIES = 64
-
-
-class v4l2_enc_idx(ctypes.Structure):
- _fields_ = [
- ('entries', ctypes.c_uint32),
- ('entries_cap', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 4),
- ('entry', v4l2_enc_idx_entry * V4L2_ENC_IDX_ENTRIES),
- ]
-
-
-V4L2_ENC_CMD_START = 0
-V4L2_ENC_CMD_STOP = 1
-V4L2_ENC_CMD_PAUSE = 2
-V4L2_ENC_CMD_RESUME = 3
-
-V4L2_ENC_CMD_STOP_AT_GOP_END = 1 << 0
-
-
-class v4l2_encoder_cmd(ctypes.Structure):
- class _u(ctypes.Union):
- class _s(ctypes.Structure):
- _fields_ = [
- ('data', ctypes.c_uint32 * 8),
- ]
-
- _fields_ = [
- ('raw', _s),
- ]
-
- _fields_ = [
- ('cmd', ctypes.c_uint32),
- ('flags', ctypes.c_uint32),
- ('_u', _u),
- ]
-
- _anonymous_ = ('_u',)
-
-
-#
-# Data services (VBI)
-#
-
-class v4l2_vbi_format(ctypes.Structure):
- _fields_ = [
- ('sampling_rate', ctypes.c_uint32),
- ('offset', ctypes.c_uint32),
- ('samples_per_line', ctypes.c_uint32),
- ('sample_format', ctypes.c_uint32),
- ('start', ctypes.c_int32 * 2),
- ('count', ctypes.c_uint32 * 2),
- ('flags', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 2),
- ]
-
-
-V4L2_VBI_UNSYNC = 1 << 0
-V4L2_VBI_INTERLACED = 1 << 1
-
-
-class v4l2_sliced_vbi_format(ctypes.Structure):
- _fields_ = [
- ('service_set', ctypes.c_uint16),
- ('service_lines', ctypes.c_uint16 * 2 * 24),
- ('io_size', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32 * 2),
- ]
-
-
-V4L2_SLICED_TELETEXT_B = 0x0001
-V4L2_SLICED_VPS = 0x0400
-V4L2_SLICED_CAPTION_525 = 0x1000
-V4L2_SLICED_WSS_625 = 0x4000
-V4L2_SLICED_VBI_525 = V4L2_SLICED_CAPTION_525
-V4L2_SLICED_VBI_625 = (
- V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625)
-
-
-class v4l2_sliced_vbi_cap(ctypes.Structure):
- _fields_ = [
- ('service_set', ctypes.c_uint16),
- ('service_lines', ctypes.c_uint16 * 2 * 24),
- ('type', v4l2_buf_type),
- ('reserved', ctypes.c_uint32 * 3),
- ]
-
-
-class v4l2_sliced_vbi_data(ctypes.Structure):
- _fields_ = [
- ('id', ctypes.c_uint32),
- ('field', ctypes.c_uint32),
- ('line', ctypes.c_uint32),
- ('reserved', ctypes.c_uint32),
- ('data', ctypes.c_char * 48),
- ]
-
-
-#
-# Sliced VBI data inserted into MPEG Streams
-#
-
-
-V4L2_MPEG_VBI_IVTV_TELETEXT_B = 1
-V4L2_MPEG_VBI_IVTV_CAPTION_525 = 4
-V4L2_MPEG_VBI_IVTV_WSS_625 = 5
-V4L2_MPEG_VBI_IVTV_VPS = 7
-
-
-class v4l2_mpeg_vbi_itv0_line(ctypes.Structure):
- _fields_ = [
- ('id', ctypes.c_char),
- ('data', ctypes.c_char * 42),
- ]
-
- _pack_ = True
-
-
-class v4l2_mpeg_vbi_itv0(ctypes.Structure):
- _fields_ = [
- ('linemask', ctypes.c_uint32 * 2), # how to define __le32 in ctypes?
- ('line', v4l2_mpeg_vbi_itv0_line * 35),
- ]
-
- _pack_ = True
-
-
-class v4l2_mpeg_vbi_ITV0(ctypes.Structure):
- _fields_ = [
- ('line', v4l2_mpeg_vbi_itv0_line * 36),
- ]
-
- _pack_ = True
-
-
-V4L2_MPEG_VBI_IVTV_MAGIC0 = "itv0"
-V4L2_MPEG_VBI_IVTV_MAGIC1 = "ITV0"
-
-
-class v4l2_mpeg_vbi_fmt_ivtv(ctypes.Structure):
- class _u(ctypes.Union):
- _fields_ = [
- ('itv0', v4l2_mpeg_vbi_itv0),
- ('ITV0', v4l2_mpeg_vbi_ITV0),
- ]
-
- _fields_ = [
- ('magic', ctypes.c_char * 4),
- ('_u', _u)
- ]
-
- _anonymous_ = ('_u',)
- _pack_ = True
-
-
-#
-# Aggregate structures
-#
-
-class v4l2_format(ctypes.Structure):
- class _u(ctypes.Union):
- _fields_ = [
- ('pix', v4l2_pix_format),
- ('win', v4l2_window),
- ('vbi', v4l2_vbi_format),
- ('sliced', v4l2_sliced_vbi_format),
- ('raw_data', ctypes.c_char * 200),
- ]
-
- _fields_ = [
- ('type', v4l2_buf_type),
- ('fmt', _u),
- ]
-
-
-class v4l2_streamparm(ctypes.Structure):
- class _u(ctypes.Union):
- _fields_ = [
- ('capture', v4l2_captureparm),
- ('output', v4l2_outputparm),
- ('raw_data', ctypes.c_char * 200),
- ]
-
- _fields_ = [
- ('type', v4l2_buf_type),
- ('parm', _u)
- ]
-
-
-#
-# Advanced debugging
-#
-
-V4L2_CHIP_MATCH_HOST = 0
-V4L2_CHIP_MATCH_I2C_DRIVER = 1
-V4L2_CHIP_MATCH_I2C_ADDR = 2
-V4L2_CHIP_MATCH_AC97 = 3
-
-
-class v4l2_dbg_match(ctypes.Structure):
- class _u(ctypes.Union):
- _fields_ = [
- ('addr', ctypes.c_uint32),
- ('name', ctypes.c_char * 32),
- ]
-
- _fields_ = [
- ('type', ctypes.c_uint32),
- ('_u', _u),
- ]
-
- _anonymous_ = ('_u',)
- _pack_ = True
-
-
-class v4l2_dbg_register(ctypes.Structure):
- _fields_ = [
- ('match', v4l2_dbg_match),
- ('size', ctypes.c_uint32),
- ('reg', ctypes.c_uint64),
- ('val', ctypes.c_uint64),
- ]
-
- _pack_ = True
-
-
-class v4l2_dbg_chip_ident(ctypes.Structure):
- _fields_ = [
- ('match', v4l2_dbg_match),
- ('ident', ctypes.c_uint32),
- ('revision', ctypes.c_uint32),
- ]
-
- _pack_ = True
-
-
-#
-# ioctl codes for video devices
-#
-
-VIDIOC_QUERYCAP = _IOR('V', 0, v4l2_capability)
-VIDIOC_RESERVED = _IO('V', 1)
-VIDIOC_ENUM_FMT = _IOWR('V', 2, v4l2_fmtdesc)
-VIDIOC_G_FMT = _IOWR('V', 4, v4l2_format)
-VIDIOC_S_FMT = _IOWR('V', 5, v4l2_format)
-VIDIOC_REQBUFS = _IOWR('V', 8, v4l2_requestbuffers)
-VIDIOC_QUERYBUF = _IOWR('V', 9, v4l2_buffer)
-VIDIOC_G_FBUF = _IOR('V', 10, v4l2_framebuffer)
-VIDIOC_S_FBUF = _IOW('V', 11, v4l2_framebuffer)
-VIDIOC_OVERLAY = _IOW('V', 14, ctypes.c_int)
-VIDIOC_QBUF = _IOWR('V', 15, v4l2_buffer)
-VIDIOC_DQBUF = _IOWR('V', 17, v4l2_buffer)
-VIDIOC_STREAMON = _IOW('V', 18, ctypes.c_int)
-VIDIOC_STREAMOFF = _IOW('V', 19, ctypes.c_int)
-VIDIOC_G_PARM = _IOWR('V', 21, v4l2_streamparm)
-VIDIOC_S_PARM = _IOWR('V', 22, v4l2_streamparm)
-VIDIOC_G_STD = _IOR('V', 23, v4l2_std_id)
-VIDIOC_S_STD = _IOW('V', 24, v4l2_std_id)
-VIDIOC_ENUMSTD = _IOWR('V', 25, v4l2_standard)
-VIDIOC_ENUMINPUT = _IOWR('V', 26, v4l2_input)
-VIDIOC_G_CTRL = _IOWR('V', 27, v4l2_control)
-VIDIOC_S_CTRL = _IOWR('V', 28, v4l2_control)
-VIDIOC_G_TUNER = _IOWR('V', 29, v4l2_tuner)
-VIDIOC_S_TUNER = _IOW('V', 30, v4l2_tuner)
-VIDIOC_G_AUDIO = _IOR('V', 33, v4l2_audio)
-VIDIOC_S_AUDIO = _IOW('V', 34, v4l2_audio)
-VIDIOC_QUERYCTRL = _IOWR('V', 36, v4l2_queryctrl)
-VIDIOC_QUERYMENU = _IOWR('V', 37, v4l2_querymenu)
-VIDIOC_G_INPUT = _IOR('V', 38, ctypes.c_int)
-VIDIOC_S_INPUT = _IOWR('V', 39, ctypes.c_int)
-VIDIOC_G_OUTPUT = _IOR('V', 46, ctypes.c_int)
-VIDIOC_S_OUTPUT = _IOWR('V', 47, ctypes.c_int)
-VIDIOC_ENUMOUTPUT = _IOWR('V', 48, v4l2_output)
-VIDIOC_G_AUDOUT = _IOR('V', 49, v4l2_audioout)
-VIDIOC_S_AUDOUT = _IOW('V', 50, v4l2_audioout)
-VIDIOC_G_MODULATOR = _IOWR('V', 54, v4l2_modulator)
-VIDIOC_S_MODULATOR = _IOW('V', 55, v4l2_modulator)
-VIDIOC_G_FREQUENCY = _IOWR('V', 56, v4l2_frequency)
-VIDIOC_S_FREQUENCY = _IOW('V', 57, v4l2_frequency)
-VIDIOC_CROPCAP = _IOWR('V', 58, v4l2_cropcap)
-VIDIOC_G_CROP = _IOWR('V', 59, v4l2_crop)
-VIDIOC_S_CROP = _IOW('V', 60, v4l2_crop)
-VIDIOC_G_JPEGCOMP = _IOR('V', 61, v4l2_jpegcompression)
-VIDIOC_S_JPEGCOMP = _IOW('V', 62, v4l2_jpegcompression)
-VIDIOC_QUERYSTD = _IOR('V', 63, v4l2_std_id)
-VIDIOC_TRY_FMT = _IOWR('V', 64, v4l2_format)
-VIDIOC_ENUMAUDIO = _IOWR('V', 65, v4l2_audio)
-VIDIOC_ENUMAUDOUT = _IOWR('V', 66, v4l2_audioout)
-VIDIOC_G_PRIORITY = _IOR('V', 67, v4l2_priority)
-VIDIOC_S_PRIORITY = _IOW('V', 68, v4l2_priority)
-VIDIOC_G_SLICED_VBI_CAP = _IOWR('V', 69, v4l2_sliced_vbi_cap)
-VIDIOC_LOG_STATUS = _IO('V', 70)
-VIDIOC_G_EXT_CTRLS = _IOWR('V', 71, v4l2_ext_controls)
-VIDIOC_S_EXT_CTRLS = _IOWR('V', 72, v4l2_ext_controls)
-VIDIOC_TRY_EXT_CTRLS = _IOWR('V', 73, v4l2_ext_controls)
-
-VIDIOC_ENUM_FRAMESIZES = _IOWR('V', 74, v4l2_frmsizeenum)
-VIDIOC_ENUM_FRAMEINTERVALS = _IOWR('V', 75, v4l2_frmivalenum)
-VIDIOC_G_ENC_INDEX = _IOR('V', 76, v4l2_enc_idx)
-VIDIOC_ENCODER_CMD = _IOWR('V', 77, v4l2_encoder_cmd)
-VIDIOC_TRY_ENCODER_CMD = _IOWR('V', 78, v4l2_encoder_cmd)
-
-VIDIOC_DBG_S_REGISTER = _IOW('V', 79, v4l2_dbg_register)
-VIDIOC_DBG_G_REGISTER = _IOWR('V', 80, v4l2_dbg_register)
-
-VIDIOC_DBG_G_CHIP_IDENT = _IOWR('V', 81, v4l2_dbg_chip_ident)
-
-VIDIOC_S_HW_FREQ_SEEK = _IOW('V', 82, v4l2_hw_freq_seek)
-VIDIOC_ENUM_DV_PRESETS = _IOWR('V', 83, v4l2_dv_enum_preset)
-VIDIOC_S_DV_PRESET = _IOWR('V', 84, v4l2_dv_preset)
-VIDIOC_G_DV_PRESET = _IOWR('V', 85, v4l2_dv_preset)
-VIDIOC_QUERY_DV_PRESET = _IOR('V', 86, v4l2_dv_preset)
-VIDIOC_S_DV_TIMINGS = _IOWR('V', 87, v4l2_dv_timings)
-VIDIOC_G_DV_TIMINGS = _IOWR('V', 88, v4l2_dv_timings)
-
-VIDIOC_OVERLAY_OLD = _IOWR('V', 14, ctypes.c_int)
-VIDIOC_S_PARM_OLD = _IOW('V', 22, v4l2_streamparm)
-VIDIOC_S_CTRL_OLD = _IOW('V', 28, v4l2_control)
-VIDIOC_G_AUDIO_OLD = _IOWR('V', 33, v4l2_audio)
-VIDIOC_G_AUDOUT_OLD = _IOWR('V', 49, v4l2_audioout)
-VIDIOC_CROPCAP_OLD = _IOR('V', 58, v4l2_cropcap)
-
-BASE_VIDIOC_PRIVATE = 192
diff --git a/plugins/light_sensor/icons/sensoroff.svg b/plugins/light_sensor/icons/sensoroff.svg
deleted file mode 100644
index 0a16670..0000000
--- a/plugins/light_sensor/icons/sensoroff.svg
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="55"
- height="55"
- viewBox="0 0 55 55"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata15"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs13" />
-<rect
- width="42.763924"
- height="42.763924"
- x="6.1180382"
- y="6.1180382"
- id="rect2986"
- style="fill:#282828;fill-opacity:1;stroke:#282828;stroke-width:2.23607516;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><g
- transform="matrix(0.87078705,0,0,0.87078705,3.2821055,2.9298726)"
- id="network-wired_1_"
- style="display:block">
- <g
- id="network-wired">
- <line
- id="line3076"
- y2="23.993"
- y1="32.438999"
- x2="16.966999"
- x1="16.966999"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round" />
- <line
- id="line3078"
- y2="28.215"
- y1="28.215"
- x2="34.938"
- x1="29.636999"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round" />
-
- <rect
- width="9.7939997"
- height="7.599"
- x="42.157001"
- y="24.312"
- id="rect3080"
- style="fill:#ffffff;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round" />
- <path
- d="m 16.967,23.993 c 0,-2.334 -1.892,-4.224 -4.224,-4.224 -2.332,0 -4.223,1.889 -4.223,4.224"
- id="path3082"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 25.413,32.439 c 0,2.334 -1.891,4.224 -4.224,4.224 -2.332,0 -4.223,-1.89 -4.223,-4.224"
- id="path3084"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 25.413,32.439 c 0,-2.332 1.893,-4.226 4.224,-4.226"
- id="path3086"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 8.52,23.993 c 0,2.332 -1.892,4.222 -4.223,4.222"
- id="path3088"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
-
- <rect
- width="14.477"
- height="11.35"
- x="31.945"
- y="22.438"
- id="rect3090"
- style="fill:#ffffff;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- </g>
-</g></svg> \ No newline at end of file
diff --git a/plugins/light_sensor/icons/sensoron.svg b/plugins/light_sensor/icons/sensoron.svg
deleted file mode 100644
index d756860..0000000
--- a/plugins/light_sensor/icons/sensoron.svg
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="55"
- height="55"
- viewBox="0 0 55 55"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata15"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs13" /><rect
- width="55"
- height="55"
- x="0"
- y="0"
- id="rect3269"
- style="fill:#ffd200;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
- transform="translate(0.27777716,18.796296)"
- id="g4054"><line
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-opacity:1"
- x1="17.778971"
- x2="17.778971"
- y1="12.381037"
- y2="5.0263696"
- id="line3076" /><line
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-opacity:1"
- x1="28.811842"
- x2="33.427887"
- y1="8.7028332"
- y2="8.7028332"
- id="line3078" /><rect
- width="8.5284882"
- height="6.6171107"
- x="39.7141"
- y="5.3041511"
- id="rect3080"
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:1.95927083;stroke-linecap:round;stroke-opacity:1" /><path
- d="m 17.778971,5.0263697 c 0,-2.032417 -1.647529,-3.6782045 -3.678204,-3.6782045 -2.030675,0 -3.677334,1.6449167 -3.677334,3.6782045"
- id="path3082"
- style="fill:none;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 25.133639,12.381037 c 0,2.032417 -1.646658,3.678205 -3.678205,3.678205 -2.030675,0 -3.677333,-1.645788 -3.677333,-3.678205"
- id="path3084"
- style="fill:none;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 25.133639,12.381037 c 0,-2.030675 1.6484,-3.679946 3.678204,-3.679946"
- id="path3086"
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 10.423433,5.0263697 c 0,2.0306754 -1.6475288,3.6764629 -3.6773334,3.6764629"
- id="path3088"
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><rect
- width="12.606384"
- height="9.8834333"
- x="30.821619"
- y="3.6722956"
- id="rect3090"
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /></g></svg> \ No newline at end of file
diff --git a/plugins/light_sensor/light_sensor.py b/plugins/light_sensor/light_sensor.py
deleted file mode 100644
index bd5655e..0000000
--- a/plugins/light_sensor/light_sensor.py
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/env python
-#Copyright (c) 2011 Walter Bender
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import os
-
-from gettext import gettext as _
-
-from plugins.plugin import Plugin
-
-from TurtleArt.tapalette import make_palette
-from TurtleArt.talogo import primitive_dictionary
-from TurtleArt.tautils import debug_output
-
-import logging
-_logger = logging.getLogger('turtleart-activity light-sensor plugin')
-
-
-LIGHT_SENSOR_DEVICE = '/sys/devices/platform/olpc-ols.0/level'
-
-
-class Light_sensor(Plugin):
-
- def __init__(self, parent):
- self._parent = parent
- if os.path.exists(LIGHT_SENSOR_DEVICE):
- self._status = True
- else:
- self._status = False
- self.running_sugar = self._parent.running_sugar
-
- def setup(self):
- # set up light-sensor specific blocks
- palette = make_palette('sensor',
- colors=["#FF6060", "#A06060"],
- help_string=_('Palette of sensor blocks'),
- position=6)
-
- primitive_dictionary['lightsensor'] = self.prim_lightsensor
- if self._status:
- palette.add_block('lightsensor',
- style='box-style',
- label=_('brightness'),
- help_string=\
- _('light level detected by light sensor'),
- prim_name='lightsensor')
- else:
- palette.add_block('lightsensor',
- style='box-style',
- label=_('brightness'),
- help_string=\
- _('light level detected by light sensor'),
- hidden=True,
- prim_name='lightsensor')
-
- self._parent.lc.def_prim(
- 'lightsensor', 0,
- lambda self: primitive_dictionary['lightsensor']())
-
- def _status_report(self):
- debug_output('Reporting light-sensor status: %s' % (str(self._status)))
- return self._status
-
- # Block primitives used in talogo
-
- def prim_lightsensor(self):
- ''' push accelerometer xyz to stack '''
- if not self._status:
- return -1
- else:
- fh = open(LIGHT_SENSOR_DEVICE)
- string = fh.read()
- fh.close()
- return float(string)
diff --git a/plugins/rfid/device.py b/plugins/rfid/device.py
deleted file mode 100644
index 04a82b2..0000000
--- a/plugins/rfid/device.py
+++ /dev/null
@@ -1,61 +0,0 @@
-import gobject
-
-class RFIDDevice(gobject.GObject):
- """
- Ancestor class for every supported device.
- The main class for the device driver must be called "RFIDReader".
- """
- # signal "tag-read" has to be emitted when a tag has been read.
- # The handler must receive the ISO-11784 hex value of the tag.
- # signal "disconnected" has to be emitted when the device is
- # unplugged or an error has been detected.
- __gsignals__ = {
- 'tag-read': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
- (gobject.TYPE_STRING,)),
- 'disconnected': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
- (gobject.TYPE_STRING,))
- }
- def __init__(self):
- """
- Initializer. Subclasses must call this method.
- """
- self.__gobject_init__()
-
- def get_present(self):
- """
- This method must detect if the device is present, returning True if so,
- or False otherwise.
- """
- raise NotImplementedError
-
- def get_version(self):
- """
- Returns a descriptive text of the device.
- """
- raise NotImplementedError
-
- def do_connect(self):
- """
- Connects to the device.
- Must return True if successfull, False otherwise.
- """
- raise NotImplementedError
-
- def do_disconnect(self):
- """
- Disconnects from the device.
- """
- raise NotImplementedError
-
- def read_tag(self):
- """
- Returns the 64 bit data in hex format of the last read tag.
- """
- raise NotImplementedError
-
- def write_tag(self, hex_val):
- """
- Could be implemented if the device is capable of writing tags.
- Receives the hex value (according to ISO 11784) to be written.
- Returns True if successfull or False if something went wrong.
- """
diff --git a/plugins/rfid/icons/sensoroff.svg b/plugins/rfid/icons/sensoroff.svg
deleted file mode 100644
index 0a16670..0000000
--- a/plugins/rfid/icons/sensoroff.svg
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="55"
- height="55"
- viewBox="0 0 55 55"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata15"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs13" />
-<rect
- width="42.763924"
- height="42.763924"
- x="6.1180382"
- y="6.1180382"
- id="rect2986"
- style="fill:#282828;fill-opacity:1;stroke:#282828;stroke-width:2.23607516;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><g
- transform="matrix(0.87078705,0,0,0.87078705,3.2821055,2.9298726)"
- id="network-wired_1_"
- style="display:block">
- <g
- id="network-wired">
- <line
- id="line3076"
- y2="23.993"
- y1="32.438999"
- x2="16.966999"
- x1="16.966999"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round" />
- <line
- id="line3078"
- y2="28.215"
- y1="28.215"
- x2="34.938"
- x1="29.636999"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round" />
-
- <rect
- width="9.7939997"
- height="7.599"
- x="42.157001"
- y="24.312"
- id="rect3080"
- style="fill:#ffffff;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round" />
- <path
- d="m 16.967,23.993 c 0,-2.334 -1.892,-4.224 -4.224,-4.224 -2.332,0 -4.223,1.889 -4.223,4.224"
- id="path3082"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 25.413,32.439 c 0,2.334 -1.891,4.224 -4.224,4.224 -2.332,0 -4.223,-1.89 -4.223,-4.224"
- id="path3084"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 25.413,32.439 c 0,-2.332 1.893,-4.226 4.224,-4.226"
- id="path3086"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- <path
- d="m 8.52,23.993 c 0,2.332 -1.892,4.222 -4.223,4.222"
- id="path3088"
- style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
-
- <rect
- width="14.477"
- height="11.35"
- x="31.945"
- y="22.438"
- id="rect3090"
- style="fill:#ffffff;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" />
- </g>
-</g></svg> \ No newline at end of file
diff --git a/plugins/rfid/icons/sensoron.svg b/plugins/rfid/icons/sensoron.svg
deleted file mode 100644
index d756860..0000000
--- a/plugins/rfid/icons/sensoron.svg
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- width="55"
- height="55"
- viewBox="0 0 55 55"
- id="svg2"
- xml:space="preserve"><metadata
- id="metadata15"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs13" /><rect
- width="55"
- height="55"
- x="0"
- y="0"
- id="rect3269"
- style="fill:#ffd200;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
- transform="translate(0.27777716,18.796296)"
- id="g4054"><line
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-opacity:1"
- x1="17.778971"
- x2="17.778971"
- y1="12.381037"
- y2="5.0263696"
- id="line3076" /><line
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-opacity:1"
- x1="28.811842"
- x2="33.427887"
- y1="8.7028332"
- y2="8.7028332"
- id="line3078" /><rect
- width="8.5284882"
- height="6.6171107"
- x="39.7141"
- y="5.3041511"
- id="rect3080"
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:1.95927083;stroke-linecap:round;stroke-opacity:1" /><path
- d="m 17.778971,5.0263697 c 0,-2.032417 -1.647529,-3.6782045 -3.678204,-3.6782045 -2.030675,0 -3.677334,1.6449167 -3.677334,3.6782045"
- id="path3082"
- style="fill:none;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 25.133639,12.381037 c 0,2.032417 -1.646658,3.678205 -3.678205,3.678205 -2.030675,0 -3.677333,-1.645788 -3.677333,-3.678205"
- id="path3084"
- style="fill:none;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 25.133639,12.381037 c 0,-2.030675 1.6484,-3.679946 3.678204,-3.679946"
- id="path3086"
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
- d="m 10.423433,5.0263697 c 0,2.0306754 -1.6475288,3.6764629 -3.6773334,3.6764629"
- id="path3088"
- style="fill:#000000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><rect
- width="12.606384"
- height="9.8834333"
- x="30.821619"
- y="3.6722956"
- id="rect3090"
- style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:3.04775476;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /></g></svg> \ No newline at end of file
diff --git a/plugins/rfid/rfid.py b/plugins/rfid/rfid.py
deleted file mode 100644
index de96a1f..0000000
--- a/plugins/rfid/rfid.py
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/usr/bin/env python
-#Copyright (C) 2010,11 Emiliano Pastorino <epastorino@plan.ceibal.edu.uy>
-#Copyright (c) 2011 Walter Bender
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import dbus
-from dbus.mainloop.glib import DBusGMainLoop
-from gettext import gettext as _
-
-from plugins.rfid.rfidutils import strhex2bin, strbin2dec, find_device
-from plugins.plugin import Plugin
-
-from TurtleArt.tapalette import make_palette
-from TurtleArt.talogo import primitive_dictionary
-from TurtleArt.tautils import debug_output
-
-import logging
-_logger = logging.getLogger('turtleart-activity RFID plugin')
-
-HAL_SERVICE = 'org.freedesktop.Hal'
-HAL_MGR_PATH = '/org/freedesktop/Hal/Manager'
-HAL_MGR_IFACE = 'org.freedesktop.Hal.Manager'
-HAL_DEV_IFACE = 'org.freedesktop.Hal.Device'
-REGEXP_SERUSB = '\/org\/freedesktop\/Hal\/devices\/usb_device['\
- 'a-z,A-Z,0-9,_]*serial_usb_[0-9]'
-
-
-class Rfid(Plugin):
-
- def __init__(self, parent):
- self._parent = parent
- self._status = False
-
- """
- The following code will initialize a USB RFID reader. Please note that
- in order to make this initialization function work, it is necessary to
- set the permission for the ttyUSB device to 0666. You can do this by
- adding a rule to /etc/udev/rules.d
-
- As root (using sudo or su), copy the following text into a new file in
- /etc/udev/rules.d/94-ttyUSB-rules
-
- KERNEL=="ttyUSB[0-9]",MODE="0666"
-
- You only have to do this once.
- """
-
- self.rfid_connected = False
- self.rfid_device = find_device()
- self.rfid_idn = ''
-
- if self.rfid_device is not None:
- _logger.info("RFID device found")
- self.rfid_connected = self.rfid_device.do_connect()
- if self.rfid_connected:
- self.rfid_device.connect("tag-read", self._tag_read_cb)
- self.rfid_device.connect("disconnected", self._disconnected_cb)
-
- loop = DBusGMainLoop()
- bus = dbus.SystemBus(mainloop=loop)
- hmgr_iface = dbus.Interface(bus.get_object(HAL_SERVICE,
- HAL_MGR_PATH), HAL_MGR_IFACE)
-
- hmgr_iface.connect_to_signal('DeviceAdded', self._device_added_cb)
-
- self._status = True
-
- def setup(self):
- # set up RFID-specific blocks
- primitive_dictionary['rfid'] = self.prim_read_rfid
- palette = make_palette('sensor',
- colors=["#FF6060", "#A06060"],
- help_string=_('Palette of sensor blocks'),
- position=6)
-
- if self._status:
- palette.add_block('rfid',
- style='box-style',
- label=_('RFID'),
- help_string=_('read value from RFID device'),
- value_block=True,
- prim_name='rfid')
- else:
- palette.add_block('rfid',
- hidden=True,
- style='box-style',
- label=_('RFID'),
- help_string=_('read value from RFID device'),
- value_block=True,
- prim_name='rfid')
-
- self._parent.lc.def_prim(
- 'rfid', 0, lambda self: primitive_dictionary['rfid']())
-
- def _status_report(self):
- debug_output('Reporting RFID status: %s' % (str(self._status)))
- return self._status
-
- def _device_added_cb(self, path):
- """
- Called from hal connection when a new device is plugged.
- """
- if not self.rfid_connected:
- self.rfid_device = find_device()
- _logger.debug("DEVICE_ADDED: %s" % self.rfid_device)
- if self.rfid_device is not None:
- _logger.debug("DEVICE_ADDED: RFID device is not None!")
- self.rfid_connected = self._device.do_connect()
- if self.rfid_connected:
- _logger.debug("DEVICE_ADDED: Connected!")
- self.rfid_device.connect("tag-read", self._tag_read_cb)
- self.rfid_device.connect("disconnected", self._disconnected_cb)
-
- def _disconnected_cb(self, device, text):
- """
- Called when the device is disconnected.
- """
- self.rfid_connected = False
- self.rfid_device = None
-
- def _tag_read_cb(self, device, tagid):
- """
- Callback for "tag-read" signal. Receives the read tag id.
- """
- idbin = strhex2bin(tagid)
- self.rfid_idn = strbin2dec(idbin[26:64])
- while self.rfid_idn.__len__() < 9:
- self.rfid_idn = '0' + self.rfid_idn
- print tagid, idbin, self.rfid_idn
- self.tw.lc.update_label_value('rfid', self.rfid_idn)
-
- # Block primitives used in talogo
-
- def prim_read_rfid(self):
- if self._status:
- return self.rfid_idn
- else:
- return '0'
diff --git a/plugins/rfid/rfidrweusb.py b/plugins/rfid/rfidrweusb.py
deleted file mode 100644
index bd12631..0000000
--- a/plugins/rfid/rfidrweusb.py
+++ /dev/null
@@ -1,200 +0,0 @@
-from device import RFIDDevice
-from serial import Serial
-import dbus
-from dbus.mainloop.glib import DBusGMainLoop
-import gobject
-from time import sleep
-import utils
-
-HAL_SERVICE = 'org.freedesktop.Hal'
-HAL_MGR_PATH = '/org/freedesktop/Hal/Manager'
-HAL_MGR_IFACE = 'org.freedesktop.Hal.Manager'
-HAL_DEV_IFACE = 'org.freedesktop.Hal.Device'
-REGEXP_SERUSB = '\/org\/freedesktop\/Hal\/devices\/usb_device['\
- 'a-z,A-Z,0-9,_]*serial_usb_[0-9]'
-
-VERSIONS = ['301']
-
-class RFIDReader(RFIDDevice):
- """
- RFIDRW-E-W interface.
- """
-
- def __init__(self):
-
- RFIDDevice.__init__(self)
- self.last_tag = ""
- self.tags = []
- self.ser = Serial()
- self.device = ''
- self.device_path = ''
- self._connected = False
-
- loop = DBusGMainLoop()
- self.bus = dbus.SystemBus(mainloop=loop)
- hmgr_iface = dbus.Interface(self.bus.get_object(HAL_SERVICE,
- HAL_MGR_PATH), HAL_MGR_IFACE)
-
- hmgr_iface.connect_to_signal('DeviceRemoved', self._device_removed_cb)
-
- def get_present(self):
- """
- Checks if RFID-RW-USB device is present.
- Returns True if so, False otherwise.
- """
- hmgr_if = dbus.Interface(self.bus.get_object(HAL_SERVICE, HAL_MGR_PATH),
- HAL_MGR_IFACE)
- serialusb_devices = set(hmgr_if.FindDeviceStringMatch('serial.type',
- 'usb')) & set(hmgr_if.FindDeviceStringMatch(
- 'info.subsystem', 'tty'))
- for i in serialusb_devices:
- serialusb_if = dbus.Interface(self.bus.get_object(HAL_SERVICE, i),
- HAL_DEV_IFACE)
- if serialusb_if.PropertyExists('info.parent'):
- parent_udi = str(serialusb_if.GetProperty('info.parent'))
- parent = dbus.Interface(self.bus.get_object(HAL_SERVICE,
- parent_udi), HAL_DEV_IFACE)
- if parent.PropertyExists('info.linux.driver') and \
- str(parent.GetProperty('info.linux.driver')) == 'ftdi_sio':
- device = str(serialusb_if.GetProperty('linux.device_file'))
- ser = Serial(device, 9600, timeout=0.1)
- ser.read(100)
- ser.write('v')
- ser.write('e')
- ser.write('r')
- ser.write('\x0D')
- resp = ser.read(4)
- if resp[0:-1] in VERSIONS:
- self.device = device
- self.device_path = i
- return True
- return False
-
- def do_connect(self):
- """
- Connects to the device.
- Returns True if successfull, False otherwise.
- """
- retval = False
- if self.get_present():
- try:
- self.ser = Serial(self.device, 9600, timeout=0.1)
- self._connected = True
- if self._select_animal_tag:
- #gobject.idle_add(self._loop)
- gobject.timeout_add(1000, self._loop)
- retval = True
- except:
- self._connected = False
- return retval
-
- def do_disconnect(self):
- """
- Disconnect from the device.
- """
- self.ser.close()
- self._connected = False
-
- def read_tag(self):
- """
- Returns the last read value.
- """
- return self.last_tag
-
- def _select_animal_tag(self):
- """
- Sends the "Select Tag 2" (animal tag) command to the device.
- """
- self.ser.read(100)
- self.ser.write('s')
- self.ser.write('t')
- self.ser.write('2')
- self.ser.write('\x0d')
- resp = self.ser.read(3)[0:-1]
- if resp == 'OK':
- return True
- return False
-
- def get_version(self):
- """
- Sends the version command to the device and returns
- a string with the device version.
- """
- #self.ser.flushInput()
- ver = "???"
- self.ser.read(100)
- self.ser.write('v')
- self.ser.write('e')
- self.ser.write('r')
- self.ser.write('\x0d')
- resp = self.ser.read(4)[0:-1]
- if resp in VERSIONS:
- return "RFIDRW-E-USB " + resp
- return ver
-
- def _device_removed_cb(self, path):
- """
- Called when a device is removed.
- Checks if the removed device is itself and emits the "disconnected"
- signal if so.
- """
- if path == self.device_path:
- self.device_path = ''
- self.ser.close()
- self._connected = False
- self.tags = []
- self.emit("disconnected","RFID-RW-USB")
-
- def _loop(self):
- """
- Threaded loop for reading data from the device.
- """
- if not self._connected:
- return False
-
- self.ser.read(100)
- self.ser.write('r')
- self.ser.write('a')
- self.ser.write('t')
- self.ser.write('\x0d')
- resp = self.ser.read(33)[0:-1].split('_')
- if resp.__len__() is not 6 or resp in self.tags:
- return True
-
- self.tags.append(resp)
- anbit_bin = utils.dec2bin(int(resp[2]))
- reserved_bin = '00000000000000'
- databit_bin = utils.dec2bin(int(resp[3]))
- country_bin = utils.dec2bin(int(resp[0]))
- while country_bin.__len__() < 10:
- country_bin = '0' + country_bin
- id_bin = utils.dec2bin(int(resp[1]))
- while id_bin.__len__() < 10:
- id_bin = '0' + id_bin
-
- tag_bin = anbit_bin + reserved_bin + databit_bin + country_bin + id_bin
- data = utils.bin2hex(tag_bin)
- self.emit("tag-read", data)
- self.last_tag = data
- #sleep(1)
- return True
-
-# Testing
-#if __name__ == '__main__':
-# def handler(device, idhex):
-# """
-# Handler for "tag-read" signal.
-# Prints the tag id.
-# """
-# print "ID: ", idhex
-#
-# dev = RFIDReader()
-# if dev.get_present():
-# print "SIPI!"
-# dev.do_connect()
-# dev.connect('tag-read', handler)
-# else:
-# print "Not connected"
-#
-# mloop = gobject.MainLoop()
-# mloop.run()
diff --git a/plugins/rfid/rfidutils.py b/plugins/rfid/rfidutils.py
deleted file mode 100644
index 4e02619..0000000
--- a/plugins/rfid/rfidutils.py
+++ /dev/null
@@ -1,123 +0,0 @@
-# utils.py - Helper functions for tis2000.py
-# Copyright (C) 2010 Emiliano Pastorino <epastorino@plan.ceibal.edu.uy>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-import os
-import logging
-
-def find_device():
- """
- Search for devices.
- Return a device instance or None.
- """
- device = None
- for i in os.listdir(os.path.join('.', 'plugins/rfid')):
- if not os.path.isdir(os.path.join('.', 'plugins/rfid', i)):
- try:
- _tempmod = __import__('rfid.%s'%i.split('.')[0], globals(),
- locals(), ['RFIDReader'], -1)
- devtemp = _tempmod.RFIDReader()
- if devtemp.get_present() == True:
- device = devtemp
- except Exception, e:
- # logging.error("FIND_DEVICE: %s: %s"%(i, e))
- pass
- if device is None:
- logging.debug("No RFID device found")
- return device
-
-
-def strhex2bin(strhex):
- """
- Convert a string representing an hex value into a
- string representing the same value in binary format.
- """
- dic = { '0':"0000",
- '1':"0001",
- '2':"0010",
- '3':"0011",
- '4':"0100",
- '5':"0101",
- '6':"0110",
- '7':"0111",
- '8':"1000",
- '9':"1001",
- 'A':"1010",
- 'B':"1011",
- 'C':"1100",
- 'D':"1101",
- 'E':"1110",
- 'F':"1111"
- }
- binstr = ""
- for i in strhex:
- binstr = binstr + dic[i.upper()]
- return binstr
-
-def strbin2dec(strbin):
- """
- Convert a string representing a binary value into a
- string representing the same value in decimal format.
- """
- strdec = "0"
- for i in range(1, strbin.__len__()+1):
- strdec = str(int(strdec)+int(strbin[-i])*int(pow(2, i-1)))
- return strdec
-
-def dec2bin(ndec):
- """
- Convert a decimal number into a string representing
- the same value in binary format.
- """
- if ndec < 1:
- return "0"
- binary = []
- while ndec != 0:
- binary.append(ndec%2)
- ndec = ndec/2
- strbin = ""
- binary.reverse()
- for i in binary:
- strbin = strbin+str(i)
- return strbin
-
-def bin2hex(strbin):
- """
- Convert a string representing a binary number into a string
- representing the same value in hexadecimal format.
- """
- dic = { "0000":"0",
- "0001":"1",
- "0010":"2",
- "0011":"3",
- "0100":"4",
- "0101":"5",
- "0110":"6",
- "0111":"7",
- "1000":"8",
- "1001":"9",
- "1010":"A",
- "1011":"B",
- "1100":"C",
- "1101":"D",
- "1110":"E",
- "1111":"F"
- }
- while strbin.__len__()%4 != 0:
- strbin = '0' + strbin
- strh = ""
- for i in range(0, strbin.__len__()/4):
- strh = strh + dic[str(strbin[i*4:i*4+4])]
- return strh
diff --git a/plugins/rfid/serial/__init__.py b/plugins/rfid/serial/__init__.py
deleted file mode 100644
index 681ad5c..0000000
--- a/plugins/rfid/serial/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env python
-#portable serial port access with python
-#this is a wrapper module for different platform implementations
-#
-# (C)2001-2002 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
-
-VERSION = '2.4'
-
-import sys
-
-if sys.platform == 'cli':
- from serialcli import *
-else:
- import os
- #chose an implementation, depending on os
- if os.name == 'nt': #sys.platform == 'win32':
- from serialwin32 import *
- elif os.name == 'posix':
- from serialposix import *
- elif os.name == 'java':
- from serialjava import *
- else:
- raise Exception("Sorry: no implementation for your platform ('%s') available" % os.name)
-
diff --git a/plugins/rfid/serial/serialposix.py b/plugins/rfid/serial/serialposix.py
deleted file mode 100644
index 174e2f7..0000000
--- a/plugins/rfid/serial/serialposix.py
+++ /dev/null
@@ -1,492 +0,0 @@
-#!/usr/bin/env python
-# Python Serial Port Extension for Win32, Linux, BSD, Jython
-# module for serial IO for POSIX compatible systems, like Linux
-# see __init__.py
-#
-# (C) 2001-2008 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
-#
-# parts based on code from Grant B. Edwards <grante@visi.com>:
-# ftp://ftp.visi.com/users/grante/python/PosixSerial.py
-# references: http://www.easysw.com/~mike/serial/serial.html
-
-import sys, os, fcntl, termios, struct, select, errno
-from serialutil import *
-
-#Do check the Python version as some constants have moved.
-if (sys.hexversion < 0x020100f0):
- import TERMIOS
-else:
- TERMIOS = termios
-
-if (sys.hexversion < 0x020200f0):
- import FCNTL
-else:
- FCNTL = fcntl
-
-#try to detect the os so that a device can be selected...
-plat = sys.platform.lower()
-
-if plat[:5] == 'linux': #Linux (confirmed)
- def device(port):
- return '/dev/ttyS%d' % port
-
-elif plat == 'cygwin': #cywin/win32 (confirmed)
- def device(port):
- return '/dev/com%d' % (port + 1)
-
-elif plat == 'openbsd3': #BSD (confirmed)
- def device(port):
- return '/dev/ttyp%d' % port
-
-elif plat[:3] == 'bsd' or \
- plat[:7] == 'freebsd' or \
- plat[:7] == 'openbsd' or \
- plat[:6] == 'darwin': #BSD (confirmed for freebsd4: cuaa%d)
- def device(port):
- return '/dev/cuad%d' % port
-
-elif plat[:6] == 'netbsd': #NetBSD 1.6 testing by Erk
- def device(port):
- return '/dev/dty%02d' % port
-
-elif plat[:4] == 'irix': #IRIX (partialy tested)
- def device(port):
- return '/dev/ttyf%d' % (port+1) #XXX different device names depending on flow control
-
-elif plat[:2] == 'hp': #HP-UX (not tested)
- def device(port):
- return '/dev/tty%dp0' % (port+1)
-
-elif plat[:5] == 'sunos': #Solaris/SunOS (confirmed)
- def device(port):
- return '/dev/tty%c' % (ord('a')+port)
-
-elif plat[:3] == 'aix': #aix
- def device(port):
- return '/dev/tty%d' % (port)
-
-else:
- #platform detection has failed...
- print """don't know how to number ttys on this system.
-! Use an explicit path (eg /dev/ttyS1) or send this information to
-! the author of this module:
-
-sys.platform = %r
-os.name = %r
-serialposix.py version = %s
-
-also add the device name of the serial port and where the
-counting starts for the first serial port.
-e.g. 'first serial port: /dev/ttyS0'
-and with a bit luck you can get this module running...
-""" % (sys.platform, os.name, VERSION)
- #no exception, just continue with a brave attempt to build a device name
- #even if the device name is not correct for the platform it has chances
- #to work using a string with the real device name as port paramter.
- def device(portum):
- return '/dev/ttyS%d' % portnum
- #~ raise Exception, "this module does not run on this platform, sorry."
-
-#whats up with "aix", "beos", ....
-#they should work, just need to know the device names.
-
-
-#load some constants for later use.
-#try to use values from TERMIOS, use defaults from linux otherwise
-TIOCMGET = hasattr(TERMIOS, 'TIOCMGET') and TERMIOS.TIOCMGET or 0x5415
-TIOCMBIS = hasattr(TERMIOS, 'TIOCMBIS') and TERMIOS.TIOCMBIS or 0x5416
-TIOCMBIC = hasattr(TERMIOS, 'TIOCMBIC') and TERMIOS.TIOCMBIC or 0x5417
-TIOCMSET = hasattr(TERMIOS, 'TIOCMSET') and TERMIOS.TIOCMSET or 0x5418
-
-#TIOCM_LE = hasattr(TERMIOS, 'TIOCM_LE') and TERMIOS.TIOCM_LE or 0x001
-TIOCM_DTR = hasattr(TERMIOS, 'TIOCM_DTR') and TERMIOS.TIOCM_DTR or 0x002
-TIOCM_RTS = hasattr(TERMIOS, 'TIOCM_RTS') and TERMIOS.TIOCM_RTS or 0x004
-#TIOCM_ST = hasattr(TERMIOS, 'TIOCM_ST') and TERMIOS.TIOCM_ST or 0x008
-#TIOCM_SR = hasattr(TERMIOS, 'TIOCM_SR') and TERMIOS.TIOCM_SR or 0x010
-
-TIOCM_CTS = hasattr(TERMIOS, 'TIOCM_CTS') and TERMIOS.TIOCM_CTS or 0x020
-TIOCM_CAR = hasattr(TERMIOS, 'TIOCM_CAR') and TERMIOS.TIOCM_CAR or 0x040
-TIOCM_RNG = hasattr(TERMIOS, 'TIOCM_RNG') and TERMIOS.TIOCM_RNG or 0x080
-TIOCM_DSR = hasattr(TERMIOS, 'TIOCM_DSR') and TERMIOS.TIOCM_DSR or 0x100
-TIOCM_CD = hasattr(TERMIOS, 'TIOCM_CD') and TERMIOS.TIOCM_CD or TIOCM_CAR
-TIOCM_RI = hasattr(TERMIOS, 'TIOCM_RI') and TERMIOS.TIOCM_RI or TIOCM_RNG
-#TIOCM_OUT1 = hasattr(TERMIOS, 'TIOCM_OUT1') and TERMIOS.TIOCM_OUT1 or 0x2000
-#TIOCM_OUT2 = hasattr(TERMIOS, 'TIOCM_OUT2') and TERMIOS.TIOCM_OUT2 or 0x4000
-TIOCINQ = hasattr(TERMIOS, 'FIONREAD') and TERMIOS.FIONREAD or 0x541B
-
-TIOCM_zero_str = struct.pack('I', 0)
-TIOCM_RTS_str = struct.pack('I', TIOCM_RTS)
-TIOCM_DTR_str = struct.pack('I', TIOCM_DTR)
-
-TIOCSBRK = hasattr(TERMIOS, 'TIOCSBRK') and TERMIOS.TIOCSBRK or 0x5427
-TIOCCBRK = hasattr(TERMIOS, 'TIOCCBRK') and TERMIOS.TIOCCBRK or 0x5428
-
-ASYNC_SPD_MASK = 0x1030
-ASYNC_SPD_CUST = 0x0030
-
-baudrate_constants = {
- 0: 0000000, # hang up
- 50: 0000001,
- 75: 0000002,
- 110: 0000003,
- 134: 0000004,
- 150: 0000005,
- 200: 0000006,
- 300: 0000007,
- 600: 0000010,
- 1200: 0000011,
- 1800: 0000012,
- 2400: 0000013,
- 4800: 0000014,
- 9600: 0000015,
- 19200: 0000016,
- 38400: 0000017,
- 57600: 0010001,
- 115200: 0010002,
- 230400: 0010003,
- 460800: 0010004,
- 500000: 0010005,
- 576000: 0010006,
- 921600: 0010007,
- 1000000: 0010010,
- 1152000: 0010011,
- 1500000: 0010012,
- 2000000: 0010013,
- 2500000: 0010014,
- 3000000: 0010015,
- 3500000: 0010016,
- 4000000: 0010017
-}
-
-
-class Serial(SerialBase):
- """Serial port class POSIX implementation. Serial port configuration is
- done with termios and fcntl. Runs on Linux and many other Un*x like
- systems."""
-
- def open(self):
- """Open port with current settings. This may throw a SerialException
- if the port cannot be opened."""
- if self._port is None:
- raise SerialException("Port must be configured before it can be used.")
- self.fd = None
- #open
- try:
- self.fd = os.open(self.portstr, os.O_RDWR|os.O_NOCTTY|os.O_NONBLOCK)
- except Exception, msg:
- self.fd = None
- raise SerialException("could not open port %s: %s" % (self._port, msg))
- #~ fcntl.fcntl(self.fd, FCNTL.F_SETFL, 0) #set blocking
-
- try:
- self._reconfigurePort()
- except:
- os.close(self.fd)
- self.fd = None
- else:
- self._isOpen = True
- #~ self.flushInput()
-
-
- def _reconfigurePort(self):
- """Set communication parameters on opened port."""
- if self.fd is None:
- raise SerialException("Can only operate on a valid port handle")
- custom_baud = None
-
- vmin = vtime = 0 #timeout is done via select
- if self._interCharTimeout is not None:
- vmin = 1
- vtime = int(self._interCharTimeout * 10)
- try:
- iflag, oflag, cflag, lflag, ispeed, ospeed, cc = termios.tcgetattr(self.fd)
- except termios.error, msg: #if a port is nonexistent but has a /dev file, it'll fail here
- raise SerialException("Could not configure port: %s" % msg)
- #set up raw mode / no echo / binary
- cflag |= (TERMIOS.CLOCAL|TERMIOS.CREAD)
- lflag &= ~(TERMIOS.ICANON|TERMIOS.ECHO|TERMIOS.ECHOE|TERMIOS.ECHOK|TERMIOS.ECHONL|
- TERMIOS.ISIG|TERMIOS.IEXTEN) #|TERMIOS.ECHOPRT
- for flag in ('ECHOCTL', 'ECHOKE'): #netbsd workaround for Erk
- if hasattr(TERMIOS, flag):
- lflag &= ~getattr(TERMIOS, flag)
-
- oflag &= ~(TERMIOS.OPOST)
- iflag &= ~(TERMIOS.INLCR|TERMIOS.IGNCR|TERMIOS.ICRNL|TERMIOS.IGNBRK)
- if hasattr(TERMIOS, 'IUCLC'):
- iflag &= ~TERMIOS.IUCLC
- if hasattr(TERMIOS, 'PARMRK'):
- iflag &= ~TERMIOS.PARMRK
-
- #setup baudrate
- try:
- ispeed = ospeed = getattr(TERMIOS,'B%s' % (self._baudrate))
- except AttributeError:
- try:
- ispeed = ospeed = baudrate_constants[self._baudrate]
- except KeyError:
- #~ raise ValueError('Invalid baud rate: %r' % self._baudrate)
- # may need custom baud rate, it isnt in our list.
- ispeed = ospeed = getattr(TERMIOS, 'B38400')
- custom_baud = int(self._baudrate) # store for later
-
- #setup char len
- cflag &= ~TERMIOS.CSIZE
- if self._bytesize == 8:
- cflag |= TERMIOS.CS8
- elif self._bytesize == 7:
- cflag |= TERMIOS.CS7
- elif self._bytesize == 6:
- cflag |= TERMIOS.CS6
- elif self._bytesize == 5:
- cflag |= TERMIOS.CS5
- else:
- raise ValueError('Invalid char len: %r' % self._bytesize)
- #setup stopbits
- if self._stopbits == STOPBITS_ONE:
- cflag &= ~(TERMIOS.CSTOPB)
- elif self._stopbits == STOPBITS_TWO:
- cflag |= (TERMIOS.CSTOPB)
- else:
- raise ValueError('Invalid stopit specification: %r' % self._stopbits)
- #setup parity
- iflag &= ~(TERMIOS.INPCK|TERMIOS.ISTRIP)
- if self._parity == PARITY_NONE:
- cflag &= ~(TERMIOS.PARENB|TERMIOS.PARODD)
- elif self._parity == PARITY_EVEN:
- cflag &= ~(TERMIOS.PARODD)
- cflag |= (TERMIOS.PARENB)
- elif self._parity == PARITY_ODD:
- cflag |= (TERMIOS.PARENB|TERMIOS.PARODD)
- else:
- raise ValueError('Invalid parity: %r' % self._parity)
- #setup flow control
- #xonxoff
- if hasattr(TERMIOS, 'IXANY'):
- if self._xonxoff:
- iflag |= (TERMIOS.IXON|TERMIOS.IXOFF) #|TERMIOS.IXANY)
- else:
- iflag &= ~(TERMIOS.IXON|TERMIOS.IXOFF|TERMIOS.IXANY)
- else:
- if self._xonxoff:
- iflag |= (TERMIOS.IXON|TERMIOS.IXOFF)
- else:
- iflag &= ~(TERMIOS.IXON|TERMIOS.IXOFF)
- #rtscts
- if hasattr(TERMIOS, 'CRTSCTS'):
- if self._rtscts:
- cflag |= (TERMIOS.CRTSCTS)
- else:
- cflag &= ~(TERMIOS.CRTSCTS)
- elif hasattr(TERMIOS, 'CNEW_RTSCTS'): #try it with alternate constant name
- if self._rtscts:
- cflag |= (TERMIOS.CNEW_RTSCTS)
- else:
- cflag &= ~(TERMIOS.CNEW_RTSCTS)
- #XXX should there be a warning if setting up rtscts (and xonxoff etc) fails??
-
- #buffer
- #vmin "minimal number of characters to be read. = for non blocking"
- if vmin < 0 or vmin > 255:
- raise ValueError('Invalid vmin: %r ' % vmin)
- cc[TERMIOS.VMIN] = vmin
- #vtime
- if vtime < 0 or vtime > 255:
- raise ValueError('Invalid vtime: %r' % vtime)
- cc[TERMIOS.VTIME] = vtime
- #activate settings
- termios.tcsetattr(self.fd, TERMIOS.TCSANOW, [iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
-
- # apply custom baud rate, if any
- if custom_baud is not None:
- import array
- buf = array.array('i', [0] * 32)
-
- # get serial_struct
- FCNTL.ioctl(self.fd, TERMIOS.TIOCGSERIAL, buf)
-
- # set custom divisor
- buf[6] = buf[7] / custom_baud
-
- # update flags
- buf[4] &= ~ASYNC_SPD_MASK
- buf[4] |= ASYNC_SPD_CUST
-
- # set serial_struct
- try:
- res = FCNTL.ioctl(self.fd, TERMIOS.TIOCSSERIAL, buf)
- except IOError:
- raise ValueError('Failed to set custom baud rate: %r' % self._baudrate)
-
- def close(self):
- """Close port"""
- if self._isOpen:
- if self.fd is not None:
- os.close(self.fd)
- self.fd = None
- self._isOpen = False
-
- def makeDeviceName(self, port):
- return device(port)
-
- # - - - - - - - - - - - - - - - - - - - - - - - -
-
- def inWaiting(self):
- """Return the number of characters currently in the input buffer."""
- #~ s = fcntl.ioctl(self.fd, TERMIOS.FIONREAD, TIOCM_zero_str)
- s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
- return struct.unpack('I',s)[0]
-
- def read(self, size=1):
- """Read size bytes from the serial port. If a timeout is set it may
- return less characters as requested. With no timeout it will block
- until the requested number of bytes is read."""
- if self.fd is None: raise portNotOpenError
- read = ''
- inp = None
- if size > 0:
- while len(read) < size:
- #print "\tread(): size",size, "have", len(read) #debug
- ready,_,_ = select.select([self.fd],[],[], self._timeout)
- if not ready:
- break #timeout
- buf = os.read(self.fd, size-len(read))
- read = read + buf
- if (self._timeout >= 0 or self._interCharTimeout > 0) and not buf:
- break #early abort on timeout
- return read
-
- def write(self, data):
- """Output the given string over the serial port."""
- if self.fd is None: raise portNotOpenError
- if not isinstance(data, str):
- raise TypeError('expected str, got %s' % type(data))
- t = len(data)
- d = data
- while t > 0:
- try:
- if self._writeTimeout is not None and self._writeTimeout > 0:
- _,ready,_ = select.select([],[self.fd],[], self._writeTimeout)
- if not ready:
- raise writeTimeoutError
- n = os.write(self.fd, d)
- if self._writeTimeout is not None and self._writeTimeout > 0:
- _,ready,_ = select.select([],[self.fd],[], self._writeTimeout)
- if not ready:
- raise writeTimeoutError
- d = d[n:]
- t = t - n
- except OSError,v:
- if v.errno != errno.EAGAIN:
- raise
-
- def flush(self):
- """Flush of file like objects. In this case, wait until all data
- is written."""
- self.drainOutput()
-
- def flushInput(self):
- """Clear input buffer, discarding all that is in the buffer."""
- if self.fd is None:
- raise portNotOpenError
- termios.tcflush(self.fd, TERMIOS.TCIFLUSH)
-
- def flushOutput(self):
- """Clear output buffer, aborting the current output and
- discarding all that is in the buffer."""
- if self.fd is None:
- raise portNotOpenError
- termios.tcflush(self.fd, TERMIOS.TCOFLUSH)
-
- def sendBreak(self, duration=0.25):
- """Send break condition. Timed, returns to idle state after given duration."""
- if self.fd is None:
- raise portNotOpenError
- termios.tcsendbreak(self.fd, int(duration/0.25))
-
- def setBreak(self, level=1):
- """Set break: Controls TXD. When active, to transmitting is possible."""
- if self.fd is None: raise portNotOpenError
- if level:
- fcntl.ioctl(self.fd, TIOCSBRK)
- else:
- fcntl.ioctl(self.fd, TIOCCBRK)
-
- def setRTS(self, level=1):
- """Set terminal status line: Request To Send"""
- if self.fd is None: raise portNotOpenError
- if level:
- fcntl.ioctl(self.fd, TIOCMBIS, TIOCM_RTS_str)
- else:
- fcntl.ioctl(self.fd, TIOCMBIC, TIOCM_RTS_str)
-
- def setDTR(self, level=1):
- """Set terminal status line: Data Terminal Ready"""
- if self.fd is None: raise portNotOpenError
- if level:
- fcntl.ioctl(self.fd, TIOCMBIS, TIOCM_DTR_str)
- else:
- fcntl.ioctl(self.fd, TIOCMBIC, TIOCM_DTR_str)
-
- def getCTS(self):
- """Read terminal status line: Clear To Send"""
- if self.fd is None: raise portNotOpenError
- s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str)
- return struct.unpack('I',s)[0] & TIOCM_CTS != 0
-
- def getDSR(self):
- """Read terminal status line: Data Set Ready"""
- if self.fd is None: raise portNotOpenError
- s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str)
- return struct.unpack('I',s)[0] & TIOCM_DSR != 0
-
- def getRI(self):
- """Read terminal status line: Ring Indicator"""
- if self.fd is None: raise portNotOpenError
- s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str)
- return struct.unpack('I',s)[0] & TIOCM_RI != 0
-
- def getCD(self):
- """Read terminal status line: Carrier Detect"""
- if self.fd is None: raise portNotOpenError
- s = fcntl.ioctl(self.fd, TIOCMGET, TIOCM_zero_str)
- return struct.unpack('I',s)[0] & TIOCM_CD != 0
-
- # - - platform specific - - - -
-
- def drainOutput(self):
- """internal - not portable!"""
- if self.fd is None: raise portNotOpenError
- termios.tcdrain(self.fd)
-
- def nonblocking(self):
- """internal - not portable!"""
- if self.fd is None:
- raise portNotOpenError
- fcntl.fcntl(self.fd, FCNTL.F_SETFL, FCNTL.O_NONBLOCK)
-
- def fileno(self):
- """For easier of the serial port instance with select.
- WARNING: this function is not portable to different platforms!"""
- if self.fd is None: raise portNotOpenError
- return self.fd
-
-if __name__ == '__main__':
- s = Serial(0,
- baudrate=19200, #baudrate
- bytesize=EIGHTBITS, #number of databits
- parity=PARITY_EVEN, #enable parity checking
- stopbits=STOPBITS_ONE, #number of stopbits
- timeout=3, #set a timeout value, None for waiting forever
- xonxoff=0, #enable software flow control
- rtscts=0, #enable RTS/CTS flow control
- )
- s.setRTS(1)
- s.setDTR(1)
- s.flushInput()
- s.flushOutput()
- s.write('hello')
- print repr(s.read(5))
- print s.inWaiting()
- del s
-
diff --git a/plugins/rfid/serial/serialutil.py b/plugins/rfid/serial/serialutil.py
deleted file mode 100644
index fd466f2..0000000
--- a/plugins/rfid/serial/serialutil.py
+++ /dev/null
@@ -1,400 +0,0 @@
-#! python
-# Python Serial Port Extension for Win32, Linux, BSD, Jython
-# see __init__.py
-#
-# (C) 2001-2008 Chris Liechti <cliechti@gmx.net>
-# this is distributed under a free software license, see license.txt
-
-PARITY_NONE, PARITY_EVEN, PARITY_ODD, PARITY_MARK, PARITY_SPACE = 'N', 'E', 'O', 'M', 'S'
-STOPBITS_ONE, STOPBITS_TWO = (1, 2)
-FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS = (5,6,7,8)
-
-PARITY_NAMES = {
- PARITY_NONE: 'None',
- PARITY_EVEN: 'Even',
- PARITY_ODD: 'Odd',
- PARITY_MARK: 'Mark',
- PARITY_SPACE:'Space',
-}
-
-XON = chr(17)
-XOFF = chr(19)
-
-#Python < 2.2.3 compatibility
-try:
- True
-except:
- True = 1
- False = not True
-
-class SerialException(Exception):
- """Base class for serial port related exceptions."""
-
-portNotOpenError = SerialException('Port not open')
-
-class SerialTimeoutException(SerialException):
- """Write timeouts give an exception"""
-
-writeTimeoutError = SerialTimeoutException("Write timeout")
-
-class FileLike(object):
- """An abstract file like class.
-
- This class implements readline and readlines based on read and
- writelines based on write.
- This class is used to provide the above functions for to Serial
- port objects.
-
- Note that when the serial port was opened with _NO_ timeout that
- readline blocks until it sees a newline (or the specified size is
- reached) and that readlines would never return and therefore
- refuses to work (it raises an exception in this case)!
- """
-
- def read(self, size): raise NotImplementedError
- def write(self, s): raise NotImplementedError
-
- def readline(self, size=None, eol='\n'):
- """read a line which is terminated with end-of-line (eol) character
- ('\n' by default) or until timeout"""
- line = ''
- while 1:
- c = self.read(1)
- if c:
- line += c #not very efficient but lines are usually not that long
- if c == eol:
- break
- if size is not None and len(line) >= size:
- break
- else:
- break
- return line
-
- def readlines(self, sizehint=None, eol='\n'):
- """read a list of lines, until timeout
- sizehint is ignored"""
- if self.timeout is None:
- raise ValueError, "Serial port MUST have enabled timeout for this function!"
- lines = []
- while 1:
- line = self.readline(eol=eol)
- if line:
- lines.append(line)
- if line[-1] != eol: #was the line received with a timeout?
- break
- else:
- break
- return lines
-
- def xreadlines(self, sizehint=None):
- """just call readlines - here for compatibility"""
- return self.readlines()
-
- def writelines(self, sequence):
- for line in sequence:
- self.write(line)
-
- def flush(self):
- """flush of file like objects"""
- pass
-
- # iterator for e.g. "for line in Serial(0): ..." usage
- def next(self):
- line = self.readline()
- if not line: raise StopIteration
- return line
-
- def __iter__(self):
- return self
-
-
-class SerialBase(FileLike):
- """Serial port base class. Provides __init__ function and properties to
- get/set port settings."""
-
- #default values, may be overriden in subclasses that do not support all values
- BAUDRATES = (50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,
- 19200,38400,57600,115200,230400,460800,500000,576000,921600,
- 1000000,1152000,1500000,2000000,2500000,3000000,3500000,4000000)
- BYTESIZES = (FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS)
- PARITIES = (PARITY_NONE, PARITY_EVEN, PARITY_ODD)
- STOPBITS = (STOPBITS_ONE, STOPBITS_TWO)
-
- def __init__(self,
- port = None, #number of device, numbering starts at
- #zero. if everything fails, the user
- #can specify a device string, note
- #that this isn't portable anymore
- #port will be opened if one is specified
- baudrate=9600, #baudrate
- bytesize=EIGHTBITS, #number of databits
- parity=PARITY_NONE, #enable parity checking
- stopbits=STOPBITS_ONE, #number of stopbits
- timeout=None, #set a timeout value, None to wait forever
- xonxoff=0, #enable software flow control
- rtscts=0, #enable RTS/CTS flow control
- writeTimeout=None, #set a timeout for writes
- dsrdtr=None, #None: use rtscts setting, dsrdtr override if true or false
- interCharTimeout=None #Inter-character timeout, None to disable
- ):
- """Initialize comm port object. If a port is given, then the port will be
- opened immediately. Otherwise a Serial port object in closed state
- is returned."""
-
- self._isOpen = False
- self._port = None #correct value is assigned below trough properties
- self._baudrate = None #correct value is assigned below trough properties
- self._bytesize = None #correct value is assigned below trough properties
- self._parity = None #correct value is assigned below trough properties
- self._stopbits = None #correct value is assigned below trough properties
- self._timeout = None #correct value is assigned below trough properties
- self._writeTimeout = None #correct value is assigned below trough properties
- self._xonxoff = None #correct value is assigned below trough properties
- self._rtscts = None #correct value is assigned below trough properties
- self._dsrdtr = None #correct value is assigned below trough properties
- self._interCharTimeout = None #correct value is assigned below trough properties
-
- #assign values using get/set methods using the properties feature
- self.port = port
- self.baudrate = baudrate
- self.bytesize = bytesize
- self.parity = parity
- self.stopbits = stopbits
- self.timeout = timeout
- self.writeTimeout = writeTimeout
- self.xonxoff = xonxoff
- self.rtscts = rtscts
- self.dsrdtr = dsrdtr
- self.interCharTimeout = interCharTimeout
-
- if port is not None:
- self.open()
-
- def isOpen(self):
- """Check if the port is opened."""
- return self._isOpen
-
- # - - - - - - - - - - - - - - - - - - - - - - - -
-
- #TODO: these are not realy needed as the is the BAUDRATES etc attribute...
- #maybe i remove them before the final release...
-
- def getSupportedBaudrates(self):
- return [(str(b), b) for b in self.BAUDRATES]
-
- def getSupportedByteSizes(self):
- return [(str(b), b) for b in self.BYTESIZES]
-
- def getSupportedStopbits(self):
- return [(str(b), b) for b in self.STOPBITS]
-
- def getSupportedParities(self):
- return [(PARITY_NAMES[b], b) for b in self.PARITIES]
-
- # - - - - - - - - - - - - - - - - - - - - - - - -
-
- def setPort(self, port):
- """Change the port. The attribute portstr is set to a string that
- contains the name of the port."""
-
- was_open = self._isOpen
- if was_open: self.close()
- if port is not None:
- if type(port) in [type(''), type(u'')]: #strings are taken directly
- self.portstr = port
- else:
- self.portstr = self.makeDeviceName(port)
- else:
- self.portstr = None
- self._port = port
- if was_open: self.open()
-
- def getPort(self):
- """Get the current port setting. The value that was passed on init or using
- setPort() is passed back. See also the attribute portstr which contains
- the name of the port as a string."""
- return self._port
-
- port = property(getPort, setPort, doc="Port setting")
-
-
- def setBaudrate(self, baudrate):
- """Change baudrate. It raises a ValueError if the port is open and the
- baudrate is not possible. If the port is closed, then tha value is
- accepted and the exception is raised when the port is opened."""
- #~ if baudrate not in self.BAUDRATES: raise ValueError("Not a valid baudrate: %r" % baudrate)
- try:
- self._baudrate = int(baudrate)
- except TypeError:
- raise ValueError("Not a valid baudrate: %r" % (baudrate,))
- else:
- if self._isOpen: self._reconfigurePort()
-
- def getBaudrate(self):
- """Get the current baudrate setting."""
- return self._baudrate
-
- baudrate = property(getBaudrate, setBaudrate, doc="Baudrate setting")
-
-
- def setByteSize(self, bytesize):
- """Change byte size."""
- if bytesize not in self.BYTESIZES: raise ValueError("Not a valid byte size: %r" % (bytesize,))
- self._bytesize = bytesize
- if self._isOpen: self._reconfigurePort()
-
- def getByteSize(self):
- """Get the current byte size setting."""
- return self._bytesize
-
- bytesize = property(getByteSize, setByteSize, doc="Byte size setting")
-
-
- def setParity(self, parity):
- """Change parity setting."""
- if parity not in self.PARITIES: raise ValueError("Not a valid parity: %r" % (parity,))
- self._parity = parity
- if self._isOpen: self._reconfigurePort()
-
- def getParity(self):
- """Get the current parity setting."""
- return self._parity
-
- parity = property(getParity, setParity, doc="Parity setting")
-
-
- def setStopbits(self, stopbits):
- """Change stopbits size."""
- if stopbits not in self.STOPBITS: raise ValueError("Not a valid stopbit size: %r" % (stopbits,))
- self._stopbits = stopbits
- if self._isOpen: self._reconfigurePort()
-
- def getStopbits(self):
- """Get the current stopbits setting."""
- return self._stopbits
-
- stopbits = property(getStopbits, setStopbits, doc="Stopbits setting")
-
-
- def setTimeout(self, timeout):
- """Change timeout setting."""
- if timeout is not None:
- if timeout < 0: raise ValueError("Not a valid timeout: %r" % (timeout,))
- try:
- timeout + 1 #test if it's a number, will throw a TypeError if not...
- except TypeError:
- raise ValueError("Not a valid timeout: %r" % (timeout,))
-
- self._timeout = timeout
- if self._isOpen: self._reconfigurePort()
-
- def getTimeout(self):
- """Get the current timeout setting."""
- return self._timeout
-
- timeout = property(getTimeout, setTimeout, doc="Timeout setting for read()")
-
-
- def setWriteTimeout(self, timeout):
- """Change timeout setting."""
- if timeout is not None:
- if timeout < 0: raise ValueError("Not a valid timeout: %r" % (timeout,))
- try:
- timeout + 1 #test if it's a number, will throw a TypeError if not...
- except TypeError:
- raise ValueError("Not a valid timeout: %r" % timeout)
-
- self._writeTimeout = timeout
- if self._isOpen: self._reconfigurePort()
-
- def getWriteTimeout(self):
- """Get the current timeout setting."""
- return self._writeTimeout
-
- writeTimeout = property(getWriteTimeout, setWriteTimeout, doc="Timeout setting for write()")
-
-
- def setXonXoff(self, xonxoff):
- """Change XonXoff setting."""
- self._xonxoff = xonxoff
- if self._isOpen: self._reconfigurePort()
-
- def getXonXoff(self):
- """Get the current XonXoff setting."""
- return self._xonxoff
-
- xonxoff = property(getXonXoff, setXonXoff, doc="Xon/Xoff setting")
-
- def setRtsCts(self, rtscts):
- """Change RtsCts flow control setting."""
- self._rtscts = rtscts
- if self._isOpen: self._reconfigurePort()
-
- def getRtsCts(self):
- """Get the current RtsCts flow control setting."""
- return self._rtscts
-
- rtscts = property(getRtsCts, setRtsCts, doc="RTS/CTS flow control setting")
-
- def setDsrDtr(self, dsrdtr=None):
- """Change DsrDtr flow control setting."""
- if dsrdtr is None:
- #if not set, keep backwards compatibility and follow rtscts setting
- self._dsrdtr = self._rtscts
- else:
- #if defined independently, follow its value
- self._dsrdtr = dsrdtr
- if self._isOpen: self._reconfigurePort()
-
- def getDsrDtr(self):
- """Get the current DsrDtr flow control setting."""
- return self._dsrdtr
-
- dsrdtr = property(getDsrDtr, setDsrDtr, "DSR/DTR flow control setting")
-
- def setInterCharTimeout(self, interCharTimeout):
- """Change inter-character timeout setting."""
- if interCharTimeout is not None:
- if interCharTimeout < 0: raise ValueError("Not a valid timeout: %r" % interCharTimeout)
- try:
- interCharTimeout + 1 #test if it's a number, will throw a TypeError if not...
- except TypeError:
- raise ValueError("Not a valid timeout: %r" % interCharTimeout)
-
- self._interCharTimeout = interCharTimeout
- if self._isOpen: self._reconfigurePort()
-
- def getInterCharTimeout(self):
- """Get the current inter-character timeout setting."""
- return self._interCharTimeout
-
- interCharTimeout = property(getInterCharTimeout, setInterCharTimeout, doc="Inter-character timeout setting for read()")
-
-
- # - - - - - - - - - - - - - - - - - - - - - - - -
-
- def __repr__(self):
- """String representation of the current port settings and its state."""
- return "%s<id=0x%x, open=%s>(port=%r, baudrate=%r, bytesize=%r, parity=%r, stopbits=%r, timeout=%r, xonxoff=%r, rtscts=%r, dsrdtr=%r)" % (
- self.__class__.__name__,
- id(self),
- self._isOpen,
- self.portstr,
- self.baudrate,
- self.bytesize,
- self.parity,
- self.stopbits,
- self.timeout,
- self.xonxoff,
- self.rtscts,
- self.dsrdtr,
- )
-
-if __name__ == '__main__':
- s = SerialBase()
- print s.portstr
- print s.getSupportedBaudrates()
- print s.getSupportedByteSizes()
- print s.getSupportedParities()
- print s.getSupportedStopbits()
- print s
diff --git a/plugins/rfid/tis2000.py b/plugins/rfid/tis2000.py
deleted file mode 100644
index 91d1991..0000000
--- a/plugins/rfid/tis2000.py
+++ /dev/null
@@ -1,252 +0,0 @@
-from device import RFIDDevice
-from serial import Serial
-import dbus
-from dbus.mainloop.glib import DBusGMainLoop
-import gobject
-import re
-from time import sleep
-
-HAL_SERVICE = 'org.freedesktop.Hal'
-HAL_MGR_PATH = '/org/freedesktop/Hal/Manager'
-HAL_MGR_IFACE = 'org.freedesktop.Hal.Manager'
-HAL_DEV_IFACE = 'org.freedesktop.Hal.Device'
-REGEXP_SERUSB = '\/org\/freedesktop\/Hal\/devices\/usb_device['\
- 'a-z,A-Z,0-9,_]*serial_usb_[0-9]'
-
-STATE_WAITING = 0
-STATE_WAITING2 = 1
-STATE_READING = 2
-
-class RFIDReader(RFIDDevice):
- """
- TIS-2000 interface.
- """
-
- def __init__(self):
-
- RFIDDevice.__init__(self)
- self.last_tag = ""
- self.ser = Serial()
- self.device = ''
- self.device_path = ''
- self._connected = False
- self._state = STATE_WAITING
-
- loop = DBusGMainLoop()
- self.bus = dbus.SystemBus(mainloop=loop)
- hmgr_iface = dbus.Interface(self.bus.get_object(HAL_SERVICE,
- HAL_MGR_PATH), HAL_MGR_IFACE)
-
- hmgr_iface.connect_to_signal('DeviceRemoved', self._device_removed_cb)
-
- def get_present(self):
- """
- Checks if TI-S2000 device is present.
- Returns True if so, False otherwise.
- """
- hmgr_if = dbus.Interface(self.bus.get_object(HAL_SERVICE, HAL_MGR_PATH),
- HAL_MGR_IFACE)
- tiusb_devices = set(hmgr_if.FindDeviceStringMatch('serial.type',
- 'usb')) & set(hmgr_if.FindDeviceStringMatch(
- 'info.product', 'TUSB3410 Microcontroller'))
- for i in tiusb_devices:
- tiusb_if = dbus.Interface(self.bus.get_object(HAL_SERVICE, i),
- HAL_DEV_IFACE)
- if tiusb_if.PropertyExists('linux.device_file'):
- self.device = str(tiusb_if.GetProperty('linux.device_file'))
- self.device_path = i
- return True
- return False
-
- def do_connect(self):
- """
- Connects to the device.
- Returns True if successfull, False otherwise.
- """
- retval = False
- if self.get_present():
- try:
- self.ser = Serial(self.device, 9600, timeout=0.1)
- self._connected = True
- self._escape()
- self._clear()
- self._format()
- gobject.idle_add(self._loop)
- retval = True
- except:
- self._connected = False
- return retval
-
- def do_disconnect(self):
- """
- Disconnect from the device.
- """
- self.ser.close()
- self._connected = False
-
- def read_tag(self):
- """
- Returns the last read value.
- """
- return self.last_tag
-
- def write_tag(self, hexval):
- """
- Usage: write_tag(hexval)
-
- Writes the hexadecimal string "hexval" into the tag.
- Returns True if successfull, False otherwise.
- """
- #self.ser.flushInput()
- reg = re.compile('([^0-9A-F]+)')
- if not (hexval.__len__() == 16 and reg.findall(hexval) == []):
- return False
- self.ser.read(100)
- self.ser.write('P')
- for i in hexval:
- self.ser.write(i)
- sleep(1)
- resp = self.ser.read(64)
- resp = resp.split()[0]
- if resp == "P0":
- return True
- else:
- return False
-
- def _escape(self):
- """
- Sends the scape command to the TIS-2000 device.
- """
- try:
- #self.ser.flushInput()
- self.ser.read(100)
- self.ser.write('\x1B')
- resp = self.ser.read()
- if resp == 'E':
- return True
- else:
- return False
- except:
- return False
-
- def _format(self):
- """
- Sends the format command to the TIS-2000 device.
- """
- try:
- #self.ser.flushInput()
- self.ser.read(100)
- self.ser.write('F')
- resp = self.ser.read()
- if resp == 'F':
- return True
- else:
- return False
- except:
- return False
-
- def _clear(self):
- """
- Sends the clear command to the TIS-2000 device.
- """
- try:
- #self.ser.flushInput()
- self.ser.read(100)
- self.ser.write('C')
- resp = self.ser.read()
- if resp == 'C':
- return True
- else:
- return False
- except:
- return False
-
- def get_version(self):
- """
- Sends the version command to the TIS-2000 device and returns
- a string with the device version.
- """
- #self.ser.flushInput()
- self.ser.read(100)
- self.ser.write('V')
- version = []
- tver = ""
- while 1:
- resp = self.ser.read()
- if resp == '\x0A' or resp == '':
- break
- if resp != '\n' and resp != '\r':
- version.append(resp)
- for i in version:
- tver = tver + i
- if tver != "":
- return tver
- return "Unknown"
-
- def _device_removed_cb(self, path):
- """
- Called when a device is removed.
- Checks if the removed device is itself and emits the "disconnected"
- signal if so.
- """
- if path == self.device_path:
- self.device_path = ''
- self.ser.close()
- self._connected = False
- self.emit("disconnected","TIS-2000")
-
- def _loop(self):
- """
- Threaded loop for reading data sent from the TIS-2000.
- """
- if not self._connected:
- return False
-
- if self._state is STATE_WAITING:
- data = self.ser.read()
- if data in ['W', 'R']:
- self._state = STATE_WAITING2
- return True
-
- elif self._state is STATE_WAITING2:
- data = self.ser.read()
- if data.isspace():
- self._state = STATE_READING
- else:
- self._clear()
- self._state = STATE_WAITING
- return True
-
- elif self._state is STATE_READING:
- data = self.ser.read(16)
- if data.__len__() < 16:
- self._clear()
- self._state = STATE_WAITING
- else:
- reg = re.compile('([^0-9A-F]+)')
- if reg.findall(data) == []:
- self.emit("tag-read", data)
- self.last_tag = data
- self._clear()
- self._state = STATE_WAITING
- return True
- return True
-
-# Testing
-#if __name__ == '__main__':
-# def handler(device, idhex):
-# """
-# Handler for "tag-read" signal.
-# Prints the tag id.
-# """
-# print "ID: ", idhex
-#
-# dev = RFIDReader()
-# if dev.get_present():
-# dev.do_connect()
-# dev.connect('tag-read', handler)
-# else:
-# print "Not connected"
-#
-# mloop = gobject.MainLoop()
-# mloop.run()
diff --git a/plugins/rfid/utils.py b/plugins/rfid/utils.py
deleted file mode 100644
index 94e5540..0000000
--- a/plugins/rfid/utils.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# utils.py - Helper functions for tis2000.py
-# Copyright (C) 2010 Emiliano Pastorino <epastorino@plan.ceibal.edu.uy>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-def strhex2bin(strhex):
- """
- Convert a string representing an hex value into a
- string representing the same value in binary format.
- """
- dic = { '0':"0000",
- '1':"0001",
- '2':"0010",
- '3':"0011",
- '4':"0100",
- '5':"0101",
- '6':"0110",
- '7':"0111",
- '8':"1000",
- '9':"1001",
- 'A':"1010",
- 'B':"1011",
- 'C':"1100",
- 'D':"1101",
- 'E':"1110",
- 'F':"1111"
- }
- binstr = ""
- for i in strhex:
- binstr = binstr + dic[i.upper()]
- return binstr
-
-def strbin2dec(strbin):
- """
- Convert a string representing a binary value into a
- string representing the same value in decimal format.
- """
- strdec = "0"
- for i in range(1, strbin.__len__()+1):
- strdec = str(int(strdec)+int(strbin[-i])*int(pow(2, i-1)))
- return strdec
-
-def dec2bin(ndec):
- """
- Convert a decimal number into a string representing
- the same value in binary format.
- """
- if ndec < 1:
- return "0"
- binary = []
- while ndec != 0:
- binary.append(ndec%2)
- ndec = ndec/2
- strbin = ""
- binary.reverse()
- for i in binary:
- strbin = strbin+str(i)
- return strbin
-
-def bin2hex(strbin):
- """
- Convert a string representing a binary number into a string
- representing the same value in hexadecimal format.
- """
- dic = { "0000":"0",
- "0001":"1",
- "0010":"2",
- "0011":"3",
- "0100":"4",
- "0101":"5",
- "0110":"6",
- "0111":"7",
- "1000":"8",
- "1001":"9",
- "1010":"A",
- "1011":"B",
- "1100":"C",
- "1101":"D",
- "1110":"E",
- "1111":"F"
- }
- while strbin.__len__()%4 != 0:
- strbin = '0' + strbin
- strh = ""
- for i in range(0, strbin.__len__()/4):
- strh = strh + dic[str(strbin[i*4:i*4+4])]
- return strh
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
index 0d31ced..d78ba94 100644
--- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py
+++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
@@ -92,6 +92,7 @@ class Turtle_blocks_extras(Plugin):
# internally expanded macro
palette.add_block('while',
+ hidden=True,
style='clamp-style-boolean',
label=_('while'),
prim_name='while',
@@ -102,6 +103,7 @@ boolean operators from Numbers palette'))
# internally expanded macro
palette.add_block('until',
+ hidden=True,
style='clamp-style-boolean',
label=_('until'),
prim_name='until',
@@ -112,6 +114,7 @@ boolean operators from Numbers palette'))
primitive_dictionary['clamp'] = self._prim_clamp
palette.add_block('sandwichclamp',
+ hidden=True,
style='clamp-style-collapsible',
label=' ',
special_name=_('top'),
@@ -120,10 +123,9 @@ boolean operators from Numbers palette'))
self.tw.lc.def_prim('clamp', 1, primitive_dictionary['clamp'], True)
def _media_palette(self):
- palette = make_palette('media',
- colors=["#A0FF00", "#80A000"],
- help_string=_('Palette of media objects'),
- position=7)
+ palette = make_palette('flow',
+ colors=["#FFC000", "#A08000"],
+ help_string=_('Palette of flow operators'))
palette.add_block('journal',
style='box-style-media',
@@ -138,6 +140,7 @@ boolean operators from Numbers palette'))
MEDIA_SHAPES.append('journalon')
palette.add_block('audio',
+ hidden=True,
style='box-style-media',
label=' ',
special_name=_('audio'),
@@ -150,6 +153,7 @@ boolean operators from Numbers palette'))
MEDIA_SHAPES.append('audioon')
palette.add_block('video',
+ hidden=True,
style='box-style-media',
label=' ',
special_name=_('video'),
@@ -162,6 +166,7 @@ boolean operators from Numbers palette'))
MEDIA_SHAPES.append('videoon')
palette.add_block('description',
+ hidden=True,
style='box-style-media',
label=' ',
special_name=_('description'),
@@ -174,6 +179,7 @@ boolean operators from Numbers palette'))
MEDIA_SHAPES.append('descriptionon')
palette.add_block('string',
+ hidden=True,
style='box-style',
label=_('text'),
default=_('text'),
@@ -182,6 +188,7 @@ boolean operators from Numbers palette'))
primitive_dictionary['show'] = self._prim_show
palette.add_block('show',
+ hidden=True,
style='basic-style-1arg',
label=_('show'),
default=_('text'),
@@ -209,6 +216,7 @@ Journal'))
primitive_dictionary['setscale'] = self._prim_setscale
palette.add_block('setscale',
+ hidden=True,
style='basic-style-1arg',
label=_('set scale'),
prim_name='setscale',
@@ -221,6 +229,7 @@ Journal'))
primitive_dictionary['savepix'] = self._prim_save_picture
palette.add_block('savepix',
+ hidden=True,
style='basic-style-1arg',
label=_('save picture'),
prim_name='savepix',
@@ -232,6 +241,7 @@ Journal'))
primitive_dictionary['savesvg'] = self._prim_save_svg
palette.add_block('savesvg',
+ hidden=True,
style='basic-style-1arg',
label=_('save SVG'),
prim_name='savesvg',
@@ -242,6 +252,7 @@ in the Sugar Journal'))
lambda self, x: primitive_dictionary['savesvg'](x))
palette.add_block('scale',
+ hidden=True,
style='box-style',
label=_('scale'),
prim_name='scale',
@@ -251,6 +262,7 @@ in the Sugar Journal'))
self.tw.lc.def_prim('scale', 0, lambda self: self.tw.lc.scale)
palette.add_block('mediawait',
+ hidden=True,
style='basic-style-extended-vertical',
label=_('media wait'),
prim_name='mediawait',
@@ -259,6 +271,7 @@ complete'))
self.tw.lc.def_prim('mediawait', 0, self.tw.lc.media_wait, True)
palette.add_block('mediastop',
+ hidden=True,
style='basic-style-extended-vertical',
label=_('media stop'),
prim_name='mediastop',
@@ -266,6 +279,7 @@ complete'))
self.tw.lc.def_prim('mediastop', 0, self.tw.lc.media_stop, True)
palette.add_block('mediapause',
+ hidden=True,
style='basic-style-extended-vertical',
label=_('media pause'),
prim_name='mediapause',
@@ -273,6 +287,7 @@ complete'))
self.tw.lc.def_prim('mediapause', 0, self.tw.lc.media_pause, True)
palette.add_block('mediaplay',
+ hidden=True,
style='basic-style-extended-vertical',
label=_('media resume'),
prim_name='mediaplay',
@@ -281,6 +296,7 @@ complete'))
primitive_dictionary['speak'] = self._prim_speak
palette.add_block('speak',
+ hidden=True,
style='basic-style-1arg',
label=_('speak'),
prim_name='speak',
@@ -291,6 +307,7 @@ complete'))
primitive_dictionary['sinewave'] = self._prim_sinewave
palette.add_block('sinewave',
+ hidden=True,
style='basic-style-3arg',
# TRANS: pitch, duration, amplitude
label=[_('sinewave') + '\n\n', _('pitch'),
@@ -304,10 +321,9 @@ amplitude, and duration (in seconds)'))
primitive_dictionary['sinewave'](x, y, z))
def _sensor_palette(self):
- palette = make_palette('sensor',
- colors=["#FF6060", "#A06060"],
- help_string=_('Palette of sensor blocks'),
- position=6)
+ palette = make_palette('flow',
+ colors=["#FFC000", "#A08000"],
+ help_string=_('Palette of flow operators'))
primitive_dictionary['mousebutton'] = self._prim_mouse_button
palette.add_block('mousebutton',
@@ -323,6 +339,7 @@ pressed'))
primitive_dictionary['mousebutton2'] = self._prim_mouse_button_bool
palette.add_block('mousebutton2',
+ hidden=True,
style='boolean-block-style',
label=_('button down'),
prim_name='mousebutton2',
@@ -334,6 +351,7 @@ pressed'))
primitive_dictionary['mousebutton2']())
palette.add_block('mousex',
+ hidden=True,
style='box-style',
label=_('mouse x'),
prim_name='mousex',
@@ -344,6 +362,7 @@ pressed'))
self.tw.mouse_x - (self.tw.canvas.width / 2))
palette.add_block('mousey',
+ hidden=True,
style='box-style',
label=_('mouse y'),
prim_name='mousey',
@@ -355,6 +374,7 @@ pressed'))
primitive_dictionary['kbinput'] = self._prim_kbinput
palette.add_block('kbinput',
+ hidden=True,
style='basic-style-extended-vertical',
label=_('query keyboard'),
prim_name='kbinput',
@@ -364,6 +384,7 @@ stored in keyboard block)'))
lambda self: primitive_dictionary['kbinput']())
palette.add_block('keyboard',
+ hidden=True,
style='box-style',
label=_('keyboard'),
prim_name='keyboard',
@@ -400,6 +421,7 @@ block as number'))
primitive_dictionary['readpixel'] = self._prim_readpixel
palette.add_block('readpixel',
+ hidden=True,
style='basic-style-extended-vertical',
label=_('read pixel'),
prim_name='readpixel',
@@ -411,6 +433,7 @@ to the stack'))
primitive_dictionary['see'] = self._prim_see
palette.add_block('see',
+ hidden=True,
style='box-style',
label=_('turtle sees'),
prim_name='see',
@@ -433,11 +456,11 @@ program started'))
def _extras_palette(self):
palette = make_palette('extras',
colors=["#FF0000", "#A00000"],
- help_string=_('Palette of extra options'),
- position=8)
+ help_string=_('Palette of extra options'))
primitive_dictionary['push'] = self._prim_push
palette.add_block('push',
+ hidden=True,
style='basic-style-1arg',
#TRANS: push adds a new item to the program stack
label=_('push'),
@@ -452,6 +475,7 @@ last-out heap)'))
primitive_dictionary['printheap'] = self._prim_printheap
palette.add_block('printheap',
+ hidden=True,
style='basic-style-extended-vertical',
label=_('show heap'),
prim_name='printheap',
@@ -465,6 +489,7 @@ end\n')
primitive_dictionary['clearheap'] = self._prim_emptyheap
palette.add_block('clearheap',
+ hidden=True,
style='basic-style-extended-vertical',
label=_('empty heap'),
prim_name='clearheap',
@@ -478,6 +503,7 @@ end\n')
primitive_dictionary['pop'] = self._prim_pop
palette.add_block('pop',
+ hidden=True,
style='box-style',
#TRANS: pop removes a new item from the program stack
label=_('pop'),
@@ -504,6 +530,7 @@ make "tmp first :taheap\nmake "taheap butfirst :taheap\noutput :tmp\nend\n')
primitive_dictionary['isheapempty2'] = self._prim_is_heap_empty_bool
palette.add_block('isheapempty2',
+ hidden=True,
style='boolean-block-style',
label=_('empty heap?'),
prim_name='isheapempty2',
@@ -515,6 +542,7 @@ make "tmp first :taheap\nmake "taheap butfirst :taheap\noutput :tmp\nend\n')
primitive_dictionary['print'] = self._prim_print
palette.add_block('comment',
+ hidden=True,
style='basic-style-1arg',
label=_('comment'),
prim_name='comment',
@@ -539,6 +567,7 @@ bottom of the screen'))
primitive_dictionary['chr'] = self._prim_chr
palette.add_block('chr',
+ hidden=True,
style='number-style-1arg',
label='chr',
prim_name='chr',
@@ -548,6 +577,7 @@ bottom of the screen'))
primitive_dictionary['int'] = self._prim_int
palette.add_block('int',
+ hidden=True,
style='number-style-1arg',
label='int',
prim_name='int',
@@ -557,6 +587,7 @@ bottom of the screen'))
primitive_dictionary['myfunction'] = self._prim_myfunction
palette.add_block('myfunc1arg',
+ hidden=True,
style='number-style-var-arg',
label=[_('Python'), 'f(x)', 'x'],
prim_name='myfunction',
@@ -598,6 +629,7 @@ advanced multi-variable math equations, e.g., sin(x+y+z)'))
primitive_dictionary['userdefined'] = self._prim_myblock
palette.add_block('userdefined',
+ hidden=True,
style='basic-style-var-arg',
label=' ',
prim_name='userdefined',
@@ -666,6 +698,7 @@ module found in the Journal'))
lambda self: self.tw.set_polar(True))
palette.add_block('addturtle',
+ hidden=True,
style='basic-style-1arg',
label=_('turtle'),
prim_name='turtle',
@@ -678,6 +711,7 @@ module found in the Journal'))
primitive_dictionary['activeturtle'] = self._prim_active_turtle
palette.add_block('activeturtle',
+ hidden=True,
style='box-style',
#TRANS: pop removes a new item from the program stack
label=_('active turtle'),
@@ -702,6 +736,7 @@ module found in the Journal'))
# macro
palette.add_block('reskin',
+ hidden=True,
style='basic-style-1arg',
label=_('turtle shell'),
help_string=_("put a custom 'shell' on the turtle"))
@@ -716,6 +751,7 @@ module found in the Journal'))
primitive_dictionary['loadblock'] = self._prim_load_block
palette.add_block('loadblock',
+ hidden=True,
style='basic-style-var-arg',
label=_('load'),
prim_name='loadblock',
@@ -726,8 +762,8 @@ module found in the Journal'))
primitive_dictionary['loadblock'](x))
palette.add_block('loadblock2arg',
- style='basic-style-var-arg',
hidden=True,
+ style='basic-style-var-arg',
label=_('load'),
prim_name='loadblock2',
string_or_number=True,
@@ -738,8 +774,8 @@ module found in the Journal'))
primitive_dictionary['loadblock']([x, y]))
palette.add_block('loadblock3arg',
- style='basic-style-var-arg',
hidden=True,
+ style='basic-style-var-arg',
label=_('load'),
string_or_number=True,
prim_name='loadblock3',
@@ -751,6 +787,7 @@ module found in the Journal'))
primitive_dictionary['loadpalette'] = self._prim_load_palette
palette.add_block('loadpalette',
+ hidden=True,
style='basic-style-1arg',
string_or_number=True,
label=_('palette'),
@@ -762,14 +799,13 @@ module found in the Journal'))
primitive_dictionary['loadpalette'](x))
def _portfolio_palette(self):
- palette = make_palette('portfolio',
- colors=["#0606FF", "#0606A0"],
- help_string=_('Palette of presentation \
-templates'),
- position=9)
+ palette = make_palette('extras',
+ colors=["#FF0000", "#FF0000"],
+ help_string=_('Palette of extra options'))
primitive_dictionary['hideblocks'] = self._prim_hideblocks
palette.add_block('hideblocks',
+ hidden=True,
style='basic-style-extended-vertical',
label=_('hide blocks'),
prim_name='hideblocks',
@@ -779,6 +815,7 @@ templates'),
primitive_dictionary['showblocks'] = self._prim_showblocks
palette.add_block('showblocks',
+ hidden=True,
style='basic-style-extended-vertical',
label=_('show blocks'),
prim_name='showblocks',
@@ -787,6 +824,7 @@ templates'),
lambda self: primitive_dictionary['showblocks']())
palette.add_block('fullscreen',
+ hidden=True,
style='basic-style-extended-vertical',
label=_('Fullscreen').lower(),
prim_name='fullscreen',
@@ -809,6 +847,7 @@ templates'),
# macros
palette.add_block('picturelist',
+ hidden=True,
style='basic-style-extended',
label=' ',
help_string=_('presentation template: list of \
@@ -816,6 +855,7 @@ bullets'))
MEDIA_SHAPES.append('list')
palette.add_block('picture1x1a',
+ hidden=True,
style='basic-style-extended',
label=' ',
help_string=_('presentation template: select \
@@ -823,6 +863,7 @@ Journal object (no description)'))
MEDIA_SHAPES.append('1x1a')
palette.add_block('picture1x1',
+ hidden=True,
style='basic-style-extended',
label=' ',
help_string=_('presentation template: select \
@@ -830,6 +871,7 @@ Journal object (with description)'))
MEDIA_SHAPES.append('1x1')
palette.add_block('picture2x2',
+ hidden=True,
style='basic-style-extended',
label=' ',
help_string=_('presentation template: select four \
@@ -837,6 +879,7 @@ Journal objects'))
MEDIA_SHAPES.append('2x2')
palette.add_block('picture2x1',
+ hidden=True,
style='basic-style-extended',
label=' ',
help_string=_('presentation template: select two \
@@ -844,6 +887,7 @@ Journal objects'))
MEDIA_SHAPES.append('2x1')
palette.add_block('picture1x2',
+ hidden=True,
style='basic-style-extended',
label=' ',
help_string=_('presentation template: select two \
@@ -852,6 +896,7 @@ Journal objects'))
# Display-dependent constants
palette.add_block('leftpos',
+ hidden=True,
style='box-style',
label=_('left'),
prim_name='lpos',
@@ -860,6 +905,7 @@ Journal objects'))
self.tw.lc.def_prim('lpos', 0, lambda self: CONSTANTS['leftpos'])
palette.add_block('bottompos',
+ hidden=True,
style='box-style',
label=_('bottom'),
prim_name='bpos',
@@ -868,6 +914,7 @@ Journal objects'))
self.tw.lc.def_prim('bpos', 0, lambda self: CONSTANTS['bottompos'])
palette.add_block('width',
+ hidden=True,
style='box-style',
label=_('width'),
prim_name='hres',
@@ -876,6 +923,7 @@ Journal objects'))
self.tw.lc.def_prim('hres', 0, lambda self: CONSTANTS['width'])
palette.add_block('rightpos',
+ hidden=True,
style='box-style',
label=_('right'),
prim_name='rpos',
@@ -884,6 +932,7 @@ Journal objects'))
self.tw.lc.def_prim('rpos', 0, lambda self: CONSTANTS['rightpos'])
palette.add_block('toppos',
+ hidden=True,
style='box-style',
label=_('top'),
prim_name='tpos',
@@ -892,6 +941,7 @@ Journal objects'))
self.tw.lc.def_prim('tpos', 0, lambda self: CONSTANTS['toppos'])
palette.add_block('height',
+ hidden=True,
style='box-style',
label=_('height'),
prim_name='vres',
diff --git a/samples/sensors-valentine.ta b/samples/sensors-valentine.ta
index e25992a..df7eba7 100644
--- a/samples/sensors-valentine.ta
+++ b/samples/sensors-valentine.ta
@@ -1,107 +1,113 @@
-[[0, ["start", 2.0], 260, 240, [null, 51]],
-[1, "hat1", 140, 240, [null, 100]],
-[2, "hat2", 17, 240, [null, 101]],
-[3, "setcolor", 21, 1208, [59, 103, 15]],
-[4, "stack1", 21, 956, [16, 58]],
-[5, "volume", 142, 788, [104, null]],
-[6, ["forever", 357], 3, 544, [98, 28, null]],
-[7, "penup", 158, 362, [63, 97]],
-[8, "pendown", 158, 446, [97, 66]],
-[9, "penup", 158, 530, [66, 71]],
-[10, "pendown", 158, 698, [74, null]],
-[11, "clean", 3, 424, [99, 12]],
-[12, ["fillscreen", 0], 3, 466, [11, 14, 13, 34]],
-[13, ["number", 80], 84, 508, [12, null]],
-[14, "white", 84, 466, [12, null]],
-[15, "stack1", 21, 1250, [3, 41]],
-[16, "setcolor", 21, 914, [60, 17, 4]],
-[17, "white", 98, 914, [16, null]],
-[18, ["storein", 0], 21, 662, [28, 19, 26, 22]],
-[19, ["string", "b"], 88, 662, [18, null]],
-[20, ["storein", 0], 3, 634, [34, 21, 40, 37]],
-[21, ["string", "b"], 70, 634, [20, null]],
-[22, ["storein", 0], 21, 746, [18, 23, 104, 106]],
-[23, ["string", "a"], 88, 746, [22, null]],
-[24, "box", 138, 1166, [59, 25, null]],
-[25, ["string", "a"], 192, 1166, [24, null]],
-[26, "box", 88, 704, [18, 27, null]],
-[27, ["string", "a"], 142, 704, [26, null]],
-[28, ["storein", 0], 21, 578, [6, 29, 30, 18]],
-[29, ["string", "c"], 88, 578, [28, null]],
-[30, "box", 88, 620, [28, 31, null]],
-[31, ["string", "b"], 142, 620, [30, null]],
-[32, "box", 138, 872, [60, 33, null]],
-[33, ["string", "c"], 192, 872, [32, null]],
-[34, ["storein", 0], 3, 550, [12, 35, 36, 20]],
-[35, ["string", "a"], 70, 550, [34, null]],
-[36, ["number", 0], 70, 592, [34, null]],
-[37, ["storein", 0], 3, 718, [20, 38, 39, null]],
-[38, ["string", "c"], 70, 718, [37, null]],
-[39, ["number", 0], 70, 760, [37, null]],
-[40, ["number", 0], 70, 676, [20, null]],
-[41, "wait", 21, 1292, [15, 42, null]],
-[42, ["number", 0.1], 79, 1292, [41, null]],
-[43, "setshade", 21, 1082, [45, 44, 48]],
-[44, ["number", 75], 106, 1082, [43, null]],
-[45, "setcolor", 21, 1040, [58, 102, 43]],
-[46, "box", 138, 998, [58, 47, null]],
-[47, ["string", "b"], 192, 998, [46, null]],
-[48, "stack1", 21, 1124, [43, 59]],
-[49, "hat", 20, 360, [null, 50, 99]],
-[50, ["string", "setup"], 78, 372, [49, null]],
-[51, "stack", 260, 286, [0, 52, 55]],
-[52, ["string", "setup"], 318, 286, [51, null]],
-[53, "hat", 20, 480, [null, 54, 98]],
-[54, ["string", "loop"], 78, 492, [53, null]],
-[55, "stack", 260, 328, [51, 56, null]],
-[56, ["string", "loop"], 318, 328, [55, null]],
-[57, "box1", 329, 320, [67, null]],
-[58, "storeinbox1", 21, 998, [4, 46, 45]],
-[59, "storeinbox1", 21, 1166, [48, 24, 3]],
-[60, "storeinbox1", 21, 872, [106, 32, 16]],
-[61, "forward", 0, 380, [76, 78, 95]],
-[62, "box2", 58, 338, [76, null]],
-[63, "storeinbox2", 158, 320, [100, 67, 7]],
-[64, "box2", 124, 380, [78, null]],
-[65, "box2", 282, 404, [69, null]],
-[66, "stack2", 158, 488, [8, 9]],
-[67, ["division2", 0], 275, 320, [63, 57, 68]],
-[68, ["number", 2], 353, 362, [67, null]],
-[69, ["division2", 0], 228, 404, [97, 65, 70]],
-[70, ["number", 2], 306, 446, [69, null]],
-[71, ["setxy2", 0], 158, 572, [9, 72, 73, 74]],
-[72, ["number", 0], 216, 572, [71, null]],
-[73, ["number", 0], 216, 614, [71, null]],
-[74, "seth", 158, 656, [71, 75, 10]],
-[75, ["number", 0], 216, 656, [74, null]],
-[76, ["arc", 0], 0, 296, [101, 77, 62, 61]],
-[77, ["number", 225], 58, 296, [76, null]],
-[78, ["product2", 0], 70, 380, [61, 64, 81]],
-[79, "sqrt", 178, 464, [81, 80]],
-[80, ["number", 2], 232, 464, [79, null]],
-[81, ["product2", 0], 124, 422, [78, 82, 79]],
-[82, ["number", 1.7], 178, 422, [81, null]],
-[83, ["arc", 0], 0, 670, [96, 84, 85, null]],
-[84, ["number", 225], 58, 670, [83, null]],
-[85, "box2", 58, 712, [83, null]],
-[86, "right", 0, 504, [95, 87, 88]],
-[87, ["number", 90], 58, 504, [86, null]],
-[88, "forward", 0, 546, [86, 89, 96]],
-[89, ["product2", 0], 70, 546, [88, 90, 91]],
-[90, "box2", 124, 546, [89, null]],
-[91, ["product2", 0], 124, 588, [89, 92, 93]],
-[92, ["number", 1.7], 178, 588, [91, null]],
-[93, "sqrt", 178, 630, [91, 94]],
-[94, ["number", 2], 232, 630, [93, null]],
-[95, ["vspace", 20], 0, 422, [61, 86]],
-[96, ["vspace", 20], 0, 588, [88, 83]],
-[97, "forward", 158, 404, [7, 69, 8]],
-[98, "sandwichclampcollapsed", 20, 534, [53, 6, null]],
-[99, "sandwichclampcollapsed", 20, 414, [49, 11, null]],
-[100, "sandwichclampcollapsed", 140, 286, [1, 63, null]],
-[101, "sandwichclampcollapsed", 17, 286, [2, 76, null]],
-[102, "red", 98, 1040, [45, null]],
-[103, "red", 98, 1208, [3, null]],
-[104, ["division2", 0], 88, 788, [22, 5, 105]],
-[105, ["number", 4], 166, 830, [104, null]],
-[106, ["vspace", 0], 21, 830, [22, 60]]]
+[[0, ["start", 1.334], 920, 60, [null, 11]],
+[1, "hat1", 280, 280, [null, 98]],
+[2, "hat2", 760, 300, [null, 99]],
+[3, "setcolor", 64, 542, [57, 101, 13]],
+[4, "stack1", 64, 346, [14, 56]],
+[5, "volume", 624, 599, [102, null]],
+[6, ["forever", 239], 52, 239, [96, 49, null]],
+[7, "penup", 292, 362, [61, 95]],
+[8, "pendown", 292, 418, [95, 64]],
+[9, "penup", 292, 474, [64, 69]],
+[10, "pendown", 292, 586, [72, null]],
+[11, "clean", 920, 91, [0, 105]],
+[12, "white", 982, 147, [105, null]],
+[13, "stack1", 64, 570, [3, 39]],
+[14, "setcolor", 64, 318, [108, 15, 4]],
+[15, "white", 115, 318, [14, null]],
+[16, ["storein", 0], 532, 515, [26, 17, 24, 20]],
+[17, ["string", "b"], 577, 515, [16, null]],
+[18, ["storein", 0], 920, 259, [32, 19, 38, 35]],
+[19, ["string", "b"], 965, 259, [18, null]],
+[20, ["storein", 0], 532, 571, [16, 21, 102, 104]],
+[21, ["string", "a"], 577, 571, [20, null]],
+[22, "box", 143, 514, [57, 23, null]],
+[23, ["string", "a"], 180, 514, [22, null]],
+[24, "box", 577, 543, [16, 25, null]],
+[25, ["string", "a"], 614, 543, [24, null]],
+[26, ["storein", 0], 532, 459, [97, 27, 28, 16]],
+[27, ["string", "c"], 577, 459, [26, null]],
+[28, "box", 577, 487, [26, 29, null]],
+[29, ["string", "b"], 614, 487, [28, null]],
+[30, "box", 611, 655, [58, 31, null]],
+[31, ["string", "c"], 648, 655, [30, null]],
+[32, ["storein", 0], 920, 203, [105, 33, 34, 18]],
+[33, ["string", "a"], 965, 203, [32, null]],
+[34, ["number", 0], 965, 231, [32, null]],
+[35, ["storein", 0], 920, 315, [18, 36, 37, 53]],
+[36, ["string", "c"], 965, 315, [35, null]],
+[37, ["number", 0], 965, 343, [35, null]],
+[38, ["number", 0], 965, 287, [18, null]],
+[39, "wait", 64, 598, [13, 40, null]],
+[40, ["number", 0.1], 103, 598, [39, null]],
+[41, "setshade", 64, 458, [43, 42, 46]],
+[42, ["number", 75], 121, 458, [41, null]],
+[43, "setcolor", 64, 430, [110, 100, 41]],
+[44, "box", 143, 374, [56, 45, null]],
+[45, ["string", "b"], 180, 374, [44, null]],
+[46, "stack1", 64, 486, [41, 57]],
+[47, "hat", 520, 400, [null, 48, 97]],
+[48, ["string", "read sensor"], 559, 408, [47, null]],
+[49, "stack", 64, 262, [6, 50, 108]],
+[50, ["string", "read sensor"], 103, 262, [49, null]],
+[51, "hat", 40, 180, [null, 52, 96]],
+[52, ["string", "loop"], 79, 188, [51, null]],
+[53, "stack", 920, 371, [35, 54, null]],
+[54, ["string", "loop"], 959, 371, [53, null]],
+[55, "box1", 418, 334, [65, null]],
+[56, "storeinbox1", 64, 374, [4, 44, 110]],
+[57, "storeinbox1", 64, 514, [46, 22, 3]],
+[58, "storeinbox1", 532, 655, [104, 30, null]],
+[59, "forward", 772, 410, [74, 76, 93]],
+[60, "box2", 811, 382, [74, null]],
+[61, "storeinbox2", 292, 334, [98, 65, 7]],
+[62, "box2", 855, 410, [76, null]],
+[63, "box2", 386, 390, [67, null]],
+[64, "stack2", 292, 446, [8, 9]],
+[65, ["division2", 0], 371, 334, [61, 55, 66]],
+[66, ["number", 2], 434, 362, [65, null]],
+[67, ["division2", 0], 339, 390, [95, 63, 68]],
+[68, ["number", 2], 402, 418, [67, null]],
+[69, ["setxy2", 0], 292, 502, [9, 70, 71, 72]],
+[70, ["number", 0], 331, 502, [69, null]],
+[71, ["number", 0], 331, 530, [69, null]],
+[72, "seth", 292, 558, [69, 73, 10]],
+[73, ["number", 0], 358, 558, [72, null]],
+[74, ["arc", 0], 772, 354, [99, 75, 60, 59]],
+[75, ["number", 225], 811, 354, [74, null]],
+[76, ["product2", 0], 819, 410, [59, 62, 79]],
+[77, "sqrt", 891, 466, [79, 78]],
+[78, ["number", 2], 927, 466, [77, null]],
+[79, ["product2", 0], 855, 438, [76, 80, 77]],
+[80, ["number", 1.7], 891, 438, [79, null]],
+[81, ["arc", 0], 772, 604, [94, 82, 83, null]],
+[82, ["number", 225], 811, 604, [81, null]],
+[83, "box2", 811, 632, [81, null]],
+[84, "right", 772, 493, [93, 85, 86]],
+[85, ["number", 90], 811, 493, [84, null]],
+[86, "forward", 772, 521, [84, 87, 94]],
+[87, ["product2", 0], 819, 521, [86, 88, 89]],
+[88, "box2", 855, 521, [87, null]],
+[89, ["product2", 0], 855, 549, [87, 90, 91]],
+[90, ["number", 1.7], 891, 549, [89, null]],
+[91, "sqrt", 891, 577, [89, 92]],
+[92, ["number", 2], 927, 577, [91, null]],
+[93, ["vspace", 20], 772, 438, [59, 84]],
+[94, ["vspace", 20], 772, 549, [86, 81]],
+[95, "forward", 292, 390, [7, 67, 8]],
+[96, ["sandwichclamp", 265], 40, 216, [51, 6, null]],
+[97, ["sandwichclamp", 147], 520, 436, [47, 26, null]],
+[98, ["sandwichclamp", 189], 280, 311, [1, 61, null]],
+[99, ["sandwichclamp", 208], 760, 331, [2, 74, null]],
+[100, "red", 115, 430, [43, null]],
+[101, "red", 115, 542, [3, null]],
+[102, ["division2", 0], 577, 599, [20, 5, 103]],
+[103, ["number", 4], 640, 627, [102, null]],
+[104, ["vspace", 0], 532, 627, [20, 58]],
+[105, "fillscreen2", 920, 119, [11, 106, 12, 107, 32]],
+[106, ["number", 60], 982, 119, [105, null]],
+[107, ["number", 100], 982, 175, [105, null]],
+[108, "setpensize", 64, 290, [49, 109, 14]],
+[109, ["number", 7.0], 139, 290, [108, null]],
+[110, "setpensize", 64, 402, [56, 111, 43]],
+[111, ["number", 5], 139, 402, [110, null]],
+[-1, ["turtle", "Yertle"], 0.0, 0.0, 0.0, 0, 50, 5.0]] \ No newline at end of file
diff --git a/turtleblocks.py b/turtleflags.py
index 5d5808f..f1f7f33 100755
--- a/turtleblocks.py
+++ b/turtleflags.py
@@ -31,6 +31,7 @@ import getopt
import sys
import os
import os.path
+import glob
import cStringIO
import errno
import ConfigParser
@@ -425,6 +426,17 @@ return %s(self)" % (p, P, P)
turtle_menu = MenuBuilder.make_sub_menu(menu, _('Turtle'))
menu = gtk.Menu()
+ self._level = 0
+ self._levels = self._get_levels()
+ self._custom_filepath = None
+ for i, level in enumerate(self._levels):
+ MenuBuilder.make_menu_item(
+ menu,
+ _(os.path.basename(level).replace('_', ' ')),
+ self._do_level_cb, i)
+ turtle_menu = MenuBuilder.make_sub_menu(menu, _('Challenges'))
+
+ menu = gtk.Menu()
MenuBuilder.make_menu_item(menu, _('About...'), self._do_about_cb)
help_menu = MenuBuilder.make_sub_menu(menu, _('Help'))
@@ -654,6 +666,46 @@ Would you like to save before quitting?'))
self.win.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))
self.tw.deleting_blocks = True
+
+ def restore_challenge(self):
+ ''' Restore the current challange after a clear screen '''
+ if self._custom_filepath is None:
+ self._load_level()
+ else:
+ self._load_level(custom=True)
+
+ def _load_level(self, custom=False):
+ self.tw.canvas.clearscreen()
+ if custom:
+ self.tw.turtles.get_active_turtle().set_xy((0, 0), pendown=False)
+ self.tw.lc.insert_image(center=True,
+ filepath=self._custom_filepath,
+ resize=True, offset=False)
+ else:
+ self.tw.turtles.get_active_turtle().set_xy((0, 0), pendown=False)
+ self.tw.lc.insert_image(center=False,
+ filepath=os.path.join(
+ self._get_execution_dir(), 'flags',
+ self._levels[self._level] + '.png'), resize=True,
+ offset=True)
+ self.tw.turtles.get_active_turtle().set_xy((0, 0), pendown=False)
+
+ def _do_level_cb(self, widget, level):
+ ''' Callback to resize blocks. '''
+ self._level = level
+ self._load_level()
+
+ def _get_levels(self):
+ ''' Look for level files in lessons directory. '''
+ levels = glob.glob(os.path.join(self._get_execution_dir(),
+ 'flags', '*.png'))
+
+ level_files = []
+ for level in levels:
+ level_files.append(level[:-4])
+
+ return level_files
+
def _do_copy_cb(self, button):
''' Callback for copy button. '''
self.tw.saving_blocks = False