diff --git a/devices/bme280/bme280_test.go b/devices/bme280/bme280_test.go index 29c4618..69414ec 100644 --- a/devices/bme280/bme280_test.go +++ b/devices/bme280/bme280_test.go @@ -46,24 +46,24 @@ func TestSPISense_success(t *testing.T) { Ops: []conntest.IO{ // Chipd ID detection. { - Write: []byte{0xD0, 0x00}, - Read: []byte{0x00, 0x60}, + W: []byte{0xD0, 0x00}, + R: []byte{0x00, 0x60}, }, // Calibration data. { - Write: []byte{0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - Read: []byte{0x00, 0xC9, 0x6C, 0x63, 0x65, 0x32, 0x00, 0x77, 0x93, 0x98, 0xD5, 0xD0, 0x0B, 0x67, 0x23, 0xBA, 0x00, 0xF9, 0xFF, 0xAC, 0x26, 0x0A, 0xD8, 0xBD, 0x10, 0x00, 0x4B}, + W: []byte{0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + R: []byte{0x00, 0xC9, 0x6C, 0x63, 0x65, 0x32, 0x00, 0x77, 0x93, 0x98, 0xD5, 0xD0, 0x0B, 0x67, 0x23, 0xBA, 0x00, 0xF9, 0xFF, 0xAC, 0x26, 0x0A, 0xD8, 0xBD, 0x10, 0x00, 0x4B}, }, // Calibration data. { - Write: []byte{0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - Read: []byte{0x00, 0x5C, 0x01, 0x00, 0x15, 0x0F, 0x00, 0x1E}, + W: []byte{0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + R: []byte{0x00, 0x5C, 0x01, 0x00, 0x15, 0x0F, 0x00, 0x1E}, }, - {Write: []byte{0x74, 0xB4, 0x72, 0x05, 0x75, 0xA0, 0x74, 0xB7}}, - // Read. + {W: []byte{0x74, 0xB4, 0x72, 0x05, 0x75, 0xA0, 0x74, 0xB7}}, + // R. { - Write: []byte{0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - Read: []byte{0x00, 0x51, 0x9F, 0xC0, 0x9E, 0x3A, 0x50, 0x5E, 0x5B}, + W: []byte{0xF7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + R: []byte{0x00, 0x51, 0x9F, 0xC0, 0x9E, 0x3A, 0x50, 0x5E, 0x5B}, }, }, }, @@ -112,8 +112,8 @@ func TestNewSPI_fail_len(t *testing.T) { Ops: []conntest.IO{ { // Chipd ID detection. - Write: []byte{0xD0, 0x00}, - Read: []byte{0x00}, + W: []byte{0xD0, 0x00}, + R: []byte{0x00}, }, }, DontPanic: true, @@ -135,8 +135,8 @@ func TestNewSPI_fail_chipid(t *testing.T) { Ops: []conntest.IO{ { // Chipd ID detection. - Write: []byte{0xD0, 0x00}, - Read: []byte{0x00, 0xFF}, + W: []byte{0xD0, 0x00}, + R: []byte{0x00, 0xFF}, }, }, }, @@ -153,7 +153,7 @@ func TestNewI2C_fail(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Chipd ID detection. - {Addr: 0x76, Write: []byte{0xd0}}, + {Addr: 0x76, W: []byte{0xd0}}, }, DontPanic: true, } @@ -171,7 +171,7 @@ func TestNewI2C_chipid(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Chipd ID detection. - {Addr: 0x76, Write: []byte{0xd0}, Read: []byte{0x60}}, + {Addr: 0x76, W: []byte{0xd0}, R: []byte{0x60}}, }, DontPanic: true, } @@ -187,12 +187,12 @@ func TestNewI2C_calib1(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Chipd ID detection. - {Addr: 0x76, Write: []byte{0xd0}, Read: []byte{0x60}}, + {Addr: 0x76, W: []byte{0xd0}, R: []byte{0x60}}, // Calibration data. { - Addr: 0x76, - Write: []byte{0x88}, - Read: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b}, + Addr: 0x76, + W: []byte{0x88}, + R: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b}, }, }, DontPanic: true, @@ -210,15 +210,15 @@ func TestNewI2C_calib2(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Chipd ID detection. - {Addr: 0x76, Write: []byte{0xd0}, Read: []byte{0x60}}, + {Addr: 0x76, W: []byte{0xd0}, R: []byte{0x60}}, // Calibration data. { - Addr: 0x76, - Write: []byte{0x88}, - Read: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b}, + Addr: 0x76, + W: []byte{0x88}, + R: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b}, }, // Calibration data. - {Addr: 0x76, Write: []byte{0xe1}, Read: []byte{0x6e, 0x1, 0x0, 0x13, 0x5, 0x0, 0x1e}}, + {Addr: 0x76, W: []byte{0xe1}, R: []byte{0x6e, 0x1, 0x0, 0x13, 0x5, 0x0, 0x1e}}, }, DontPanic: true, } @@ -257,19 +257,19 @@ func TestI2CSense_fail(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Chipd ID detection. - {Addr: 0x76, Write: []byte{0xd0}, Read: []byte{0x60}}, + {Addr: 0x76, W: []byte{0xd0}, R: []byte{0x60}}, // Calibration data. { - Addr: 0x76, - Write: []byte{0x88}, - Read: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b}, + Addr: 0x76, + W: []byte{0x88}, + R: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b}, }, // Calibration data. - {Addr: 0x76, Write: []byte{0xe1}, Read: []byte{0x6e, 0x1, 0x0, 0x13, 0x5, 0x0, 0x1e}}, + {Addr: 0x76, W: []byte{0xe1}, R: []byte{0x6e, 0x1, 0x0, 0x13, 0x5, 0x0, 0x1e}}, // Configuration. - {Addr: 0x76, Write: []byte{0xf4, 0x6c, 0xf2, 0x3, 0xf5, 0xe0, 0xf4, 0x6f}, Read: nil}, + {Addr: 0x76, W: []byte{0xf4, 0x6c, 0xf2, 0x3, 0xf5, 0xe0, 0xf4, 0x6f}, R: nil}, // Read. - {Addr: 0x76, Write: []byte{0xf7}}, + {Addr: 0x76, W: []byte{0xf7}}, }, DontPanic: true, } @@ -292,21 +292,21 @@ func TestI2CSense_success(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Chipd ID detection. - {Addr: 0x76, Write: []byte{0xd0}, Read: []byte{0x60}}, + {Addr: 0x76, W: []byte{0xd0}, R: []byte{0x60}}, // Calibration data. { - Addr: 0x76, - Write: []byte{0x88}, - Read: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b}, + Addr: 0x76, + W: []byte{0x88}, + R: []byte{0x10, 0x6e, 0x6c, 0x66, 0x32, 0x0, 0x5d, 0x95, 0xb8, 0xd5, 0xd0, 0xb, 0x77, 0x1e, 0x9d, 0xff, 0xf9, 0xff, 0xac, 0x26, 0xa, 0xd8, 0xbd, 0x10, 0x0, 0x4b}, }, // Calibration data. - {Addr: 0x76, Write: []byte{0xe1}, Read: []byte{0x6e, 0x1, 0x0, 0x13, 0x5, 0x0, 0x1e}}, + {Addr: 0x76, W: []byte{0xe1}, R: []byte{0x6e, 0x1, 0x0, 0x13, 0x5, 0x0, 0x1e}}, // Configuration. - {Addr: 0x76, Write: []byte{0xf4, 0x6c, 0xf2, 0x3, 0xf5, 0xe0, 0xf4, 0x6f}, Read: nil}, + {Addr: 0x76, W: []byte{0xf4, 0x6c, 0xf2, 0x3, 0xf5, 0xe0, 0xf4, 0x6f}, R: nil}, // Read. - {Addr: 0x76, Write: []byte{0xf7}, Read: []byte{0x4a, 0x52, 0xc0, 0x80, 0x96, 0xc0, 0x7a, 0x76}}, + {Addr: 0x76, W: []byte{0xf7}, R: []byte{0x4a, 0x52, 0xc0, 0x80, 0x96, 0xc0, 0x7a, 0x76}}, // Stop. - {Addr: 0x76, Write: []byte{0xf4, 0x0}}, + {Addr: 0x76, W: []byte{0xf4, 0x0}}, }, } dev, err := NewI2C(&bus, nil) diff --git a/devices/bme280/bme280smoketest/bme280smoketest.go b/devices/bme280/bme280smoketest/bme280smoketest.go index 524788b..65da9f7 100644 --- a/devices/bme280/bme280smoketest/bme280smoketest.go +++ b/devices/bme280/bme280smoketest/bme280smoketest.go @@ -75,15 +75,15 @@ func (s *SmokeTest) Run(args []string) (err error) { fmt.Print("I²C recorder\n") } for _, op := range i2cRecorder.Ops { - fmt.Print(" Write: ") - for i, b := range op.Write { + fmt.Print(" W: ") + for i, b := range op.W { if i != 0 { fmt.Print(", ") } fmt.Printf("0x%02X", b) } - fmt.Print("\n Read: ") - for i, b := range op.Read { + fmt.Print("\n R: ") + for i, b := range op.R { if i != 0 { fmt.Print(", ") } @@ -93,12 +93,12 @@ func (s *SmokeTest) Run(args []string) (err error) { } fmt.Print("\nSPI recorder\n") for _, op := range spiRecorder.Ops { - fmt.Print(" Write: ") - if len(op.Read) != 0 { + fmt.Print(" W: ") + if len(op.R) != 0 { // Read data. - fmt.Printf("0x%02X\n Read: ", op.Write[0]) + fmt.Printf("0x%02X\n R: ", op.W[0]) // first byte is dummy. - for i, b := range op.Read[1:] { + for i, b := range op.R[1:] { if i != 0 { fmt.Print(", ") } @@ -106,13 +106,13 @@ func (s *SmokeTest) Run(args []string) (err error) { } } else { // Write-only command. - for i, b := range op.Write { + for i, b := range op.W { if i != 0 { fmt.Print(", ") } fmt.Printf("0x%02X", b) } - fmt.Print("\n Read: ") + fmt.Print("\n R: ") } fmt.Print("\n") } diff --git a/devices/ds18b20/ds18b20_test.go b/devices/ds18b20/ds18b20_test.go index a434d95..f41bb58 100644 --- a/devices/ds18b20/ds18b20_test.go +++ b/devices/ds18b20/ds18b20_test.go @@ -36,18 +36,18 @@ func TestTemperature(t *testing.T) { ops := []onewiretest.IO{ // Match ROM + Read Scratchpad (init) { - Write: []uint8{0x55, 0x28, 0xac, 0x41, 0xe, 0x7, 0x0, 0x0, 0x74, 0xbe}, - Read: []uint8{0xe0, 0x1, 0x0, 0x0, 0x3f, 0xff, 0x10, 0x10, 0x3f}, + W: []uint8{0x55, 0x28, 0xac, 0x41, 0xe, 0x7, 0x0, 0x0, 0x74, 0xbe}, + R: []uint8{0xe0, 0x1, 0x0, 0x0, 0x3f, 0xff, 0x10, 0x10, 0x3f}, }, // Match ROM + Convert { - Write: []uint8{0x55, 0x28, 0xac, 0x41, 0xe, 0x7, 0x0, 0x0, 0x74, 0x44}, - Pull: true, + W: []uint8{0x55, 0x28, 0xac, 0x41, 0xe, 0x7, 0x0, 0x0, 0x74, 0x44}, + Pull: true, }, // Match ROM + Read Scratchpad (read temp) { - Write: []uint8{0x55, 0x28, 0xac, 0x41, 0xe, 0x7, 0x0, 0x0, 0x74, 0xbe}, - Read: []uint8{0xe0, 0x1, 0x0, 0x0, 0x3f, 0xff, 0x10, 0x10, 0x3f}, + W: []uint8{0x55, 0x28, 0xac, 0x41, 0xe, 0x7, 0x0, 0x0, 0x74, 0xbe}, + R: []uint8{0xe0, 0x1, 0x0, 0x0, 0x3f, 0xff, 0x10, 0x10, 0x3f}, }, } var addr onewire.Address = 0x740000070e41ac28 @@ -84,7 +84,7 @@ func TestConvertAll(t *testing.T) { // set-up playback using the recording output. ops := []onewiretest.IO{ // Skip ROM + Convert - {Write: []uint8{0xcc, 0x44}, Read: []uint8(nil), Pull: true}, + {W: []uint8{0xcc, 0x44}, R: []uint8(nil), Pull: true}, } bus := onewiretest.Playback{Ops: ops} // Perform the conversion diff --git a/devices/ds248x/ds248x_test.go b/devices/ds248x/ds248x_test.go index a5a34b3..e24963c 100644 --- a/devices/ds248x/ds248x_test.go +++ b/devices/ds248x/ds248x_test.go @@ -43,11 +43,11 @@ func Example() { func TestNew(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ - {Addr: 0x18, Write: []byte{0xf0}}, - {Addr: 0x18, Write: []byte{0xe1, 0xf0}, Read: []byte{0x18}}, - {Addr: 0x18, Write: []byte{0xd2, 0xe1}, Read: []byte{0x1}}, - {Addr: 0x18, Write: []byte{0xe1, 0xb4}}, - {Addr: 0x18, Write: []byte{0xc3, 0x6, 0x26, 0x46, 0x66, 0x86}}, + {Addr: 0x18, W: []byte{0xf0}}, + {Addr: 0x18, W: []byte{0xe1, 0xf0}, R: []byte{0x18}}, + {Addr: 0x18, W: []byte{0xd2, 0xe1}, R: []byte{0x1}}, + {Addr: 0x18, W: []byte{0xe1, 0xb4}}, + {Addr: 0x18, W: []byte{0xc3, 0x6, 0x26, 0x46, 0x66, 0x86}}, }, } d, err := New(&bus, nil) @@ -65,11 +65,11 @@ func TestNew(t *testing.T) { func TestNew_opts(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ - {Addr: 0x18, Write: []byte{0xf0}}, - {Addr: 0x18, Write: []byte{0xe1, 0xf0}, Read: []byte{0x18}}, - {Addr: 0x18, Write: []byte{0xd2, 0xe1}, Read: []byte{0x1}}, - {Addr: 0x18, Write: []byte{0xe1, 0xb4}}, - {Addr: 0x18, Write: []byte{0xc3, 0x6, 0x26, 0x46, 0x66, 0x86}}, + {Addr: 0x18, W: []byte{0xf0}}, + {Addr: 0x18, W: []byte{0xe1, 0xf0}, R: []byte{0x18}}, + {Addr: 0x18, W: []byte{0xd2, 0xe1}, R: []byte{0x1}}, + {Addr: 0x18, W: []byte{0xe1, 0xb4}}, + {Addr: 0x18, W: []byte{0xc3, 0x6, 0x26, 0x46, 0x66, 0x86}}, }, } opts := &Opts{Addr: 0x18} @@ -114,7 +114,7 @@ func TestRecordInit(t *testing.T) { // Output the recording. t.Logf("var ops = i2ctest.IO{\n") for _, op := range i2cBus.Ops { - t.Logf(" {Addr: %#x, Write: %#v, Read: %#v},\n", op.Addr, op.Write, op.Read) + t.Logf(" {Addr: %#x, W: %#v, R: %#v},\n", op.Addr, op.W, op.R) } t.Logf("}\n") } diff --git a/devices/ssd1306/ssd1306_test.go b/devices/ssd1306/ssd1306_test.go index 4be8576..c6e12fe 100644 --- a/devices/ssd1306/ssd1306_test.go +++ b/devices/ssd1306/ssd1306_test.go @@ -107,9 +107,9 @@ func TestI2C_Draw_VerticalLSD_fast(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Startup initialization. - {Addr: 0x3c, Write: initCmdI2C()}, + {Addr: 0x3c, W: initCmdI2C()}, // Actual draw buffer. - {Addr: 0x3c, Write: buf}, + {Addr: 0x3c, W: buf}, }, } dev, err := NewI2C(&bus, 128, 64, false) @@ -135,13 +135,13 @@ func TestI2C_Halt_Write(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Startup initialization. - {Addr: 0x3c, Write: initCmdI2C()}, + {Addr: 0x3c, W: initCmdI2C()}, // Halt() - {Addr: 0x3c, Write: []byte{0x0, 0xae}}, + {Addr: 0x3c, W: []byte{0x0, 0xae}}, // transparent resume - {Addr: 0x3c, Write: []byte{0x0, 0xaf}}, + {Addr: 0x3c, W: []byte{0x0, 0xaf}}, // Actual draw buffer. - {Addr: 0x3c, Write: buf}, + {Addr: 0x3c, W: buf}, }, } dev, err := NewI2C(&bus, 128, 64, false) @@ -165,9 +165,9 @@ func TestI2C_Halt_resume_fail(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Startup initialization. - {Addr: 0x3c, Write: initCmdI2C()}, + {Addr: 0x3c, W: initCmdI2C()}, // Halt() - {Addr: 0x3c, Write: []byte{0x0, 0xae}}, + {Addr: 0x3c, W: []byte{0x0, 0xae}}, }, DontPanic: true, } @@ -190,7 +190,7 @@ func TestI2C_Write_invalid_size(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Startup initialization. - {Addr: 0x3c, Write: initCmdI2C()}, + {Addr: 0x3c, W: initCmdI2C()}, }, } dev, err := NewI2C(&bus, 128, 64, false) @@ -209,7 +209,7 @@ func TestI2C_Write_fail(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Startup initialization. - {Addr: 0x3c, Write: initCmdI2C()}, + {Addr: 0x3c, W: initCmdI2C()}, }, DontPanic: true, } @@ -229,7 +229,7 @@ func TestI2C_Draw_fail(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Startup initialization. - {Addr: 0x3c, Write: initCmdI2C()}, + {Addr: 0x3c, W: initCmdI2C()}, }, DontPanic: true, } @@ -250,9 +250,9 @@ func TestI2C_DrawGray(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ // Startup initialization. - {Addr: 0x3c, Write: initCmdI2C()}, + {Addr: 0x3c, W: initCmdI2C()}, // Actual draw buffer. - {Addr: 0x3c, Write: append([]byte{i2cData}, grayCheckboard()...)}, + {Addr: 0x3c, W: append([]byte{i2cData}, grayCheckboard()...)}, }, } dev, err := NewI2C(&bus, 128, 64, false) @@ -276,13 +276,13 @@ func TestI2C_DrawGray(t *testing.T) { func TestI2C_Scroll(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ - {Addr: 0x3c, Write: initCmdI2C()}, + {Addr: 0x3c, W: initCmdI2C()}, // Scroll Left. - {Addr: 0x3c, Write: []byte{0x0, 0x27, 0x0, 0x0, 0x6, 0x7, 0x0, 0xff, 0x2f}}, + {Addr: 0x3c, W: []byte{0x0, 0x27, 0x0, 0x0, 0x6, 0x7, 0x0, 0xff, 0x2f}}, // Scroll UpRight. - {Addr: 0x3c, Write: []byte{0x0, 0x29, 0x0, 0x0, 0x6, 0x0, 0x1, 0x2f}}, + {Addr: 0x3c, W: []byte{0x0, 0x29, 0x0, 0x0, 0x6, 0x0, 0x1, 0x2f}}, // StopScroll. - {Addr: 0x3c, Write: []byte{0x0, 0x2e}}, + {Addr: 0x3c, W: []byte{0x0, 0x2e}}, }, } dev, err := NewI2C(&bus, 128, 64, false) @@ -315,10 +315,10 @@ func TestI2C_Scroll(t *testing.T) { func TestI2C_SetContrast(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ - {Addr: 0x3c, Write: initCmdI2C()}, - {Addr: 0x3c, Write: []byte{0x0, 0x81, 0x0}}, - {Addr: 0x3c, Write: []byte{0x0, 0x81, 0x7f}}, - {Addr: 0x3c, Write: []byte{0x0, 0x81, 0xff}}, + {Addr: 0x3c, W: initCmdI2C()}, + {Addr: 0x3c, W: []byte{0x0, 0x81, 0x0}}, + {Addr: 0x3c, W: []byte{0x0, 0x81, 0x7f}}, + {Addr: 0x3c, W: []byte{0x0, 0x81, 0xff}}, }, } dev, err := NewI2C(&bus, 128, 64, false) @@ -342,13 +342,13 @@ func TestI2C_SetContrast(t *testing.T) { func TestI2C_Invert_Halt_resume(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ - {Addr: 0x3c, Write: initCmdI2C()}, + {Addr: 0x3c, W: initCmdI2C()}, // Invert(true) - {Addr: 0x3c, Write: []byte{0x0, 0xa7}}, + {Addr: 0x3c, W: []byte{0x0, 0xa7}}, // Halt() - {Addr: 0x3c, Write: []byte{0x0, 0xae}}, + {Addr: 0x3c, W: []byte{0x0, 0xae}}, // transparent resume + Invert(false) - {Addr: 0x3c, Write: []byte{0x0, 0xaf, 0xa6}}, + {Addr: 0x3c, W: []byte{0x0, 0xaf, 0xa6}}, }, } dev, err := NewI2C(&bus, 128, 64, false) @@ -372,11 +372,11 @@ func TestI2C_Invert_Halt_resume(t *testing.T) { func TestI2C_Halt(t *testing.T) { bus := i2ctest.Playback{ Ops: []i2ctest.IO{ - {Addr: 0x3c, Write: initCmdI2C()}, + {Addr: 0x3c, W: initCmdI2C()}, // Halt() - {Addr: 0x3c, Write: []byte{0x0, 0xae}}, + {Addr: 0x3c, W: []byte{0x0, 0xae}}, // transparent resume + StopScroll() - {Addr: 0x3c, Write: []byte{0x0, 0xaf, 0x2e}}, + {Addr: 0x3c, W: []byte{0x0, 0xaf, 0x2e}}, }, DontPanic: true, } @@ -422,7 +422,7 @@ func TestSPI_3wire(t *testing.T) { func TestSPI_4wire_String(t *testing.T) { bus := spitest.Playback{ Playback: conntest.Playback{ - Ops: []conntest.IO{{Write: getInitCmd(128, 64, false)}}, + Ops: []conntest.IO{{W: getInitCmd(128, 64, false)}}, }, } dev, err := NewSPI(&bus, &gpiotest.Pin{N: "pin1", Num: 42}, 128, 64, false) @@ -447,11 +447,11 @@ func TestSPI_4wire_Write_differential(t *testing.T) { bus := spitest.Playback{ Playback: conntest.Playback{ Ops: []conntest.IO{ - {Write: getInitCmd(128, 64, false)}, - {Write: buf1}, + {W: getInitCmd(128, 64, false)}, + {W: buf1}, // Reset to write only to the first page. - {Write: []byte{0x21, 0x0, 0x7f, 0x22, 0x1, 0x1}}, - {Write: buf2}, + {W: []byte{0x21, 0x0, 0x7f, 0x22, 0x1, 0x1}}, + {W: buf2}, }, }, } @@ -479,8 +479,8 @@ func TestSPI_4wire_Write_differential_fail(t *testing.T) { bus := spitest.Playback{ Playback: conntest.Playback{ Ops: []conntest.IO{ - {Write: getInitCmd(128, 64, false)}, - {Write: buf1}, + {W: getInitCmd(128, 64, false)}, + {W: buf1}, }, DontPanic: true, }, @@ -506,9 +506,7 @@ func TestSPI_4wire_Write_differential_fail(t *testing.T) { func TestSPI_4wire_gpio_fail(t *testing.T) { bus := spitest.Playback{ Playback: conntest.Playback{ - Ops: []conntest.IO{ - {Write: getInitCmd(128, 64, false)}, - }, + Ops: []conntest.IO{{W: getInitCmd(128, 64, false)}}, }, } pin := &failPin{fail: false} @@ -543,7 +541,7 @@ func getI2CPlayback() *i2ctest.Playback { return &i2ctest.Playback{ Ops: []i2ctest.IO{ // Startup initialization. - {Addr: 0x3c, Write: initCmdI2C()}, + {Addr: 0x3c, W: initCmdI2C()}, }, } } diff --git a/devices/ssd1306/ssd1306smoketest/ssd1306smoketest.go b/devices/ssd1306/ssd1306smoketest/ssd1306smoketest.go index 01ada55..ccd06a9 100644 --- a/devices/ssd1306/ssd1306smoketest/ssd1306smoketest.go +++ b/devices/ssd1306/ssd1306smoketest/ssd1306smoketest.go @@ -105,15 +105,15 @@ func (s *SmokeTest) Run(args []string) (err error) { fmt.Print("I²C recorder\n") } for _, op := range i2cRecorder.Ops { - fmt.Print(" Write: ") - for i, b := range op.Write { + fmt.Print(" W: ") + for i, b := range op.W { if i != 0 { fmt.Print(", ") } fmt.Printf("0x%02X", b) } - fmt.Print("\n Read: ") - for i, b := range op.Read { + fmt.Print("\n R: ") + for i, b := range op.R { if i != 0 { fmt.Print(", ") } @@ -123,12 +123,12 @@ func (s *SmokeTest) Run(args []string) (err error) { } fmt.Print("\nSPI recorder\n") for _, op := range spiRecorder.Ops { - fmt.Print(" Write: ") - if len(op.Read) != 0 { + fmt.Print(" W: ") + if len(op.R) != 0 { // Read data. - fmt.Printf("0x%02X\n Read: ", op.Write[0]) + fmt.Printf("0x%02X\n R: ", op.W[0]) // first byte is dummy. - for i, b := range op.Read[1:] { + for i, b := range op.R[1:] { if i != 0 { fmt.Print(", ") } @@ -136,13 +136,13 @@ func (s *SmokeTest) Run(args []string) (err error) { } } else { // Write-only command. - for i, b := range op.Write { + for i, b := range op.W { if i != 0 { fmt.Print(", ") } fmt.Printf("0x%02X", b) } - fmt.Print("\n Read: ") + fmt.Print("\n R: ") } fmt.Print("\n") }