![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Contains all code needed for analog digital and oscope
Diff: main.cpp
- Revision:
- 4:374219f35b8e
- Parent:
- 3:60f30ca6a65d
- Child:
- 5:6b72bf1da751
--- a/main.cpp Tue Apr 21 22:00:33 2020 +0000 +++ b/main.cpp Wed Apr 22 19:42:30 2020 +0000 @@ -68,6 +68,7 @@ volatile bool newoScope=false; volatile unsigned char oScopeArray[20000]; volatile int oScopeCount=0; +volatile unsigned char oScopeTriggerType; void digital_sample_func(void) //sampling function, samples each pin specified and Ors it @@ -130,16 +131,36 @@ } void oScope_poll_trig(){ - /* - float first, second; - bool run_poll =true; - while(run_poll){ - first = a1; - wait (.001); - second=a1; - if( (second - first)>.1){run_poll = false;} - } */ + bool nTriggered = true; + myled=1; + unsigned char trig; + int state =0; + while(nTriggered){ + + trig=a1*254; + switch(state){ + + case 0: + if((trig < 85) & (oScopeTriggerType == rise) ){state = 1;} + else if((trig > 85) & (oScopeTriggerType == fall) ){state = 2;} + else { state = 0;} + break; + case 1: + if(trig < 85){state=1;} + if(trig > 85){state=3;} + break; + case 2: + if(trig > 85){state = 2;} + if(trig < 85){state = 3;} + break; + case 3: + nTriggered=false; + break; + } + wait(.01); + } + myled=0; switch(oScopeTime) { case ms1: @@ -213,6 +234,7 @@ oScopeTime=command & timeMask; oScope_poll=true; oScopeStatus=1; + oScopeTriggerType= command & trigger; break; } }