Skip to content

Commit

Permalink
feat: add toggle for heatmap
Browse files Browse the repository at this point in the history
Allows it to be turned off, since generating it is quite CPU intensive
and might mess with other things on less powerful hardware like Pi
Zeros.
  • Loading branch information
mKeRix committed Nov 12, 2020
1 parent 01c01f0 commit 60afaa5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/integrations/grid-eye.md
Expand Up @@ -76,6 +76,7 @@ When placing your sensor you need to consider a few factors to get reliable resu

| Name | Type | Default | Description |
| ------------------ | ------- | ------- | ------------------------------------------------------------ |
| `enabled` | Boolean | `true` | Whether the heatmap generation should be enabled or not. Turn this off if you notice very high CPU usage. |
| `minTemperature` | Number | `16` | Temperature that will be considered the lower bound for the color scale in °C. |
| `maxTemperature` | Number | `30` | Temperature that will be considered the upper bound for the color scale in °C. |
| `rotation` | Number | `0` | The amount of degrees that the heatmap output image should be rotated. Only `0`, `90`, `180` or `270` are supported as values. |
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/omron-d6t.md
Expand Up @@ -82,6 +82,7 @@ When placing your sensor you need to consider a few factors to get reliable resu

| Name | Type | Default | Description |
| ------------------ | ------- | ------- | ------------------------------------------------------------ |
| `enabled` | Boolean | `true` | Whether the heatmap generation should be enabled or not. Turn this off if you notice very high CPU usage. |
| `minTemperature` | Number | `16` | Temperature that will be considered the lower bound for the color scale in °C. |
| `maxTemperature` | Number | `30` | Temperature that will be considered the upper bound for the color scale in °C. |
| `rotation` | Number | `0` | The amount of degrees that the heatmap output image should be rotated. Only `0`, `90`, `180` or `270` are supported as values. |
Expand Down
16 changes: 11 additions & 5 deletions src/integrations/grid-eye/grid-eye.service.ts
Expand Up @@ -48,7 +48,10 @@ export class GridEyeService
this.setRegister(FRAMERATE_REGISTER, 1); // set framerate to 1 FPS -> less noise

this.sensor = this.createSensor();
this.camera = this.createHeatmapCamera();

if (this.config.heatmap.enabled) {
this.camera = this.createHeatmapCamera();
}
}

/**
Expand All @@ -72,10 +75,13 @@ export class GridEyeService

this.sensor.state = coordinates.length;
this.sensor.attributes.coordinates = coordinates;
this.camera.state = await this.generateHeatmap(
temperatures,
this.config.heatmap
);

if (this.config.heatmap.enabled) {
this.camera.state = await this.generateHeatmap(
temperatures,
this.config.heatmap
);
}
}

/**
Expand Down
16 changes: 11 additions & 5 deletions src/integrations/omron-d6t/omron-d6t.service.ts
Expand Up @@ -45,7 +45,10 @@ export class OmronD6tService
this.logger.log(`Opening i2c bus ${this.config.busNumber}`);
this.i2cBus = await i2cBus.openPromisified(this.config.busNumber);
this.sensor = this.createSensor();
this.camera = this.createHeatmapCamera();

if (this.config.heatmap.enabled) {
this.camera = this.createHeatmapCamera();
}
}

/**
Expand All @@ -70,10 +73,13 @@ export class OmronD6tService

this.sensor.state = coordinates.length;
this.sensor.attributes.coordinates = coordinates;
this.camera.state = await this.generateHeatmap(
temperatures,
this.config.heatmap
);

if (this.config.heatmap.enabled) {
this.camera.state = await this.generateHeatmap(
temperatures,
this.config.heatmap
);
}
} catch (e) {
if (e instanceof I2CError) {
this.logger.debug(`Error during I2C communication: ${e.message}`);
Expand Down
1 change: 1 addition & 0 deletions src/integrations/thermopile/thermopile-occupancy.config.ts
@@ -1,6 +1,7 @@
import { RotationOption } from './thermopile-occupancy.service';

export class HeatmapOptions {
enabled = true;
minTemperature = 16;
maxTemperature = 30;
rotation: RotationOption = 0;
Expand Down
Expand Up @@ -142,6 +142,7 @@ describe('ThermopileOccupancyService', () => {
await service.generateHeatmap(
PRESENCE_TEMPERATURES,
{
enabled: true,
rotation: 90,
minTemperature: 16,
maxTemperature: 30,
Expand Down

0 comments on commit 60afaa5

Please sign in to comment.