Library to control the bike (just basic for now)

Dependents:   TORTUGA_BLE

BikeControl.cpp

Committer:
ptuytsch
Date:
2016-07-18
Revision:
0:792a8f167ac0
Child:
1:39f462024f10

File content as of revision 0:792a8f167ac0:

#include "mbed.h"
#include "BikeControl.h"

BikeControl::BikeControl(){
        //PullUp on userButton input
        userButton.mode(PullUp);
        //PullUp on brake inputs
        brakeFront.mode(PullUp);
        brakeRear.mode(PullUp);
    
        //Call function on rise of interruptpin
        generatorHallA.rise(&generatorHallAPulsed);
        generatorHallB.rise(&generatorHallBPulsed);
        generatorBrake.period_us(50);
        generatorBrake.write(0.5f);
        generatorHallACounter=0;
        generatorHallARpm=0;
        generatorHallBCounter=0;
        generatorHallBRpm=0;
    
        //motor
        motorRightCtrl.period_ms(100);
        motorRightCtrl.write(0.0f);
        motorRightHall.rise(&motorRightPulsed);
        motorLeftCtrl.period_ms(100);
        motorLeftCtrl.write(0.0f);
        motorLeftHall.rise(&motorLeftPulsed);
    
        //Button inputs
        buttonGreen.mode(PullUp);
        buttonRed.mode(PullUp);
        buttonDirectionRight.mode(PullUp);
        buttonDirectionLeft.mode(PullUp);
    
        //SWITCH
        switchOn.mode(PullUp);
        switchWalk.mode(PullUp);
    }