Library to control the bike (just basic for now)

Dependents:   TORTUGA_BLE

Committer:
ptuytsch
Date:
Mon Jul 18 09:25:53 2016 +0000
Revision:
0:792a8f167ac0
Child:
1:39f462024f10
start of the bikeControl library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ptuytsch 0:792a8f167ac0 1 #include "mbed.h"
ptuytsch 0:792a8f167ac0 2 #include "BikeControl.h"
ptuytsch 0:792a8f167ac0 3
ptuytsch 0:792a8f167ac0 4 BikeControl::BikeControl(){
ptuytsch 0:792a8f167ac0 5 //PullUp on userButton input
ptuytsch 0:792a8f167ac0 6 userButton.mode(PullUp);
ptuytsch 0:792a8f167ac0 7 //PullUp on brake inputs
ptuytsch 0:792a8f167ac0 8 brakeFront.mode(PullUp);
ptuytsch 0:792a8f167ac0 9 brakeRear.mode(PullUp);
ptuytsch 0:792a8f167ac0 10
ptuytsch 0:792a8f167ac0 11 //Call function on rise of interruptpin
ptuytsch 0:792a8f167ac0 12 generatorHallA.rise(&generatorHallAPulsed);
ptuytsch 0:792a8f167ac0 13 generatorHallB.rise(&generatorHallBPulsed);
ptuytsch 0:792a8f167ac0 14 generatorBrake.period_us(50);
ptuytsch 0:792a8f167ac0 15 generatorBrake.write(0.5f);
ptuytsch 0:792a8f167ac0 16 generatorHallACounter=0;
ptuytsch 0:792a8f167ac0 17 generatorHallARpm=0;
ptuytsch 0:792a8f167ac0 18 generatorHallBCounter=0;
ptuytsch 0:792a8f167ac0 19 generatorHallBRpm=0;
ptuytsch 0:792a8f167ac0 20
ptuytsch 0:792a8f167ac0 21 //motor
ptuytsch 0:792a8f167ac0 22 motorRightCtrl.period_ms(100);
ptuytsch 0:792a8f167ac0 23 motorRightCtrl.write(0.0f);
ptuytsch 0:792a8f167ac0 24 motorRightHall.rise(&motorRightPulsed);
ptuytsch 0:792a8f167ac0 25 motorLeftCtrl.period_ms(100);
ptuytsch 0:792a8f167ac0 26 motorLeftCtrl.write(0.0f);
ptuytsch 0:792a8f167ac0 27 motorLeftHall.rise(&motorLeftPulsed);
ptuytsch 0:792a8f167ac0 28
ptuytsch 0:792a8f167ac0 29 //Button inputs
ptuytsch 0:792a8f167ac0 30 buttonGreen.mode(PullUp);
ptuytsch 0:792a8f167ac0 31 buttonRed.mode(PullUp);
ptuytsch 0:792a8f167ac0 32 buttonDirectionRight.mode(PullUp);
ptuytsch 0:792a8f167ac0 33 buttonDirectionLeft.mode(PullUp);
ptuytsch 0:792a8f167ac0 34
ptuytsch 0:792a8f167ac0 35 //SWITCH
ptuytsch 0:792a8f167ac0 36 switchOn.mode(PullUp);
ptuytsch 0:792a8f167ac0 37 switchWalk.mode(PullUp);
ptuytsch 0:792a8f167ac0 38 }