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:
- 9:97b26dcd1035
- Parent:
- 8:96c852630824
- Child:
- 11:95e4e04a7dd2
--- a/main.cpp Sun Dec 11 16:28:43 2016 +0000 +++ b/main.cpp Mon Dec 12 22:25:35 2016 +0000 @@ -2,106 +2,115 @@ #include "model.h" #include "structures.h" #include "Serial.h" + Timer tms; -DigitalOut cervena(LED1); -DigitalOut zelena(LED2); -Ticker ticker; -void calc(); -void SerialCallBack(); +//DigitalOut cervena(LED1); +//DigitalOut zelena(LED2); +//Ticker ticker; +//Ticker ticker2; +//void calc(); +//void SerialCallBack(); Serial pc(USBTX,USBRX); -char startByteIn; -char targetAdd; -char sourceAdd; -char DataLength; -char DataIn[2]; -char CrcIn; -char wd[1]; - -Model *mModel=new Model(&pc,tms); -char datal; -int pom=0; - -void calc() -{ - pom++; - if (pom==1) { - zelena =0; - cervena=1; - mModel->sendPacket(0xa0,0xfe,0x00,wd,1); - } else { - zelena=1; - cervena=0; - pom=0; - } -} - - -void SerialCallBack() -{ - char data[1]; - - pom++; - - startByteIn=mModel->pc->getc(); - targetAdd=mModel->pc->getc(); - sourceAdd=mModel->pc->getc(); - DataLength=mModel->pc->getc(); - - for (unsigned int i=0; i< DataLength; i++) { - DataIn[i]=mModel->pc->getc(); - } - - CrcIn=mModel->pc->getc(); - if(pom==1) { - zelena=0; - } else { - zelena=1; - pom=0; - } - switch( sourceAdd) { - case 0xc4: - case 0xb4: - mModel->mapPoschodie.find("p4")->second=true; - break; - case 0xb3: - case 0xc3: - mModel->mapPoschodie.find("p3")->second=true; - break; - case 0xb2: - case 0xc2: - mModel->mapPoschodie.find("p2")->second=true; - break; - case 0xb1: - case 0xc1: - mModel->mapPoschodie.find("p1")->second=true; - break; - case 0xb0: - case 0xc0: - mModel->mapPoschodie.find("p0")->second=true; - break; - default: - - break; - - } - -} +//char startByteIn; +//char targetAdd; +//char sourceAdd; +//char DataLength; +//char DataIn[6]; +//char CrcIn; +//char wd[1]; +//char checktargetAdd; +//char checsourceAdd; +//int checkDataLength; +//char *checkData; +// +// +Model *mModel=new Model(&pc); +//char datal; +//int pom=0; +// +//void calc() +//{ +// pom++; +// if (pom==1) { +// zelena =0; +// cervena=1; +// mModel->sendPacket(0xa0,0xfe,0x00,wd,1); +// +// } else { +// zelena=1; +// cervena=0; +// pom=0; +// } +//} +// +// +//void SerialCallBack() +//{ +// +// pom++; +// if(pom==1) { +// zelena=0; +// } else { +// zelena=1; +// pom=0; +// } +// startByteIn=mModel->pc->getc(); +// targetAdd=mModel->pc->getc(); +// sourceAdd=mModel->pc->getc(); +// DataLength=mModel->pc->getc(); +// for (unsigned int i=0; i< DataLength; i++) { +// DataIn[i]=mModel->pc->getc(); +// } +//// CrcIn=mModel->pc->getc(); +//// checktargetAdd=targetAdd; +//// checsourceAdd=sourceAdd; +//// checkDataLength=DataLength; +////strcpy(checkData,DataIn); +// switch( sourceAdd) { +// case 0xc4: +// case 0xb4: +// mModel->mapPoschodie.find("p4")->second=true; +// break; +// case 0xb3: +// case 0xc3: +// mModel->mapPoschodie.find("p3")->second=true; +// break; +// case 0xb2: +// case 0xc2: +// mModel->mapPoschodie.find("p2")->second=true; +// break; +// case 0xb1: +// case 0xc1: +// mModel->mapPoschodie.find("p1")->second=true; +// break; +// case 0xb0: +// case 0xc0: +// mModel->mapPoschodie.find("p0")->second=true; +// break; +// default: +// break; +// +// } +// +//} +// int main() { - // mModel = new Model(&pc); - - cervena=1; - zelena=1; +// mModel = new Model(&pc); - ticker.attach(&calc,0.4); -wd[0]=0xff; - char data[1]; - data[0]=0x43; - mModel->getSerial()->attach(&SerialCallBack,Serial::RxIrq); - mModel->sendPacket(0xa0,0xd0,0x00,data,1); +// cervena=1; +// zelena=1; +// +// ticker.attach(&calc,0.4); +// wd[0]=0xff; +// char data[1]; +// data[0]=0x43; +// mModel->getSerial()->attach(&SerialCallBack,Serial::RxIrq); +// mModel->sendPacket(0xa0,0xd0,0x00,data,1); + while(1) { - mModel->doSomething(sourceAdd); - } + mModel->doSomething(mModel->getSourceAdd()); + }; // } \ No newline at end of file