![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
dfawer
Dependencies: FuncGen Serial_HL mbed
Fork of ProcVisDemo by
Revision 2:7884bf7a7dae, committed 2017-04-25
- Comitter:
- ogris
- Date:
- Tue Apr 25 06:53:30 2017 +0000
- Parent:
- 1:e88b745f2ca2
- Commit message:
- asw
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BtnEventM0.h Tue Apr 25 06:53:30 2017 +0000 @@ -0,0 +1,174 @@ + +// V4.0 + +class BtnEventM0 { + public: + int16_t pressed; + + BtnEventM0(PinName pin) : _isr(pin) + { pressed=0; } + + // Ist eine steigende Flanke aufgetreten ? + int CheckFlag(); + + // 1..Button is pressed else 0 + int CheckButton() + { return _isr.read(); } + + void Init(); + // { _isr.rise(this,&BtnEventM0::RisingISR); } + + void RisingISR(); + + protected: + InterruptIn _isr; +}; + +void BtnEventM0::Init() + { _isr.rise(this,&BtnEventM0::RisingISR); } + +void BtnEventM0::RisingISR() +{ + if( _isr.read() ) + pressed = 1; +} + +int BtnEventM0::CheckFlag() +{ + if( pressed ) + { pressed=0; return 1; } + return 0; +} + + + + + +/* +class BtnEventM02 : public BtnEventM0 +{ +public: + BtnEventM02(PinName pin) : BtnEventM0(pin) { + _tm.stop(); + _tm.reset(); + _state=1; + } + + void Init() { + _isr.rise(this, &BtnEventM02::RisingISR); + } + + void RisingISR() { + if( !_isr.read() ) + return; + pressed = 1; + _tm.start(); + _state = 2; + } + + void CheckButton() { + if( _state==1 ) + return; + if( _state==2 ) { + if( !_isr.read() ) { + _state = 1; + return; + } + if( _tm.read_ms()>500 ) { + _tm.reset(); + _state = 3; + pressed = 1; + } + } else if( _state==3 ) { + if( !_isr.read() ) { + _state = 1; + return; + } + if( _tm.read_ms()>100 ) { + _tm.reset(); + _state = 3; + pressed = 1; + } + } + } +private: + int16_t _state; + Timer _tm; +}; +*/ + +class AnalogInHL : public AnalogIn +{ +public: + AnalogInHL(PinName pin) : AnalogIn(pin) { } + int Read() { + return read_u16()>>6; + } +}; + +class BtnEventM0S { + public: + BtnEventM0S(PinName pin) : _btn(pin) { } + + void Init() {} + + // Ist eine steigende Flanke aufgetreten ? + int CheckFlag() + { + if( _btn ) + { wait_ms(100); return 1; } + else + return 0; + } + + protected: + DigitalIn _btn; +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FuncGen.lib Tue Apr 25 06:53:30 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/Projekte_werkstatt/code/FuncGen/#2e0be62147b1
--- a/ProcVisDemo.cpp Fri Oct 09 07:58:26 2015 +0000 +++ b/ProcVisDemo.cpp Tue Apr 25 06:53:30 2017 +0000 @@ -1,66 +1,62 @@ #include "mbed.h" #include "Serial_HL.h" - +#include "FuncGenFSST3.h" + SerialBLK pc(USBTX, USBRX); SvProtocol ua0(&pc); -// V2.0 -// BusOut leds(LED1,LED2,LED3,LED4); Bertl14 -// M0-Board -BusOut leds(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1); +void CommandHandler(); +SingnedRampGen fg1; +float ampl=1.0, v1=0.0; -void CommandHandler(); +void ExecSignalChain(); int main(void) { - pc.format(8,SerialBLK::None,1); - pc.baud(115200); - leds = 9; - - ua0.SvMessage("SvTest_Serial_HL"); // Meldung zum PC senden + pc.format(8,SerialBLK::None,1); pc.baud(500000); // 115200 + + + ua0.SvMessage("FuncGenMain2"); // Meldung zum PC senden + + Timer stw; stw.start(); + while(1) // while(1)-Loop der mit dem PC kommuniziert + { + CommandHandler(); + if( (stw.read_ms()>10) ) // 100Hz + { // dieser Teil wird mit 100Hz aufgerufen + ExecSignalChain(); + stw.reset(); + if( ua0.acqON ) { + ua0.WriteSV(1, v1); + } + } + } + return 1; +} - int16_t sv1=0, sv2=100; - Timer stw; - stw.start(); - while(1) { - CommandHandler(); - if( ua0.acqON && (stw.read_ms()>100) ) { // 10Hz - // dieser Teil wird mit 10Hz aufgerufen - stw.reset(); - sv1++; - sv2++; - if( ua0.acqON ) { - // nur wenn vom PC aus das Senden eingeschaltet wurde - // wird auch etwas gesendet - ua0.WriteSvI16(1, sv1); - ua0.WriteSvI16(2, sv2); - } - } - } - return 1; +void ExecSignalChain() +{ + fg1.CalcOneStep(); + v1 = fg1.val*ampl; } void CommandHandler() { - uint8_t cmd; - int16_t idata1, idata2; - - // Fragen ob überhaupt etwas im RX-Reg steht - if( !pc.IsDataAvail() ) - return; + uint8_t cmd; + if( !pc.IsDataAvail() ) + return; + cmd = ua0.GetCommand(); - // wenn etwas im RX-Reg steht - // Kommando lesen - cmd = ua0.GetCommand(); + if( cmd==2 ) { // set Frequ + fg1.SetFrequ(ua0.ReadF()); + ua0.SvMessage("SetFrequ"); + } - if( cmd==2 ) { - // cmd2 hat 2 int16 Parameter - idata1 = ua0.ReadI16(); - idata2 = ua0.ReadI16(); - // für die Analyse den Wert einfach nur zum PC zurücksenden - ua0.SvPrintf("Command2 %d %d", idata1, idata2); - } + if( cmd==3 ) { // set Ampl + ampl = ua0.ReadF(); + ua0.SvMessage("Set Ampl"); + } }