Hey Guys, another SHORT UPDATE , I have somehow managed to get the button interrupts working yayyyyy with the BLE Code So now I can go further
Here is a video demonstrating updation of Nextion display based on the Hall Sensor Data and some Computations.
Code Snippets
1. Define Global Timer Object
Timer tick;
2. in Main()
stopC = 1; // skips calculation of speed if set to : 1
BLEStat = 0;
hallSensorCounter = 0;
hallSensor.fall(&irqcallback_hallSensor); // interrupt
3. In ISR
stopC = 0; // enables calculation of Speed
timex = tick.read_ms();
hallSensorCounter++;
tick.reset();
//hallSensor.enable_irq();
4. In periodic function computing the speed Dist and other details
if (tick.read_ms() > 10000) { //(tick.read_ms() < 100 || tick.read_ms() > 10000 ) // check if bike is ideal standing ..
stopC = 1;
} else stopC = 0;
if (stopC == 0) {
timex = timex * 100 * 60; //min
ridingSpeed = (2 * M_PI * cycleTyreRadius) / timex ; // in mtr/sec
} else if(stopC == 1) {
ridingSpeed = 0;
}
totalDist = 2* M_PI * cycleTyreRadius * hallSensorCounter; // calculating total distance
avgSpeed[avgCtr] = ridingSpeed;
avgCtr++;
if(avgCtr == 4) avgCtr = 0;
for(int i = 0; i == 4; i++) { // calculation of avg speed
avgSpeedF += avgSpeed[i];
}
avgSpeedF = avgSpeedF/5;
Thanks for Reading
Regards,
GS Gill