nerdDoro I'm cogfused; COGNEW DIRA pin considerations?
Jeffa
Posts: 80
A couple days ago In an "aha" moment experienced more like a Homer Simpson "Doh!" I realized that some of the code in my nerdDoro project would benefit from a move to another cog. There I was cramming more and more functionality into my main pub in the wait for client connect.
I read the COGNEW and DIRA sections in the Propeller Manual v1.2 a couple times. I moved the code that was in the wait for client connect to a cognew like this:
The Sensirion functions quit working. I pondered on this for a long time note the absurdly large gedStack until I remember difficulty I had with my push button code when I moved it to a cog. That pointed me to the DIRA changes I added. The Sensirion works much better now but still has apparently bad reads perhaps 33% of the time. Previously with the Sensirion reads in the main pub client wait it functioned100%
From reading the DIRA section I assume that I only need to set the DIRA int he cog once assuming the remainder is just a continuous loop. I shouldnt have to set the DIRA in the loop? I've tried it both ways with about the same results.
Any comments or suggestions about moving code to a COG will be appreicated. This is basically the first time I've really used the power of the COGs. Your experience may be helpful.
The nerdDoro code used at the time of this writing is attached. My github is not updated. I will be experimenting with moving the gitErDone to a seperate file today.
Thanks! - jeffa
repeat PlxST.Str(string("Waiting for a client to connect....", PlxST#NL)) repeat updateLCD ' update LCD with date time and temperature. usrButton pomTime while !W5100.SocketTCPestablished(0) PlxST.Str(string("connection established...", PlxST#NL))
I read the COGNEW and DIRA sections in the Propeller Manual v1.2 a couple times. I moved the code that was in the wait for client connect to a cognew like this:
repeat PlxST.Str(string("Waiting for a client to connect....", PlxST#NL)) repeat while !W5100.SocketTCPestablished(0) PlxST.Str(string("connection established...", PlxST#NL))
VAR long gedStack[128] 'Stack space for gitErDone cog long gitErDoneID ... cognew(gitErDone, @gedStack) ' lcd display etc... ... pub gitErDone | X dira[24]~ dira[25]~~ 'dira[23]~ hasPomed := 0 repeat if ina[23] == 1 timer.reset timer.run hasPomed := 0 else 'dira[23]~~ RTC.Update lcd.str(string(128)) ' Move cursor to line 0, position 0 lcd.str(RTC.ShortFmtDateTime) ' print short dateTime rawTemp := f.FFloat(sht.readTemperature) tempC := celsius(rawTemp) lcd.str(string(148)) ' Move cursor to line 1, position 0 lcd.str(string("Tf In: ")) ' print temperature in degrees fahrenheit lcd.str(fp.FloatToFormat(fahrenheit(tempC), 5,1)) lcd.str(string(168)) ' Move cursor to line 2, position 0 lcd.str(string("Pomodoro timer")) lcd.str(string(188)) ' Move cursor to line 3, position 0 lcd.str(timer.showTimer) if timer.rdReg(2) == 1 plxst.str(string(cr,lf,"we've got pomodoro!")) lcd.str(string(11)) pausemsec(10) ' pomTime
The Sensirion functions quit working. I pondered on this for a long time note the absurdly large gedStack until I remember difficulty I had with my push button code when I moved it to a cog. That pointed me to the DIRA changes I added. The Sensirion works much better now but still has apparently bad reads perhaps 33% of the time. Previously with the Sensirion reads in the main pub client wait it functioned100%
From reading the DIRA section I assume that I only need to set the DIRA int he cog once assuming the remainder is just a continuous loop. I shouldnt have to set the DIRA in the loop? I've tried it both ways with about the same results.
Any comments or suggestions about moving code to a COG will be appreicated. This is basically the first time I've really used the power of the COGs. Your experience may be helpful.
The nerdDoro code used at the time of this writing is attached. My github is not updated. I will be experimenting with moving the gitErDone to a seperate file today.
Thanks! - jeffa
spin
46K
Comments
-Phil