ticker syntax fix

This commit is contained in:
Ryan Cox 2015-08-25 21:29:22 -07:00
parent 578a009880
commit 21a23f897c
1 changed files with 6 additions and 4 deletions

View File

@ -153,7 +153,9 @@ func (i *ISL29125) setup() error {
time.Sleep(100 * time.Millisecond)
// verify status after reset is ready
if status, err := i.Bus.ReadByteFromReg(SensorAddr, CmdGetStatus); err != nil {
status, err := i.Bus.ReadByteFromReg(SensorAddr, CmdGetStatus)
if err != nil {
return err
}
@ -218,15 +220,15 @@ func (i *ISL29125) Run() {
go func() {
i.quit = make(chan bool)
i.readings = make(chan *Reading)
timer := time.NewTicker(time.Duration(i.Poll) * time.Millisecond)
defer timer.Stop()
ticker := time.NewTicker(time.Duration(i.Poll) * time.Millisecond)
defer ticker.Stop()
var reading *Reading
for {
select {
case i.readings <- reading:
case <-timer:
case <-ticker.C:
r, err := i.getReading()
if err == nil {
reading = r