1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# -*- coding: utf-8 -*-
# Copyright (c) 2011 Rafael Ortiz rafael@activitycentral.com
# Arduino plugin for TurtleArt http://wiki.sugarlabs.org/go/Activities/TurtleArt
#
# 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
# 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
#Imports for TA plugins
from TurtleArt.tapalette import make_palette, palette_name_to_index
from TurtleArt.taconstants import BLACK, WHITE, CONSTANTS, BOX_COLORS
import gst
import gtk
from fcntl import ioctl
import os
from plugins.plugin import Plugin
from TurtleArt.talogo import media_blocks_dictionary, primitive_dictionary
from TurtleArt.tautils import get_path, debug_output
import logging
_logger = logging.getLogger('TurtleArt-activity plugin Arduino')
from gettext import gettext as _
from taarduino import TAArduino # Arduino setup
class Arduino(Plugin):
# plugin class
def __init__(self, parent):
self._parent = parent
self._status = False
def setup(self): # set up Arduino-specific blocks
palette = make_palette('Arduino', # the name of your palette
colors=["#00FF00", "#00A000"],
help_string=_('Arduino Commands'))
primitive_dictionary['blink'] = self._blink_boton
palette.add_block('blink', # the name of your block
style='basic-style-1arg', # the block style
label=_('blink'), # the label for the block
prim_name='blink', # code reference (see below)
help_string=_('blinks the onboard arduino led'))
# Next, you need to define what your block will do:
# def_prim takes 3 arguments: the primitive name, the number of
# of arguments, 0 in this case, and the function to call, in this
# case, the canvas function to set the heading.
self._parent.lc.def_prim('blink', 1, lambda self, blink: primitive_dictionary['blink'](blink)) #aca debe ir las funciones para hacer blink con arduino
def _blink_boton(self, blink):
print "El valor del boton ", blink
|