Giter Club home page Giter Club logo

arduino-debugger-macros's People

arduino-debugger-macros's Issues

The Debugger Macros

//values view macros
//integer viewer
#define I(x) do {char wtbuf[640]; sprintf(wtbuf,"\r\n["#x"=%d] ",(x));Serial.print(wtbuf); delay(1);} while(0);
//hex viewer
#define X(x) do {char wtbuf[640]; sprintf(wtbuf,"\r\n["#x"=0x%x] ",(x));Serial.print(wtbuf);delay(1);} while(0);
//float viewer
#define FL(x) do {char wtbuf[640]; Serial.print("\r\n["#x"="); dtostrf((x),10,5,wtbuf); Serial.print(wtbuf);Serial.print("]");delay(1);} while(0);
//buffer viwer
#define B(x) do {char wtbuf[640]; Serial.print("\r\n["#x"="); for(int i=0;i<sizeof(x);i++){ sprintf(wtbuf,"%02X ",(x)[i]);Serial.print(wtbuf);Serial.print("]"); delay(1);} Serial.print(" "); } while(0);
//string viewer
#define S(x) do {Serial.print("\r\n["#x"=""); Serial.print((x));Serial.print(""] ");delay(1);} while(0);
//break point macro BP
#define BP(x) {char wtbuf[1000]; delay(1); sprintf(wtbuf,"\r\n******BreakPoint in %s() @file:...%s ******",FUNCTION,(char *)(FILE)+strlen(FILE)-20); Serial.print(wtbuf); Serial.print("\r\n=>"); sprintf(wtbuf,"%d ",LINE); Serial.print(wtbuf); Serial.print(#x); while(!Serial.available())delay(1); Serial.read();} x

Demo:

void setup() {
pinMode(13, OUTPUT);
Serial.begin(115200);
}

void loop() {
int i=1;
float f=0.1;

I(i) //view i
FL(f) //view f

BP(digitalWrite(13, HIGH);) // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
BP(digitalWrite(13, LOW);) // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

Note:
//BP(digitalWrite(13, HIGH);) set a breakpoint at here.

when running the program,open comport monitor please,and select baudrate to 115200, and select options to send an end char after click "send" button.

Then in the monitor ,will display,

******BreakPoint in loop() @file:...tch_883305\Blink.ino ******
=>27 digitalWrite(13, HIGH);

This means that code is running at line 27, in function loop() ,and CPU fall into the breakpoint , you can click the "send" button or press Enter to continue:

******BreakPoint in loop() @file:...tch_201339\Blink.ino ******
=>36 digitalWrite(13, LOW);
[i=1]
[f= 0.10000]
******BreakPoint in loop() @file:...tch_201339\Blink.ino ******
=>34 digitalWrite(13, HIGH);
******BreakPoint in loop() @file:...tch_201339\Blink.ino ******
=>36 digitalWrite(13, LOW);
[i=1]
[f= 0.10000]
******BreakPoint in loop() @file:...tch_201339\Blink.ino ******
=>34 digitalWrite(13, HIGH);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.