Skip to content

Commit

Permalink
Fix: Fix the fan and light bar power value of the enclosure module
Browse files Browse the repository at this point in the history
  • Loading branch information
xhycode authored and scotthsl committed Apr 7, 2021
1 parent 97caac4 commit a0e979a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions snapmaker/src/module/enclosure.cpp
Expand Up @@ -84,14 +84,17 @@ ErrCode Enclosure::PostInit() {

ErrCode Enclosure::SetLightBar(uint8_t brightness) {
CanStdFuncCmd_t cmd;
brightness = (brightness > 100) ? 100 : brightness;
uint8_t out = brightness * 255 / 100;

uint8_t buffer[4];

buffer[0] = 1;
buffer[1] = brightness;
buffer[2] = brightness;
buffer[3] = brightness;
buffer[1] = out;
buffer[2] = out;
buffer[3] = out;

LOG_I("Eclosure: set FAN speed %u\n", brightness);
LOG_I("Eclosure: set LIGHT power %u\n", brightness);

cmd.id = MODULE_FUNC_SET_ENCLOSURE_LIGHT;
cmd.data = buffer;
Expand All @@ -106,9 +109,11 @@ ErrCode Enclosure::SetLightBar(uint8_t brightness) {
ErrCode Enclosure::SetFanSpeed(uint8_t speed) {
CanStdFuncCmd_t cmd;
uint8_t buffer[2];
speed = (speed > 100) ? 100 : speed;
uint8_t out = speed * 255 / 100;

buffer[0] = 0;
buffer[1] = speed;
buffer[1] = out;

LOG_I("Eclosure: set FAN speed %u\n", speed);

Expand Down

0 comments on commit a0e979a

Please sign in to comment.