Library for heating Nichrome
Nichrome_lib.cpp@0:e1e1b1f8c5d9, 2020-03-17 (annotated)
- Committer:
- Sigma884
- Date:
- Tue Mar 17 12:30:27 2020 +0000
- Revision:
- 0:e1e1b1f8c5d9
commit for publish stability_seed2019_v1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sigma884 | 0:e1e1b1f8c5d9 | 1 | #include "Nichrome_lib.h" |
Sigma884 | 0:e1e1b1f8c5d9 | 2 | #include "mbed.h" |
Sigma884 | 0:e1e1b1f8c5d9 | 3 | |
Sigma884 | 0:e1e1b1f8c5d9 | 4 | Nichrome_lib :: Nichrome_lib(PinName userPin) : nichrome(userPin){ |
Sigma884 | 0:e1e1b1f8c5d9 | 5 | nlib = this; |
Sigma884 | 0:e1e1b1f8c5d9 | 6 | nichrome = 0; |
Sigma884 | 0:e1e1b1f8c5d9 | 7 | status = false; |
Sigma884 | 0:e1e1b1f8c5d9 | 8 | } |
Sigma884 | 0:e1e1b1f8c5d9 | 9 | |
Sigma884 | 0:e1e1b1f8c5d9 | 10 | void Nichrome_lib :: fire(float time){ |
Sigma884 | 0:e1e1b1f8c5d9 | 11 | if(time <= 0.0f){ |
Sigma884 | 0:e1e1b1f8c5d9 | 12 | return; |
Sigma884 | 0:e1e1b1f8c5d9 | 13 | } |
Sigma884 | 0:e1e1b1f8c5d9 | 14 | fire_on(); |
Sigma884 | 0:e1e1b1f8c5d9 | 15 | stopTime.attach(nlib, &Nichrome_lib::fire_off, time); |
Sigma884 | 0:e1e1b1f8c5d9 | 16 | } |
Sigma884 | 0:e1e1b1f8c5d9 | 17 | |
Sigma884 | 0:e1e1b1f8c5d9 | 18 | void Nichrome_lib :: fire_on(){ |
Sigma884 | 0:e1e1b1f8c5d9 | 19 | nichrome = 1; |
Sigma884 | 0:e1e1b1f8c5d9 | 20 | status = true; |
Sigma884 | 0:e1e1b1f8c5d9 | 21 | } |
Sigma884 | 0:e1e1b1f8c5d9 | 22 | |
Sigma884 | 0:e1e1b1f8c5d9 | 23 | void Nichrome_lib :: fire_off(){ |
Sigma884 | 0:e1e1b1f8c5d9 | 24 | nichrome = 0; |
Sigma884 | 0:e1e1b1f8c5d9 | 25 | status = false; |
Sigma884 | 0:e1e1b1f8c5d9 | 26 | } |