Proyecto realizado para controlar el desplazamiento de un cuadro como obra de arte
Dependencies: DS1307 FPointer TextLCD USBHost keypad mbed
Fork of MSCUsbHost_FULL by
main.cpp@1:4daed536a970, 2013-09-17 (annotated)
- Committer:
- sherckuith
- Date:
- Tue Sep 17 01:37:10 2013 +0000
- Revision:
- 1:4daed536a970
- Parent:
- 0:144fed3d9420
Publicacion de trabajo hecho para Patricio Barberan
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chris | 0:144fed3d9420 | 1 | #include "mbed.h" |
sherckuith | 1:4daed536a970 | 2 | #include "keypad.h" |
sherckuith | 1:4daed536a970 | 3 | #include "ds1307.h" |
sherckuith | 1:4daed536a970 | 4 | #include "USBHostMSD.h" |
sherckuith | 1:4daed536a970 | 5 | #include "TextLCD.h" |
sherckuith | 1:4daed536a970 | 6 | |
sherckuith | 1:4daed536a970 | 7 | DigitalOut FW(p5); |
sherckuith | 1:4daed536a970 | 8 | DigitalOut RW(p6); |
sherckuith | 1:4daed536a970 | 9 | DigitalOut door_on(p7); |
sherckuith | 1:4daed536a970 | 10 | DigitalOut door_off(p8); |
sherckuith | 1:4daed536a970 | 11 | |
sherckuith | 1:4daed536a970 | 12 | DS1307 my1307(p9,p10); |
sherckuith | 1:4daed536a970 | 13 | |
sherckuith | 1:4daed536a970 | 14 | TextLCD lcd(p11, p12, p13, p14, p15, p16, TextLCD::LCD20x4); // rs, e, d4-d7 |
sherckuith | 1:4daed536a970 | 15 | |
sherckuith | 1:4daed536a970 | 16 | AnalogIn rigth_sense(p17); |
sherckuith | 1:4daed536a970 | 17 | AnalogIn left_sense(p19); |
sherckuith | 1:4daed536a970 | 18 | AnalogIn ain(p20); |
sherckuith | 1:4daed536a970 | 19 | |
sherckuith | 1:4daed536a970 | 20 | |
sherckuith | 1:4daed536a970 | 21 | DigitalOut led5(LED1); |
sherckuith | 1:4daed536a970 | 22 | DigitalOut led6(LED2); |
sherckuith | 1:4daed536a970 | 23 | DigitalOut led7(LED3); |
sherckuith | 1:4daed536a970 | 24 | DigitalOut led8(LED4); |
sherckuith | 1:4daed536a970 | 25 | |
sherckuith | 1:4daed536a970 | 26 | DigitalOut led1(p29); |
sherckuith | 1:4daed536a970 | 27 | DigitalOut led2(p30); |
sherckuith | 1:4daed536a970 | 28 | DigitalOut led3(USBTX); |
sherckuith | 1:4daed536a970 | 29 | DigitalOut led4(USBRX); |
sherckuith | 1:4daed536a970 | 30 | |
sherckuith | 1:4daed536a970 | 31 | //Serial pc(USBTX, USBRX); // tx, rx for debug and usb pc comunications |
sherckuith | 1:4daed536a970 | 32 | |
sherckuith | 1:4daed536a970 | 33 | Keypad keypad(p25, p26, p27, p28, p21, p22, p23, p24); |
sherckuith | 1:4daed536a970 | 34 | /* |
sherckuith | 1:4daed536a970 | 35 | Teclado membrana Mbed |
sherckuith | 1:4daed536a970 | 36 | C3 P21 |
sherckuith | 1:4daed536a970 | 37 | C2 P22 |
sherckuith | 1:4daed536a970 | 38 | C1 P23 |
sherckuith | 1:4daed536a970 | 39 | C0 P24 |
sherckuith | 1:4daed536a970 | 40 | F3 P25 |
sherckuith | 1:4daed536a970 | 41 | F2 P26 |
sherckuith | 1:4daed536a970 | 42 | F1 P27 |
sherckuith | 1:4daed536a970 | 43 | F0 P28 |
sherckuith | 1:4daed536a970 | 44 | |
sherckuith | 1:4daed536a970 | 45 | keypad.class: f3, f2 , f1 , f0 , c3 , c2 , c1 , c0 |
sherckuith | 1:4daed536a970 | 46 | mbed pinout: p25, p26, p27, p28, p21, p22, p23, p24 |
sherckuith | 1:4daed536a970 | 47 | 24 23 22 21 |
sherckuith | 1:4daed536a970 | 48 | 25 '1', '2', '3', 'A', |
sherckuith | 1:4daed536a970 | 49 | 26 '4', '5', '6', 'B', |
sherckuith | 1:4daed536a970 | 50 | 27 '7', '8', '9', 'C', |
sherckuith | 1:4daed536a970 | 51 | 28 '*', '0', '#', 'D' |
sherckuith | 1:4daed536a970 | 52 | |
sherckuith | 1:4daed536a970 | 53 | Teclado PLASTICO Mbed |
sherckuith | 1:4daed536a970 | 54 | F3 P21 |
sherckuith | 1:4daed536a970 | 55 | F2 P22 |
sherckuith | 1:4daed536a970 | 56 | F1 P23 |
sherckuith | 1:4daed536a970 | 57 | F0 P24 |
sherckuith | 1:4daed536a970 | 58 | C3 P25 |
sherckuith | 1:4daed536a970 | 59 | C2 P26 |
sherckuith | 1:4daed536a970 | 60 | C1 P27 |
sherckuith | 1:4daed536a970 | 61 | C0 P28 |
sherckuith | 1:4daed536a970 | 62 | |
sherckuith | 1:4daed536a970 | 63 | keypad.class: f3, f2 , f1 , f0 , c3 , c2 , c1 , c0 |
sherckuith | 1:4daed536a970 | 64 | mbed pinout: p21, p22, p23, p24, p25, p26, p27, p28 |
sherckuith | 1:4daed536a970 | 65 | 24 23 22 21 |
sherckuith | 1:4daed536a970 | 66 | 25 '1', '2', '3', 'A', |
sherckuith | 1:4daed536a970 | 67 | 26 '4', '5', '6', 'B', |
sherckuith | 1:4daed536a970 | 68 | 27 '7', '8', '9', 'C', |
sherckuith | 1:4daed536a970 | 69 | 28 '*', '0', '#', 'D' |
sherckuith | 1:4daed536a970 | 70 | */ |
sherckuith | 1:4daed536a970 | 71 | |
sherckuith | 1:4daed536a970 | 72 | |
sherckuith | 1:4daed536a970 | 73 | |
sherckuith | 1:4daed536a970 | 74 | |
sherckuith | 1:4daed536a970 | 75 | //sensores |
sherckuith | 1:4daed536a970 | 76 | float rigth = 0, left = 0; |
sherckuith | 1:4daed536a970 | 77 | |
sherckuith | 1:4daed536a970 | 78 | //archivos USB |
sherckuith | 1:4daed536a970 | 79 | char file[80]; |
sherckuith | 1:4daed536a970 | 80 | int hours = 0, min = 0, sec = 0, year = 0, month = 0, date = 0, day = 0; |
sherckuith | 1:4daed536a970 | 81 | int a=0, b=0; |
sherckuith | 1:4daed536a970 | 82 | |
sherckuith | 1:4daed536a970 | 83 | const unsigned short page[229] = { |
sherckuith | 1:4daed536a970 | 84 | 0x3C,0x21,0x2D,0x2D,0x20,0x41,0x6C,0x6C,0x20,0x50,0x6F,0x77,0x65,0x72,0x20,0x4D, |
sherckuith | 1:4daed536a970 | 85 | 0x69,0x63,0x72,0x6F,0x63,0x6F,0x6E,0x74,0x72,0x6F,0x6C,0x6C,0x65,0x72,0x20,0x57, |
sherckuith | 1:4daed536a970 | 86 | 0x65,0x62,0x73,0x69,0x74,0x65,0x20,0x61,0x6E,0x64,0x20,0x41,0x75,0x74,0x68,0x65, |
sherckuith | 1:4daed536a970 | 87 | 0x6E,0x74,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x53,0x68,0x6F,0x72,0x74,0x63, |
sherckuith | 1:4daed536a970 | 88 | 0x75,0x74,0x20,0x2D,0x2D,0x3E,0x0D,0x0A,0x3C,0x68,0x74,0x6D,0x6C,0x3E,0x0D,0x0A, |
sherckuith | 1:4daed536a970 | 89 | 0x3C,0x68,0x65,0x61,0x64,0x3E,0x0D,0x0A,0x3C,0x6D,0x65,0x74,0x61,0x20,0x68,0x74, |
sherckuith | 1:4daed536a970 | 90 | 0x74,0x70,0x2D,0x65,0x71,0x75,0x69,0x76,0x3D,0x22,0x72,0x65,0x66,0x72,0x65,0x73, |
sherckuith | 1:4daed536a970 | 91 | 0x68,0x22,0x20,0x63,0x6F,0x6E,0x74,0x65,0x6E,0x74,0x3D,0x22,0x30,0x3B,0x20,0x75, |
sherckuith | 1:4daed536a970 | 92 | 0x72,0x6C,0x3D,0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x61,0x70, |
sherckuith | 1:4daed536a970 | 93 | 0x6D,0x6D,0x69,0x63,0x72,0x6F,0x2E,0x63,0x6F,0x6D,0x22,0x2F,0x3E,0x0D,0x0A,0x3C, |
sherckuith | 1:4daed536a970 | 94 | 0x74,0x69,0x74,0x6C,0x65,0x3E,0x41,0x50,0x4D,0x20,0x57,0x65,0x62,0x73,0x69,0x74, |
sherckuith | 1:4daed536a970 | 95 | 0x65,0x20,0x53,0x68,0x6F,0x72,0x74,0x63,0x75,0x74,0x3C,0x2F,0x74,0x69,0x74,0x6C, |
sherckuith | 1:4daed536a970 | 96 | 0x65,0x3E,0x0D,0x0A,0x3C,0x2F,0x68,0x65,0x61,0x64,0x3E,0x0D,0x0A,0x3C,0x62,0x6F, |
sherckuith | 1:4daed536a970 | 97 | 0x64,0x79,0x3E,0x3C,0x2F,0x62,0x6F,0x64,0x79,0x3E,0x0D,0x0A,0x3C,0x2F,0x68,0x74, |
sherckuith | 1:4daed536a970 | 98 | 0x6D,0x6C,0x3E,0x0D,0x0A |
sherckuith | 1:4daed536a970 | 99 | |
sherckuith | 1:4daed536a970 | 100 | }; |
sherckuith | 1:4daed536a970 | 101 | |
sherckuith | 1:4daed536a970 | 102 | const unsigned short data_Os[976] = { |
sherckuith | 1:4daed536a970 | 103 | 0x42,0x6F,0x6F,0x74,0x6C,0x6F,0x61,0x64,0x65,0x72,0x2E,0x2E,0x2E,0x20,0x4F,0x4B, |
sherckuith | 1:4daed536a970 | 104 | 0x0D,0x0A,0x41,0x52,0x4D,0x20,0x43,0x6F,0x72,0x74,0x65,0x78,0x20,0x4D,0x33,0x20, |
sherckuith | 1:4daed536a970 | 105 | 0x43,0x50,0x55,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x47,0x72,0x61,0x70,0x68, |
sherckuith | 1:4daed536a970 | 106 | 0x69,0x63,0x20,0x50,0x72,0x6F,0x63,0x65,0x73,0x73,0x69,0x6E,0x67,0x20,0x55,0x6E, |
sherckuith | 1:4daed536a970 | 107 | 0x69,0x74,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x4C,0x69,0x62,0x72,0x65,0x72, |
sherckuith | 1:4daed536a970 | 108 | 0x69,0x65,0x73,0x20,0x46,0x61,0x74,0x20,0x46,0x2E,0x20,0x53,0x79,0x73,0x74,0x65, |
sherckuith | 1:4daed536a970 | 109 | 0x6D,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x50,0x44,0x53,0x2E,0x20,0x53,0x65, |
sherckuith | 1:4daed536a970 | 110 | 0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x41,0x72,0x65,0x61,0x2E,0x2E,0x2E,0x20,0x4F, |
sherckuith | 1:4daed536a970 | 111 | 0x4B,0x0D,0x0A,0x52,0x53,0x41,0x2E,0x20,0x50,0x72,0x6F,0x74,0x65,0x63,0x74,0x69, |
sherckuith | 1:4daed536a970 | 112 | 0x6F,0x6E,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x48,0x6F,0x73,0x74,0x20,0x55, |
sherckuith | 1:4daed536a970 | 113 | 0x53,0x42,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x44,0x65,0x76,0x69,0x63,0x65, |
sherckuith | 1:4daed536a970 | 114 | 0x20,0x55,0x53,0x42,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x53,0x44,0x20,0x43, |
sherckuith | 1:4daed536a970 | 115 | 0x61,0x72,0x64,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x53,0x61,0x76,0x65,0x3A, |
sherckuith | 1:4daed536a970 | 116 | 0x20,0x62,0x69,0x6F,0x73,0x2E,0x44,0x41,0x54,0x0D,0x0A,0x0D,0x0A,0x2A,0x2F,0x2F, |
sherckuith | 1:4daed536a970 | 117 | 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F, |
sherckuith | 1:4daed536a970 | 118 | 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F, |
sherckuith | 1:4daed536a970 | 119 | 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F, |
sherckuith | 1:4daed536a970 | 120 | 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F, |
sherckuith | 1:4daed536a970 | 121 | 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x0D,0x0A,0x41,0x6C,0x6C,0x20,0x50, |
sherckuith | 1:4daed536a970 | 122 | 0x6F,0x77,0x65,0x72,0x20,0x4D,0x69,0x63,0x72,0x6F,0x63,0x6F,0x6E,0x74,0x72,0x6F, |
sherckuith | 1:4daed536a970 | 123 | 0x6C,0x6C,0x65,0x72,0x2C,0x20,0x4F,0x70,0x65,0x72,0x61,0x74,0x69,0x76,0x65,0x20, |
sherckuith | 1:4daed536a970 | 124 | 0x53,0x79,0x73,0x74,0x65,0x6D,0x20,0x42,0x69,0x6F,0x5F,0x4F,0x73,0x0D,0x0A,0x0D, |
sherckuith | 1:4daed536a970 | 125 | 0x0A,0x46,0x61,0x74,0x20,0x46,0x69,0x6C,0x65,0x20,0x53,0x79,0x73,0x74,0x65,0x6D, |
sherckuith | 1:4daed536a970 | 126 | 0x20,0x4C,0x69,0x62,0x72,0x61,0x72,0x79,0x20,0x42,0x61,0x73,0x65,0x20,0x43,0x6C, |
sherckuith | 1:4daed536a970 | 127 | 0x61,0x73,0x73,0x20,0x61,0x6E,0x64,0x20,0x47,0x72,0x61,0x70,0x68,0x69,0x63,0x20, |
sherckuith | 1:4daed536a970 | 128 | 0x49,0x6E,0x74,0x65,0x72,0x66,0x61,0x63,0x65,0x20,0x69,0x73,0x20,0x70,0x72,0x6F, |
sherckuith | 1:4daed536a970 | 129 | 0x74,0x65,0x63,0x74,0x65,0x64,0x20,0x77,0x68,0x69,0x74,0x68,0x0D,0x0A,0x43,0x6F, |
sherckuith | 1:4daed536a970 | 130 | 0x70,0x79,0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x63,0x29,0x20,0x32,0x30,0x30,0x31, |
sherckuith | 1:4daed536a970 | 131 | 0x31,0x2D,0x32,0x30,0x31,0x32,0x20,0x45,0x63,0x75,0x61,0x64,0x6F,0x72,0x0D,0x0A, |
sherckuith | 1:4daed536a970 | 132 | 0x52,0x65,0x6C,0x65,0x61,0x73,0x65,0x64,0x20,0x75,0x6E,0x64,0x65,0x72,0x20,0x4C, |
sherckuith | 1:4daed536a970 | 133 | 0x69,0x63,0x65,0x6E,0x73,0x65,0x20,0x6F,0x66,0x20,0x69,0x6E,0x74,0x65,0x6C,0x65, |
sherckuith | 1:4daed536a970 | 134 | 0x63,0x74,0x75,0x61,0x6C,0x20,0x70,0x72,0x6F,0x70,0x69,0x65,0x74,0x79,0x20,0x6F, |
sherckuith | 1:4daed536a970 | 135 | 0x66,0x20,0x41,0x6E,0x67,0x65,0x6C,0x20,0x44,0x2E,0x20,0x59,0x61,0x67,0x75,0x61, |
sherckuith | 1:4daed536a970 | 136 | 0x6E,0x61,0x0D,0x0A,0x0D,0x0A,0x45,0x6C,0x20,0x70,0x72,0x65,0x73,0x65,0x6E,0x74, |
sherckuith | 1:4daed536a970 | 137 | 0x65,0x20,0x70,0x72,0x6F,0x79,0x65,0x63,0x74,0x6F,0x20,0x65,0x73,0x20,0x72,0x65, |
sherckuith | 1:4daed536a970 | 138 | 0x61,0x6C,0x69,0x7A,0x61,0x64,0x6F,0x20,0x62,0x61,0x6A,0x6F,0x20,0x61,0x63,0x75, |
sherckuith | 1:4daed536a970 | 139 | 0x65,0x72,0x64,0x6F,0x20,0x64,0x65,0x20,0x6C,0x69,0x63,0x65,0x6E,0x63,0x69,0x61, |
sherckuith | 1:4daed536a970 | 140 | 0x20,0x6F,0x74,0x6F,0x72,0x67,0x61,0x64,0x6F,0x20,0x70,0x6F,0x72,0x20,0x65,0x6C, |
sherckuith | 1:4daed536a970 | 141 | 0x20,0x0D,0x0A,0x41,0x75,0x74,0x6F,0x72,0x20,0x63,0x6F,0x6E,0x20,0x74,0x65,0x72, |
sherckuith | 1:4daed536a970 | 142 | 0x6D,0x69,0x6E,0x6F,0x73,0x20,0x65,0x73,0x70,0x65,0x63,0x69,0x66,0x69,0x63,0x61, |
sherckuith | 1:4daed536a970 | 143 | 0x64,0x6F,0x73,0x20,0x70,0x6F,0x72,0x20,0x6C,0x61,0x20,0x6C,0x69,0x63,0x65,0x6E, |
sherckuith | 1:4daed536a970 | 144 | 0x63,0x69,0x61,0x20,0x47,0x4E,0x55,0x20,0x47,0x50,0x4C,0x20,0x6C,0x61,0x20,0x63, |
sherckuith | 1:4daed536a970 | 145 | 0x75,0x61,0x6C,0x20,0x6C,0x65,0x20,0x70,0x65,0x72,0x6D,0x69,0x74,0x65,0x20,0x0D, |
sherckuith | 1:4daed536a970 | 146 | 0x0A,0x75,0x73,0x61,0x72,0x20,0x6C,0x61,0x73,0x20,0x6C,0x69,0x62,0x72,0x65,0x72, |
sherckuith | 1:4daed536a970 | 147 | 0x69,0x61,0x73,0x20,0x70,0x65,0x72,0x6F,0x20,0x70,0x72,0x6F,0x68,0x69,0x62,0x65, |
sherckuith | 1:4daed536a970 | 148 | 0x20,0x73,0x75,0x20,0x76,0x65,0x6E,0x74,0x61,0x20,0x6F,0x20,0x63,0x6F,0x6D,0x65, |
sherckuith | 1:4daed536a970 | 149 | 0x72,0x63,0x69,0x61,0x6C,0x69,0x7A,0x61,0x63,0x69,0x6F,0x6E,0x20,0x63,0x6F,0x6E, |
sherckuith | 1:4daed536a970 | 150 | 0x20,0x66,0x69,0x6E,0x65,0x73,0x20,0x64,0x65,0x20,0x6C,0x75,0x63,0x72,0x6F,0x20, |
sherckuith | 1:4daed536a970 | 151 | 0x0D,0x0A,0x73,0x69,0x6E,0x20,0x70,0x72,0x65,0x76,0x69,0x61,0x20,0x72,0x65,0x74, |
sherckuith | 1:4daed536a970 | 152 | 0x72,0x69,0x62,0x75,0x63,0x69,0x6F,0x6E,0x20,0x70,0x6F,0x72,0x20,0x64,0x65,0x72, |
sherckuith | 1:4daed536a970 | 153 | 0x65,0x63,0x68,0x6F,0x73,0x20,0x64,0x65,0x20,0x70,0x72,0x6F,0x70,0x69,0x65,0x64, |
sherckuith | 1:4daed536a970 | 154 | 0x61,0x64,0x20,0x69,0x6E,0x74,0x65,0x6C,0x65,0x63,0x74,0x75,0x61,0x6C,0x20,0x64, |
sherckuith | 1:4daed536a970 | 155 | 0x65,0x20,0x42,0x69,0x6F,0x5F,0x4F,0x73,0x0D,0x0A,0x2A,0x2F,0x2F,0x2F,0x2F,0x2F, |
sherckuith | 1:4daed536a970 | 156 | 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F, |
sherckuith | 1:4daed536a970 | 157 | 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F, |
sherckuith | 1:4daed536a970 | 158 | 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F, |
sherckuith | 1:4daed536a970 | 159 | 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F, |
sherckuith | 1:4daed536a970 | 160 | 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x0D,0x0A,0x0D,0x0A,0x0D,0x0A,0x0D,0x0A,0x2F,0x2F, |
sherckuith | 1:4daed536a970 | 161 | 0x42,0x69,0x6F,0x5F,0x4F,0x73,0x20,0x77,0x61,0x73,0x20,0x64,0x65,0x76,0x65,0x6C, |
sherckuith | 1:4daed536a970 | 162 | 0x6F,0x70,0x6D,0x65,0x6E,0x74,0x20,0x62,0x79,0x20,0x53,0x68,0x65,0x72,0x63,0x6B, |
sherckuith | 1:4daed536a970 | 163 | 0x75,0x69,0x74,0x68,0x20,0x69,0x6E,0x20,0x32,0x30,0x31,0x32,0x2F,0x3C,0x00,0x00 |
sherckuith | 1:4daed536a970 | 164 | }; |
sherckuith | 1:4daed536a970 | 165 | |
sherckuith | 1:4daed536a970 | 166 | |
sherckuith | 1:4daed536a970 | 167 | //read_RAM var |
sherckuith | 1:4daed536a970 | 168 | int get_start_date_ram=0,get_start_month_ram=0,get_start_year_ram=0,get_start_hour_ram=0,get_start_min_ram=0,get_start_sec_ram=0; |
sherckuith | 1:4daed536a970 | 169 | int get_end_date_ram=0,get_end_month_ram=0,get_end_year_ram=0,get_end_hour_ram=0,get_end_min_ram=0,get_end_sec_ram=0; |
sherckuith | 1:4daed536a970 | 170 | int get_speed_ram= 0, get_sense_ram= 0,get_space_ram= 0; |
sherckuith | 1:4daed536a970 | 171 | float get_space_Z4= 0, speed_ram_powten_3= 0, sense_ram_powten_3= 0; |
sherckuith | 1:4daed536a970 | 172 | |
sherckuith | 1:4daed536a970 | 173 | //Config var |
sherckuith | 1:4daed536a970 | 174 | int set_start_hour=0,set_start_min=0,set_start_sec=0,set_start_date=0,set_start_month=0,set_start_year=0; |
sherckuith | 1:4daed536a970 | 175 | int set_end_hour=0,set_end_min=0,set_end_sec=0,set_end_date=0,set_end_month=0,set_end_year=0; |
sherckuith | 1:4daed536a970 | 176 | int set_speed= 0, set_sense= 0,set_space= 0; |
sherckuith | 1:4daed536a970 | 177 | |
sherckuith | 1:4daed536a970 | 178 | //Upload var |
sherckuith | 1:4daed536a970 | 179 | int new_hour=0,new_min=0,new_sec=0,new_date=0,new_mont=0,new_year=0,new_day=0; |
sherckuith | 1:4daed536a970 | 180 | |
sherckuith | 1:4daed536a970 | 181 | //Registre |
sherckuith | 1:4daed536a970 | 182 | int Old_Speed_RAM= 0, Old_sense_RAM= 0,Old_Space_RAM= 0; |
sherckuith | 1:4daed536a970 | 183 | |
sherckuith | 1:4daed536a970 | 184 | //Keypad |
sherckuith | 1:4daed536a970 | 185 | int t=0,cnt=1,j=0,key=0; |
sherckuith | 1:4daed536a970 | 186 | int pass=0,l=0; |
sherckuith | 1:4daed536a970 | 187 | char data[6]; |
sherckuith | 1:4daed536a970 | 188 | int key0=0, key1=0, key2=0, key3=0, key4=0, key5=0; |
sherckuith | 1:4daed536a970 | 189 | char Keytable[] = { '1', '2', '3', 'A', |
sherckuith | 1:4daed536a970 | 190 | '4', '5', '6', 'B', |
sherckuith | 1:4daed536a970 | 191 | '7', '8', '9', 'C', |
sherckuith | 1:4daed536a970 | 192 | '*', '0', '#', 'D' |
sherckuith | 1:4daed536a970 | 193 | }; |
sherckuith | 1:4daed536a970 | 194 | //EZ4 |
sherckuith | 1:4daed536a970 | 195 | float adc,cm5=0, prom=0,result=0, Radar=0; |
sherckuith | 1:4daed536a970 | 196 | int cnt_Z4=0; |
sherckuith | 1:4daed536a970 | 197 | int interval=0; |
sherckuith | 1:4daed536a970 | 198 | |
sherckuith | 1:4daed536a970 | 199 | //funciones |
sherckuith | 1:4daed536a970 | 200 | void Set_Time(int set_sec, int set_min, int set_hours, int set_day, int set_date, int set_month, int set_year); |
sherckuith | 1:4daed536a970 | 201 | void read_RAM(); |
sherckuith | 1:4daed536a970 | 202 | float get_Z4(); |
sherckuith | 1:4daed536a970 | 203 | uint32_t cbAfterInput(uint32_t index); |
sherckuith | 1:4daed536a970 | 204 | //extern "C" void mbed_reset(); |
sherckuith | 1:4daed536a970 | 205 | |
sherckuith | 1:4daed536a970 | 206 | int i = 0; |
sherckuith | 1:4daed536a970 | 207 | int flag_usb_1=0,flag_usb_2=0; |
sherckuith | 1:4daed536a970 | 208 | int c=0; |
sherckuith | 1:4daed536a970 | 209 | |
sherckuith | 1:4daed536a970 | 210 | int FLAG_DOOR_OFF=0; |
sherckuith | 1:4daed536a970 | 211 | int FLAG_DOOR_ON=0; |
sherckuith | 1:4daed536a970 | 212 | int FLAG_NEW_PASS=0; |
sherckuith | 1:4daed536a970 | 213 | int FLAG_PUT_PASS=0; |
sherckuith | 1:4daed536a970 | 214 | int FLAG_NEW_PASS_FULL=0; |
sherckuith | 1:4daed536a970 | 215 | |
sherckuith | 1:4daed536a970 | 216 | |
sherckuith | 1:4daed536a970 | 217 | int main() |
sherckuith | 1:4daed536a970 | 218 | { |
sherckuith | 1:4daed536a970 | 219 | ////pc.baud(115200); |
sherckuith | 1:4daed536a970 | 220 | |
sherckuith | 1:4daed536a970 | 221 | keypad.CallAfterInput(&cbAfterInput); |
sherckuith | 1:4daed536a970 | 222 | keypad.Start(); |
sherckuith | 1:4daed536a970 | 223 | //rigth_sense.mode(PullDown); |
sherckuith | 1:4daed536a970 | 224 | //left_sense.mode(PullDown); |
sherckuith | 1:4daed536a970 | 225 | |
sherckuith | 1:4daed536a970 | 226 | for(i=0; i<10; i++) { |
sherckuith | 1:4daed536a970 | 227 | wait(0.1); |
sherckuith | 1:4daed536a970 | 228 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 229 | } |
chris | 0:144fed3d9420 | 230 | |
sherckuith | 1:4daed536a970 | 231 | c=255; |
sherckuith | 1:4daed536a970 | 232 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 233 | lcd.printf(" %c%c %c%c%c %c %c ",c,c,c,c,c,c,c); |
sherckuith | 1:4daed536a970 | 234 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 235 | lcd.printf("%c %c %c %c %c%c %c%c GYE",c,c,c,c,c,c,c,c); |
sherckuith | 1:4daed536a970 | 236 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 237 | lcd.printf("%c%c%c%c %c%c%c %c %c %c ECU.",c,c,c,c,c,c,c,c,c,c); |
sherckuith | 1:4daed536a970 | 238 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 239 | lcd.printf("%c %c %c %c %c ",c,c,c,c,c); |
sherckuith | 1:4daed536a970 | 240 | for(int z=0; z<10; z++) { |
sherckuith | 1:4daed536a970 | 241 | wait(0.05); |
sherckuith | 1:4daed536a970 | 242 | led1=1; |
sherckuith | 1:4daed536a970 | 243 | led5=1; |
sherckuith | 1:4daed536a970 | 244 | led2=0; |
sherckuith | 1:4daed536a970 | 245 | led6=0; |
sherckuith | 1:4daed536a970 | 246 | led3=0; |
sherckuith | 1:4daed536a970 | 247 | led7=0; |
sherckuith | 1:4daed536a970 | 248 | led4=0; |
sherckuith | 1:4daed536a970 | 249 | led8=0; |
sherckuith | 1:4daed536a970 | 250 | wait(0.05); |
sherckuith | 1:4daed536a970 | 251 | led1=0; |
sherckuith | 1:4daed536a970 | 252 | led5=0; |
sherckuith | 1:4daed536a970 | 253 | led2=1; |
sherckuith | 1:4daed536a970 | 254 | led6=1; |
sherckuith | 1:4daed536a970 | 255 | led3=0; |
sherckuith | 1:4daed536a970 | 256 | led7=0; |
sherckuith | 1:4daed536a970 | 257 | led4=0; |
sherckuith | 1:4daed536a970 | 258 | led8=0; |
sherckuith | 1:4daed536a970 | 259 | wait(0.05); |
sherckuith | 1:4daed536a970 | 260 | led1=0; |
sherckuith | 1:4daed536a970 | 261 | led5=0; |
sherckuith | 1:4daed536a970 | 262 | led2=0; |
sherckuith | 1:4daed536a970 | 263 | led6=0; |
sherckuith | 1:4daed536a970 | 264 | led3=1; |
sherckuith | 1:4daed536a970 | 265 | led7=1; |
sherckuith | 1:4daed536a970 | 266 | led4=0; |
sherckuith | 1:4daed536a970 | 267 | led8=0; |
sherckuith | 1:4daed536a970 | 268 | wait(0.05); |
sherckuith | 1:4daed536a970 | 269 | led1=0; |
sherckuith | 1:4daed536a970 | 270 | led5=0; |
sherckuith | 1:4daed536a970 | 271 | led2=0; |
sherckuith | 1:4daed536a970 | 272 | led6=0; |
sherckuith | 1:4daed536a970 | 273 | led3=0; |
sherckuith | 1:4daed536a970 | 274 | led7=0; |
sherckuith | 1:4daed536a970 | 275 | led4=1; |
sherckuith | 1:4daed536a970 | 276 | led8=1; |
sherckuith | 1:4daed536a970 | 277 | wait(0.05); |
sherckuith | 1:4daed536a970 | 278 | led1=0; |
sherckuith | 1:4daed536a970 | 279 | led5=0; |
sherckuith | 1:4daed536a970 | 280 | led2=0; |
sherckuith | 1:4daed536a970 | 281 | led6=0; |
sherckuith | 1:4daed536a970 | 282 | led3=1; |
sherckuith | 1:4daed536a970 | 283 | led7=1; |
sherckuith | 1:4daed536a970 | 284 | led4=0; |
sherckuith | 1:4daed536a970 | 285 | led8=0; |
sherckuith | 1:4daed536a970 | 286 | wait(0.05); |
sherckuith | 1:4daed536a970 | 287 | led1=0; |
sherckuith | 1:4daed536a970 | 288 | led5=0; |
sherckuith | 1:4daed536a970 | 289 | led2=1; |
sherckuith | 1:4daed536a970 | 290 | led6=1; |
sherckuith | 1:4daed536a970 | 291 | led3=0; |
sherckuith | 1:4daed536a970 | 292 | led7=0; |
sherckuith | 1:4daed536a970 | 293 | led4=0; |
sherckuith | 1:4daed536a970 | 294 | led8=0; |
sherckuith | 1:4daed536a970 | 295 | wait(0.05); |
sherckuith | 1:4daed536a970 | 296 | led1=1; |
sherckuith | 1:4daed536a970 | 297 | led5=1; |
sherckuith | 1:4daed536a970 | 298 | led2=0; |
sherckuith | 1:4daed536a970 | 299 | led6=0; |
sherckuith | 1:4daed536a970 | 300 | led3=0; |
sherckuith | 1:4daed536a970 | 301 | led7=0; |
sherckuith | 1:4daed536a970 | 302 | led4=0; |
sherckuith | 1:4daed536a970 | 303 | led8=0; |
sherckuith | 1:4daed536a970 | 304 | } |
sherckuith | 1:4daed536a970 | 305 | led1=led2=led3=led4=0; |
sherckuith | 1:4daed536a970 | 306 | led5=led6=led7=led8=0; |
sherckuith | 1:4daed536a970 | 307 | wait(2); |
sherckuith | 1:4daed536a970 | 308 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 309 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 310 | lcd.printf(" Los Rios #2914 "); |
sherckuith | 1:4daed536a970 | 311 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 312 | lcd.printf(" y Letamendi "); |
sherckuith | 1:4daed536a970 | 313 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 314 | lcd.printf("apm.litoral@gmail.co"); |
sherckuith | 1:4daed536a970 | 315 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 316 | lcd.printf(" Cell: 0991439123 "); |
sherckuith | 1:4daed536a970 | 317 | wait(5); |
sherckuith | 1:4daed536a970 | 318 | |
sherckuith | 1:4daed536a970 | 319 | for(i=0; i<5; i++) { |
sherckuith | 1:4daed536a970 | 320 | wait(0.1); |
sherckuith | 1:4daed536a970 | 321 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 322 | } |
sherckuith | 1:4daed536a970 | 323 | |
sherckuith | 1:4daed536a970 | 324 | //pc.printf("Angel D. Yaguana...\r\n"); |
sherckuith | 1:4daed536a970 | 325 | //pc.printf("Proyecto Datafast de la vida...\r\n"); |
sherckuith | 1:4daed536a970 | 326 | //pc.printf("Artista: Patricio Barberan\r\n"); |
sherckuith | 1:4daed536a970 | 327 | |
sherckuith | 1:4daed536a970 | 328 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 329 | lcd.printf(" Proyecto \"Datafast\" "); |
sherckuith | 1:4daed536a970 | 330 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 331 | lcd.printf(" Patricio Barberan "); |
sherckuith | 1:4daed536a970 | 332 | wait(2); |
sherckuith | 1:4daed536a970 | 333 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 334 | lcd.printf(" Iniciando... "); |
sherckuith | 1:4daed536a970 | 335 | wait(3); |
sherckuith | 1:4daed536a970 | 336 | |
sherckuith | 1:4daed536a970 | 337 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 338 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 339 | lcd.printf("Conecte una memoria "); |
sherckuith | 1:4daed536a970 | 340 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 341 | lcd.printf("USB para ingresar la"); |
sherckuith | 1:4daed536a970 | 342 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 343 | lcd.printf("nueva configuracion!"); |
sherckuith | 1:4daed536a970 | 344 | wait(5); |
sherckuith | 1:4daed536a970 | 345 | led1=led2=led3=led4=0; |
sherckuith | 1:4daed536a970 | 346 | led5=led6=led7=led8=0; |
sherckuith | 1:4daed536a970 | 347 | |
sherckuith | 1:4daed536a970 | 348 | |
sherckuith | 1:4daed536a970 | 349 | USBHostMSD msd("host"); |
sherckuith | 1:4daed536a970 | 350 | |
sherckuith | 1:4daed536a970 | 351 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 352 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 353 | lcd.printf(" Buscando"); |
sherckuith | 1:4daed536a970 | 354 | |
sherckuith | 1:4daed536a970 | 355 | for(i=0; i<5; i++) { |
sherckuith | 1:4daed536a970 | 356 | wait(0.5); |
sherckuith | 1:4daed536a970 | 357 | msd.connect(); |
sherckuith | 1:4daed536a970 | 358 | lcd.printf("."); |
sherckuith | 1:4daed536a970 | 359 | } |
sherckuith | 1:4daed536a970 | 360 | |
sherckuith | 1:4daed536a970 | 361 | if(msd.connected()) { |
sherckuith | 1:4daed536a970 | 362 | wait(1); |
sherckuith | 1:4daed536a970 | 363 | lcd.printf("!"); |
sherckuith | 1:4daed536a970 | 364 | led1=led2=led3=led4=1; |
sherckuith | 1:4daed536a970 | 365 | led5=led6=led7=led8=1; |
sherckuith | 1:4daed536a970 | 366 | wait(1); |
sherckuith | 1:4daed536a970 | 367 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 368 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 369 | lcd.printf(" USB Stick "); |
sherckuith | 1:4daed536a970 | 370 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 371 | lcd.printf(" encontrado! "); |
sherckuith | 1:4daed536a970 | 372 | wait(1); |
sherckuith | 1:4daed536a970 | 373 | } |
sherckuith | 1:4daed536a970 | 374 | led1=led2=led3=led4=0; |
sherckuith | 1:4daed536a970 | 375 | led5=led6=led7=led8=0; |
chris | 0:144fed3d9420 | 376 | |
sherckuith | 1:4daed536a970 | 377 | if(!msd.connected()) { |
sherckuith | 1:4daed536a970 | 378 | lcd.printf("?"); |
sherckuith | 1:4daed536a970 | 379 | wait(1); |
sherckuith | 1:4daed536a970 | 380 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 381 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 382 | lcd.printf(" USB Stick "); |
sherckuith | 1:4daed536a970 | 383 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 384 | lcd.printf(" No encontrado! "); |
sherckuith | 1:4daed536a970 | 385 | wait(1); |
sherckuith | 1:4daed536a970 | 386 | } |
sherckuith | 1:4daed536a970 | 387 | led1=led2=led3=led4=0; |
sherckuith | 1:4daed536a970 | 388 | led5=led6=led7=led8=0; |
sherckuith | 1:4daed536a970 | 389 | |
sherckuith | 1:4daed536a970 | 390 | if(msd.connected()) { |
sherckuith | 1:4daed536a970 | 391 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 392 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 393 | lcd.printf("Generando archivo de"); |
sherckuith | 1:4daed536a970 | 394 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 395 | lcd.printf("ayuda en menoria USB"); |
sherckuith | 1:4daed536a970 | 396 | wait(1); |
sherckuith | 1:4daed536a970 | 397 | FILE *fp1; |
sherckuith | 1:4daed536a970 | 398 | if ((fp1 = fopen( "/host/Manual de ayuda.rtf", "w"))!=NULL) { |
sherckuith | 1:4daed536a970 | 399 | fprintf(fp1,"Archivos de configuracion:");//Start:14-03-2013 08:30:00 |
sherckuith | 1:4daed536a970 | 400 | fprintf(fp1,"\r\n\r\nClock.txt\r\n\r\n\r\n"); |
sherckuith | 1:4daed536a970 | 401 | fprintf(fp1,"Contenido:\r\n\r\n"); |
sherckuith | 1:4daed536a970 | 402 | fprintf(fp1,"Start:14-03-2013 08:30:00\r\n"); |
sherckuith | 1:4daed536a970 | 403 | fprintf(fp1,"End:01-12-2013 22:30:00\r\n"); |
sherckuith | 1:4daed536a970 | 404 | fprintf(fp1,"Speed:80\r\n"); |
sherckuith | 1:4daed536a970 | 405 | fprintf(fp1,"Sense:30\r\n"); |
sherckuith | 1:4daed536a970 | 406 | fprintf(fp1,"Space:90\r\n"); |
sherckuith | 1:4daed536a970 | 407 | fprintf(fp1,"\r\nExplicacion:\r\n\r\n"); |
sherckuith | 1:4daed536a970 | 408 | fprintf(fp1,"Start:(Fecha de inicio) (hora de inicio diaria)\r\n"); |
sherckuith | 1:4daed536a970 | 409 | fprintf(fp1,"End:(Fecha de finalizacion) (hora de finalizacion diaria)\r\n"); |
sherckuith | 1:4daed536a970 | 410 | fprintf(fp1,"Speed:(porcentaje de velocidad de desplazamiento del cuadro)\r\n"); |
sherckuith | 1:4daed536a970 | 411 | fprintf(fp1,"Sense:(Intervalo en segundos entre detecciones)\r\n"); |
sherckuith | 1:4daed536a970 | 412 | fprintf(fp1,"Space:(Distancia entre 30 y 300 para deteccion)\r\n"); |
sherckuith | 1:4daed536a970 | 413 | fprintf(fp1,"\r\n\r\n\r\nTimer.txt\r\n\r\n\r\n"); |
sherckuith | 1:4daed536a970 | 414 | fprintf(fp1,"Contenido:\r\n\r\n"); |
sherckuith | 1:4daed536a970 | 415 | fprintf(fp1,"7 29-05-2013 17:35:00\r\n"); |
sherckuith | 1:4daed536a970 | 416 | fprintf(fp1,"\r\nExplicacion:\r\n\r\n"); |
sherckuith | 1:4daed536a970 | 417 | fprintf(fp1,"7:(Dia de la semana)\r\n"); |
sherckuith | 1:4daed536a970 | 418 | fprintf(fp1,"29-05-2013:(Fecha actual para cargar)\r\n"); |
sherckuith | 1:4daed536a970 | 419 | fprintf(fp1,"17:35:00:(Hora actual para cargar)\r\n"); |
sherckuith | 1:4daed536a970 | 420 | fprintf(fp1,"\r\nFirmware propiedad de:\r\n"); |
sherckuith | 1:4daed536a970 | 421 | fprintf(fp1,"Angel D. Yaguana H. & Ivan A. Sanchez\r\n"); |
sherckuith | 1:4daed536a970 | 422 | fprintf(fp1,"All Power Microcontroller Litoral.\r\n"); |
sherckuith | 1:4daed536a970 | 423 | fprintf(fp1,"Los Rios 2912 y Letamendi\r\n"); |
sherckuith | 1:4daed536a970 | 424 | fprintf(fp1,"Cell: 0992430921-0991439123-0989200942\r\n"); |
sherckuith | 1:4daed536a970 | 425 | fprintf(fp1,"Email: apm.litoral@gmail.com\r\n"); |
sherckuith | 1:4daed536a970 | 426 | //pc.printf("\r\nPrint Help OK\r\n"); |
sherckuith | 1:4daed536a970 | 427 | fclose(fp1); |
sherckuith | 1:4daed536a970 | 428 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 429 | lcd.printf(" Listo! "); |
sherckuith | 1:4daed536a970 | 430 | wait(1); |
sherckuith | 1:4daed536a970 | 431 | } else { |
sherckuith | 1:4daed536a970 | 432 | //pc.printf("\r\nPrint Help fail\r\n"); |
sherckuith | 1:4daed536a970 | 433 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 434 | lcd.printf(" Error! "); |
sherckuith | 1:4daed536a970 | 435 | wait(1); |
sherckuith | 1:4daed536a970 | 436 | } |
sherckuith | 1:4daed536a970 | 437 | |
sherckuith | 1:4daed536a970 | 438 | FILE *binary = fopen("/host/All Power Microcontroller Litoral.html", "w"); |
sherckuith | 1:4daed536a970 | 439 | while (a<=229) { |
sherckuith | 1:4daed536a970 | 440 | fprintf(binary,(const char *)&page[a]); |
sherckuith | 1:4daed536a970 | 441 | a++; |
sherckuith | 1:4daed536a970 | 442 | } |
sherckuith | 1:4daed536a970 | 443 | fclose(binary); |
sherckuith | 1:4daed536a970 | 444 | |
sherckuith | 1:4daed536a970 | 445 | FILE *octal = fopen("/host/Status Bio_Os.rtf", "w"); |
sherckuith | 1:4daed536a970 | 446 | while (b<=976) { |
sherckuith | 1:4daed536a970 | 447 | fprintf(octal,(const char *)&data_Os[b]); |
sherckuith | 1:4daed536a970 | 448 | b++; |
sherckuith | 1:4daed536a970 | 449 | } |
sherckuith | 1:4daed536a970 | 450 | fclose(octal); |
sherckuith | 1:4daed536a970 | 451 | |
sherckuith | 1:4daed536a970 | 452 | FILE *fp2 = fopen( "/host/Clock_ejemplo.txt", "w"); |
sherckuith | 1:4daed536a970 | 453 | fprintf(fp1,"Start:14-03-2013 08:30:00\r\n"); |
sherckuith | 1:4daed536a970 | 454 | fprintf(fp1,"End:01-12-2013 22:30:00\r\n"); |
sherckuith | 1:4daed536a970 | 455 | fprintf(fp1,"Speed:80\r\n"); |
sherckuith | 1:4daed536a970 | 456 | fprintf(fp1,"Sense:30\r\n"); |
sherckuith | 1:4daed536a970 | 457 | fprintf(fp1,"Space:90\r\n"); |
sherckuith | 1:4daed536a970 | 458 | fclose(fp1); |
sherckuith | 1:4daed536a970 | 459 | |
sherckuith | 1:4daed536a970 | 460 | FILE *fp3 = fopen( "/host/Timer_ejemplo.txt", "w"); |
sherckuith | 1:4daed536a970 | 461 | fprintf(fp1,"7 29-05-2013 17:35:00\r\n"); |
sherckuith | 1:4daed536a970 | 462 | fclose(fp1); |
sherckuith | 1:4daed536a970 | 463 | } |
sherckuith | 1:4daed536a970 | 464 | led1=led2=led3=led4=0; |
sherckuith | 1:4daed536a970 | 465 | led5=led6=led7=led8=0; |
sherckuith | 1:4daed536a970 | 466 | |
sherckuith | 1:4daed536a970 | 467 | |
sherckuith | 1:4daed536a970 | 468 | |
sherckuith | 1:4daed536a970 | 469 | if(msd.connected()) { |
sherckuith | 1:4daed536a970 | 470 | flag_usb_1=1; |
sherckuith | 1:4daed536a970 | 471 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 472 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 473 | lcd.printf(" Actualizando Reloj "); |
sherckuith | 1:4daed536a970 | 474 | my1307.gettime( &sec, &min, &hours, &day, &date, &month, &year); |
sherckuith | 1:4daed536a970 | 475 | wait(1); |
sherckuith | 1:4daed536a970 | 476 | FILE *fp2; |
sherckuith | 1:4daed536a970 | 477 | if ((fp2 = fopen( "/host/Clock.txt", "r"))!=NULL) { |
sherckuith | 1:4daed536a970 | 478 | fscanf(fp2,"%2d %2d-%2d-20%2d %2d:%2d:%2d",&new_day,&new_date,&new_mont,&new_year,&new_hour,&new_min,&new_sec); |
sherckuith | 1:4daed536a970 | 479 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 480 | lcd.printf(" Listo! "); |
sherckuith | 1:4daed536a970 | 481 | //pc.printf("USB Time: %2d %2d/%2d/20%2d %2d:%2d:%2d\r\n",new_day,new_date,new_mont,new_year,new_hour,new_min,new_sec); |
sherckuith | 1:4daed536a970 | 482 | wait(1); |
sherckuith | 1:4daed536a970 | 483 | |
sherckuith | 1:4daed536a970 | 484 | Set_Time( new_sec, new_min, new_hour, new_day, new_date, new_mont, new_year); // Set the time on the DS1307 |
sherckuith | 1:4daed536a970 | 485 | //pc.printf("Old Time: %2d %2d/%2d/20%2d %2d:%2d:%2d\r\n",day,date,month,year,hours,min,sec); |
sherckuith | 1:4daed536a970 | 486 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 487 | lcd.printf("Temporizador actual"); |
sherckuith | 1:4daed536a970 | 488 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 489 | lcd.printf(" %02d-%02d-%02d %02d:%02d:%02d ",date,month,year,hours,min,sec); |
sherckuith | 1:4daed536a970 | 490 | |
sherckuith | 1:4daed536a970 | 491 | my1307.gettime( &sec, &min, &hours, &day, &date, &month, &year); |
sherckuith | 1:4daed536a970 | 492 | //pc.printf("New Time: %2d %2d/%2d/20%2d %2d:%2d:%2d\r\n",day,date,month,year,hours,min,sec); |
sherckuith | 1:4daed536a970 | 493 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 494 | lcd.printf("Temporizador nuevo "); |
sherckuith | 1:4daed536a970 | 495 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 496 | lcd.printf(" %02d-%02d-%02d %02d:%02d:%02d ",date,month,year,hours,min,sec); |
sherckuith | 1:4daed536a970 | 497 | wait(5); |
sherckuith | 1:4daed536a970 | 498 | //pc.printf("\r\nTime Uploaded succesfully!\r\n"); |
sherckuith | 1:4daed536a970 | 499 | fclose(fp2); |
sherckuith | 1:4daed536a970 | 500 | wait(1); |
sherckuith | 1:4daed536a970 | 501 | } else { |
sherckuith | 1:4daed536a970 | 502 | my1307.gettime( &sec, &min, &hours, &day, &date, &month, &year); |
sherckuith | 1:4daed536a970 | 503 | //pc.printf("Time: %2d %2d-%2d-20%2d %2d:%2d:%2d\r\n",day,date,month,year,hours,min,sec); |
sherckuith | 1:4daed536a970 | 504 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 505 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 506 | lcd.printf(" Error! "); |
sherckuith | 1:4daed536a970 | 507 | wait(1); |
sherckuith | 1:4daed536a970 | 508 | } |
sherckuith | 1:4daed536a970 | 509 | } |
sherckuith | 1:4daed536a970 | 510 | led1=led2=led3=led4=0; |
sherckuith | 1:4daed536a970 | 511 | led5=led6=led7=led8=0; |
sherckuith | 1:4daed536a970 | 512 | |
sherckuith | 1:4daed536a970 | 513 | |
sherckuith | 1:4daed536a970 | 514 | if(msd.connected()) { |
sherckuith | 1:4daed536a970 | 515 | flag_usb_2=1; |
sherckuith | 1:4daed536a970 | 516 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 517 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 518 | lcd.printf(" Configurando "); |
sherckuith | 1:4daed536a970 | 519 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 520 | lcd.printf(" temporizador "); |
sherckuith | 1:4daed536a970 | 521 | |
sherckuith | 1:4daed536a970 | 522 | FILE *fp2; |
sherckuith | 1:4daed536a970 | 523 | if ((fp2 = fopen( "/host/Timer.txt", "r"))!=NULL) { |
sherckuith | 1:4daed536a970 | 524 | fscanf(fp2,"Start:%2d-%2d-20%2d %2d:%2d:%2d End:%2d-%2d-20%2d %2d:%2d:%2d Speed:%d Sense:%d Space:%d",&set_start_date,&set_start_month,&set_start_year,&set_start_hour,&set_start_min,&set_start_sec,&set_end_date,&set_end_month,&set_end_year,&set_end_hour,&set_end_min,&set_end_sec,&set_speed,&set_sense,&set_space); |
sherckuith | 1:4daed536a970 | 525 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 526 | lcd.printf(" Listo! "); |
sherckuith | 1:4daed536a970 | 527 | //pc.printf( "Start:%2d/%2d/20%2d %2d:%2d:%2d End:%2d/%2d/20%2d %2d:%2d:%2d Speed:%3d Sense:%3d Space:%3d\n",set_start_date,set_start_month,set_start_year,set_start_hour,set_start_min,set_start_sec,set_end_date,set_end_month,set_end_year,set_end_hour,set_end_min,set_end_sec,set_speed,set_sense,set_space); |
sherckuith | 1:4daed536a970 | 528 | |
sherckuith | 1:4daed536a970 | 529 | my1307.write( 0x08, set_start_date); |
sherckuith | 1:4daed536a970 | 530 | my1307.write( 0x09, set_start_month); |
sherckuith | 1:4daed536a970 | 531 | my1307.write( 0x0A, set_start_year); |
sherckuith | 1:4daed536a970 | 532 | my1307.write( 0x0B, set_start_hour); |
sherckuith | 1:4daed536a970 | 533 | my1307.write( 0x0C, set_start_min); |
sherckuith | 1:4daed536a970 | 534 | my1307.write( 0x0D, set_start_sec); |
sherckuith | 1:4daed536a970 | 535 | |
sherckuith | 1:4daed536a970 | 536 | my1307.write( 0x0E, set_end_date); |
sherckuith | 1:4daed536a970 | 537 | my1307.write( 0x0F, set_end_month); |
sherckuith | 1:4daed536a970 | 538 | my1307.write( 0x10, set_end_year); |
sherckuith | 1:4daed536a970 | 539 | my1307.write( 0x11, set_end_hour); |
sherckuith | 1:4daed536a970 | 540 | my1307.write( 0x12, set_end_min); |
sherckuith | 1:4daed536a970 | 541 | my1307.write( 0x13, set_end_sec); |
sherckuith | 1:4daed536a970 | 542 | |
sherckuith | 1:4daed536a970 | 543 | my1307.write( 0x14, set_speed); |
sherckuith | 1:4daed536a970 | 544 | my1307.write( 0x15, set_sense); |
sherckuith | 1:4daed536a970 | 545 | my1307.write( 0x16, set_space); |
chris | 0:144fed3d9420 | 546 | |
sherckuith | 1:4daed536a970 | 547 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 548 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 549 | lcd.printf("F.Inicio: %02d-%02d-20%02d",set_start_date,set_start_month,set_start_year); |
sherckuith | 1:4daed536a970 | 550 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 551 | lcd.printf("F.Fin : %02d-%02d-20%02d",set_end_date,set_end_month,set_end_year); |
sherckuith | 1:4daed536a970 | 552 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 553 | lcd.printf("H.Inicio: %02d:%02d:%02d",set_start_hour,set_start_min,set_start_sec); |
sherckuith | 1:4daed536a970 | 554 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 555 | lcd.printf("H.Fin : %02d:%02d:%02d",set_end_hour,set_end_min,set_end_sec); |
sherckuith | 1:4daed536a970 | 556 | wait(5); |
sherckuith | 1:4daed536a970 | 557 | |
sherckuith | 1:4daed536a970 | 558 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 559 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 560 | lcd.printf("Configuracion nueva"); |
sherckuith | 1:4daed536a970 | 561 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 562 | lcd.printf("Velocidad : %3d%",set_speed); |
sherckuith | 1:4daed536a970 | 563 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 564 | lcd.printf("Sencibilidad : %3d%",set_sense); |
sherckuith | 1:4daed536a970 | 565 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 566 | lcd.printf("Distancia max: %3d",set_space); |
sherckuith | 1:4daed536a970 | 567 | wait(5); |
sherckuith | 1:4daed536a970 | 568 | //pc.printf("\nSet Timer succesfully\n"); |
sherckuith | 1:4daed536a970 | 569 | fclose(fp2); |
sherckuith | 1:4daed536a970 | 570 | } else { |
sherckuith | 1:4daed536a970 | 571 | //pc.printf("Set Timer fail\n"); |
sherckuith | 1:4daed536a970 | 572 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 573 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 574 | lcd.printf(" Error! "); |
sherckuith | 1:4daed536a970 | 575 | wait(1); |
sherckuith | 1:4daed536a970 | 576 | } |
sherckuith | 1:4daed536a970 | 577 | } |
sherckuith | 1:4daed536a970 | 578 | led1=led2=led3=led4=0; |
sherckuith | 1:4daed536a970 | 579 | led5=led6=led7=led8=0; |
sherckuith | 1:4daed536a970 | 580 | |
sherckuith | 1:4daed536a970 | 581 | |
sherckuith | 1:4daed536a970 | 582 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 583 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 584 | lcd.printf("Iniciando aplicacion"); |
sherckuith | 1:4daed536a970 | 585 | wait(2); |
sherckuith | 1:4daed536a970 | 586 | |
sherckuith | 1:4daed536a970 | 587 | read_RAM(); |
sherckuith | 1:4daed536a970 | 588 | |
sherckuith | 1:4daed536a970 | 589 | my1307.gettime( &sec, &min, &hours, &day, &date, &month, &year); |
sherckuith | 1:4daed536a970 | 590 | my1307.read( 0x14, &Old_Speed_RAM); |
sherckuith | 1:4daed536a970 | 591 | my1307.read( 0x15, &Old_sense_RAM); |
sherckuith | 1:4daed536a970 | 592 | my1307.read( 0x16, &Old_Space_RAM); |
sherckuith | 1:4daed536a970 | 593 | led1=led2=led3=led4=0; |
sherckuith | 1:4daed536a970 | 594 | led5=led6=led7=led8=0; |
sherckuith | 1:4daed536a970 | 595 | |
sherckuith | 1:4daed536a970 | 596 | if(msd.connected()) { |
sherckuith | 1:4daed536a970 | 597 | FILE *fp1; |
sherckuith | 1:4daed536a970 | 598 | if ((fp1 = fopen( "/host/Registro.csv", "a"))!=NULL) { |
sherckuith | 1:4daed536a970 | 599 | fprintf(fp1,"%2d %2d/%2d/20%2d %2d:%2d:%2d %3d %3d %3d;\n",day,date,month,year,hours,min,sec,Old_Speed_RAM,Old_sense_RAM,Old_Space_RAM); |
sherckuith | 1:4daed536a970 | 600 | //pc.printf( "Dia:%2d Fecha:%2d/%2d/20%2d Hora:%2d:%2d:%2d Speed RAM:%3d Sense RAM:%3d Space RAM:%3d;\r\n",day,date,month,year,hours,min,sec,Old_Speed_RAM,Old_sense_RAM,Old_Space_RAM); |
sherckuith | 1:4daed536a970 | 601 | //pc.printf("\r\nRegistro OK\r\n"); |
sherckuith | 1:4daed536a970 | 602 | fclose(fp1); |
sherckuith | 1:4daed536a970 | 603 | } else { |
sherckuith | 1:4daed536a970 | 604 | //pc.printf("\r\nRegistre fail\r\n"); |
sherckuith | 1:4daed536a970 | 605 | //pc.printf( "Dia:%2d Fecha:%2d/%2d/20%2d Hora:%2d:%2d:%2d Speed RAM:%3d Sense RAM:%3d Space RAM:%3d;\r\n",day,date,month,year,hours,min,sec,Old_Speed_RAM,Old_sense_RAM,Old_Space_RAM); |
sherckuith | 1:4daed536a970 | 606 | } |
sherckuith | 1:4daed536a970 | 607 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 608 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 609 | lcd.printf(" Nueva "); |
sherckuith | 1:4daed536a970 | 610 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 611 | lcd.printf(" configuracion "); |
sherckuith | 1:4daed536a970 | 612 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 613 | lcd.printf(" satisfactoria "); |
sherckuith | 1:4daed536a970 | 614 | wait(3); |
sherckuith | 1:4daed536a970 | 615 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 616 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 617 | lcd.printf("Por favor remueva la"); |
sherckuith | 1:4daed536a970 | 618 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 619 | lcd.printf(" memoria USB ahora! "); |
sherckuith | 1:4daed536a970 | 620 | wait(5); |
sherckuith | 1:4daed536a970 | 621 | } |
sherckuith | 1:4daed536a970 | 622 | led1=led2=led3=led4=0; |
sherckuith | 1:4daed536a970 | 623 | led5=led6=led7=led8=0; |
sherckuith | 1:4daed536a970 | 624 | |
sherckuith | 1:4daed536a970 | 625 | |
sherckuith | 1:4daed536a970 | 626 | //pc.printf("\r\nRun_app Start\r\n"); |
sherckuith | 1:4daed536a970 | 627 | /* |
sherckuith | 1:4daed536a970 | 628 | PwmOut led1(LED1); |
sherckuith | 1:4daed536a970 | 629 | PwmOut led2(LED2); |
sherckuith | 1:4daed536a970 | 630 | PwmOut led3(LED3); |
sherckuith | 1:4daed536a970 | 631 | PwmOut led4(LED4); |
sherckuith | 1:4daed536a970 | 632 | */ |
sherckuith | 1:4daed536a970 | 633 | led1=led2=led3=led4=0; |
sherckuith | 1:4daed536a970 | 634 | led5=led6=led7=led8=0; |
sherckuith | 1:4daed536a970 | 635 | wait(0.5); |
sherckuith | 1:4daed536a970 | 636 | |
sherckuith | 1:4daed536a970 | 637 | FW=0; |
sherckuith | 1:4daed536a970 | 638 | RW=0; |
sherckuith | 1:4daed536a970 | 639 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 640 | int lcd_reset=0; |
sherckuith | 1:4daed536a970 | 641 | |
sherckuith | 1:4daed536a970 | 642 | while(1) { |
sherckuith | 1:4daed536a970 | 643 | /* |
sherckuith | 1:4daed536a970 | 644 | if(FLAG_DOOR_OFF==1) { |
sherckuith | 1:4daed536a970 | 645 | FLAG_DOOR_OFF=0; |
sherckuith | 1:4daed536a970 | 646 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 647 | lcd.printf(" Cerrando puerta "); |
sherckuith | 1:4daed536a970 | 648 | wait(2); |
sherckuith | 1:4daed536a970 | 649 | } |
sherckuith | 1:4daed536a970 | 650 | |
sherckuith | 1:4daed536a970 | 651 | if(FLAG_DOOR_ON==1) { |
sherckuith | 1:4daed536a970 | 652 | FLAG_DOOR_ON=0; |
sherckuith | 1:4daed536a970 | 653 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 654 | lcd.printf(" Abriendo puerta "); |
sherckuith | 1:4daed536a970 | 655 | wait(2); |
sherckuith | 1:4daed536a970 | 656 | } |
sherckuith | 1:4daed536a970 | 657 | |
sherckuith | 1:4daed536a970 | 658 | if(FLAG_NEW_PASS==1) { |
sherckuith | 1:4daed536a970 | 659 | FLAG_NEW_PASS=0; |
sherckuith | 1:4daed536a970 | 660 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 661 | lcd.printf(" Nueva clave "); |
sherckuith | 1:4daed536a970 | 662 | wait(2); |
sherckuith | 1:4daed536a970 | 663 | } |
sherckuith | 1:4daed536a970 | 664 | |
sherckuith | 1:4daed536a970 | 665 | if(FLAG_PUT_PASS==1) { |
sherckuith | 1:4daed536a970 | 666 | FLAG_PUT_PASS=0; |
sherckuith | 1:4daed536a970 | 667 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 668 | lcd.printf(" Ingrese clave "); |
sherckuith | 1:4daed536a970 | 669 | wait(2); |
sherckuith | 1:4daed536a970 | 670 | } |
sherckuith | 1:4daed536a970 | 671 | |
sherckuith | 1:4daed536a970 | 672 | if(FLAG_NEW_PASS_FULL==1) { |
sherckuith | 1:4daed536a970 | 673 | FLAG_NEW_PASS_FULL=0; |
sherckuith | 1:4daed536a970 | 674 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 675 | lcd.printf(" Nueva clave "); |
sherckuith | 1:4daed536a970 | 676 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 677 | lcd.printf("guardada en memoria!"); |
sherckuith | 1:4daed536a970 | 678 | wait(2); |
sherckuith | 1:4daed536a970 | 679 | } |
sherckuith | 1:4daed536a970 | 680 | */ |
sherckuith | 1:4daed536a970 | 681 | if(lcd_reset<=65535) { |
sherckuith | 1:4daed536a970 | 682 | if(lcd_reset==65535) { |
sherckuith | 1:4daed536a970 | 683 | lcd_reset=0; |
sherckuith | 1:4daed536a970 | 684 | TextLCD lcd(p11, p12, p13, p14, p15, p16, TextLCD::LCD20x4); // rs, e, d4-d7 |
sherckuith | 1:4daed536a970 | 685 | wait(0.10); |
sherckuith | 1:4daed536a970 | 686 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 687 | wait(0.10); |
sherckuith | 1:4daed536a970 | 688 | } |
sherckuith | 1:4daed536a970 | 689 | } |
sherckuith | 1:4daed536a970 | 690 | |
sherckuith | 1:4daed536a970 | 691 | lcd_reset++; |
sherckuith | 1:4daed536a970 | 692 | |
sherckuith | 1:4daed536a970 | 693 | wait(0.25); |
sherckuith | 1:4daed536a970 | 694 | //pc.printf("\r\nObstaculo 1: %8.6fcm\n",get_Z4()); |
sherckuith | 1:4daed536a970 | 695 | my1307.gettime( &sec, &min, &hours, &day, &date, &month, &year); |
sherckuith | 1:4daed536a970 | 696 | //pc.printf("RTC: [%2d:%.2d:%2d %2d/%2d/20%2d]\n",hours,min,sec,date,month,year); |
sherckuith | 1:4daed536a970 | 697 | Radar=get_Z4(); |
sherckuith | 1:4daed536a970 | 698 | |
sherckuith | 1:4daed536a970 | 699 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 700 | lcd.printf("Deteccion: %3.3fcm ",Radar); |
sherckuith | 1:4daed536a970 | 701 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 702 | lcd.printf(" %02d-%02d-%02d %02d-%02d-%02d ",get_start_date_ram, get_start_month_ram, get_start_year_ram, get_end_date_ram,get_end_month_ram,get_end_year_ram); |
sherckuith | 1:4daed536a970 | 703 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 704 | lcd.printf(" %02d:%02d:%02d %02d:%02d:%02d ",get_start_hour_ram, get_start_min_ram, get_start_sec_ram,get_end_hour_ram,get_end_min_ram,get_end_sec_ram); |
sherckuith | 1:4daed536a970 | 705 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 706 | lcd.printf(" %02d-%02d-%02d %02d:%02d:%02d ",date,month,year,hours,min,sec); |
sherckuith | 1:4daed536a970 | 707 | |
sherckuith | 1:4daed536a970 | 708 | int time_sec_onclock = 0, time_sec_start = 0, time_sec_end = 0; |
sherckuith | 1:4daed536a970 | 709 | |
sherckuith | 1:4daed536a970 | 710 | time_sec_onclock = (hours*60*60)+(min*60)+sec; |
sherckuith | 1:4daed536a970 | 711 | time_sec_start = (get_start_hour_ram*60*60)+(get_start_min_ram*60)+get_start_sec_ram; |
sherckuith | 1:4daed536a970 | 712 | time_sec_end = (get_end_hour_ram*60*60)+(get_end_min_ram*60)+get_end_sec_ram; |
sherckuith | 1:4daed536a970 | 713 | |
sherckuith | 1:4daed536a970 | 714 | float time_day_onclock = 0,time_day_start = 0,time_day_end = 0; |
sherckuith | 1:4daed536a970 | 715 | |
sherckuith | 1:4daed536a970 | 716 | time_day_onclock = (month*30.4166)-30.4166+date; |
sherckuith | 1:4daed536a970 | 717 | time_day_start = (get_start_month_ram*30.4166)-30.4166+get_start_date_ram; |
sherckuith | 1:4daed536a970 | 718 | time_day_end = (get_end_month_ram*30.4166)-30.4166+get_end_date_ram; |
chris | 0:144fed3d9420 | 719 | |
sherckuith | 1:4daed536a970 | 720 | if(time_day_onclock<=time_day_end && time_day_onclock>=time_day_start) { |
sherckuith | 1:4daed536a970 | 721 | if(time_sec_onclock<time_sec_end && time_sec_onclock>time_sec_start) { |
sherckuith | 1:4daed536a970 | 722 | //ejecucion de sensor de obstaculos |
sherckuith | 1:4daed536a970 | 723 | if(Radar<=get_space_ram*1.5) { |
sherckuith | 1:4daed536a970 | 724 | //pc.printf("Obstaculo 2: %8.6fcm\n",Radar); |
sherckuith | 1:4daed536a970 | 725 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 726 | lcd.printf(" Detectando...! "); |
sherckuith | 1:4daed536a970 | 727 | wait(1-sense_ram_powten_3); |
sherckuith | 1:4daed536a970 | 728 | Radar=get_Z4(); |
sherckuith | 1:4daed536a970 | 729 | if(Radar<=get_space_ram) { |
sherckuith | 1:4daed536a970 | 730 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 731 | lcd.printf(" Desplazando cuadro "); |
sherckuith | 1:4daed536a970 | 732 | //pc.printf("Obstaculo 3: %8.6fcm\n",Radar); |
sherckuith | 1:4daed536a970 | 733 | led1=1; |
sherckuith | 1:4daed536a970 | 734 | led5=1; |
sherckuith | 1:4daed536a970 | 735 | led2=0; |
sherckuith | 1:4daed536a970 | 736 | led6=0; |
sherckuith | 1:4daed536a970 | 737 | led3=0; |
sherckuith | 1:4daed536a970 | 738 | led7=0; |
sherckuith | 1:4daed536a970 | 739 | led4=0; |
sherckuith | 1:4daed536a970 | 740 | led8=0; |
sherckuith | 1:4daed536a970 | 741 | wait(0.025); |
sherckuith | 1:4daed536a970 | 742 | led1=0; |
sherckuith | 1:4daed536a970 | 743 | led5=0; |
sherckuith | 1:4daed536a970 | 744 | led2=1; |
sherckuith | 1:4daed536a970 | 745 | led6=1; |
sherckuith | 1:4daed536a970 | 746 | led3=0; |
sherckuith | 1:4daed536a970 | 747 | led7=0; |
sherckuith | 1:4daed536a970 | 748 | led4=0; |
sherckuith | 1:4daed536a970 | 749 | led8=0; |
sherckuith | 1:4daed536a970 | 750 | wait(0.025); |
sherckuith | 1:4daed536a970 | 751 | led1=0; |
sherckuith | 1:4daed536a970 | 752 | led5=0; |
sherckuith | 1:4daed536a970 | 753 | led2=0; |
sherckuith | 1:4daed536a970 | 754 | led6=0; |
sherckuith | 1:4daed536a970 | 755 | led3=1; |
sherckuith | 1:4daed536a970 | 756 | led7=1; |
sherckuith | 1:4daed536a970 | 757 | led4=0; |
sherckuith | 1:4daed536a970 | 758 | led8=0; |
sherckuith | 1:4daed536a970 | 759 | wait(0.025); |
sherckuith | 1:4daed536a970 | 760 | do { |
sherckuith | 1:4daed536a970 | 761 | FW=1; |
sherckuith | 1:4daed536a970 | 762 | RW=0; |
sherckuith | 1:4daed536a970 | 763 | led1=0; |
sherckuith | 1:4daed536a970 | 764 | led5=0; |
sherckuith | 1:4daed536a970 | 765 | led2=0; |
sherckuith | 1:4daed536a970 | 766 | led6=0; |
sherckuith | 1:4daed536a970 | 767 | led3=0; |
sherckuith | 1:4daed536a970 | 768 | led7=0; |
sherckuith | 1:4daed536a970 | 769 | led4=1; |
sherckuith | 1:4daed536a970 | 770 | led8=1; |
sherckuith | 1:4daed536a970 | 771 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 772 | lcd.printf(">>> >>> >>> >>> >>> "); |
sherckuith | 1:4daed536a970 | 773 | wait(0.025); |
sherckuith | 1:4daed536a970 | 774 | led1=0; |
sherckuith | 1:4daed536a970 | 775 | led5=0; |
sherckuith | 1:4daed536a970 | 776 | led2=0; |
sherckuith | 1:4daed536a970 | 777 | led6=0; |
sherckuith | 1:4daed536a970 | 778 | led3=1; |
sherckuith | 1:4daed536a970 | 779 | led7=1; |
sherckuith | 1:4daed536a970 | 780 | led4=0; |
sherckuith | 1:4daed536a970 | 781 | led8=0; |
sherckuith | 1:4daed536a970 | 782 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 783 | lcd.printf(" >>> >>> >>> >>> >>>"); |
sherckuith | 1:4daed536a970 | 784 | wait(0.025); |
sherckuith | 1:4daed536a970 | 785 | led1=0; |
sherckuith | 1:4daed536a970 | 786 | led5=0; |
sherckuith | 1:4daed536a970 | 787 | led2=1; |
sherckuith | 1:4daed536a970 | 788 | led6=1; |
sherckuith | 1:4daed536a970 | 789 | led3=0; |
sherckuith | 1:4daed536a970 | 790 | led7=0; |
sherckuith | 1:4daed536a970 | 791 | led4=0; |
sherckuith | 1:4daed536a970 | 792 | led8=0; |
sherckuith | 1:4daed536a970 | 793 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 794 | lcd.printf("> >>> >>> >>> >>> >>"); |
sherckuith | 1:4daed536a970 | 795 | wait(0.025); |
sherckuith | 1:4daed536a970 | 796 | led1=1; |
sherckuith | 1:4daed536a970 | 797 | led5=1; |
sherckuith | 1:4daed536a970 | 798 | led2=0; |
sherckuith | 1:4daed536a970 | 799 | led6=0; |
sherckuith | 1:4daed536a970 | 800 | led3=0; |
sherckuith | 1:4daed536a970 | 801 | led7=0; |
sherckuith | 1:4daed536a970 | 802 | led4=0; |
sherckuith | 1:4daed536a970 | 803 | led8=0; |
sherckuith | 1:4daed536a970 | 804 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 805 | lcd.printf(">> >>> >>> >>> >>> >"); |
sherckuith | 1:4daed536a970 | 806 | wait(0.025); |
sherckuith | 1:4daed536a970 | 807 | rigth=rigth_sense.read(); |
sherckuith | 1:4daed536a970 | 808 | } while(rigth<1); |
sherckuith | 1:4daed536a970 | 809 | //pc.printf("\r\nRIGHT_______: %8.6f\n",rigth); |
sherckuith | 1:4daed536a970 | 810 | FW=0; |
sherckuith | 1:4daed536a970 | 811 | RW=0; |
sherckuith | 1:4daed536a970 | 812 | wait(0.025); |
sherckuith | 1:4daed536a970 | 813 | led1=0; |
sherckuith | 1:4daed536a970 | 814 | led5=0; |
sherckuith | 1:4daed536a970 | 815 | led2=0; |
sherckuith | 1:4daed536a970 | 816 | led6=0; |
sherckuith | 1:4daed536a970 | 817 | led3=1; |
sherckuith | 1:4daed536a970 | 818 | led7=1; |
sherckuith | 1:4daed536a970 | 819 | led4=0; |
sherckuith | 1:4daed536a970 | 820 | led8=0; |
sherckuith | 1:4daed536a970 | 821 | wait(0.025); |
sherckuith | 1:4daed536a970 | 822 | led1=0; |
sherckuith | 1:4daed536a970 | 823 | led5=0; |
sherckuith | 1:4daed536a970 | 824 | led2=1; |
sherckuith | 1:4daed536a970 | 825 | led6=1; |
sherckuith | 1:4daed536a970 | 826 | led3=0; |
sherckuith | 1:4daed536a970 | 827 | led7=0; |
sherckuith | 1:4daed536a970 | 828 | led4=0; |
sherckuith | 1:4daed536a970 | 829 | led8=0; |
sherckuith | 1:4daed536a970 | 830 | wait(0.025); |
sherckuith | 1:4daed536a970 | 831 | //wait(3-sense_ram_powten_3); |
sherckuith | 1:4daed536a970 | 832 | do { |
sherckuith | 1:4daed536a970 | 833 | FW=0; |
sherckuith | 1:4daed536a970 | 834 | RW=1; |
sherckuith | 1:4daed536a970 | 835 | led1=1; |
sherckuith | 1:4daed536a970 | 836 | led5=1; |
sherckuith | 1:4daed536a970 | 837 | led2=0; |
sherckuith | 1:4daed536a970 | 838 | led6=0; |
sherckuith | 1:4daed536a970 | 839 | led3=0; |
sherckuith | 1:4daed536a970 | 840 | led7=0; |
sherckuith | 1:4daed536a970 | 841 | led4=0; |
sherckuith | 1:4daed536a970 | 842 | led8=0; |
sherckuith | 1:4daed536a970 | 843 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 844 | lcd.printf("<<< <<< <<< <<< <<< "); |
sherckuith | 1:4daed536a970 | 845 | wait(0.025); |
sherckuith | 1:4daed536a970 | 846 | led1=0; |
sherckuith | 1:4daed536a970 | 847 | led5=0; |
sherckuith | 1:4daed536a970 | 848 | led2=0; |
sherckuith | 1:4daed536a970 | 849 | led6=0; |
sherckuith | 1:4daed536a970 | 850 | led3=0; |
sherckuith | 1:4daed536a970 | 851 | led7=0; |
sherckuith | 1:4daed536a970 | 852 | led4=1; |
sherckuith | 1:4daed536a970 | 853 | led8=1; |
sherckuith | 1:4daed536a970 | 854 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 855 | lcd.printf(" <<< <<< <<< <<< <<<"); |
sherckuith | 1:4daed536a970 | 856 | wait(0.025); |
sherckuith | 1:4daed536a970 | 857 | led1=0; |
sherckuith | 1:4daed536a970 | 858 | led5=0; |
sherckuith | 1:4daed536a970 | 859 | led2=0; |
sherckuith | 1:4daed536a970 | 860 | led6=0; |
sherckuith | 1:4daed536a970 | 861 | led3=1; |
sherckuith | 1:4daed536a970 | 862 | led7=1; |
sherckuith | 1:4daed536a970 | 863 | led4=0; |
sherckuith | 1:4daed536a970 | 864 | led8=0; |
sherckuith | 1:4daed536a970 | 865 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 866 | lcd.printf("< <<< <<< <<< <<< <<"); |
sherckuith | 1:4daed536a970 | 867 | wait(0.025); |
sherckuith | 1:4daed536a970 | 868 | led1=0; |
sherckuith | 1:4daed536a970 | 869 | led5=0; |
sherckuith | 1:4daed536a970 | 870 | led2=1; |
sherckuith | 1:4daed536a970 | 871 | led6=1; |
sherckuith | 1:4daed536a970 | 872 | led3=0; |
sherckuith | 1:4daed536a970 | 873 | led7=0; |
sherckuith | 1:4daed536a970 | 874 | led4=0; |
sherckuith | 1:4daed536a970 | 875 | led8=0; |
sherckuith | 1:4daed536a970 | 876 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 877 | lcd.printf("<< <<< <<< <<< <<< <"); |
sherckuith | 1:4daed536a970 | 878 | wait(0.025); |
sherckuith | 1:4daed536a970 | 879 | left=left_sense.read(); |
sherckuith | 1:4daed536a970 | 880 | } while(left<1); |
sherckuith | 1:4daed536a970 | 881 | //pc.printf("\r\nLEFT_______: %8.6f\n",left); |
sherckuith | 1:4daed536a970 | 882 | FW=0; |
sherckuith | 1:4daed536a970 | 883 | RW=0; |
sherckuith | 1:4daed536a970 | 884 | //wait(1-sense_ram_powten_3); |
sherckuith | 1:4daed536a970 | 885 | led1=led2=led3=led4=0; |
sherckuith | 1:4daed536a970 | 886 | led5=led6=led7=led8=0; |
sherckuith | 1:4daed536a970 | 887 | } |
sherckuith | 1:4daed536a970 | 888 | } |
sherckuith | 1:4daed536a970 | 889 | } |
sherckuith | 1:4daed536a970 | 890 | } |
sherckuith | 1:4daed536a970 | 891 | } |
sherckuith | 1:4daed536a970 | 892 | |
sherckuith | 1:4daed536a970 | 893 | } |
sherckuith | 1:4daed536a970 | 894 | |
sherckuith | 1:4daed536a970 | 895 | float get_Z4() |
sherckuith | 1:4daed536a970 | 896 | { |
sherckuith | 1:4daed536a970 | 897 | prom=0; |
sherckuith | 1:4daed536a970 | 898 | cnt_Z4=0; |
sherckuith | 1:4daed536a970 | 899 | result=0; |
sherckuith | 1:4daed536a970 | 900 | for(interval=0; interval<5; interval++) { |
sherckuith | 1:4daed536a970 | 901 | wait(1/20); |
sherckuith | 1:4daed536a970 | 902 | adc = ain.read(); // read analog as a float |
sherckuith | 1:4daed536a970 | 903 | if(adc >= 0 && adc <= 0.508) { |
sherckuith | 1:4daed536a970 | 904 | cm5 = ((adc * 5)*2.54)*100; |
sherckuith | 1:4daed536a970 | 905 | prom=prom+(cm5-10); |
sherckuith | 1:4daed536a970 | 906 | cnt_Z4++; |
sherckuith | 1:4daed536a970 | 907 | } |
sherckuith | 1:4daed536a970 | 908 | } |
sherckuith | 1:4daed536a970 | 909 | result=prom/cnt_Z4; |
sherckuith | 1:4daed536a970 | 910 | //pc.printf("#:%2d P:%5.3f D:%3.3f cm\n", cnt_Z4, prom, result); |
sherckuith | 1:4daed536a970 | 911 | //led1=led2=led3=led4=1;led5=led6=led7=led8=1; |
sherckuith | 1:4daed536a970 | 912 | //wait(1/20); |
sherckuith | 1:4daed536a970 | 913 | return result; |
sherckuith | 1:4daed536a970 | 914 | } |
sherckuith | 1:4daed536a970 | 915 | |
sherckuith | 1:4daed536a970 | 916 | |
sherckuith | 1:4daed536a970 | 917 | void read_RAM() |
sherckuith | 1:4daed536a970 | 918 | { |
sherckuith | 1:4daed536a970 | 919 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 920 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 921 | lcd.printf("Leyendo datos desde"); |
sherckuith | 1:4daed536a970 | 922 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 923 | lcd.printf("la memoria..."); |
sherckuith | 1:4daed536a970 | 924 | wait(1); |
sherckuith | 1:4daed536a970 | 925 | |
sherckuith | 1:4daed536a970 | 926 | //pc.printf("\r\nVariables leidas:\r\n"); |
sherckuith | 1:4daed536a970 | 927 | |
sherckuith | 1:4daed536a970 | 928 | my1307.read( 0x08, &get_start_date_ram); |
sherckuith | 1:4daed536a970 | 929 | my1307.read( 0x09, &get_start_month_ram); |
sherckuith | 1:4daed536a970 | 930 | my1307.read( 0x0A, &get_start_year_ram); |
sherckuith | 1:4daed536a970 | 931 | my1307.read( 0x0B, &get_start_hour_ram); |
sherckuith | 1:4daed536a970 | 932 | my1307.read( 0x0C, &get_start_min_ram); |
sherckuith | 1:4daed536a970 | 933 | my1307.read( 0x0D, &get_start_sec_ram); |
sherckuith | 1:4daed536a970 | 934 | |
sherckuith | 1:4daed536a970 | 935 | my1307.read( 0x0E, &get_end_date_ram); |
sherckuith | 1:4daed536a970 | 936 | my1307.read( 0x0F, &get_end_month_ram); |
sherckuith | 1:4daed536a970 | 937 | my1307.read( 0x10, &get_end_year_ram); |
sherckuith | 1:4daed536a970 | 938 | my1307.read( 0x11, &get_end_hour_ram); |
sherckuith | 1:4daed536a970 | 939 | my1307.read( 0x12, &get_end_min_ram); |
sherckuith | 1:4daed536a970 | 940 | my1307.read( 0x13, &get_end_sec_ram); |
sherckuith | 1:4daed536a970 | 941 | |
sherckuith | 1:4daed536a970 | 942 | my1307.read( 0x14, &get_speed_ram); |
sherckuith | 1:4daed536a970 | 943 | my1307.read( 0x15, &get_sense_ram); |
sherckuith | 1:4daed536a970 | 944 | my1307.read( 0x16, &get_space_ram); |
sherckuith | 1:4daed536a970 | 945 | |
sherckuith | 1:4daed536a970 | 946 | //pc.printf( "Start:%2d/%2d/20%2d %2d:%2d:%2d \r\nEnd:%2d/%2d/20%2d %2d:%2d:%2d \r\nSpeed:%3d \r\nSense:%3d \r\nSpace:%3d\r\n",get_start_date_ram,get_start_month_ram,get_start_year_ram,get_start_hour_ram,get_start_min_ram,get_start_sec_ram,get_end_date_ram,get_end_month_ram,get_end_year_ram,get_end_hour_ram,get_end_min_ram,get_end_sec_ram,get_speed_ram,get_sense_ram,get_space_ram); |
sherckuith | 1:4daed536a970 | 947 | if(flag_usb_1 == 0 && flag_usb_2 ==0) { |
sherckuith | 1:4daed536a970 | 948 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 949 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 950 | lcd.printf("F.Inicio: %02d-%02d-20%02d",get_start_date_ram,get_start_month_ram,get_start_year_ram); |
sherckuith | 1:4daed536a970 | 951 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 952 | lcd.printf("F.Fin : %02d-%02d-20%02d",get_end_date_ram,get_end_month_ram,get_end_year_ram); |
sherckuith | 1:4daed536a970 | 953 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 954 | lcd.printf("H.Inicio: %02d:%02d:%02d",get_start_hour_ram,get_start_min_ram,get_start_sec_ram); |
sherckuith | 1:4daed536a970 | 955 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 956 | lcd.printf("H.Fin : %02d:%02d:%02d",get_end_hour_ram,get_end_min_ram,get_end_sec_ram); |
sherckuith | 1:4daed536a970 | 957 | wait(5); |
sherckuith | 1:4daed536a970 | 958 | |
sherckuith | 1:4daed536a970 | 959 | lcd.cls(); |
sherckuith | 1:4daed536a970 | 960 | lcd.locate(0,0); |
sherckuith | 1:4daed536a970 | 961 | lcd.printf("Configuracion actual"); |
sherckuith | 1:4daed536a970 | 962 | lcd.locate(0,1); |
sherckuith | 1:4daed536a970 | 963 | lcd.printf("Velocidad : %3d%",get_speed_ram); |
sherckuith | 1:4daed536a970 | 964 | lcd.locate(0,2); |
sherckuith | 1:4daed536a970 | 965 | lcd.printf("Sencibilidad : %3d%",get_sense_ram); |
sherckuith | 1:4daed536a970 | 966 | lcd.locate(0,3); |
sherckuith | 1:4daed536a970 | 967 | lcd.printf("Distancia max: %3d",get_space_ram); |
sherckuith | 1:4daed536a970 | 968 | wait(5); |
sherckuith | 1:4daed536a970 | 969 | } |
sherckuith | 1:4daed536a970 | 970 | if (get_speed_ram<100) { |
sherckuith | 1:4daed536a970 | 971 | speed_ram_powten_3 = get_speed_ram%100; |
sherckuith | 1:4daed536a970 | 972 | speed_ram_powten_3 = speed_ram_powten_3/100; |
sherckuith | 1:4daed536a970 | 973 | } else |
sherckuith | 1:4daed536a970 | 974 | speed_ram_powten_3 = get_speed_ram/get_speed_ram; |
sherckuith | 1:4daed536a970 | 975 | |
sherckuith | 1:4daed536a970 | 976 | if (get_sense_ram<100) { |
sherckuith | 1:4daed536a970 | 977 | sense_ram_powten_3 = get_sense_ram%100; |
sherckuith | 1:4daed536a970 | 978 | sense_ram_powten_3 = sense_ram_powten_3/100; |
sherckuith | 1:4daed536a970 | 979 | } else |
sherckuith | 1:4daed536a970 | 980 | sense_ram_powten_3 = get_sense_ram/get_sense_ram; |
sherckuith | 1:4daed536a970 | 981 | |
sherckuith | 1:4daed536a970 | 982 | //pc.printf("\r\nSpeed result: %f\r\n",speed_ram_powten_3); |
sherckuith | 1:4daed536a970 | 983 | //pc.printf("Sense result: %f\r\n",sense_ram_powten_3); |
sherckuith | 1:4daed536a970 | 984 | //pc.printf("Space result: %d\r\n",get_space_ram); |
sherckuith | 1:4daed536a970 | 985 | //pc.printf("/******************************************************************************************************************/\r\n"); |
sherckuith | 1:4daed536a970 | 986 | } |
sherckuith | 1:4daed536a970 | 987 | |
sherckuith | 1:4daed536a970 | 988 | |
sherckuith | 1:4daed536a970 | 989 | void Set_Time(int set_sec, int set_min, int set_hours, int set_day, int set_date, int set_month, int set_year) |
sherckuith | 1:4daed536a970 | 990 | { |
sherckuith | 1:4daed536a970 | 991 | my1307.twentyfour_hour(); |
sherckuith | 1:4daed536a970 | 992 | my1307.settime( set_sec, set_min, set_hours, set_day, set_date, set_month, set_year); // Set the time on the DS1307 |
sherckuith | 1:4daed536a970 | 993 | my1307.write(0x07,0x10); |
sherckuith | 1:4daed536a970 | 994 | } |
sherckuith | 1:4daed536a970 | 995 | |
sherckuith | 1:4daed536a970 | 996 | |
sherckuith | 1:4daed536a970 | 997 | |
sherckuith | 1:4daed536a970 | 998 | uint32_t cbAfterInput(uint32_t index) |
sherckuith | 1:4daed536a970 | 999 | { |
sherckuith | 1:4daed536a970 | 1000 | //lcd.printf("TEST\n"); |
sherckuith | 1:4daed536a970 | 1001 | ////pc.printf("Indice: %d\n", index); |
sherckuith | 1:4daed536a970 | 1002 | ////pc.printf("Tecla: %c\n", Keytable[index]); |
sherckuith | 1:4daed536a970 | 1003 | //led3!=led3; |
sherckuith | 1:4daed536a970 | 1004 | |
sherckuith | 1:4daed536a970 | 1005 | if (index == 12 || cnt>=5) { |
sherckuith | 1:4daed536a970 | 1006 | ////pc.printf("cnt:%i\n",cnt); |
sherckuith | 1:4daed536a970 | 1007 | if(cnt==5) { |
sherckuith | 1:4daed536a970 | 1008 | FLAG_NEW_PASS=1; |
sherckuith | 1:4daed536a970 | 1009 | } |
sherckuith | 1:4daed536a970 | 1010 | led1=1; |
sherckuith | 1:4daed536a970 | 1011 | led5=1; //Show that we are alive |
sherckuith | 1:4daed536a970 | 1012 | wait(0.5); |
sherckuith | 1:4daed536a970 | 1013 | led1=0; |
sherckuith | 1:4daed536a970 | 1014 | led5=0; |
sherckuith | 1:4daed536a970 | 1015 | cnt++; |
sherckuith | 1:4daed536a970 | 1016 | if (cnt>=7 && j<=6) { |
sherckuith | 1:4daed536a970 | 1017 | ////pc.printf("Index2:%d ===> Key2:%c\n", index, Keytable[index]); |
sherckuith | 1:4daed536a970 | 1018 | j++; |
sherckuith | 1:4daed536a970 | 1019 | my1307.write( 24+j, index); |
sherckuith | 1:4daed536a970 | 1020 | led2=1; |
sherckuith | 1:4daed536a970 | 1021 | led6=1; //Show that we are alive |
sherckuith | 1:4daed536a970 | 1022 | wait(0.2); |
sherckuith | 1:4daed536a970 | 1023 | led2=0; |
sherckuith | 1:4daed536a970 | 1024 | led6=0; |
sherckuith | 1:4daed536a970 | 1025 | |
sherckuith | 1:4daed536a970 | 1026 | my1307.read( 24+j, &key); |
sherckuith | 1:4daed536a970 | 1027 | ////pc.printf("J:%d, Key EEprom:%d, cnt:%i\n",j, key,cnt); |
sherckuith | 1:4daed536a970 | 1028 | |
sherckuith | 1:4daed536a970 | 1029 | if(j==6) { |
sherckuith | 1:4daed536a970 | 1030 | FLAG_NEW_PASS_FULL=1; |
sherckuith | 1:4daed536a970 | 1031 | ////pc.printf("New Pass was completed\n"); |
sherckuith | 1:4daed536a970 | 1032 | j=0; |
sherckuith | 1:4daed536a970 | 1033 | cnt=1; |
sherckuith | 1:4daed536a970 | 1034 | led1=led2=led3=led4=1; |
sherckuith | 1:4daed536a970 | 1035 | led5=led6=led7=led8=1; |
sherckuith | 1:4daed536a970 | 1036 | wait(3); |
sherckuith | 1:4daed536a970 | 1037 | led1=led2=led3=led4=0; |
sherckuith | 1:4daed536a970 | 1038 | led5=led6=led7=led8=0; |
sherckuith | 1:4daed536a970 | 1039 | |
sherckuith | 1:4daed536a970 | 1040 | } |
sherckuith | 1:4daed536a970 | 1041 | } |
sherckuith | 1:4daed536a970 | 1042 | } else if (index == 14 || pass>0) { |
sherckuith | 1:4daed536a970 | 1043 | FLAG_PUT_PASS=1; |
sherckuith | 1:4daed536a970 | 1044 | ////pc.printf("index:%i, pass:%i\n", index,pass); |
sherckuith | 1:4daed536a970 | 1045 | led1=1; |
sherckuith | 1:4daed536a970 | 1046 | led5=1; //Show that we are alive |
sherckuith | 1:4daed536a970 | 1047 | wait(0.5); |
sherckuith | 1:4daed536a970 | 1048 | led1=0; |
sherckuith | 1:4daed536a970 | 1049 | led5=0; |
sherckuith | 1:4daed536a970 | 1050 | pass++; |
sherckuith | 1:4daed536a970 | 1051 | if (pass>1 && l<=6) { |
sherckuith | 1:4daed536a970 | 1052 | data[pass-2]= index; |
sherckuith | 1:4daed536a970 | 1053 | ////pc.printf("J:%d, data[%d] = %d;\n", l, pass-2, index); |
sherckuith | 1:4daed536a970 | 1054 | led2=1; |
sherckuith | 1:4daed536a970 | 1055 | led6=1; //Show that we are alive |
sherckuith | 1:4daed536a970 | 1056 | wait(0.2); |
sherckuith | 1:4daed536a970 | 1057 | led2=0; |
sherckuith | 1:4daed536a970 | 1058 | led6=0; |
sherckuith | 1:4daed536a970 | 1059 | |
sherckuith | 1:4daed536a970 | 1060 | l++; |
sherckuith | 1:4daed536a970 | 1061 | if(l==6) { |
sherckuith | 1:4daed536a970 | 1062 | ////pc.printf("Pass was completed\n"); |
sherckuith | 1:4daed536a970 | 1063 | l=0; |
sherckuith | 1:4daed536a970 | 1064 | pass=0; |
sherckuith | 1:4daed536a970 | 1065 | //comprobar clave |
sherckuith | 1:4daed536a970 | 1066 | my1307.read( 25, &key0); |
sherckuith | 1:4daed536a970 | 1067 | my1307.read( 26, &key1); |
sherckuith | 1:4daed536a970 | 1068 | my1307.read( 27, &key2); |
sherckuith | 1:4daed536a970 | 1069 | my1307.read( 28, &key3); |
sherckuith | 1:4daed536a970 | 1070 | my1307.read( 29, &key4); |
sherckuith | 1:4daed536a970 | 1071 | my1307.read( 30, &key5); |
sherckuith | 1:4daed536a970 | 1072 | |
sherckuith | 1:4daed536a970 | 1073 | if(data[0]==key0 && data[1]==key1 && data[2]==key2 && data[3]==key3 && data[4]==key4 && data[5]==key5) { |
sherckuith | 1:4daed536a970 | 1074 | led1=led3=1; |
sherckuith | 1:4daed536a970 | 1075 | led5=led7=1; |
sherckuith | 1:4daed536a970 | 1076 | door_off = 1; |
sherckuith | 1:4daed536a970 | 1077 | wait(1.200); |
sherckuith | 1:4daed536a970 | 1078 | door_off = 0; |
sherckuith | 1:4daed536a970 | 1079 | FLAG_DOOR_OFF=1; |
sherckuith | 1:4daed536a970 | 1080 | ////pc.printf("Door OPEN\n"); |
sherckuith | 1:4daed536a970 | 1081 | wait(2); |
sherckuith | 1:4daed536a970 | 1082 | led1=led3=0; |
sherckuith | 1:4daed536a970 | 1083 | led5=led7=0; |
sherckuith | 1:4daed536a970 | 1084 | } else { |
sherckuith | 1:4daed536a970 | 1085 | led2=led4=1; |
sherckuith | 1:4daed536a970 | 1086 | led6=led8=1; |
sherckuith | 1:4daed536a970 | 1087 | door_on = 1; |
sherckuith | 1:4daed536a970 | 1088 | wait(1.200); |
sherckuith | 1:4daed536a970 | 1089 | door_on = 0; |
sherckuith | 1:4daed536a970 | 1090 | FLAG_DOOR_ON=1; |
sherckuith | 1:4daed536a970 | 1091 | ////pc.printf("Door Closed\n"); |
sherckuith | 1:4daed536a970 | 1092 | wait(2); |
sherckuith | 1:4daed536a970 | 1093 | led2=led4=0; |
sherckuith | 1:4daed536a970 | 1094 | led6=led8=0; |
sherckuith | 1:4daed536a970 | 1095 | } |
sherckuith | 1:4daed536a970 | 1096 | } |
sherckuith | 1:4daed536a970 | 1097 | } |
sherckuith | 1:4daed536a970 | 1098 | } |
sherckuith | 1:4daed536a970 | 1099 | |
sherckuith | 1:4daed536a970 | 1100 | return 0; |
sherckuith | 1:4daed536a970 | 1101 | } |