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.
Diff: main.cpp
- Revision:
- 3:1e9b4a4bf177
- Parent:
- 2:554edc4b0cf2
- Child:
- 4:f81b40e04a58
--- a/main.cpp Wed Apr 15 20:46:13 2015 +0000 +++ b/main.cpp Sun Apr 19 23:03:43 2015 +0000 @@ -28,19 +28,20 @@ double slice_time; double rotate_time; int current_slice; -char slice_data [NUMBER_OF_SLICES][8]; //[slice][forSepcificArm][eachBit] +char slice_data [NUMBER_OF_SLICES][16]; //[slice][specific bit] & with approppriate bit for each arm double firstTime; Serial pc(USBTX, USBRX); // tx, rx +Serial bt(p9, p10);// tx, rx -void pushData (char (*bits) [8]){ - for (int i = 0; i < 8; i ++){ - dataArmOne = bits [0][i] & 0x80; - dataArmTwo = bits [1][i] & 0x40; - dataArmThree = bits [2][i]& 0x20; - dataArmFour = bits [3][i]& 0x10; - // dataArmFive = *bits [4][i]; +void pushData (char (*bits) [16]){ + for (int i = 0; i < 16; i ++){ + dataArmOne = *bits [i] & 0x80; + dataArmTwo = *bits [i] & 0x40; + dataArmThree = *bits [i]& 0x20; + dataArmFour = *bits [i]& 0x10; + dataArmFive = *bits [i] & 0x08; //dataArmSix = *bits [5][i]; //dataArmSeven = *bits [6][i]; //dataArmEight = *bits [7][i]; @@ -65,16 +66,19 @@ //Hall sensor interupt void rotate_sense(){ + pc.printf("interupt"); if (firstTime){ rotationTime.reset(); rotationTime.start(); firstTime = 0; - printf("first time"); + pc.printf("first time"); + led = !led; return; } else if(current_slice < NUMBER_OF_SLICES / 2){ return; } - printf("seconod time \n"); + pc.printf("seconod time \n"); + led = !led; rotate_time = rotationTime.read_us(); rotationTime.reset(); rotationTime.start(); @@ -86,24 +90,25 @@ int main() { - printf("started"); + pc.printf("started"); firstTime = 1; current_slice = 90; - hallSensor.rise(&rotate_sense); + hallSensor.fall(&rotate_sense); for (int i = 0; i < 45; i ++){ - slice_data [i][0] = 0x80; + slice_data [i][0] = 0x80; // bit 0 is high on arm 0 //{1,1,1,1,0,0,0,0,1,1,1,0,0,0,1,0}; } for (int i = 45; i < 90; i++){ - slice_data [i][0] = 0x80; + slice_data [i][0] = 0x00; //{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; } while(1) { - //TODO: add in the ability to update the buffers - led = !led; - wait(.25); + if (bt.readable()){ + pc.printf("%f \n", bt.getc()); + pc.printf("read that ish"); + //TODO: add in the ability to update the buffers } }