tim003 tim003
/
LV3-PAI-Grupa2-Tim003
Mirhat Babić Granulo Eldar
main.cpp@0:34def52d2c80, 2014-03-17 (annotated)
- Committer:
- tim003
- Date:
- Mon Mar 17 10:15:34 2014 +0000
- Revision:
- 0:34def52d2c80
LV3-PAI-Grupa2-Tim003-Zadatak1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tim003 | 0:34def52d2c80 | 1 | #include "mbed.h" |
tim003 | 0:34def52d2c80 | 2 | |
tim003 | 0:34def52d2c80 | 3 | using namespace std; |
tim003 | 0:34def52d2c80 | 4 | |
tim003 | 0:34def52d2c80 | 5 | BusOut segments(dp26, dp27, dp5, dp6, dp28, dp1, dp2); |
tim003 | 0:34def52d2c80 | 6 | BusOut digit(dp23, dp24, dp25); |
tim003 | 0:34def52d2c80 | 7 | DigitalOut point(dp4); |
tim003 | 0:34def52d2c80 | 8 | |
tim003 | 0:34def52d2c80 | 9 | Timer count; |
tim003 | 0:34def52d2c80 | 10 | |
tim003 | 0:34def52d2c80 | 11 | int codes[10] = {0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x078,0x0,0x10}; |
tim003 | 0:34def52d2c80 | 12 | |
tim003 | 0:34def52d2c80 | 13 | |
tim003 | 0:34def52d2c80 | 14 | |
tim003 | 0:34def52d2c80 | 15 | void display(float time) { |
tim003 | 0:34def52d2c80 | 16 | int numbers[3] = { (int)(time / 10.) % 10, (int)(time) % 10, |
tim003 | 0:34def52d2c80 | 17 | (int)(time * 10.) % 10 }; |
tim003 | 0:34def52d2c80 | 18 | |
tim003 | 0:34def52d2c80 | 19 | |
tim003 | 0:34def52d2c80 | 20 | digit = 3; |
tim003 | 0:34def52d2c80 | 21 | segments = codes[ numbers[2]]; |
tim003 | 0:34def52d2c80 | 22 | wait_ms(2); |
tim003 | 0:34def52d2c80 | 23 | |
tim003 | 0:34def52d2c80 | 24 | digit = 7; |
tim003 | 0:34def52d2c80 | 25 | |
tim003 | 0:34def52d2c80 | 26 | digit = 5; |
tim003 | 0:34def52d2c80 | 27 | segments = codes[ numbers[1]]; |
tim003 | 0:34def52d2c80 | 28 | point = 0; |
tim003 | 0:34def52d2c80 | 29 | wait_ms(2); |
tim003 | 0:34def52d2c80 | 30 | |
tim003 | 0:34def52d2c80 | 31 | digit = 7; |
tim003 | 0:34def52d2c80 | 32 | |
tim003 | 0:34def52d2c80 | 33 | digit = 6; |
tim003 | 0:34def52d2c80 | 34 | segments = codes[ numbers[0]]; |
tim003 | 0:34def52d2c80 | 35 | point = 1; |
tim003 | 0:34def52d2c80 | 36 | |
tim003 | 0:34def52d2c80 | 37 | wait_ms(2); |
tim003 | 0:34def52d2c80 | 38 | |
tim003 | 0:34def52d2c80 | 39 | digit = 7; |
tim003 | 0:34def52d2c80 | 40 | |
tim003 | 0:34def52d2c80 | 41 | digit = 0; |
tim003 | 0:34def52d2c80 | 42 | segments = 7; |
tim003 | 0:34def52d2c80 | 43 | point = 1; |
tim003 | 0:34def52d2c80 | 44 | } |
tim003 | 0:34def52d2c80 | 45 | |
tim003 | 0:34def52d2c80 | 46 | int main() { |
tim003 | 0:34def52d2c80 | 47 | |
tim003 | 0:34def52d2c80 | 48 | wait(2.); |
tim003 | 0:34def52d2c80 | 49 | count.start(); |
tim003 | 0:34def52d2c80 | 50 | |
tim003 | 0:34def52d2c80 | 51 | |
tim003 | 0:34def52d2c80 | 52 | while(true) { |
tim003 | 0:34def52d2c80 | 53 | if(count.read() > 12.3) display(12.3); |
tim003 | 0:34def52d2c80 | 54 | else display(count.read()); |
tim003 | 0:34def52d2c80 | 55 | |
tim003 | 0:34def52d2c80 | 56 | } |
tim003 | 0:34def52d2c80 | 57 | |
tim003 | 0:34def52d2c80 | 58 | |
tim003 | 0:34def52d2c80 | 59 | } |