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

TOGGLE command bug in SimpleTools.h #27

Closed kgracey closed 8 years ago

kgracey commented 8 years ago

I created the following code from Blockly and had to add the low(26) and low(27) to make it work properly:

#include "simpletools.h"

// Describe this function...
void blink26() {
  low(26);
  while(1) {
    toggle(26);
    pause(100);
  }
}

// Describe this function...
void blink27() {
  low(27);
  while(1) {
    toggle(27);
    pause(105);
  }
}

int main() {
  cog_run(blink26, 128);
  cog_run(blink27, 128);
}

It seems that SimpleTools.h should default the pin to low so this isn't needed in the code. @AndyLindsay is aware of the issue and proper solution. Until this is fixed I will work around it by having Blockly add the low into the two cogs. - KG

DavidZemon commented 8 years ago

Looks like this is just a matter of setting the DIRA register with DIRA |= mask; as the last line in toggle(), is that all that is being asked? I'll submit a merge request for this tonight. It seems like a good idea so that toggle() is consistent with high() and low().

AndyLindsay commented 8 years ago

Done, and now compiled and ready to test. Thanks DavidZemon!