Luca Jel
/
mbed5a_testy
sdsd
Fork of mbed5a_testy by
Diff: main.cpp
- Revision:
- 2:0fcc9b85c8f6
- Parent:
- 0:e69a0b7f4b41
--- a/main.cpp Fri May 05 20:01:41 2017 +0000 +++ b/main.cpp Tue Jun 20 16:02:06 2017 +0000 @@ -1,29 +1,10 @@ #include "mbed.h" -//#include "servo.h" -//#include "command_decoder.h" #include "led.h" #include "serwo.h" #include "command_decoder.h" -//#define DETECTOR_bm (PA4) - - -//DigitalIn det(PA_5); -//Ticker serwoTim; - - - - -//************************************************************************/ - -/******************************************************************/ -//------------------------------------ -// Hyperterminal configuration -// 9600 bauds, 8-bit data, no parity -//------------------------------------ - RawSerial pc(USBTX,USBRX,9600); DigitalOut led_green(LED1); @@ -68,16 +49,6 @@ return(0); } -void hardbeatSend() -{ - static int count=0; - char tekst[25]; - sprintf(tekst,"hardbeat number: %d \r\n", count ); - //pc.printf("This program runs since %d seconds.\r\n", i); - my_puts(tekst,22); - count++; -} - char my_gets(char str[],int size) { if (!pc.readable())return (NULL); @@ -107,44 +78,36 @@ unsigned int uiPreviusPos; - //ButtonInit(); - //Servo_Init(500); + char cOdebranyString[20]; char init[] = "system start\r\n"; const char tekstSize = 20; my_puts(init,tekstSize); - Servo_Init(100); - //Servo_Callib(); - + Servo_Init(100); + while(1){ - - - - - - if (my_gets(cOdebranyString,tekstSize)!=NULL) { - //if(eReciever_GetStatus() == READY){ - - //Reciever_GetStringCopy( cOdebranyString ); DecodeMsg( cOdebranyString ); if ((ucTokenNr > 0) && (asToken[0].eType == KEYWORD)){ switch (asToken[0].uValue.eKeyword){ case CALLIB: Servo_Callib(); + my_puts("OK",3); break; case GOTO: if (asToken[1].eType == NUMBER){ Servo_GoTo(asToken[1].uValue.uiNumber); uiPreviusPos = asToken[1].uValue.uiNumber; + my_puts("OK",3); } break; case STEP: if (asToken[1].eType == NUMBER){ Servo_GoTo(uiPreviusPos + asToken[1].uValue.uiNumber); uiPreviusPos = uiPreviusPos + asToken[1].uValue.uiNumber; + my_puts("OK",3); } break; case ID: @@ -162,42 +125,3 @@ - - - - -/* -int main() -{ - - - bool flag=false; - - const char tekstSize = 7; - char tekst[tekstSize]; - //my_puts("[2J",5);//clear console - //pc.putc('[2J'); - pc.putc(27); - char init[] = "system start\r\n"; - my_puts(init,tekstSize); - Sender.attach(&hardbeatSend,1); - - - - while(1) { - - - - if (my_gets(tekst,tekstSize)!=NULL) { - - my_puts(tekst,tekstSize); - if(strcmp(tekst,"on"))flag = true; - if(strcmp(tekst,"off"))flag = false; - if(strcmp(tekst,"toggle"))flag = !flag; - led_green =flag; - } - - } -} -*/ -