parallaxinc / Simple-Libraries

Contents of the SimpleIDE workspace folder and its Parallax Learn Simple Libraries subfolder.
http://learn.parallax.com/propeller-c-set-simpleide/update-your-learn-folder
21 stars 21 forks source link

SimpleTools pause() function #85

Closed JonMcPhalen closed 7 years ago

JonMcPhalen commented 7 years ago

I found that the pause() function can be tripped up with large values. May I suggest that it be re-coded as follows?

void pause(int time)                          // pause function definition
{ // If st_pauseTicks not initialized, set it up to 1 ms.
  // if(!st_pauseTicks) set_pause_dt(CLKFREQ/1000);

  long t0 = CNT;

  while (time--) {
    waitcnt(t0 += st_pauseTicks);
  }  
}
AndyLindsay commented 7 years ago

Hmmm, let's see... That would increase the max pause from 26, 843 ms to almost 24.9 days. Sounds good to me; thanks Jon!

JonMcPhalen commented 7 years ago

My pleasure, Andy. It's been a long-time coming, but I am finally forcing myself to work with C on the Propeller. I just finished a commercial app that is 6K lines (Spin); I'm wanting to see if I can do it in CMM and get more speed.

AndyLindsay commented 7 years ago

Repository updated. This change will appear in the next distribution.

AndyLindsay commented 7 years ago

Cool, sounds like a pretty epic project. There's a nice Spin to C++ (or C) converter available called spin2cpp. It might provide a first-cut on execution speed with less effort than a by-hand port.

https://github.com/totalspectrum/spin2cpp/releases

Andy

On Fri, Jun 2, 2017 at 6:39 PM, JonMcPhalen notifications@github.com wrote:

My pleasure, Andy. It's been a long-time coming, but I am finally forcing myself to work with C on the Propeller. I just finished a commercial app that is 6K lines (Spin); I'm wanting to see if I can do it in CMM and get more speed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/parallaxinc/Simple-Libraries/issues/85#issuecomment-305942204, or mute the thread https://github.com/notifications/unsubscribe-auth/ALCgd29L034tC2TTHUjB2zJWPQzzpzu6ks5sALlmgaJpZM4Nu3hR .

JonMcPhalen commented 7 years ago

It was tough -- a continually moving target (kind of like the P2!). The client finally stopped making changes, I finished the code, and testing -- so far -- has shown that it's working as desired.

I have experimented with the Spin-to-C converter on small fragments, but wouldn't use it on a real project as that would deny me the opportunity to learn and optimize my own libraries.