Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed DMX TextLCD mbed-rtos
main.cpp@36:dba7a0094213, 2016-05-23 (annotated)
- Committer:
- Ayrton_L
- Date:
- Mon May 23 17:39:39 2016 +0000
- Revision:
- 36:dba7a0094213
- Parent:
- 35:23656910be93
Menu fixed
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Ayrton_L | 35:23656910be93 | 1 | #include "main.h" |
| Ayrton_L | 28:4b327f1cb9cb | 2 | |
| Ayrton_L | 34:fc85eeb84a93 | 3 | void V_EnableRotary() |
| Ayrton_L | 34:fc85eeb84a93 | 4 | { |
| Ayrton_L | 34:fc85eeb84a93 | 5 | RightTwist.rise(&V_Right); |
| Ayrton_L | 34:fc85eeb84a93 | 6 | LeftTwist.rise(&V_Left); |
| Ayrton_L | 34:fc85eeb84a93 | 7 | } |
| Ayrton_L | 34:fc85eeb84a93 | 8 | |
| Ayrton_L | 36:dba7a0094213 | 9 | void V_GeneralTxt(uint32_t I32_Line) |
| Ayrton_L | 36:dba7a0094213 | 10 | { |
| Ayrton_L | 36:dba7a0094213 | 11 | Sc.V_Clear(); |
| Ayrton_L | 36:dba7a0094213 | 12 | char *C_Line=new char[S_Menu[I32_Line].size()+1]; |
| Ayrton_L | 36:dba7a0094213 | 13 | C_Line[S_Menu[I32_Line].size()] = 0; |
| Ayrton_L | 36:dba7a0094213 | 14 | memcpy(C_Line, S_Menu[I32_Line].c_str(), S_Menu[I32_Line].size()); |
| Ayrton_L | 36:dba7a0094213 | 15 | V_WriteTxt(6, 0, C_Line); |
| Ayrton_L | 36:dba7a0094213 | 16 | } |
| Ayrton_L | 36:dba7a0094213 | 17 | |
| Ayrton_L | 36:dba7a0094213 | 18 | void V_WriteTxt(uint32_t I32_Kolom, uint32_t I32_Rij, char * C_Tekst) |
| Ayrton_L | 36:dba7a0094213 | 19 | { |
| Ayrton_L | 36:dba7a0094213 | 20 | Sc.V_SetRij(I32_Rij); |
| Ayrton_L | 36:dba7a0094213 | 21 | Sc.V_SetKolom(I32_Kolom); |
| Ayrton_L | 36:dba7a0094213 | 22 | Sc.V_SetTekst(C_Tekst); |
| Ayrton_L | 36:dba7a0094213 | 23 | Sc.V_Printit(); |
| Ayrton_L | 36:dba7a0094213 | 24 | } |
| Ayrton_L | 36:dba7a0094213 | 25 | |
| Ayrton_L | 29:4a11f841dae1 | 26 | void V_InterruptMenu() |
| Ayrton_L | 29:4a11f841dae1 | 27 | { |
| Ayrton_L | 36:dba7a0094213 | 28 | if(S.B_GetOK() == false) |
| Ayrton_L | 36:dba7a0094213 | 29 | { |
| Ayrton_L | 36:dba7a0094213 | 30 | S.V_SetOK(true); |
| Ayrton_L | 36:dba7a0094213 | 31 | } |
| Ayrton_L | 36:dba7a0094213 | 32 | else |
| Ayrton_L | 36:dba7a0094213 | 33 | { |
| Ayrton_L | 36:dba7a0094213 | 34 | S.V_SetMenu(true); |
| Ayrton_L | 36:dba7a0094213 | 35 | } |
| Ayrton_L | 36:dba7a0094213 | 36 | } |
| Ayrton_L | 36:dba7a0094213 | 37 | |
| Ayrton_L | 36:dba7a0094213 | 38 | void V_MenuThread(void const *args) |
| Ayrton_L | 36:dba7a0094213 | 39 | { |
| Ayrton_L | 36:dba7a0094213 | 40 | PushButton.rise(&V_InterruptMenu); //interrupt bij push op button, rising edge |
| Ayrton_L | 36:dba7a0094213 | 41 | RightTwist.rise(&V_Right); |
| Ayrton_L | 36:dba7a0094213 | 42 | LeftTwist.rise(&V_Left); |
| Ayrton_L | 36:dba7a0094213 | 43 | |
| Ayrton_L | 36:dba7a0094213 | 44 | while(1) |
| Ayrton_L | 36:dba7a0094213 | 45 | { |
| Ayrton_L | 36:dba7a0094213 | 46 | uint32_t I32_Line; |
| Ayrton_L | 36:dba7a0094213 | 47 | I32_Line - S.I32_GetLine(); |
| Ayrton_L | 36:dba7a0094213 | 48 | if(S.I32_GetOldLine() == I32_Line) |
| Ayrton_L | 36:dba7a0094213 | 49 | { |
| Ayrton_L | 36:dba7a0094213 | 50 | if(S.B_GetOK() == true) |
| Ayrton_L | 36:dba7a0094213 | 51 | { |
| Ayrton_L | 36:dba7a0094213 | 52 | switch (I32_Line) |
| Ayrton_L | 36:dba7a0094213 | 53 | { |
| Ayrton_L | 36:dba7a0094213 | 54 | case 0: |
| Ayrton_L | 36:dba7a0094213 | 55 | { |
| Ayrton_L | 36:dba7a0094213 | 56 | Sc.V_Clear(); |
| Ayrton_L | 36:dba7a0094213 | 57 | V_WriteTxt(6, 1, FIRMWARE); |
| Ayrton_L | 36:dba7a0094213 | 58 | } |
| Ayrton_L | 36:dba7a0094213 | 59 | case 1: |
| Ayrton_L | 36:dba7a0094213 | 60 | { |
| Ayrton_L | 36:dba7a0094213 | 61 | Sc.V_Clear(); |
| Ayrton_L | 36:dba7a0094213 | 62 | V_WriteTxt(6, 1, "Output 1:"); |
| Ayrton_L | 36:dba7a0094213 | 63 | V_WriteTxt(6, 1, "Universe"); |
| Ayrton_L | 36:dba7a0094213 | 64 | while (S.B_GetMenu() == false); |
| Ayrton_L | 36:dba7a0094213 | 65 | { |
| Ayrton_L | 36:dba7a0094213 | 66 | int32_t I32_InputCounter; |
| Ayrton_L | 36:dba7a0094213 | 67 | if(S.I32_GetLine() <= I32_Line - 1) |
| Ayrton_L | 36:dba7a0094213 | 68 | { |
| Ayrton_L | 36:dba7a0094213 | 69 | I32_InputCounter--; |
| Ayrton_L | 36:dba7a0094213 | 70 | if(I32_InputCounter == -1) |
| Ayrton_L | 36:dba7a0094213 | 71 | { |
| Ayrton_L | 36:dba7a0094213 | 72 | I32_InputCounter = 255; |
| Ayrton_L | 36:dba7a0094213 | 73 | } |
| Ayrton_L | 36:dba7a0094213 | 74 | } |
| Ayrton_L | 36:dba7a0094213 | 75 | else if(S.I32_GetLine() >= I32_Line + 1) |
| Ayrton_L | 36:dba7a0094213 | 76 | { |
| Ayrton_L | 36:dba7a0094213 | 77 | I32_InputCounter++; |
| Ayrton_L | 36:dba7a0094213 | 78 | if(I32_InputCounter == 256) |
| Ayrton_L | 36:dba7a0094213 | 79 | { |
| Ayrton_L | 36:dba7a0094213 | 80 | I32_InputCounter = 0; |
| Ayrton_L | 36:dba7a0094213 | 81 | } |
| Ayrton_L | 36:dba7a0094213 | 82 | } |
| Ayrton_L | 36:dba7a0094213 | 83 | char C_Buffer [33]; |
| Ayrton_L | 36:dba7a0094213 | 84 | sprintf (C_Buffer, "%d", I32_InputCounter); //itoa werkt niet, dus sprintf om conversie te maken |
| Ayrton_L | 36:dba7a0094213 | 85 | V_WriteTxt(9, 2, C_Buffer); |
| Ayrton_L | 36:dba7a0094213 | 86 | S.V_SetOutput1(I32_InputCounter); |
| Ayrton_L | 36:dba7a0094213 | 87 | S.V_SetLine(I32_Line); |
| Ayrton_L | 36:dba7a0094213 | 88 | } |
| Ayrton_L | 36:dba7a0094213 | 89 | } |
| Ayrton_L | 36:dba7a0094213 | 90 | case 2: |
| Ayrton_L | 36:dba7a0094213 | 91 | { |
| Ayrton_L | 36:dba7a0094213 | 92 | Sc.V_Clear(); |
| Ayrton_L | 36:dba7a0094213 | 93 | V_WriteTxt(6, 1, "Output 2:"); |
| Ayrton_L | 36:dba7a0094213 | 94 | V_WriteTxt(6, 1, "Universe"); |
| Ayrton_L | 36:dba7a0094213 | 95 | while (S.B_GetMenu() == false); |
| Ayrton_L | 36:dba7a0094213 | 96 | { |
| Ayrton_L | 36:dba7a0094213 | 97 | int32_t I32_InputCounter; |
| Ayrton_L | 36:dba7a0094213 | 98 | if(S.I32_GetLine() <= I32_Line - 1) |
| Ayrton_L | 36:dba7a0094213 | 99 | { |
| Ayrton_L | 36:dba7a0094213 | 100 | I32_InputCounter--; |
| Ayrton_L | 36:dba7a0094213 | 101 | if(I32_InputCounter == -1) |
| Ayrton_L | 36:dba7a0094213 | 102 | { |
| Ayrton_L | 36:dba7a0094213 | 103 | I32_InputCounter = 255; |
| Ayrton_L | 36:dba7a0094213 | 104 | } |
| Ayrton_L | 36:dba7a0094213 | 105 | } |
| Ayrton_L | 36:dba7a0094213 | 106 | else if(S.I32_GetLine() >= I32_Line + 1) |
| Ayrton_L | 36:dba7a0094213 | 107 | { |
| Ayrton_L | 36:dba7a0094213 | 108 | I32_InputCounter++; |
| Ayrton_L | 36:dba7a0094213 | 109 | if(I32_InputCounter == 256) |
| Ayrton_L | 36:dba7a0094213 | 110 | { |
| Ayrton_L | 36:dba7a0094213 | 111 | I32_InputCounter = 0; |
| Ayrton_L | 36:dba7a0094213 | 112 | } |
| Ayrton_L | 36:dba7a0094213 | 113 | } |
| Ayrton_L | 36:dba7a0094213 | 114 | char C_Buffer [33]; |
| Ayrton_L | 36:dba7a0094213 | 115 | sprintf (C_Buffer, "%d", I32_InputCounter); |
| Ayrton_L | 36:dba7a0094213 | 116 | V_WriteTxt(9, 2, C_Buffer); |
| Ayrton_L | 36:dba7a0094213 | 117 | S.V_SetOutput2(I32_InputCounter); |
| Ayrton_L | 36:dba7a0094213 | 118 | S.V_SetLine(I32_Line); |
| Ayrton_L | 36:dba7a0094213 | 119 | } |
| Ayrton_L | 36:dba7a0094213 | 120 | } |
| Ayrton_L | 36:dba7a0094213 | 121 | case 3: |
| Ayrton_L | 36:dba7a0094213 | 122 | { |
| Ayrton_L | 36:dba7a0094213 | 123 | Sc.V_Clear(); |
| Ayrton_L | 36:dba7a0094213 | 124 | V_WriteTxt(6, 1, "Output 3:"); |
| Ayrton_L | 36:dba7a0094213 | 125 | V_WriteTxt(6, 1, "Universe"); |
| Ayrton_L | 36:dba7a0094213 | 126 | while (S.B_GetMenu() == false); |
| Ayrton_L | 36:dba7a0094213 | 127 | { |
| Ayrton_L | 36:dba7a0094213 | 128 | int32_t I32_InputCounter; |
| Ayrton_L | 36:dba7a0094213 | 129 | if(S.I32_GetLine() == I32_Line - 1) |
| Ayrton_L | 36:dba7a0094213 | 130 | { |
| Ayrton_L | 36:dba7a0094213 | 131 | I32_InputCounter--; |
| Ayrton_L | 36:dba7a0094213 | 132 | if(I32_InputCounter <= -1) |
| Ayrton_L | 36:dba7a0094213 | 133 | { |
| Ayrton_L | 36:dba7a0094213 | 134 | I32_InputCounter = 255; |
| Ayrton_L | 36:dba7a0094213 | 135 | } |
| Ayrton_L | 36:dba7a0094213 | 136 | } |
| Ayrton_L | 36:dba7a0094213 | 137 | else if(S.I32_GetLine() == I32_Line + 1) |
| Ayrton_L | 36:dba7a0094213 | 138 | { |
| Ayrton_L | 36:dba7a0094213 | 139 | I32_InputCounter++; |
| Ayrton_L | 36:dba7a0094213 | 140 | if(I32_InputCounter >= 256) |
| Ayrton_L | 36:dba7a0094213 | 141 | { |
| Ayrton_L | 36:dba7a0094213 | 142 | I32_InputCounter = 0; |
| Ayrton_L | 36:dba7a0094213 | 143 | } |
| Ayrton_L | 36:dba7a0094213 | 144 | } |
| Ayrton_L | 36:dba7a0094213 | 145 | char C_Buffer [33]; |
| Ayrton_L | 36:dba7a0094213 | 146 | sprintf (C_Buffer, "%d", I32_InputCounter); |
| Ayrton_L | 36:dba7a0094213 | 147 | V_WriteTxt(9, 2, C_Buffer); |
| Ayrton_L | 36:dba7a0094213 | 148 | S.V_SetOutput3(I32_InputCounter); |
| Ayrton_L | 36:dba7a0094213 | 149 | S.V_SetLine(I32_Line); |
| Ayrton_L | 36:dba7a0094213 | 150 | } |
| Ayrton_L | 36:dba7a0094213 | 151 | } |
| Ayrton_L | 36:dba7a0094213 | 152 | default: |
| Ayrton_L | 36:dba7a0094213 | 153 | { |
| Ayrton_L | 36:dba7a0094213 | 154 | Error4 = !Error4; |
| Ayrton_L | 36:dba7a0094213 | 155 | wait_ms(500); |
| Ayrton_L | 36:dba7a0094213 | 156 | } |
| Ayrton_L | 36:dba7a0094213 | 157 | } |
| Ayrton_L | 36:dba7a0094213 | 158 | } |
| Ayrton_L | 36:dba7a0094213 | 159 | } |
| Ayrton_L | 36:dba7a0094213 | 160 | else |
| Ayrton_L | 36:dba7a0094213 | 161 | { |
| Ayrton_L | 36:dba7a0094213 | 162 | V_GeneralTxt(I32_Line); |
| Ayrton_L | 36:dba7a0094213 | 163 | } |
| Ayrton_L | 36:dba7a0094213 | 164 | } |
| Ayrton_L | 29:4a11f841dae1 | 165 | } |
| Ayrton_L | 25:2f69b935060f | 166 | |
| Ayrton_L | 10:33faa2c71dad | 167 | int main() |
| Ayrton_L | 10:33faa2c71dad | 168 | { |
| Ayrton_L | 36:dba7a0094213 | 169 | // RightTwist.mode(PullUp); |
| Ayrton_L | 36:dba7a0094213 | 170 | // LeftTwist.mode(PullUp); |
| Ayrton_L | 36:dba7a0094213 | 171 | |
| Ayrton_L | 36:dba7a0094213 | 172 | Thread T_Menu(V_MenuThread); |
| Ayrton_L | 35:23656910be93 | 173 | |
| Ayrton_L | 35:23656910be93 | 174 | XLR1.V_Start(); |
| Ayrton_L | 35:23656910be93 | 175 | XLR2.V_Start(); |
| Ayrton_L | 35:23656910be93 | 176 | XLR3.V_Start(); |
| Ayrton_L | 28:4b327f1cb9cb | 177 | |
| Ayrton_L | 28:4b327f1cb9cb | 178 | char C_Buf[572]; |
| Ayrton_L | 28:4b327f1cb9cb | 179 | uint16_t I16_Universe; |
| Ayrton_L | 28:4b327f1cb9cb | 180 | while(1) |
| Ayrton_L | 25:2f69b935060f | 181 | { |
| Ayrton_L | 36:dba7a0094213 | 182 | int size = eth.receive(); |
| Ayrton_L | 36:dba7a0094213 | 183 | if(size > 0) |
| Ayrton_L | 29:4a11f841dae1 | 184 | { |
| Ayrton_L | 36:dba7a0094213 | 185 | Error2 = 1; |
| Ayrton_L | 36:dba7a0094213 | 186 | eth.read(C_Buf, size); |
| Ayrton_L | 36:dba7a0094213 | 187 | Error8 = 1; |
| Ayrton_L | 36:dba7a0094213 | 188 | if(C_Buf[34] == 0x19 and C_Buf[35] == 0x36 and C_Buf[36] == 0x19 and C_Buf[37] == 0x36) //Poort checken (6465 = 0x1936 // deel van udp protocol |
| Ayrton_L | 35:23656910be93 | 189 | { |
| Ayrton_L | 36:dba7a0094213 | 190 | Error1 = 1; |
| Ayrton_L | 36:dba7a0094213 | 191 | char C_ID[7]; |
| Ayrton_L | 36:dba7a0094213 | 192 | memcpy(C_ID, &C_Buf[42], 7); |
| Ayrton_L | 36:dba7a0094213 | 193 | if(I32_CheckHeader(C_ID) == 0) |
| Ayrton_L | 36:dba7a0094213 | 194 | { //Art-Net Header checken |
| Ayrton_L | 36:dba7a0094213 | 195 | if(C_Buf[50] == 0x00 and C_Buf[51]== 0x50) |
| Ayrton_L | 36:dba7a0094213 | 196 | { //OPcode checken |
| Ayrton_L | 36:dba7a0094213 | 197 | if(C_Buf[52] == 0x00 and C_Buf[53]== 0x0E) |
| Ayrton_L | 36:dba7a0094213 | 198 | { //Protocol Versie (14) checken |
| Ayrton_L | 36:dba7a0094213 | 199 | // 56/57 = universe |
| Ayrton_L | 36:dba7a0094213 | 200 | I16_Universe = C_Buf[56]; |
| Ayrton_L | 36:dba7a0094213 | 201 | I16_Universe = I16_Universe << 8; |
| Ayrton_L | 36:dba7a0094213 | 202 | I16_Universe = I16_Universe & 0xFF00; |
| Ayrton_L | 36:dba7a0094213 | 203 | I16_Universe = I16_Universe + C_Buf[57]; |
| Ayrton_L | 36:dba7a0094213 | 204 | |
| Ayrton_L | 36:dba7a0094213 | 205 | uint8_t I8_Values[511]; |
| Ayrton_L | 36:dba7a0094213 | 206 | uint32_t I32_Teller; |
| Ayrton_L | 36:dba7a0094213 | 207 | Error4 = 1; |
| Ayrton_L | 36:dba7a0094213 | 208 | if(I16_Universe == S.I32_GetOutput1()) |
| Ayrton_L | 28:4b327f1cb9cb | 209 | { |
| Ayrton_L | 36:dba7a0094213 | 210 | memcpy(I8_Values, &C_Buf[60], 512); |
| Ayrton_L | 36:dba7a0094213 | 211 | Error8 = 1; |
| Ayrton_L | 36:dba7a0094213 | 212 | for (I32_Teller = 1; I32_Teller < 512; I32_Teller ++) |
| Ayrton_L | 29:4a11f841dae1 | 213 | { |
| Ayrton_L | 36:dba7a0094213 | 214 | XLR1.V_PutData(I32_Teller, I8_Values[I32_Teller -1]); |
| Ayrton_L | 36:dba7a0094213 | 215 | XLR2.V_PutData(I32_Teller, I8_Values[I32_Teller -1]); |
| Ayrton_L | 29:4a11f841dae1 | 216 | } |
| Ayrton_L | 36:dba7a0094213 | 217 | } |
| Ayrton_L | 36:dba7a0094213 | 218 | if(I16_Universe == S.I32_GetOutput2()) |
| Ayrton_L | 36:dba7a0094213 | 219 | { |
| Ayrton_L | 36:dba7a0094213 | 220 | memcpy(I8_Values, &C_Buf[60], 512); |
| Ayrton_L | 36:dba7a0094213 | 221 | for (I32_Teller = 0; I32_Teller < 512; I32_Teller ++) |
| Ayrton_L | 28:4b327f1cb9cb | 222 | { |
| Ayrton_L | 36:dba7a0094213 | 223 | XLR2.V_PutData(I32_Teller, I8_Values[I32_Teller -1]); |
| Ayrton_L | 36:dba7a0094213 | 224 | } |
| Ayrton_L | 36:dba7a0094213 | 225 | } |
| Ayrton_L | 36:dba7a0094213 | 226 | if(I16_Universe == S.I32_GetOutput3()) |
| Ayrton_L | 36:dba7a0094213 | 227 | { |
| Ayrton_L | 36:dba7a0094213 | 228 | memcpy(I8_Values, &C_Buf[60], 512); |
| Ayrton_L | 36:dba7a0094213 | 229 | for (I32_Teller = 0; I32_Teller < 512; I32_Teller ++) |
| Ayrton_L | 36:dba7a0094213 | 230 | { |
| Ayrton_L | 36:dba7a0094213 | 231 | XLR3.V_PutData(I32_Teller, I8_Values[I32_Teller -1]); |
| Ayrton_L | 36:dba7a0094213 | 232 | } |
| Ayrton_L | 36:dba7a0094213 | 233 | } //einde universes |
| Ayrton_L | 36:dba7a0094213 | 234 | } //einde protocol |
| Ayrton_L | 36:dba7a0094213 | 235 | }//einde OPCODE |
| Ayrton_L | 36:dba7a0094213 | 236 | }//Einde Artnet |
| Ayrton_L | 36:dba7a0094213 | 237 | }//Einde Poort checken |
| Ayrton_L | 36:dba7a0094213 | 238 | }//einde if(size... |
| Ayrton_L | 35:23656910be93 | 239 | }//einde while |
| Ayrton_L | 29:4a11f841dae1 | 240 | }//einde main |
| Ayrton_L | 29:4a11f841dae1 | 241 | |
| Ayrton_L | 30:51a4370a88bf | 242 | void V_Reset() |
| Ayrton_L | 29:4a11f841dae1 | 243 | { |
| Ayrton_L | 29:4a11f841dae1 | 244 | Sc.V_Clear(); |
| Ayrton_L | 30:51a4370a88bf | 245 | delete &S; |
| Ayrton_L | 29:4a11f841dae1 | 246 | } |
| Ayrton_L | 29:4a11f841dae1 | 247 | |
| Ayrton_L | 29:4a11f841dae1 | 248 | void V_Right() |
| Ayrton_L | 29:4a11f841dae1 | 249 | { |
| Ayrton_L | 36:dba7a0094213 | 250 | V_DisableRotary(); |
| Ayrton_L | 29:4a11f841dae1 | 251 | if(S.B_GetLeft() == true) |
| Ayrton_L | 29:4a11f841dae1 | 252 | { |
| Ayrton_L | 31:f7f44632c3cd | 253 | uint32_t I32_Count = S.I32_GetLine(); |
| Ayrton_L | 36:dba7a0094213 | 254 | if(I32_Count == 4) |
| Ayrton_L | 31:f7f44632c3cd | 255 | { |
| Ayrton_L | 31:f7f44632c3cd | 256 | I32_Count = 0; |
| Ayrton_L | 31:f7f44632c3cd | 257 | } |
| Ayrton_L | 31:f7f44632c3cd | 258 | else |
| Ayrton_L | 31:f7f44632c3cd | 259 | { |
| Ayrton_L | 31:f7f44632c3cd | 260 | I32_Count++; |
| Ayrton_L | 31:f7f44632c3cd | 261 | } |
| Ayrton_L | 36:dba7a0094213 | 262 | S.V_SetLine(I32_Count); |
| Ayrton_L | 29:4a11f841dae1 | 263 | } |
| Ayrton_L | 29:4a11f841dae1 | 264 | else |
| Ayrton_L | 29:4a11f841dae1 | 265 | { |
| Ayrton_L | 29:4a11f841dae1 | 266 | S.V_SetRight(true); |
| Ayrton_L | 29:4a11f841dae1 | 267 | } |
| Ayrton_L | 31:f7f44632c3cd | 268 | |
| Ayrton_L | 29:4a11f841dae1 | 269 | S.V_SetLeft(false); |
| Ayrton_L | 29:4a11f841dae1 | 270 | } |
| Ayrton_L | 29:4a11f841dae1 | 271 | |
| Ayrton_L | 29:4a11f841dae1 | 272 | void V_Left() |
| Ayrton_L | 29:4a11f841dae1 | 273 | { |
| Ayrton_L | 36:dba7a0094213 | 274 | V_DisableRotary(); |
| Ayrton_L | 29:4a11f841dae1 | 275 | if(S.B_GetRight() == true) |
| Ayrton_L | 29:4a11f841dae1 | 276 | { |
| Ayrton_L | 31:f7f44632c3cd | 277 | uint32_t I32_Count = S.I32_GetLine(); |
| Ayrton_L | 31:f7f44632c3cd | 278 | if(I32_Count == 0) |
| Ayrton_L | 31:f7f44632c3cd | 279 | { |
| Ayrton_L | 36:dba7a0094213 | 280 | I32_Count = 4; |
| Ayrton_L | 31:f7f44632c3cd | 281 | } |
| Ayrton_L | 31:f7f44632c3cd | 282 | else |
| Ayrton_L | 31:f7f44632c3cd | 283 | { |
| Ayrton_L | 31:f7f44632c3cd | 284 | I32_Count--; |
| Ayrton_L | 31:f7f44632c3cd | 285 | } |
| Ayrton_L | 36:dba7a0094213 | 286 | S.V_SetLine(I32_Count); |
| Ayrton_L | 29:4a11f841dae1 | 287 | } |
| Ayrton_L | 29:4a11f841dae1 | 288 | else |
| Ayrton_L | 29:4a11f841dae1 | 289 | { |
| Ayrton_L | 29:4a11f841dae1 | 290 | S.V_SetLeft(true); |
| Ayrton_L | 29:4a11f841dae1 | 291 | } |
| Ayrton_L | 29:4a11f841dae1 | 292 | S.V_SetRight(false); |
| Ayrton_L | 29:4a11f841dae1 | 293 | } |
| Ayrton_L | 29:4a11f841dae1 | 294 | |
| Ayrton_L | 34:fc85eeb84a93 | 295 | void V_DisableRotary() |
| Ayrton_L | 34:fc85eeb84a93 | 296 | { |
| Ayrton_L | 34:fc85eeb84a93 | 297 | RightTwist.rise(NULL); |
| Ayrton_L | 34:fc85eeb84a93 | 298 | LeftTwist.rise(NULL); |
| Ayrton_L | 36:dba7a0094213 | 299 | EnableRotary.attach_us(&V_EnableRotary, 5000); //na 5 ms intterupts terug enablen |
| Ayrton_L | 34:fc85eeb84a93 | 300 | } |
| Ayrton_L | 34:fc85eeb84a93 | 301 | |
| Ayrton_L | 28:4b327f1cb9cb | 302 | uint32_t I32_CheckHeader(char C_Header[6]) |
| Ayrton_L | 28:4b327f1cb9cb | 303 | { |
| Ayrton_L | 28:4b327f1cb9cb | 304 | if(C_Header[0] == 'A') |
| Ayrton_L | 28:4b327f1cb9cb | 305 | { |
| Ayrton_L | 28:4b327f1cb9cb | 306 | if(C_Header[1] == 'r') |
| Ayrton_L | 28:4b327f1cb9cb | 307 | { |
| Ayrton_L | 28:4b327f1cb9cb | 308 | if(C_Header[2] == 't') |
| Ayrton_L | 28:4b327f1cb9cb | 309 | { |
| Ayrton_L | 28:4b327f1cb9cb | 310 | if(C_Header[3] == '-') |
| Ayrton_L | 28:4b327f1cb9cb | 311 | { |
| Ayrton_L | 28:4b327f1cb9cb | 312 | if(C_Header[4] == 'N') |
| Ayrton_L | 28:4b327f1cb9cb | 313 | { |
| Ayrton_L | 28:4b327f1cb9cb | 314 | if(C_Header[5] == 'e') |
| Ayrton_L | 28:4b327f1cb9cb | 315 | { |
| Ayrton_L | 28:4b327f1cb9cb | 316 | if(C_Header[6] == 't') |
| Ayrton_L | 28:4b327f1cb9cb | 317 | { |
| Ayrton_L | 28:4b327f1cb9cb | 318 | return 0; |
| Ayrton_L | 28:4b327f1cb9cb | 319 | } |
| Ayrton_L | 28:4b327f1cb9cb | 320 | else |
| Ayrton_L | 28:4b327f1cb9cb | 321 | { |
| Ayrton_L | 28:4b327f1cb9cb | 322 | return 1; |
| Ayrton_L | 28:4b327f1cb9cb | 323 | } |
| Ayrton_L | 28:4b327f1cb9cb | 324 | } |
| Ayrton_L | 28:4b327f1cb9cb | 325 | else |
| Ayrton_L | 28:4b327f1cb9cb | 326 | { |
| Ayrton_L | 28:4b327f1cb9cb | 327 | return 1; |
| Ayrton_L | 28:4b327f1cb9cb | 328 | } |
| Ayrton_L | 28:4b327f1cb9cb | 329 | } |
| Ayrton_L | 28:4b327f1cb9cb | 330 | else |
| Ayrton_L | 28:4b327f1cb9cb | 331 | { |
| Ayrton_L | 28:4b327f1cb9cb | 332 | return 1; |
| Ayrton_L | 28:4b327f1cb9cb | 333 | } |
| Ayrton_L | 28:4b327f1cb9cb | 334 | } |
| Ayrton_L | 28:4b327f1cb9cb | 335 | else |
| Ayrton_L | 28:4b327f1cb9cb | 336 | { |
| Ayrton_L | 28:4b327f1cb9cb | 337 | return 1; |
| Ayrton_L | 28:4b327f1cb9cb | 338 | } |
| Ayrton_L | 28:4b327f1cb9cb | 339 | } |
| Ayrton_L | 28:4b327f1cb9cb | 340 | else |
| Ayrton_L | 28:4b327f1cb9cb | 341 | { |
| Ayrton_L | 28:4b327f1cb9cb | 342 | return 1; |
| Ayrton_L | 28:4b327f1cb9cb | 343 | } |
| Ayrton_L | 28:4b327f1cb9cb | 344 | } |
| Ayrton_L | 28:4b327f1cb9cb | 345 | else |
| Ayrton_L | 28:4b327f1cb9cb | 346 | { |
| Ayrton_L | 28:4b327f1cb9cb | 347 | return 1; |
| Ayrton_L | 28:4b327f1cb9cb | 348 | } |
| Ayrton_L | 28:4b327f1cb9cb | 349 | } |
| Ayrton_L | 28:4b327f1cb9cb | 350 | else |
| Ayrton_L | 28:4b327f1cb9cb | 351 | { |
| Ayrton_L | 28:4b327f1cb9cb | 352 | return 1; |
| Ayrton_L | 28:4b327f1cb9cb | 353 | } |
| Ayrton_L | 28:4b327f1cb9cb | 354 | } |