Skip to content

Instantly share code, notes, and snippets.

@bnewbold
Created February 7, 2013 21:53
Show Gist options
  • Save bnewbold/4734595 to your computer and use it in GitHub Desktop.
Save bnewbold/4734595 to your computer and use it in GitHub Desktop.
From http://code.google.com/p/leaflabs/issues/detail?id=70 autoformat chokes, gui seems dead until an exception brings it back to life What steps will reproduce the problem? 1.autoformat the attached code
class Pin {
uint8 pin;
public:
Pin(uint8 pin,WiringPinMode mode):
pin(pin){
pinMode(pin,mode);
}
operator bool (void)const{
return digitalRead(pin)!=0;
}
/** set a pin and return what you asked to set it to.*/
bool operator = (bool beHigh){
digitalWrite(pin,beHigh);
return beHigh;
}
};
class InputPin:
public Pin {
public: //bug: the comment on the line below causes autoformat to spin until it is out of memory.
InputPin(uint8 pin,int pull=-1)://default is pulldown as that is what test equipment hanging on a pin does. IE I want the device to startup the same whether I have an o'scope attached or not
Pin(pin,pull>0?INPUT_PULLUP :pull<0?INPUT_PULLDOWN:INPUT_FLOATING){
}
};
class OutputPin:
public Pin {
public:
OutputPin(uint8 pin,int pull=-1):
Pin(pin,pull>0?INPUT_PULLUP :pull<0?INPUT_PULLDOWN:INPUT_FLOATING){
}
};
/*
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2894)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:117)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:407)
at java.lang.StringBuffer.append(StringBuffer.java:241)
at processing.app.tools.AutoFormat.p_tabs(AutoFormat.java:265)
at processing.app.tools.AutoFormat.indent_puts(AutoFormat.java:161)
at processing.app.tools.AutoFormat.run(AutoFormat.java:651)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment