ニクロム線に電流を流したり流さなかったりするライブラリです.
Dependents: Hybrid_main_FirstEdtion HYBRYD2018_IZU_ROCKET
Diff: nicrom.hpp
- Revision:
- 0:55796b0c5005
- Child:
- 1:c39bb138b40c
diff -r 000000000000 -r 55796b0c5005 nicrom.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nicrom.hpp Mon Feb 20 08:07:38 2017 +0000 @@ -0,0 +1,60 @@ +#ifndef _NICROM_HPP_ +#define _NICROM_HPP_ + +/** + @file nicrom.hpp + @author Gaku MATSUMOTO + @bref ニクロム線に電流を流したり流さなかったりするライブラリです. + @note オブジェクト指向の真似事としてクラスにしてみました. +*/ +class Nicrom{ + public: + Nicrom(PinName _pin); + private: + Timeout stopTimer; + Nicrom* _nic; + DigitalOut _nicrom; + PinName pinBango; + public: + int status; + void fire(); + void stop(); + void autoStop(float t); +}; + +Nicrom::Nicrom(PinName _pin) : _nicrom(_pin){ + _nic = this; + pinBango = _pin; + _nicrom = 0; + status = 0; +} + +/** + @bref ニクロム線を通電します. + @note 当然ですが,あくまでトリガーとして利用してください. +*/ +void Nicrom::fire(){ + _nicrom = 1; + status = 1; + printf("fire\r\n"); +} + +/** + @bref ニクロム線の電流を止めます. + @note MOSFETの種類によっては漏れ電流などで少し流れる場合があります. +*/ +void Nicrom::stop(){ + _nicrom = 0; + status = 0; + printf("stop\r\n"); +} + +/** + @bref 指定した時間だけ,電流を流し,時間が来たら止めます. + @note 連続で何度も実行しないようにお願いします. +*/ +void Nicrom::autoStop(float t){ + fire(); + stopTimer.attach(_nic, &Nicrom::stop, t); +} +#endif \ No newline at end of file