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.
Dependents: Motorino_Lib xxx_Motorino_Lib
Kanal.cpp
00001 #include "Kanal.h" 00002 00003 Kanal::Kanal(int nr) 00004 { 00005 this->nr=nr; 00006 meinMotorino=Motorino::gibMotorino(); 00007 Bewegung=new Thread(); 00008 Bewegung->start(callback(this,&Kanal::fahre)); 00009 } 00010 00011 Kanal::Kanal() 00012 { 00013 } 00014 00015 void Kanal::fahre() 00016 { 00017 while(1) 00018 { 00019 if (busy==true) 00020 { 00021 printf("gestartet %d\r\n",nr); 00022 for (int i=0;i<zyklen;i++) 00023 { 00024 w_alt+=dw; 00025 //printf("w alt %d zyklen %d\r\n",(int)w_alt,zyklen); 00026 meinMotorino->servo(w_alt,nr,start,end); //pos 0..180° 00027 ThisThread::sleep_for(25ms); 00028 } 00029 meinMotorino->servo(w_ziel,nr,start,end); //pos 0..180° 00030 w_alt=w_ziel; 00031 busy=false; 00032 } 00033 ThisThread::sleep_for(50ms); 00034 } 00035 } 00036 00037 void Kanal::go(float w, int zeit) //Zeit in ms 00038 { 00039 printf("gostart %d, %d, %d\r\n",(int)w,zeit,(int) busy); 00040 if (busy==false) 00041 { 00042 zyklen=zeit/25; 00043 dw=(w-w_alt)/zyklen; 00044 w_ziel=w; 00045 busy=true; 00046 } 00047 00048 } 00049 00050 void Kanal::grundstellung(float w) 00051 { 00052 meinMotorino->servo(w,nr,start,end); //pos 0..180° 00053 w_alt=w; 00054 } 00055 00056 bool Kanal::isBusy() 00057 { 00058 //if (busy==false) Bewegung.terminate(); 00059 return busy; 00060 } 00061 00062 void Kanal::setStartEnd(float pStart, float pEnd) 00063 { 00064 if (pStart>0 && pStart<100 && pStart<pEnd) start=pStart; 00065 if (pEnd>0 && pEnd<100 && pStart<pEnd) end=pEnd; 00066 } 00067
Generated on Mon Sep 5 2022 02:15:19 by
1.7.2