summaryrefslogtreecommitdiff
path: root/Origin/tools/scilab/windows/macros/ARDUINO_WRITE.sci
blob: 5d70487a70e496662e657ca104667a97cb415bce (plain)
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
66
67
68
69
70
71
72
73
//
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2012-2012 - Scilab Enterprises - Bruno JOFRET
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
//
//

function [x, y, typ]=ARDUINO_WRITE(job, arg1, arg2)
    x=[];
    y=[];
    typ=[];
    select job
     case 'plot' then
// deprecated
     case 'getinputs' then
// deprecater
     case 'getoutputs' then
// deprecated
     case 'getorigin' then
// deprecated
     case 'set' then
      x=arg1;
      graphics=arg1.graphics;
      exprs=graphics.exprs
      model=arg1.model;

      while %t do
          [ok,num_pin,exprs]=scicos_getvalue('Arduino Digital Write parameters',..
                                                        [gettext('Digital Pin')], ..
                                                        list('vec',1), ..
                                                        exprs)
          mess=[];

          if ~ok then// Cancel
              break;
          end

          if num_pin < 0 | num_pin>13
              mess=[mess ;_("Digital Pin must be between 0 and 13.")]
              ok = %f
          end


          if ok then// Everything's ok
              model.rpar=num_pin;
              graphics.exprs = exprs;
              x.model=model;
              x.graphics = graphics;
              break
          else
              message(mess);
          end

      end
     case 'define' then
      model=scicos_model();
      model.sim=list("ARDUINO_WRITE_sim", 5)
      model.blocktype='d';
      model.dep_ut=[%f %f];
      model.in=[1];
      DigOut=0;
      model.rpar=[DigOut]; //Digital Output number
      x=standard_define([2 2],model,[],[]);
      x.graphics.in_implicit=['E'];
      x.graphics.style=["blockWithLabel;verticalLabelPosition=bottom;verticalAlign=top;displayedLabel=DigOut %s"]
      x.graphics.exprs=string(DigOut);
    end
endfunction