Callum and Adel's changes on 12/02/19
Dependencies: Crypto
Diff: main.cpp
- Revision:
- 18:7ee632098fd4
- Parent:
- 16:db7ef0a4aa23
- Child:
- 19:805c87360b55
--- a/main.cpp Wed Mar 06 10:43:22 2019 +0000 +++ b/main.cpp Wed Mar 06 11:26:27 2019 +0000 @@ -104,9 +104,10 @@ void stateUpdate(int8_t *params[]) { // () { // **params + *params[0] = readRotorState(); int8_t currentState = *params[0]; int8_t offset = *params[1]; - currentState = readRotorState(); + motorOut((currentState - offset + lead + 6) % 6); } @@ -137,6 +138,7 @@ // Motor States int8_t orState = 0; //Rotot offset at motor state 0 int8_t currentState = 0; //Rotot offset at motor state 0 + int8_t stateList[6]; //Rotot offset at motor state 0 //Run the motor synchronisation orState = motorHome(); @@ -152,6 +154,10 @@ I2.fall(callback(&stateUpdate,params)); I3.fall(callback(&stateUpdate,params)); + I1.rise(callback(&stateUpdate,params)); + I2.rise(callback(&stateUpdate,params)); + I3.rise(callback(&stateUpdate,params)); + // Push motor to move currentState = readRotorState(); motorOut((currentState-orState+lead+6)%6); // We push it digitally @@ -168,6 +174,7 @@ // Keep the program running indefinitely timer.start(); // start timer + int stateCount = 0; while (1) { // pc.printf("Current:%d \t Next:%d \n\r", currentState, (currentState-orState+lead+6)%6); Miner.computeHash(hash, sequence, length64); @@ -182,6 +189,18 @@ // Try a new nonce (*nonce)++; + if (stateCount<6){ + stateList[stateCount] = currentState; + stateCount++; + } + else { + pc.printf("states"); + for(int i = 0; i < 6; ++i) + pc.printf("%02i,", stateList[i]); + pc.printf("\n\r"); + stateCount = 0; + } + // Per Second i.e. when greater or equal to 1 if (timer.read() >= 1){ pc.printf("HashRate = %02u \n\r",hashCounter);