tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/ssd1289/pinbus.go (about) 1 package ssd1289 2 3 import "machine" 4 5 type pinBus struct { 6 pins [16]machine.Pin 7 } 8 9 func NewPinBus(pins [16]machine.Pin) pinBus { 10 11 for i := 0; i < 16; i++ { 12 pins[i].Configure(machine.PinConfig{Mode: machine.PinOutput}) 13 } 14 15 return pinBus{ 16 pins: pins, 17 } 18 } 19 20 func (b pinBus) Set(data uint16) { 21 b.pins[15].Set((data & (1 << 15)) != 0) 22 b.pins[14].Set((data & (1 << 14)) != 0) 23 b.pins[13].Set((data & (1 << 13)) != 0) 24 b.pins[12].Set((data & (1 << 12)) != 0) 25 b.pins[11].Set((data & (1 << 11)) != 0) 26 b.pins[10].Set((data & (1 << 10)) != 0) 27 b.pins[9].Set((data & (1 << 9)) != 0) 28 b.pins[8].Set((data & (1 << 8)) != 0) 29 b.pins[7].Set((data & (1 << 7)) != 0) 30 b.pins[6].Set((data & (1 << 6)) != 0) 31 b.pins[5].Set((data & (1 << 5)) != 0) 32 b.pins[4].Set((data & (1 << 4)) != 0) 33 b.pins[3].Set((data & (1 << 3)) != 0) 34 b.pins[2].Set((data & (1 << 2)) != 0) 35 b.pins[1].Set((data & (1 << 1)) != 0) 36 b.pins[0].Set((data & (1 << 0)) != 0) 37 }