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CAA2C,KAAK,QAAQ,MAAM,SAC7E,OAAO,EAAS,IAAI,MAAM,GAU9B,EAQA,eAAe,UAAU,MAAQ,SAAS,EAAM,GAC9C,IAAI,EAAQ,KAGZ,EAAM,gBAAe,SAAS,GAC5B,GAAI,EAAS,OAAO,EAAS,GAG7B,EAAM,WAAW,OAAM,SAAS,GAC9B,GAAI,EAAS,OAAO,EAAS,GAG7B,EAAM,SAAS,QAAQ,EAAM,EAC/B,GACF,GACF,EAQA,eAAe,UAAU,UAAY,eAAe,UACpD,eAAe,UAAU,KAAO,eAAe,KAAO,SAAS,GAC7D,OAAO,WAAW,UAAU,WAAW,EACzC,EAKA,eAAe,gBAAkB,WAE/B,OAAO,OAAO,KAAK,QAAQ,QAAO,SAAS,GAEzC,IAAI,EAAU,OAAO,GAAM,QAE3B,OAAQ,KAAa,EAAQ,QAAQ,EACvC,GACF,EAEA,OAAO,QAAU","file":"/npm/@dawee/avrgirl-arduino@3.0.2/avrgirl-arduino.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@dawee/avrgirl-arduino@3.0.2/avrgirl-arduino.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var boards = require('./boards');\r\nvar Connection = require('./lib/connection');\r\nvar protocols = require('./lib/protocols');\r\n\r\n/**\r\n * Constructor\r\n *\r\n * @param {object} opts - options for consumer to pass in\r\n */\r\nvar AvrgirlArduino = function(opts) {\r\n  opts = opts || {};\r\n\r\n  this.options = {\r\n    debug: opts.debug || false,\r\n    board: opts.board || 'uno',\r\n    port: opts.port || '',\r\n    manualReset: opts.manualReset || false\r\n  };\r\n\r\n  // this here checks for 3 conditions:\r\n  // if debug option is simply true, we want to fall back to default debug function\r\n  // if a custom debug function is passed in, we want to assign debug to be that\r\n  // if debug option is false, then run debug as a no-op\r\n  if (this.options.debug === true) {\r\n    this.debug = console.log.bind(console);\r\n  } else if (typeof this.options.debug === 'function') {\r\n    this.debug = this.options.debug;\r\n  } else {\r\n    this.debug = function() {};\r\n  }\r\n\r\n  if (typeof this.options.board === 'string') {\r\n    this.options.board = boards[this.options.board];\r\n  } else if (typeof this.options.board === 'object') {\r\n    this.options.board = this.options.board;\r\n  }\r\n\r\n  if (this.options.board && !this.options.board.manualReset) {\r\n    this.options.board.manualReset = this.options.manualReset;\r\n  }\r\n\r\n  this.connection = new Connection(this.options);\r\n\r\n  if (this.options.board) {\r\n    var Protocol = protocols[this.options.board.protocol] || function() {};\r\n\r\n    this.protocol = new Protocol({\r\n      board: this.options.board,\r\n      connection: this.connection,\r\n      debug: this.debug\r\n    });\r\n  }\r\n};\r\n\r\n/**\r\n * Validates the board properties\r\n *\r\n * @param {function} callback - function to run upon completion/error\r\n */\r\nAvrgirlArduino.prototype._validateBoard = function(callback) {\r\n  if (typeof this.options.board !== 'object') {\r\n    // cannot find a matching board in supported list\r\n    return callback(new Error('\"' + this.options.board + '\" is not a supported board type.'));\r\n\r\n  } else if (!this.protocol.chip) {\r\n    // something went wrong trying to set up the protocol\r\n    var errorMsg = 'not a supported programming protocol: ' + this.options.board.protocol;\r\n    return callback(new Error(errorMsg));\r\n\r\n  } else if (!this.options.port && this.options.board.name === 'pro-mini') {\r\n    // when using a pro mini, a port is required in the options\r\n    return callback(new Error('using a pro-mini, please specify the port in your options.'));\r\n\r\n  } else {\r\n    // all good\r\n    return callback(null);\r\n  }\r\n};\r\n\r\n/**\r\n * Public method for flashing a hex file to the main program allocation of the Arduino\r\n *\r\n * @param {string} file - path to hex file for uploading\r\n * @param {function} callback - function to run upon completion/error\r\n */\r\nAvrgirlArduino.prototype.flash = function(file, callback) {\r\n  var _this = this;\r\n\r\n  // validate board properties first\r\n  _this._validateBoard(function(error) {\r\n    if (error) { return callback(error); }\r\n\r\n    // set up serialport connection\r\n    _this.connection._init(function(error) {\r\n      if (error) { return callback(error); }\r\n\r\n      // upload file to board\r\n      _this.protocol._upload(file, callback);\r\n    });\r\n  });\r\n};\r\n\r\n/**\r\n * Return a list of devices on serial ports. In addition to the output provided\r\n * by SerialPort.list, it adds a platform independent PID in _pid\r\n *\r\n * @param {function} callback - function to run upon completion/error\r\n */\r\nAvrgirlArduino.prototype.listPorts = AvrgirlArduino.listPorts =\r\nAvrgirlArduino.prototype.list = AvrgirlArduino.list = function(callback) {\r\n  return Connection.prototype._listPorts(callback);\r\n};\r\n\r\n/**\r\n * Static method to return the names of all known boards.\r\n */\r\nAvrgirlArduino.listKnownBoards = function() {\r\n  // filter the boards to find all non-aliases\r\n  return Object.keys(boards).filter(function(name) {\r\n    // fetch the current board aliases\r\n    var aliases = boards[name].aliases;\r\n    // only allow the name if it's not an alias\r\n    return !aliases || !~aliases.indexOf(name);\r\n  });\r\n};\r\n\r\nmodule.exports = AvrgirlArduino;"]}