@ -141,12 +141,12 @@ func TestDev_InputStatus(t *testing.T) {
}
}
for _ , tt := range tests {
for _ , tt := range tests {
t . Run ( tt . name , func ( t * testing . T ) {
t . Run ( tt . name , func ( t * testing . T ) {
d , err := NewI2C ( tt . bus , DefaultOpts ( ) )
d , err := NewI2C ( tt . bus , & DefaultOpts )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
got , err := d . InputStatus ( )
var got [ 8 ] TouchStatus
if err != nil {
if err := d . InputStatus ( got [ : ] ) ; err != nil {
t . Fatalf ( "Dev.InputStatus() error = %v" , err )
t . Fatalf ( "Dev.InputStatus() error = %v" , err )
}
}
if ! reflect . DeepEqual ( got , tt . want ) {
if ! reflect . DeepEqual ( got , tt . want ) {
@ -173,24 +173,23 @@ func TestDev_InputStatus(t *testing.T) {
}
}
// Set the recorded response to have the retrigger option on.
// Set the recorded response to have the retrigger option on.
bus . Ops [ 10 ] = i2ctest . IO { Addr : 40 , W : [ ] byte { 0x28 , 0xff } , R : nil }
bus . Ops [ 10 ] = i2ctest . IO { Addr : 40 , W : [ ] byte { 0x28 , 0xff } , R : nil }
opts := DefaultOpts ( )
opts := DefaultOpts
// Following option needs to be true so we can get the held status.
// Following option needs to be true so we can get the held status.
opts . RetriggerOnHold = true
opts . RetriggerOnHold = true
d , err := NewI2C ( bus , opts )
d , err := NewI2C ( bus , & opts )
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
// first check
// first check
got , err := d . InputStatus ( )
var got [ 8 ] TouchStatus
if err != nil {
if err := d . InputStatus ( got [ : ] ) ; err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
if ! reflect . DeepEqual ( got , [ 8 ] TouchStatus { PressedStatus , OffStatus , OffStatus , OffStatus , OffStatus , OffStatus , OffStatus , OffStatus } ) {
if ! reflect . DeepEqual ( got , [ 8 ] TouchStatus { PressedStatus , OffStatus , OffStatus , OffStatus , OffStatus , OffStatus , OffStatus , OffStatus } ) {
t . Fatalf ( "expected to have the first sensor touched but instead got %v" , got )
t . Fatalf ( "expected to have the first sensor touched but instead got %v" , got )
}
}
// 2nd check
// 2nd check
got , err = d . InputStatus ( )
if err = d . InputStatus ( got [ : ] ) ; err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
}
}
if ! reflect . DeepEqual ( got , [ 8 ] TouchStatus { HeldStatus , OffStatus , OffStatus , OffStatus , OffStatus , OffStatus , OffStatus , OffStatus } ) {
if ! reflect . DeepEqual ( got , [ 8 ] TouchStatus { HeldStatus , OffStatus , OffStatus , OffStatus , OffStatus , OffStatus , OffStatus , OffStatus } ) {