![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Callum and Adel's changes on 12/02/19
Dependencies: Crypto
Diff: main.cpp
- Revision:
- 16:db7ef0a4aa23
- Parent:
- 15:2f95f2fb68e3
- Child:
- 17:5a443275680a
- Child:
- 18:7ee632098fd4
diff -r 2f95f2fb68e3 -r db7ef0a4aa23 main.cpp --- a/main.cpp Tue Mar 05 15:48:43 2019 +0000 +++ b/main.cpp Wed Mar 06 10:43:22 2019 +0000 @@ -48,11 +48,6 @@ //Phase lead to make motor spin const int8_t lead = 2; //2 for forwards, -2 for backwards -// Global States -// TODO: Can we not use globals? -int8_t orState = 0; //Rotot offset at motor state 0 -int8_t currentState = 0; //Rotot offset at motor state 0 - //Status LED DigitalOut led1(LED1); @@ -107,10 +102,12 @@ return readRotorState(); } -void stateUpdate(/*int8_t *currentState, int8_t offset, int8_t lead*/) { - // TODO: Global fix + +void stateUpdate(int8_t *params[]) { // () { // **params + int8_t currentState = *params[0]; + int8_t offset = *params[1]; currentState = readRotorState(); - motorOut((currentState - orState + lead + 6) % 6); + motorOut((currentState - offset + lead + 6) % 6); } //Main @@ -137,13 +134,23 @@ uint32_t hashCounter = 0; Timer timer; + // Motor States + int8_t orState = 0; //Rotot offset at motor state 0 + int8_t currentState = 0; //Rotot offset at motor state 0 //Run the motor synchronisation orState = motorHome(); // Add callbacks - I1.fall(&stateUpdate); - I2.fall(&stateUpdate); - I3.fall(&stateUpdate); +// I1.fall(&stateUpdate); +// I2.fall(&stateUpdate); +// I3.fall(&stateUpdate); + int8_t* params[2]; + params[0] = ¤tState; + params[1] = &orState; + + I1.fall(callback(&stateUpdate,params)); + I2.fall(callback(&stateUpdate,params)); + I3.fall(callback(&stateUpdate,params)); // Push motor to move currentState = readRotorState(); @@ -172,6 +179,7 @@ pc.printf("\n\r"); } + // Try a new nonce (*nonce)++; // Per Second i.e. when greater or equal to 1