<commit_before>define(function (require) {

  'use strict';

  var utils = require('src/client/socket_utils');
  var modeError = "Please check mode. Value should be 'analog', 'digital', or 'pwm'";
  var _board;
  var eventQ = [];

  p5.Board = function (port, type){
    this.port = port;
    this.type = type.toLowerCase() || 'arduino';
    // Will be set when board is connected
    this.ready = false;
  };

  p5.Pin = function(num, mode, direction){
    this.pin = num;
    this.mode = mode ? mode.toLowerCase() : 'digital';
    this.direction = direction ? direction.toLowerCase() : 'output';

    this.write = function() { throw new Error(modeError) },
    this.read = function() { throw new Error(modeError) }
  };

  p5.board = function (port, type){
    _board = new p5.Board(port, type);

    // also emit board object & listen for return
    utils.boardInit(port, type);
    utils.socket.on('board ready', function(){
     _board.ready = true;
     eventQ.forEach(function(el){
      el.func.apply(null, el.args);
     });
    });
     
    return _board;
  };

  p5.pin = function(num, mode, direction){
    var _pin = new p5.Pin(num, mode, direction);
    var init = utils.pinInit(num, mode, direction);
    var setVal = function(data){
          this.val = data.val;
    };

    _board.ready ? init() 
                 : eventQ.push({
                    func: init,
                    args: []
                  }); <commit_msg>Call analog pins with analog calls<commit_after>define(function (require) {

  'use strict';

  var utils = require('src/client/socket_utils');
  var modeError = "Please check mode. Value should be 'analog', 'digital', or 'pwm'";
  var _board;
  var eventQ = [];

  p5.Board = function (port, type){
    this.port = port;
    this.type = type.toLowerCase() || 'arduino';
    // Will be set when board is connected
    this.ready = false;
  };

  p5.Pin = function(num, mode, direction){
    this.pin = mode.toLowerCase() === 'analog' ? num + 14 : num;
    this.mode = mode ? mode.toLowerCase() : 'digital';
    this.direction = direction ? direction.toLowerCase() : 'output';

    this.write = function() { throw new Error(modeError) },
    this.read = function() { throw new Error(modeError) }
  };

  p5.board = function (port, type){
    _board = new p5.Board(port, type);

    // also emit board object & listen for return
    utils.boardInit(port, type);
    utils.socket.on('board ready', function(){
     _board.ready = true;
     eventQ.forEach(function(el){
      el.func.apply(null, el.args);
     });
    });
     
    return _board;
  };

  p5.pin = function(num, mode, direction){
    var _pin = new p5.Pin(num, mode, direction);
    var init = utils.pinInit(_pin.pin, _pin.mode, _pin.direction);
    var setVal = function(data){
          this.val = data.val;
    };

    _board.ready ? init() 
                 : eventQ.push({
                    func: init,
                    args: []
                  }); 
{'fraction_non_alphanumeric': 0.1468507915122937, 'fraction_numerical': 0.004715392388009431, 'mean_word_length': 2.413793103448276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7104193', 'n_tokens_mistral': 948, 'n_tokens_neox': 932, 'n_words': 245}