Johannes Otto
/
simple_stm_ignition
programmable ignition for an mz ts 150. The interruptor needs to be replaced by an hall effect sensor
Diff: main.cpp
- Revision:
- 3:5efd78be4662
- Parent:
- 2:469b3daa6b98
--- a/main.cpp Tue Oct 13 16:41:04 2015 +0000 +++ b/main.cpp Sun Oct 25 16:58:59 2015 +0000 @@ -1,54 +1,14 @@ #include "mbed.h" - -InterruptIn interruptor(D2); - -float offset=34.14f; -float def_ignition=26.13f; - - -class IgnMod -{ -private: - Timeout ignition_timer; - Timer t; - - DigitalOut *pin; - - int ignition_length; - int round_time; - int ignition_delay; +#include "IgnitionModule.h" - void on() { - pin->write(1); - ignition_timer.attach_us(this,&IgnMod::off,ignition_length); - } - void off() { - pin->write(0); - } - - int get_delay(int round_time) { - return round_time*(offset-def_ignition)/360; - } -public: - IgnMod() { - ignition_length=100; - DigitalOut pin(D3); - t.start(); - } - void ignite() { - round_time=t.read_us(); - t.reset(); - ignition_delay=get_delay(round_time); - ignition_timer.attach_us(this,&IgnMod::on,ignition_delay-t.read_us()); - } -}; - -IgnMod ignition; +InterruptIn interruptor(D15); +IgnMod ignition(D4,100,6.0f,3.0f,58.0f); int main() -{ +{ + wait(1); + interruptor.rise(&ignition,&IgnMod::ignite); interruptor.mode(PullUp); - interruptor.rise(&ignition,&IgnMod::ignite); - while(1) { + while(1) { } } \ No newline at end of file