Interrupt Spielereien

Dependencies:   mbed

main.cpp

Committer:
Ursukar
Date:
2019-12-16
Revision:
2:afd73f8f51fe
Parent:
1:c880c990b9b9

File content as of revision 2:afd73f8f51fe:

#include "mbed.h"
#define BUTTON1 p14     // push joystick pin
#define BUTTONLEFT p13
#define BUTTONDOWN p12

BusOut myleds(LED1, LED2, LED3, LED4);

Ticker t1;
Ticker t3;
Timeout t2;
InterruptIn btn(BUTTON1);
InterruptIn btnLeft(BUTTONLEFT);
InterruptIn btnDown(BUTTONDOWN);

uint8_t bitMask = 0x00;

void blink_led4() {
    
    myleds = myleds ^ 0x08;
}
 
void toggle_led1() {
    
    myleds = myleds | 0x01;
}
 
void turn_all_Led_on() {
    
    myleds = myleds | 0x0F;
    t1.detach();
}

void leds_off(){
    
    myleds = myleds & bitMask;
    t1.attach(callback(&blink_led4), 1.0f);
}

void ledsLeft(){
    
    myleds = myleds << 1;
}
int main() {
     
    t1.attach(callback(&blink_led4), 1.0f);
    t3.attach(callback(&leds_off), 15.0f);
    btn.fall(callback(&toggle_led1));
    btnLeft.fall(callback(&ledsLeft));
    btnDown.fall(callback(&turn_all_Led_on));
        
}