tes ir atas semua
Dependencies: mbed ADS1115 StepperMotor SRF05 TPA81new
Uvtron/Uvtron.cpp@12:1e3227a6fcd7, 2018-12-16 (annotated)
- Committer:
- hisyamfs
- Date:
- Sun Dec 16 01:53:07 2018 +0000
- Revision:
- 12:1e3227a6fcd7
test board v1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hisyamfs | 12:1e3227a6fcd7 | 1 | #include "Uvtron.h" |
hisyamfs | 12:1e3227a6fcd7 | 2 | |
hisyamfs | 12:1e3227a6fcd7 | 3 | Uvtron::Uvtron(PinName a) : _a(a) |
hisyamfs | 12:1e3227a6fcd7 | 4 | { |
hisyamfs | 12:1e3227a6fcd7 | 5 | Counter=0; |
hisyamfs | 12:1e3227a6fcd7 | 6 | PrevCounter=0; |
hisyamfs | 12:1e3227a6fcd7 | 7 | NextCounter=0; |
hisyamfs | 12:1e3227a6fcd7 | 8 | Flag=0; |
hisyamfs | 12:1e3227a6fcd7 | 9 | _a.mode(OpenDrain); |
hisyamfs | 12:1e3227a6fcd7 | 10 | _a.rise(this, &Uvtron::Count); |
hisyamfs | 12:1e3227a6fcd7 | 11 | } |
hisyamfs | 12:1e3227a6fcd7 | 12 | |
hisyamfs | 12:1e3227a6fcd7 | 13 | void Uvtron::Count() |
hisyamfs | 12:1e3227a6fcd7 | 14 | { |
hisyamfs | 12:1e3227a6fcd7 | 15 | Counter++; |
hisyamfs | 12:1e3227a6fcd7 | 16 | } |
hisyamfs | 12:1e3227a6fcd7 | 17 | |
hisyamfs | 12:1e3227a6fcd7 | 18 | void Uvtron::Read() |
hisyamfs | 12:1e3227a6fcd7 | 19 | { |
hisyamfs | 12:1e3227a6fcd7 | 20 | |
hisyamfs | 12:1e3227a6fcd7 | 21 | PrevCounter = NextCounter; |
hisyamfs | 12:1e3227a6fcd7 | 22 | NextCounter = Counter; |
hisyamfs | 12:1e3227a6fcd7 | 23 | |
hisyamfs | 12:1e3227a6fcd7 | 24 | |
hisyamfs | 12:1e3227a6fcd7 | 25 | if(NextCounter>(PrevCounter+1)&&Flag==0) |
hisyamfs | 12:1e3227a6fcd7 | 26 | { |
hisyamfs | 12:1e3227a6fcd7 | 27 | Flag=1; |
hisyamfs | 12:1e3227a6fcd7 | 28 | Counter=0; |
hisyamfs | 12:1e3227a6fcd7 | 29 | } |
hisyamfs | 12:1e3227a6fcd7 | 30 | else if (NextCounter==PrevCounter&&Flag==1) |
hisyamfs | 12:1e3227a6fcd7 | 31 | { |
hisyamfs | 12:1e3227a6fcd7 | 32 | Flag=0; |
hisyamfs | 12:1e3227a6fcd7 | 33 | } |
hisyamfs | 12:1e3227a6fcd7 | 34 | } |
hisyamfs | 12:1e3227a6fcd7 | 35 | |
hisyamfs | 12:1e3227a6fcd7 | 36 | void Uvtron::UVScan() |
hisyamfs | 12:1e3227a6fcd7 | 37 | { |
hisyamfs | 12:1e3227a6fcd7 | 38 | PrevCounter = NextCounter; |
hisyamfs | 12:1e3227a6fcd7 | 39 | NextCounter = Counter; |
hisyamfs | 12:1e3227a6fcd7 | 40 | |
hisyamfs | 12:1e3227a6fcd7 | 41 | if((NextCounter>PrevCounter) && (FlagScan==0)){ |
hisyamfs | 12:1e3227a6fcd7 | 42 | FlagScan = 1; |
hisyamfs | 12:1e3227a6fcd7 | 43 | Counter = 0; |
hisyamfs | 12:1e3227a6fcd7 | 44 | } |
hisyamfs | 12:1e3227a6fcd7 | 45 | else{ |
hisyamfs | 12:1e3227a6fcd7 | 46 | //FlagScan = 0; |
hisyamfs | 12:1e3227a6fcd7 | 47 | } |
hisyamfs | 12:1e3227a6fcd7 | 48 | } |
hisyamfs | 12:1e3227a6fcd7 | 49 | |
hisyamfs | 12:1e3227a6fcd7 | 50 | |
hisyamfs | 12:1e3227a6fcd7 | 51 |