This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Plays "silent night" on a piezo buzzer attached to pin 18 of the Onion Omega2 | |
# Things required: python lite, pwm needs to be enabled via: | |
# omega2-ctrl gpiomux set pwm0 pwm | |
from time import sleep | |
exportStr="/sys/class/pwm/pwmchip0/export" | |
periodStr="/sys/class/pwm/pwmchip0/pwm%s/period" | |
dutyStr="/sys/class/pwm/pwmchip0/pwm%s/duty_cycle" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Derived from http://stackoverflow.com/a/8545403/106786 | |
function decodeFloat(bytes, signBits, exponentBits, fractionBits, eMin, eMax, littleEndian) { | |
var totalBits = (signBits + exponentBits + fractionBits); | |
var binary = ""; | |
for (var i = 0, l = bytes.length; i < l; i++) { | |
var bits = bytes[i].toString(2); | |
while (bits.length < 8) | |
bits = "0" + bits; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Int64.js | |
// | |
// Copyright (c) 2012 Robert Kieffer | |
// MIT License - http://opensource.org/licenses/mit-license.php | |
/** | |
* Support for handling 64-bit int numbers in Javascript (node.js) | |
* | |
* JS Numbers are IEEE-754 binary double-precision floats, which limits the | |
* range of values that can be represented with integer precision to: |