Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/camera_plugin.py30
-rw-r--r--plugins/plugin.py22
-rw-r--r--plugins/rfid_plugin.py31
3 files changed, 70 insertions, 13 deletions
diff --git a/plugins/camera_plugin.py b/plugins/camera_plugin.py
index 9b68da0..e443933 100644
--- a/plugins/camera_plugin.py
+++ b/plugins/camera_plugin.py
@@ -61,7 +61,7 @@ class Camera_plugin(Plugin):
def setup(self):
# set up camera-specific blocks
- if self._self_test():
+ if self._status:
PALETTES[PALETTE_NAMES.index('sensor')].append('luminance')
BOX_STYLE.append('luminance')
BLOCK_NAMES['luminance'] = [_('brightness')]
@@ -81,19 +81,35 @@ class Camera_plugin(Plugin):
HELP_STRINGS['camera'] = _('camera output')
MEDIA_BLOCKS_DICTIONARY['camera'] = self.prim_take_picture
+ def start(self):
+ # This gets called by the start button
+ pass
+
def stop(self):
- # Ths gets called by the stop button
- if self._self_test():
+ # This gets called by the stop button
+ if self._status:
self._camera.stop_camera_input()
- def _self_test(self):
- print 'reporting Camera status %s' % (str(self._status))
+ 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
+ pass
+
+ def _status_report(self):
+ print 'Reporting camera status: %s' % (str(self._status))
return self._status
# Block primitives used in talogo
def prim_take_picture(self):
- if self._self_test():
+ if self._status:
''' method called by media block '''
self._camera.save_camera_input_to_file()
self._camera.stop_camera_input()
@@ -104,7 +120,7 @@ class Camera_plugin(Plugin):
pixbuf = None
array = None
w, h = self._parent.lc._w(), self._parent.lc._h()
- if w > 0 and h > 0 and self._self_test():
+ if w > 0 and h > 0 and self._status:
try:
self._video_capture_device = open('/dev/video0', 'rw')
except:
diff --git a/plugins/plugin.py b/plugins/plugin.py
index 366c1bc..0fe836b 100644
--- a/plugins/plugin.py
+++ b/plugins/plugin.py
@@ -28,7 +28,29 @@ class Plugin(gobject.GObject):
gobject.GObject.__init__(self)
def setup(self):
+ """ Setup is called once, when the Turtle Window is created. """
raise RuntimeError("You need to define setup for your plugin.")
+ def start(self):
+ """ start is called when run button is pressed. """
+ raise RuntimeError("You need to define start for your plugin.")
+
def stop(self):
+ """ stop is called when stop button is pressed. """
raise RuntimeError("You need to define stop for your plugin.")
+
+ def goto_background(self):
+ """ goto_background is called when the activity is sent to the
+ background. """
+ raise RuntimeError(
+ "You need to define goto_background for your plugin.")
+
+ def return_to_foreground(self):
+ """ return_to_foreground is called when the activity returns to
+ the foreground. """
+ raise RuntimeError(
+ "You need to define return_to_foreground for your plugin.")
+
+ def quit(self):
+ """ cleanup is called when the activity is exiting. """
+ raise RuntimeError("You need to define quit for your plugin.")
diff --git a/plugins/rfid_plugin.py b/plugins/rfid_plugin.py
index 30d9aa2..e0cfafc 100644
--- a/plugins/rfid_plugin.py
+++ b/plugins/rfid_plugin.py
@@ -84,7 +84,7 @@ class Rfid_plugin(Plugin):
def setup(self):
# set up camera-specific blocks
- if self._self_test():
+ if self._status:
PALETTES[PALETTE_NAMES.index('sensor')].append('rfid')
BOX_STYLE.append('rfid')
BLOCK_NAMES['rfid'] = [_('RFID')]
@@ -93,14 +93,33 @@ class Rfid_plugin(Plugin):
VALUE_BLOCKS.append('rfid')
PLUGIN_DICTIONARY['rfid'] = self.prim_read_rfid
self._parent.lc._def_prim('rfid', 0,
- lambda self: PLUGIN_DICTIONARY['rfid'](True))
+ lambda self: PLUGIN_DICTIONARY['rfid']())
+
+
+ def start(self):
+ # This gets called by the start button
+ if self._status:
+ pass
def stop(self):
- # Ths gets called by the stop button
+ # This gets called by the stop button
+ if self._status:
+ pass
+
+ 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
pass
- def _self_test(self):
- print 'reporting RFID status %s' % (str(self._status))
+ def _status_report(self):
+ print 'Reporting RFID status: %s' % (str(self._status))
return self._status
def _device_added_cb(self, path):
@@ -138,5 +157,5 @@ class Rfid_plugin(Plugin):
# Block primitives used in talogo
def prim_read_rfid(self):
- if self._self_test():
+ if self._status:
return self.rfid_idn