Skip to content

Commit

Permalink
optimizie waiting operations
Browse files Browse the repository at this point in the history
  • Loading branch information
akif999 committed Feb 13, 2023
1 parent 22e66b7 commit 8a6cb9c
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions e220/e220.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func (d *Device) Configure(startupE220Mode uint8) error {
return err
}

// AUX Pin becomes Low Level for about 30ms after the E220 is started.
// therefore, wait until transmission/reception becomes possible.
time.Sleep(50 * time.Millisecond)

return nil
}

Expand All @@ -113,9 +117,6 @@ func (d *Device) SetMode(mode uint8) error {
return fmt.Errorf("Invalid mode: %d", mode)
}

// AUX Pin becomes Low Level for about 20ms after the mode is changed
time.Sleep(30 * time.Millisecond)

return nil
}

Expand All @@ -135,10 +136,6 @@ func (d *Device) ReadRegister(startAddr uint8, length uint8) ([]byte, error) {
return nil, fmt.Errorf("unexpected response: %X", response)
}

// Wait for about 50ms because requests are not accepted for a while
// after register access (= Format error: 0xFF 0xFF0x FF is returned)
time.Sleep(50 * time.Millisecond)

return response, nil
}

Expand All @@ -155,10 +152,6 @@ func (d *Device) WriteRegister(startAddr uint8, params []byte) error {
[]byte{0xC1, startAddr, byte(len(params))}, params, response)
}

// Wait for about 50ms because requests are not accepted for a while
// after register access (= Format error: 0xFF 0xFF0x FF is returned)
time.Sleep(50 * time.Millisecond)

return nil
}

Expand Down

0 comments on commit 8a6cb9c

Please sign in to comment.