-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (32 loc) · 855 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// package main is a module with raspberry pi board component.
package main
import (
"context"
"github.com/viam-modules/wit-motion/imuwit"
"go.viam.com/rdk/components/movementsensor"
"go.viam.com/rdk/logging"
"go.viam.com/rdk/module"
"go.viam.com/utils"
)
func main() {
utils.ContextualMain(mainWithArgs, module.NewLoggerFromArgs("wit-motion"))
}
func mainWithArgs(ctx context.Context, args []string, logger logging.Logger) error {
module, err := module.NewModuleFromArgs(ctx)
if err != nil {
return err
}
if err = module.AddModelFromRegistry(ctx, movementsensor.API, imuwit.Model); err != nil {
return err
}
if err = module.AddModelFromRegistry(ctx, movementsensor.API, imuwit.Model905); err != nil {
return err
}
err = module.Start(ctx)
defer module.Close(ctx)
if err != nil {
return err
}
<-ctx.Done()
return nil
}