Browse Source

Added opacitycalculation

master
Rino Grupp 3 years ago
parent
commit
308a46a415
5 changed files with 11 additions and 8 deletions
  1. +1
    -1
      database.js
  2. +1
    -1
      hardwaredriver/driver-dummy.js
  3. +1
    -1
      hardwaredriver/driver-i2c.js
  4. +6
    -4
      hardwaredriver/hardwaredriver.js
  5. +2
    -1
      index.js

+ 1
- 1
database.js View File

@ -29,7 +29,7 @@ class Database {
}
getLampChannelConfig(id) {
return db.execute("SELECT `mapping-light`.`channel`, `mapping-light`.`key`, `board`.`address` \
return db.execute("SELECT `mapping-light`.`channel`, `mapping-light`.`key` \
FROM `light`, `mapping-light`, `board` \
WHERE `light`.`PK_light` = "+ id + " AND `mapping-light`.`FK_light` = " + id + " AND `mapping-light`.`FK_board` = `board`.`PK_board`")
.then(res => {

+ 1
- 1
hardwaredriver/driver-dummy.js View File

@ -17,7 +17,7 @@ class DummyDriver {
* @param {*} value Between 0&256
*/
setChannel(channel, value) {
console.log(`Set channel ${channel} on board ${this.address} to ${value}`)
console.log(`DEMO: Set channel ${channel} on board ${this.address} to ${value}`)
}
/*setRGB(channelConfig, color) {

+ 1
- 1
hardwaredriver/driver-i2c.js View File

@ -45,7 +45,7 @@ class I2CDriver {
* @param {*} value Between 0&256
*/
setChannel(channel, value) {
console.log(`set color on board ${this.address}, channel ${channel} to ${value}`)
console.log(`I2C: Set channel ${channel} on board ${this.address} to ${value}`)
this.pwm.setPulseRange(channel, 0, (value * 16))
}

+ 6
- 4
hardwaredriver/hardwaredriver.js View File

@ -5,7 +5,7 @@ class HardwareDriver {
constructor(driver){
this.driver = []
this.driverType = driver
@ -39,12 +39,14 @@ class HardwareDriver {
* @param {*} value Between 0&256
*/
setChannel(board,channel, value) {
this.driver.setChannel(board, channel, value)
this.driver[board].setChannel(channel, value)
}
setRGB(channelConfig, color) {
setRGB(boardID, channelConfig, color) {
console.log(channelConfig)
console.log(color)
channelConfig.forEach(channel => {
this.setChannel(channel.address, channel.channel, color[channel.key])
this.setChannel(boardID, channel.channel, Math.round(color[channel.key]*color.a))
});
}

+ 2
- 1
index.js View File

@ -81,7 +81,8 @@ function initRoutes() {
db.getLampChannelConfig(req.body.id)
.then(lamp => {
if (driver) {
driver.setRGB(lamp, req.body.color);
driver.setRGB(req.body.id, lamp, req.body.color);
console.log(req.body.color)
res.sendStatus(200)
} else {
console.log("Board not found")

Loading…
Cancel
Save