bamlor nuttymaisuay
Dependencies: mbed
Diff: main.cpp
- Revision:
- 3:46cc9d386ff4
- Parent:
- 2:af822f5a5120
- Child:
- 4:9cc307f25dc9
--- a/main.cpp Sun Dec 10 10:44:17 2017 +0000 +++ b/main.cpp Sun Dec 10 11:45:47 2017 +0000 @@ -33,7 +33,7 @@ - +float x = 9,y = 0; float sum = 0; uint32_t sumCount = 0; char buffer[14]; @@ -46,10 +46,11 @@ -BusOut B(PA_0,PA_1,PA_4,PB_0,PC_1,PC_2,PC_3), A(PC_10,PC_12,PA_13,PA_14,PC_13,PC_11,PD_2), C(PA_5,PA_6,PA_7,PC_7,PB_2,PB_1,PB_15); +BusOut C(PA_0,PA_1,PA_4,PB_0,PC_1,PC_2,PC_3), A(PC_10,PC_12,PA_13,PA_14,PC_13,PC_11,PD_2), B(PA_5,PA_6,PA_7,PC_7,PB_2,PB_1,PB_15); float posA,posB,posC; int main() { + A = 0x7F; pc.baud(9600); //Set up I2C i2c.frequency(400000); // use fast (400 kHz) I2C @@ -165,16 +166,47 @@ delt_t = t.read_ms() - count; if (delt_t > 5) { // update LCD once per half-second independent of read rate pc.printf("delt_t = %f\n",delt_t); - posA += (gz*delt_t/1000); + pc.printf(" x = %f", x); + y += 1; + if (y == 2000) + { + x+=0.5; + y = 0; + } + posA += (gz*delt_t*x/1000); posB = posA + 120; posC = posA + 240; -// if (posA >= 90) - // + // if (posA >= 360 && posA < 720) +// { // A = 0x7F; // B = 0x7F; // C = 0x7F; // } +// else if (posA >= 720 && posA < 1080) +// { +// A = 0x7F; +// B = 0; +// C = 0; +// } +// else if (posA >= 1080 && posA < 1440) +// { +// A = 0x7F; +// B = 0x7F; +// C = 0x7F; +// } +// else if (posA >= 1440 && posA < 1800) +// { +// A = 0x7F; +// B = 0; +// C = 0; +// } +// else if (posA >= 1800) +// { +// A = 0x7F; +// B = 0x7F; +// C = 0x7F; +// } // else // { // A = 0; @@ -185,42 +217,42 @@ // { // break; // } - //if (posA >= 360) -// { -// posA-=360; -// } -// if (posA > 0 && posA < 30) -// { -// A = 0x7F; -// } -// else -// { -// A = 0x00; -// } -// if (posB >= 360) -// { -// posB-=360; -// } -// if (posB > 0 && posB < 30) -// { -// B = 0x7F; -// } -// else -// { -// B = 0x00; -// } -// if (posC >= 360) -// { -// posC-=360; -// } -// if (posC > 0 && posC < 30) -// { -// C = 0x7F; -// } -// else -// { -// C = 0x00; -// } + if (posA >= 360) + { + posA-=360; + } + if (posA > 0 && posA < 30) + { + A = 0x7F; + } + else + { + A = 0x00; + } + if (posB >= 360) + { + posB-=360; + } + if (posB > 0 && posB < 30) + { + B = 0x7F; + } + else + { + B = 0x00; + } + if (posC >= 360) + { + posC-=360; + } + if (posC > 0 && posC < 30) + { + C = 0x7F; + } + else + { + C = 0x00; + } // pc.printf("ax = %f", 1000*ax); // pc.printf(" ay = %f", 1000*ay); // pc.printf(" az = %f mg\n\r", 1000*az); @@ -280,8 +312,6 @@ sumCount = 0; } } -A = 0; -B = 0; -C = 0; + pc.printf("fuck you"); } \ No newline at end of file