mirror of
https://github.com/compute-blade-community/compute-blade-agent.git
synced 2026-04-16 15:35:42 +02:00
* chore: update repository references from uptime-industries to compute-blade-community chore: update repository references from uptime-industries to compute-blade-community for consistency and clarity across all files fix: update links in CHANGELOG.md and README.md to point to the new repository location for accurate documentation fix: update Dockerfile and systemd service file to reflect the new repository URL for proper source tracking refactor: change import paths in Go files to use the new repository name for correct package referencing * chore: Add CODEOWNERS * feat: add auto-labeling --------- Co-authored-by: Cedric Kienzler <cedric@specht-labs.de>
50 lines
889 B
Go
50 lines
889 B
Go
//go:build !tinygo
|
|
|
|
package hal_test
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/compute-blade-community/compute-blade-agent/pkg/hal"
|
|
"github.com/compute-blade-community/compute-blade-agent/pkg/hal/led"
|
|
)
|
|
|
|
func ExampleNewSmartFanUnit() {
|
|
ctx := context.Background()
|
|
|
|
client, err := hal.NewSmartFanUnit("/dev/tty.usbmodem11102")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
go func() {
|
|
err := client.Run(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}()
|
|
|
|
// Set LED color for the blade to red
|
|
err = client.SetLed(ctx, led.Color{Red: 100, Green: 0, Blue: 0})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
// Set fan speed to 20%
|
|
err = client.SetFanSpeedPercent(ctx, 20)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
tmp, err := client.AirFlowTemperature(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
log.Println("AirflowTemp", tmp)
|
|
rpm, err := client.FanSpeedRPM(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
log.Println("RPM", rpm)
|
|
}
|