mirror of
https://github.com/compute-blade-community/compute-blade-agent.git
synced 2026-04-21 17:45:43 +02:00
* feat: add smart fanunit (serial) protocol Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com> * feat: add rudimentary eventbus to ease implementation Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com> * feat: smart fanunit client Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com> * feat: initial smart fan unit implementation Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com> * feat: improve logging, double btn press Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com> * fix: testcases Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com> * fix: context closure handling, RPM reporting Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com> * fix: address linting issues Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com> * fix: edge line closure Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com> * fix: reset CPU after i2c lockup Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com> * feat: add uf2 to release Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com> --------- Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>
22 lines
516 B
Go
22 lines
516 B
Go
package smartfanunit
|
|
|
|
import "github.com/xvzf/computeblade-agent/pkg/smartfanunit/proto"
|
|
|
|
func float32To24Bit(val float32) proto.Data {
|
|
// Convert float32 to number with 3 bytes (0.1 precision)
|
|
tmp := uint32(val * 10)
|
|
if tmp > 0xffffff {
|
|
tmp = 0xffffff // cap
|
|
}
|
|
return proto.Data{
|
|
uint8((tmp >> 16) & 0xFF),
|
|
uint8((tmp >> 8) & 0xFF),
|
|
uint8(tmp & 0xFF),
|
|
}
|
|
}
|
|
|
|
func float32From24Bit(data proto.Data) float32 {
|
|
tmp := uint32(data[0])<<16 | uint32(data[1])<<8 | uint32(data[2])
|
|
return float32(tmp) / 10
|
|
}
|