Dia antes primera install

This commit is contained in:
2025-12-08 15:20:28 -06:00
commit 1416478c9c
4130 changed files with 886376 additions and 0 deletions

87
node_modules/i2c-bus/example/ds1621-async-callback.js generated vendored Normal file
View File

@@ -0,0 +1,87 @@
'use strict';
const async = require('async');
const i2c = require('../');
const DS1621_ADDR = 0x48;
const CMD_ACCESS_CONFIG = 0xac;
const CMD_READ_TEMP = 0xaa;
const CMD_START_CONVERT = 0xee;
const toCelsius = rawTemp => {
const halfDegrees = ((rawTemp & 0xff) << 1) + (rawTemp >> 15);
if ((halfDegrees & 0x100) === 0) {
return halfDegrees / 2; // Temp +ve
}
return -((~halfDegrees & 0xff) / 2); // Temp -ve
};
const displayTemperature = _ => {
let i2c1;
async.series([
cb => i2c1 = i2c.open(1, cb),
// Enter one shot mode (this is a non volatile setting)
cb => i2c1.writeByte(DS1621_ADDR, CMD_ACCESS_CONFIG, 0x01, cb),
// Wait while non volatile memory busy
cb => {
const wait = _ => {
i2c1.readByte(DS1621_ADDR, CMD_ACCESS_CONFIG, (err, config) => {
if (err) {
return cb(err);
}
if (config & 0x10) {
return wait();
}
cb(null);
});
};
wait();
},
// Start temperature conversion
cb => i2c1.sendByte(DS1621_ADDR, CMD_START_CONVERT, cb),
// Wait for temperature conversion to complete
cb => {
const wait = _ => {
i2c1.readByte(DS1621_ADDR, CMD_ACCESS_CONFIG, (err, config) => {
if (err) {
return cb(err);
}
if ((config & 0x80) === 0) {
return wait();
}
cb(null);
});
};
wait();
},
// Display temperature
cb => {
i2c1.readWord(DS1621_ADDR, CMD_READ_TEMP, (err, rawTemp) => {
if (err) {
return cb(err);
}
console.log('temp: ' + toCelsius(rawTemp));
cb(null);
});
},
cb => i2c1.close(cb)
], err => {
if (err) {
throw err;
}
});
};
displayTemperature();

BIN
node_modules/i2c-bus/example/ds1621-bb.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

BIN
node_modules/i2c-bus/example/ds1621-pi.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 KiB

45
node_modules/i2c-bus/example/ds1621-sync.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
'use strict';
const i2c = require('../');
const DS1621_ADDR = 0x48;
const CMD_ACCESS_CONFIG = 0xac;
const CMD_READ_TEMP = 0xaa;
const CMD_START_CONVERT = 0xee;
const toCelsius = rawTemp => {
const halfDegrees = ((rawTemp & 0xff) << 1) + (rawTemp >> 15);
if ((halfDegrees & 0x100) === 0) {
return halfDegrees / 2; // Temp +ve
}
return -((~halfDegrees & 0xff) / 2); // Temp -ve
};
const displayTemperature = _ => {
const i2c1 = i2c.openSync(1);
// Enter one shot mode (this is a non volatile setting)
i2c1.writeByteSync(DS1621_ADDR, CMD_ACCESS_CONFIG, 0x01);
// Wait while non volatile memory busy
while (i2c1.readByteSync(DS1621_ADDR, CMD_ACCESS_CONFIG) & 0x10) {
}
// Start temperature conversion
i2c1.sendByteSync(DS1621_ADDR, CMD_START_CONVERT);
// Wait for temperature conversion to complete
while ((i2c1.readByteSync(DS1621_ADDR, CMD_ACCESS_CONFIG) & 0x80) === 0) {
}
// Display temperature
const rawTemp = i2c1.readWordSync(DS1621_ADDR, CMD_READ_TEMP);
console.log('temp: ' + toCelsius(rawTemp));
i2c1.closeSync();
};
displayTemperature();

16
node_modules/i2c-bus/example/i2c-list-busses.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
'use strict';
// Determine the bus numbers of the I2C busses available on the current
// machine and print those bus numbers to the screen.
const glob = require('glob');
const busNumbers = glob.sync('/dev/i2c-*').
filter(fileName => fileName.match(/\/i2c-\d+$/) !== null).
map(fileName => parseInt(fileName.match(/\d+$/)[0], 10));
console.log(busNumbers);
// Here glob is used synchronously but it can also be used asynchronously.
// busNumbers is an array of numbers.

48
node_modules/i2c-bus/example/i2cdetect-quick.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
'use strict';
// When run, this program will output the same information as the
// command 'i2cdetect -y -q 1'
// An error message will be printed on the BeagleBone as it doesn't
// support the SMBus quick command.
// This program is similar to i2cdetect.js, but it uses writeQuickSync
// rather than receiveByteSync to detect devices.
const fs = require('fs');
const i2c = require('../');
const i2c1 = i2c.openSync(1);
const EBUSY = 16; /* Device or resource busy */
const scan = (first, last) => {
fs.writeSync(0, ' 0 1 2 3 4 5 6 7 8 9 a b c d e f');
for (let addr = 0; addr <= 127; addr += 1) {
if (addr % 16 === 0) {
fs.writeSync(0, '\n' + (addr === 0 ? '0' : ''));
fs.writeSync(0, addr.toString(16) + ':');
}
if (addr < first || addr > last) {
fs.writeSync(0, ' ');
} else {
try {
i2c1.writeQuickSync(addr, 0);
fs.writeSync(0, ' ' + addr.toString(16)); // device found, print addr
} catch (e) {
if (e.errno === EBUSY) {
fs.writeSync(0, ' UU');
} else {
fs.writeSync(0, ' --');
}
}
}
}
fs.writeSync(0, '\n');
};
if (!i2c1.i2cFuncsSync().smbusQuick) {
console.log('Error: Can\'t use SMBus Quick Write command on this bus#');
} else {
scan(0x3, 0x77);
}

40
node_modules/i2c-bus/example/i2cdetect.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
'use strict';
// When run, this program will output the same information as the
// command 'i2cdetect -y -r 1'
const fs = require('fs');
const i2c = require('../');
const i2c1 = i2c.openSync(1);
const EBUSY = 16; /* Device or resource busy */
const scan = (first, last) => {
fs.writeSync(0, ' 0 1 2 3 4 5 6 7 8 9 a b c d e f');
for (let addr = 0; addr <= 127; addr += 1) {
if (addr % 16 === 0) {
fs.writeSync(0, '\n' + (addr === 0 ? '0' : ''));
fs.writeSync(0, addr.toString(16) + ':');
}
if (addr < first || addr > last) {
fs.writeSync(0, ' ');
} else {
try {
i2c1.receiveByteSync(addr);
fs.writeSync(0, ' ' + addr.toString(16)); // device found, print addr
} catch (e) {
if (e.errno === EBUSY) {
fs.writeSync(0, ' UU');
} else {
fs.writeSync(0, ' --');
}
}
}
}
fs.writeSync(0, '\n');
};
scan(0x3, 0x77);

37
node_modules/i2c-bus/example/i2cfuncs.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
'use strict';
// When run, this program will output the same information as the
// command 'i2cdetect -F 1'
const i2c = require('../');
const i2c1 = i2c.open(1, err => {
if (err) {
throw err;
}
i2c1.i2cFuncs((err, i2cFuncs) => {
const boolToYesNo = bool => bool ? 'yes' : 'no';
if (err) {
throw err;
}
console.log('Functionalities implemented by /dev/i2c-1:');
console.log('I2C ' + boolToYesNo(i2cFuncs.i2c));
console.log('SMBus Quick Command ' + boolToYesNo(i2cFuncs.smbusQuick));
console.log('SMBus Send Byte ' + boolToYesNo(i2cFuncs.smbusSendByte));
console.log('SMBus Receive Byte ' + boolToYesNo(i2cFuncs.smbusReceiveByte));
console.log('SMBus Write Byte ' + boolToYesNo(i2cFuncs.smbusWriteByte));
console.log('SMBus Read Byte ' + boolToYesNo(i2cFuncs.smbusReadByte));
console.log('SMBus Write Word ' + boolToYesNo(i2cFuncs.smbusWriteWord));
console.log('SMBus Read Word ' + boolToYesNo(i2cFuncs.smbusReadWord));
console.log('SMBus Process Call ' + boolToYesNo(i2cFuncs.smbusProcCall));
console.log('SMBus Block Write ' + boolToYesNo(i2cFuncs.smbusWriteBlock));
console.log('SMBus Block Read ' + boolToYesNo(i2cFuncs.smbusReadBlock));
console.log('SMBus Block Process Call ' + boolToYesNo(i2cFuncs.smbusBlockProcCall));
console.log('SMBus PEC ' + boolToYesNo(i2cFuncs.smbusPec));
console.log('I2C Block Write ' + boolToYesNo(i2cFuncs.smbusWriteI2cBlock));
console.log('I2C Block Read ' + boolToYesNo(i2cFuncs.smbusReadI2cBlock));
});
});

36
node_modules/i2c-bus/example/mcp9808-async-callback.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
'use strict';
const i2c = require('../');
const MCP9808_ADDR = 0x18;
const TEMP_REG = 0x05;
const toCelsius = rawData => {
rawData = (rawData >> 8) + ((rawData & 0xff) << 8);
let celsius = (rawData & 0x0fff) / 16;
if (rawData & 0x1000) {
celsius -= 256;
}
return celsius;
};
const i2c1 = i2c.open(1, err => {
if (err) {
throw err;
}
i2c1.readWord(MCP9808_ADDR, TEMP_REG, (err, rawData) => {
if (err) {
throw err;
}
console.log(toCelsius(rawData));
i2c1.close(err => {
if (err) {
throw err;
}
});
});
});

BIN
node_modules/i2c-bus/example/mcp9808-pi.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@@ -0,0 +1,25 @@
'use strict';
const i2c = require('../');
const MCP9808_ADDR = 0x18;
const TEMP_REG = 0x05;
const toCelsius = rawData => {
let celsius = (rawData & 0x0fff) / 16;
if (rawData & 0x1000) {
celsius -= 256;
}
return celsius;
};
const wbuf = Buffer.from([TEMP_REG]);
const rbuf = Buffer.alloc(2);
i2c.openPromisified(1).
then(i2c1 => i2c1.i2cWrite(MCP9808_ADDR, wbuf.length, wbuf).
then(_ => i2c1.i2cRead(MCP9808_ADDR, rbuf.length, rbuf)).
then(data => console.log(toCelsius(data.buffer.readUInt16BE()))).
then(_ => i2c1.close())
).catch(console.log);

22
node_modules/i2c-bus/example/mcp9808-promise.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
'use strict';
const i2c = require('../');
const MCP9808_ADDR = 0x18;
const TEMP_REG = 0x05;
const toCelsius = rawData => {
rawData = (rawData >> 8) + ((rawData & 0xff) << 8);
let celsius = (rawData & 0x0fff) / 16;
if (rawData & 0x1000) {
celsius -= 256;
}
return celsius;
};
i2c.openPromisified(1).
then(i2c1 => i2c1.readWord(MCP9808_ADDR, TEMP_REG).
then(rawData => console.log(toCelsius(rawData))).
then(_ => i2c1.close())
).catch(console.log);

21
node_modules/i2c-bus/example/mcp9808-sync.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
'use strict';
const i2c = require('../');
const MCP9808_ADDR = 0x18;
const TEMP_REG = 0x05;
const toCelsius = rawData => {
rawData = (rawData >> 8) + ((rawData & 0xff) << 8);
let celsius = (rawData & 0x0fff) / 16;
if (rawData & 0x1000) {
celsius -= 256;
}
return celsius;
};
const i2c1 = i2c.openSync(1);
const rawData = i2c1.readWordSync(MCP9808_ADDR, TEMP_REG);
console.log(toCelsius(rawData));
i2c1.closeSync();

40
node_modules/i2c-bus/example/two-devices.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
'use strict';
const i2c = require('../');
const DS1621_ADDR = 0x48;
const DS1621_CMD_ACCESS_TH = 0xa1;
const TSL2561_ADDR = 0x39;
const TSL2561_CMD = 0x80;
const TSL2561_REG_ID = 0x0a;
const i2c1 = i2c.open(1, err => {
if (err) {
throw err;
}
const readDs1621TempHigh = _ => {
i2c1.readWord(DS1621_ADDR, DS1621_CMD_ACCESS_TH, (err, tempHigh) => {
if (err) {
throw err;
}
console.log(tempHigh);
readDs1621TempHigh();
});
};
const readTsl2561Id = _ => {
i2c1.readByte(TSL2561_ADDR, TSL2561_CMD | TSL2561_REG_ID, (err, id) => {
if (err) {
throw err;
}
console.log(id);
readTsl2561Id();
});
};
readDs1621TempHigh();
readTsl2561Id();
});