Debian Codegraph @

io/spi/example_test.go

raw symbols SCIP
1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package spi_test
6
7 import "golang.org/x/exp/io/spi"
8
9 // Example illustrates a program that drives an APA-102 LED strip.
10 func Example() {
11 dev, err := spi.Open(&spi.Devfs{
12 Dev: "/dev/spidev0.1",
13 Mode: spi.Mode3,
14 MaxSpeed: 500000,
15 })
16 if err != nil {
17 panic(err)
18 }
19 defer dev.Close()
20
21 if err := dev.Tx([]byte{
22 0, 0, 0, 0,
23 0xff, 200, 0, 200,
24 0xff, 200, 0, 200,
25 0xe0, 200, 0, 200,
26 0xff, 200, 0, 200,
27 0xff, 8, 50, 0,
28 0xff, 200, 0, 0,
29 0xff, 0, 0, 0,
30 0xff, 200, 0, 200,
31 0xff, 0xff, 0xff, 0xff,
32 0xff, 0xff, 0xff, 0xff,
33 0xff, 0xff, 0xff, 0xff,
34 0xff, 0xff, 0xff, 0xff,
35 }, nil); err != nil {
36 panic(err)
37 }
38 }