FSST - Hardwarenahe Programmierung

Debugginfo auf LCD Display C12832

#include "mbed.h"
#include "C12832.h"

#define DEBUG_LEVEL 1   // Auskommentieren

C12832 lcd(p5, p7, p6, p8, p11);

class DigitalAus : public DigitalOut
{
    public:
    DigitalAus(PinName ld) : DigitalOut(ld){
#ifdef DEBUG_LEVEL
        lcd.cls();
        lcd.locate(0,0);
        lcd.printf("Debugging Information");
#endif
}
    
    int lese() {
        return read();
    }
    void schreibe(int value);
};

void DigitalAus :: schreibe(int value) {
#ifdef DEBUG_LEVEL
        lcd.locate(0,10);
        lcd.printf("Value: %d", value);
#endif
        write(value);
    }

 
DigitalAus led(LED1);
 
int main() {
    while (1) {
        led.schreibe(0);
        printf("Blink! LED is now %d\n", led.read());
        wait_ms(500);
            
        led.schreibe(1);
        printf("Blink! LED is now %d\n", led.read());
        wait_ms(500);
    }
    return 0;
}

Debugglevels

Debugglevels

#include "mbed.h"
#include "C12832.h"

#define DEBUG_LEVEL 1   // oder 2 bzw. noch weitere

C12832 lcd(p5, p7, p6, p8, p11);

class DigitalAus : public DigitalOut
{
    public:
    DigitalAus(PinName ld) : DigitalOut(ld){
#if DEBUG_LEVEL == 1
        lcd.cls();
        lcd.locate(0,0);
        lcd.printf("Debugging Information");
#endif
}
    
    int lese() {
        return read();
    }
    void schreibe(int value);
};

void DigitalAus :: schreibe(int value) {
#if DEBUG_LEVEL > 0
        lcd.locate(0,10);
        lcd.printf("Value: %d", value);
//#elif DEBUG_LEVEL == 2
#endif
#if DEBUG_LEVEL == 2
        lcd.locate(0,20);
        lcd.printf("DLEVEL: %d", value);
#endif
        write(value);
}
// https://msdn.microsoft.com/en-us/library/ew2hz0yd.aspx 

All wikipages