tim010 tim010
/
Grupa7-ProjekatRadarDodatniDio
Muris Nuhodžić Edis Kunić
Diff: main.cpp
- Revision:
- 1:d75b1ae184ea
- Parent:
- 0:0b1211077b9a
--- a/main.cpp Mon Jun 02 16:45:34 2014 +0000 +++ b/main.cpp Wed Jun 04 22:05:15 2014 +0000 @@ -20,6 +20,45 @@ pc.printf("4- pokretanje/zaustavljanje motora\n\r"); } +void postaviOsovinu(){ + int ugao; + pc.printf("\n Unesi ugao: \n\r"); + pc.scanf("%d", &ugao); + if (ugao > 0 ) + motor.step(numstep / 360 * (ugao % 360), direction, step_speed); // number of steps, direction, speed + else + motor.step(numstep / 360 * (ugao % 360), 1 - direction, step_speed); // number of steps, direction, speed + meni();if(upaljen) motor.step(numstep, direction, step_speed); +} + +void promijeniSmjer(){ + direction = 1 - direction; + pc.printf("\n Smjer je promjenjen\n"); + meni();if(upaljen) motor.step(numstep, direction, step_speed); +} + +void promijeniBrzinu(){ + pc.printf("\n trenutna brzina: %d\n\r", step_speed); + pc.printf("\n Unesi novu brzinu: \n\r"); + pc.scanf("%d",&step_speed); + if(upaljen) motor.step(numstep, direction, step_speed); + meni();if(upaljen) motor.step(numstep, direction, step_speed); + } + +void pokreniZaustavi(){ + if(upaljen == false) { + upaljen = true; + motor.step(numstep, direction, step_speed); + pc.printf("\n motor je upaljen \n"); + } else { + upaljen = false; + motor.step(numstep, direction, 0); + pc.printf("\n motor je ugasen \n"); + } + meni();if(upaljen) motor.step(numstep, direction, step_speed); + } + + int main() { meni(); @@ -33,40 +72,18 @@ meni(); continue; }*/ - int ugao; - pc.printf("\n Unesi ugao: \n\r"); - pc.scanf("%d", &ugao); - if (ugao > 0 ) - motor.step(numstep / 360 * (ugao % 360), direction, step_speed); // number of steps, direction, speed - else - motor.step(numstep / 360 * (ugao % 360), 1 - direction, step_speed); // number of steps, direction, speed - meni();if(upaljen) motor.step(numstep, direction, step_speed); + postaviOsovinu(); } if (c =='2') { - direction = 1 - direction; - pc.printf("\n Smjer je promjenjen\n"); - meni();if(upaljen) motor.step(numstep, direction, step_speed); + promijeniSmjer(); } if ( c =='3') { - pc.printf("\n trenutna brzina: %d\n\r", step_speed); - pc.printf("\n Unesi novu brzinu: \n\r"); - pc.scanf("%d",&step_speed); - if(upaljen) motor.step(numstep, direction, step_speed); - meni();if(upaljen) motor.step(numstep, direction, step_speed); + promijeniBrzinu(); } if (c =='4') { - if(upaljen == false) { - upaljen = true; - motor.step(numstep, direction, step_speed); - pc.printf("\n motor je upaljen \n"); - } else { - upaljen = false; - motor.step(numstep, direction, 0); - pc.printf("\n motor je ugasen \n"); - } - meni();if(upaljen) motor.step(numstep, direction, step_speed); + pokreniZaustavi(); } } }