Skip to content

Commit

Permalink
Added setFreq
Browse files Browse the repository at this point in the history
  • Loading branch information
G0l committed Mar 13, 2014
1 parent 1de7162 commit e033b72
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion motorshield/motorshield.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,20 @@ exports.setDivider = function (value) {
divider = value;
freq = parseInt(25000000 / (divider + 1) / 4096);
tic = 1 / freq / 4096;

fs.writeFileSync("/sys/bus/i2c/devices/1-00" + address.toString(16) + "/freq", divider);
console.log("freq divider set to " + value);
}

/* set I2C PWM frequency */
exports.setFreq = function (value) {
freq = value;
divider = Math.round(25000000 / (4096 * freq)) -1;
tic = 1 / freq / 4096;
fs.writeFileSync("/sys/bus/i2c/devices/1-00" + address.toString(16) + "/freq", divider);
console.log("freq set to " + value);
}


/* motorshield init */
exports.init = function () {

Expand Down

0 comments on commit e033b72

Please sign in to comment.