![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
pin.c@219:2d3475d0dd1b, 2017-09-27 (annotated)
- Committer:
- Kovalev_D
- Date:
- Wed Sep 27 13:09:24 2017 +0000
- Revision:
- 219:2d3475d0dd1b
- Parent:
- 218:b4067cac75c0
hnjtfgyy
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kovalev_D | 28:1c9acd3b224d | 1 | #include "Global.h" |
Kovalev_D | 208:19150d2b528f | 2 | int Try=0,TimeDischarg=0; |
Kovalev_D | 208:19150d2b528f | 3 | int Light=0; |
Kovalev_D | 28:1c9acd3b224d | 4 | void PinCheng(void) |
Kovalev_D | 28:1c9acd3b224d | 5 | { |
Kovalev_D | 40:8a6494f61326 | 6 | //================ блок управления ногой поджига====================== |
Kovalev_D | 40:8a6494f61326 | 7 | if((Gyro.PinReg & PinRegBitD) != (Gyro.PinRegOld & PinRegBitD)) {//если текушее состояние бита поджига в регистре ног отличается от предыдущего то: |
Kovalev_D | 40:8a6494f61326 | 8 | if(Gyro.PinReg & PinRegBitD) LightUpON else LightUpOFF//если бита поджига еденица то включить поджиг если 0 отключить |
Kovalev_D | 40:8a6494f61326 | 9 | } |
igor_v | 42:6fc307c4963e | 10 | |
Kovalev_D | 40:8a6494f61326 | 11 | //============= блок управления подсветкой====================== |
Kovalev_D | 40:8a6494f61326 | 12 | if((Gyro.PinReg & PinRegBitL) != (Gyro.PinRegOld & PinRegBitL)) { |
Kovalev_D | 40:8a6494f61326 | 13 | if(Gyro.PinReg & PinRegBitL) BackLightON else BackLightOFF |
Kovalev_D | 40:8a6494f61326 | 14 | } |
Kovalev_D | 203:3a6615de9581 | 15 | /* |
Kovalev_D | 40:8a6494f61326 | 16 | //============= блок управления вибро нога 1====================== |
Kovalev_D | 40:8a6494f61326 | 17 | if((Gyro.PinReg & PinRegBit_1V) != (Gyro.PinRegOld & PinRegBit_1V)) { |
Kovalev_D | 47:d902ef6f7564 | 18 | if(Gyro.PinReg & PinRegBit_1V) ClrV1 else SetV1 |
Kovalev_D | 40:8a6494f61326 | 19 | } |
igor_v | 42:6fc307c4963e | 20 | |
Kovalev_D | 40:8a6494f61326 | 21 | //============= блок управления вибро нога 2====================== |
Kovalev_D | 40:8a6494f61326 | 22 | if((Gyro.PinReg & PinRegBit_2V) != (Gyro.PinRegOld & PinRegBit_2V)) { |
Kovalev_D | 47:d902ef6f7564 | 23 | if(Gyro.PinReg & PinRegBit_2V) ClrV2 else SetV2 |
Kovalev_D | 40:8a6494f61326 | 24 | } |
Kovalev_D | 188:4c523cc373cc | 25 | */ |
Kovalev_D | 47:d902ef6f7564 | 26 | |
Kovalev_D | 47:d902ef6f7564 | 27 | if((Gyro.PinReg & PinRegBitTXE) != (Gyro.PinRegOld & PinRegBitTXE)) { |
Kovalev_D | 47:d902ef6f7564 | 28 | if(Gyro.PinReg & PinRegBitTXE) TXOn else TXOff |
Kovalev_D | 47:d902ef6f7564 | 29 | } |
Kovalev_D | 190:289514f730ee | 30 | Gyro.PinRegOld = Gyro.PinReg; //сохранение текущего регистра как старого для следующего такта сравнения. |
Kovalev_D | 190:289514f730ee | 31 | } |
Kovalev_D | 190:289514f730ee | 32 | |
Kovalev_D | 28:1c9acd3b224d | 33 | |
Kovalev_D | 190:289514f730ee | 34 | void Discharg ()//проверка битового поля поджига и установка значения бита поджига |
Kovalev_D | 208:19150d2b528f | 35 | { |
Kovalev_D | 208:19150d2b528f | 36 | /* sprintf((Time),"%d %d\r\n",Gyro.RgConA, Gyro.RgConB); |
Kovalev_D | 208:19150d2b528f | 37 | WriteCon(Time); */ |
Kovalev_D | 208:19150d2b528f | 38 | |
Kovalev_D | 190:289514f730ee | 39 | if (Gyro.Discharg) |
Kovalev_D | 208:19150d2b528f | 40 | { |
Kovalev_D | 218:b4067cac75c0 | 41 | if(Gyro.LG_Type==1) {/*Spi.DAC_A=(unsigned int)(26000);*/}//Spi.DAC_A = (unsigned int)(32767-(GyroP.Str.DAC_current_Work>>1)); |
Kovalev_D | 211:ac8251b067d2 | 42 | else Spi.DAC_A =(((int)(GyroP.Str.DAC_current_Start*0.98+0x7fff) & 0xffff)); |
Kovalev_D | 211:ac8251b067d2 | 43 | |
Kovalev_D | 208:19150d2b528f | 44 | Gyro.Discharg = Gyro.Discharg >> 1; |
Kovalev_D | 209:224e7331a061 | 45 | if(!Gyro.LaserOn) |
Kovalev_D | 209:224e7331a061 | 46 | { |
Kovalev_D | 208:19150d2b528f | 47 | Gyro.RgConA = 0x0000; |
Kovalev_D | 208:19150d2b528f | 48 | Gyro.RgConB = 0x0000; |
Kovalev_D | 209:224e7331a061 | 49 | } |
Kovalev_D | 190:289514f730ee | 50 | //Проверка здвигового поля(последовательности) поджига |
Kovalev_D | 190:289514f730ee | 51 | //если последний бит 1 то установить бит поджига в еденицу, иначе в 0; |
Kovalev_D | 208:19150d2b528f | 52 | if (Gyro.Discharg & 0x1) Gyro.PinReg |= PinRegBitD; |
Kovalev_D | 208:19150d2b528f | 53 | else Gyro.PinReg &= ~PinRegBitD; |
Kovalev_D | 190:289514f730ee | 54 | } |
Kovalev_D | 208:19150d2b528f | 55 | else if(TimeDischarg<3) |
Kovalev_D | 208:19150d2b528f | 56 | { |
Kovalev_D | 208:19150d2b528f | 57 | TimeDischarg++; |
Kovalev_D | 208:19150d2b528f | 58 | if(TimeDischarg==1) |
Kovalev_D | 208:19150d2b528f | 59 | { |
Kovalev_D | 213:9953db9543d6 | 60 | if (Spi.ADC5>30000) |
Kovalev_D | 208:19150d2b528f | 61 | { |
Kovalev_D | 208:19150d2b528f | 62 | if (Try<10) |
Kovalev_D | 208:19150d2b528f | 63 | { |
Kovalev_D | 218:b4067cac75c0 | 64 | Spi.DAC_A-=300; |
Kovalev_D | 208:19150d2b528f | 65 | Gyro.Discharg = StartDischarg << ShiftStart0; |
Kovalev_D | 208:19150d2b528f | 66 | Gyro.BackLight = StartBackLight << ShiftStart0; |
Kovalev_D | 208:19150d2b528f | 67 | TimeDischarg=0; |
Kovalev_D | 208:19150d2b528f | 68 | Try++; |
Kovalev_D | 208:19150d2b528f | 69 | } |
Kovalev_D | 218:b4067cac75c0 | 70 | } |
Kovalev_D | 208:19150d2b528f | 71 | else |
Kovalev_D | 208:19150d2b528f | 72 | { |
Kovalev_D | 209:224e7331a061 | 73 | if(!Gyro.LaserOn) |
Kovalev_D | 209:224e7331a061 | 74 | { |
Kovalev_D | 208:19150d2b528f | 75 | Gyro.LaserOn=1; |
Kovalev_D | 211:ac8251b067d2 | 76 | if(Gyro.LG_Type==1) Gyro.RgConA = 0xff; |
Kovalev_D | 211:ac8251b067d2 | 77 | else Gyro.RgConA = 0xfd; |
Kovalev_D | 209:224e7331a061 | 78 | Gyro.RgConB = 0x4; |
Kovalev_D | 209:224e7331a061 | 79 | } |
Kovalev_D | 208:19150d2b528f | 80 | TimeDischarg=5; |
Kovalev_D | 208:19150d2b528f | 81 | Try=0; |
Kovalev_D | 213:9953db9543d6 | 82 | if(Gyro.LG_Type==1){}// Spi.DAC_A = (unsigned int)(32767-(GyroP.Str.DAC_current_Work>>1)); |
Kovalev_D | 213:9953db9543d6 | 83 | else Spi.DAC_A = ((((int)(GyroP.Str.DAC_current_Work+0x7fff) & 0xffff)+22544)*0.65); |
Kovalev_D | 208:19150d2b528f | 84 | } |
Kovalev_D | 208:19150d2b528f | 85 | } |
Kovalev_D | 208:19150d2b528f | 86 | } |
Kovalev_D | 190:289514f730ee | 87 | } |
Kovalev_D | 190:289514f730ee | 88 | void BackLight () |
Kovalev_D | 190:289514f730ee | 89 | { |
Kovalev_D | 190:289514f730ee | 90 | if (Gyro.BackLight) |
Kovalev_D | 208:19150d2b528f | 91 | { Gyro.BackLight = Gyro.BackLight >> 1; |
Kovalev_D | 190:289514f730ee | 92 | //Проверка здвигового поля(последовательности) подсветки |
Kovalev_D | 190:289514f730ee | 93 | //если последний бит в битовом поле 1 то установить бит подсветки в еденицу, иначе в 0; |
Kovalev_D | 208:19150d2b528f | 94 | if (Gyro.BackLight & 0x1) Gyro.PinReg |= PinRegBitL; else Gyro.PinReg &= ~PinRegBitL; |
Kovalev_D | 208:19150d2b528f | 95 | } |
Kovalev_D | 28:1c9acd3b224d | 96 | } |