andrei popa
/
4Ctestwidwid
s
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "C12832.h" 00003 00004 Serial pc(USBTX, USBRX); // tx, rx 00005 DigitalOut led(LED1); 00006 00007 Thread blinky; 00008 Thread joythread; 00009 00010 PwmOut led1 (LED1); 00011 DigitalIn down(A3); 00012 DigitalIn up(A2); 00013 BusIn joy(p15,p12,p13,p16); 00014 00015 00016 unsigned int ton_off = 1000; 00017 00018 void plus100(){ 00019 ton_off=ton_off+100; 00020 if(ton_off<2000){ ton_off=2000; } 00021 } 00022 00023 void minus100(){ 00024 ton_off=ton_off-100; 00025 if(ton_off<200){ ton_off=200; } 00026 } 00027 00028 void Joy_of_thread() 00029 { 00030 for(;;) 00031 { 00032 if(up){ 00033 plus100(); 00034 //p15.rise(&plus100); 00035 pc.printf("wartezeit zwischen ein-aus:%d",ton_off); 00036 } 00037 00038 if(down){ 00039 minus100(); 00040 //p12.rise(&minus100); 00041 pc.printf("wartezeit zwischen ein-aus:%d",ton_off); 00042 00043 } 00044 thread_sleep_for(10);//fragen sie alle 10ms die tasten ab 00045 } 00046 } 00047 00048 00049 void blinky_thread() 00050 { 00051 for(;;) //wie while(true), es ist aber grad in. 00052 { 00053 led1=1; 00054 thread_sleep_for(ton_off); 00055 led1=0; 00056 thread_sleep_for(ton_off); 00057 } 00058 } 00059 00060 int main() 00061 { 00062 blinky.start(blinky_thread); 00063 joythread.start(Joy_of_thread); 00064 00065 while(1){ 00066 wait(1); 00067 } 00068 } // Klammern {} Gross-klein schreibung while() 00069 00070
Generated on Tue Aug 9 2022 20:42:47 by 1.7.2