URS - LV11 - HMI - 2. zadatak
Dependencies: mbed
main.cpp
- Committer:
- dfraj
- Date:
- 2022-01-22
- Revision:
- 1:a397ad7e537b
- Parent:
- 0:57ec9c61562e
- Child:
- 2:d7142743ba21
File content as of revision 1:a397ad7e537b:
#include "mbed.h" InterruptIn optic(p18); Serial nextion(p28, p27); Ticker sendData; Timer t; float T = 0; uint16_t rpm = 0; bool flag = false; void prolaz(){ T = t.read(); t.reset(); flag = true; } void data(){ if (t.read() < 1.0 && flag) rpm = 30.0/T; // rpm = 60 * f = 60 * 1/T * 1/2 = 30/T else rpm = 0; nextion.printf("t1.txt=\"%d rpm\"%c%c%c", rpm, 255, 255, 255); nextion.printf("add 5,0,%d%c%c%c", rpm/100, 255, 255, 255); } int main(){ t.start(); optic.rise(&prolaz); sendData.attach(&data, 1.0); while(1) { wait(1.0); } }