Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
solenoid.cpp@1:a04fadd675dc, 2017-09-27 (annotated)
- Committer:
- uru
- Date:
- Wed Sep 27 10:10:41 2017 +0000
- Revision:
- 1:a04fadd675dc
- Parent:
- 0:31ce4ad8c8f6
oobobobobobobob
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| uru | 0:31ce4ad8c8f6 | 1 | #include "solenoid.h" |
| uru | 0:31ce4ad8c8f6 | 2 | void solenoid::output() |
| uru | 0:31ce4ad8c8f6 | 3 | { |
| uru | 1:a04fadd675dc | 4 | i2c->write(adr<<1,&PORT,1); |
| uru | 0:31ce4ad8c8f6 | 5 | } |
| uru | 1:a04fadd675dc | 6 | solenoid::solenoid(I2C *I2c,char adr_):i2c(I2c) |
| uru | 0:31ce4ad8c8f6 | 7 | { |
| uru | 0:31ce4ad8c8f6 | 8 | adr=adr_; |
| uru | 0:31ce4ad8c8f6 | 9 | } |
| uru | 0:31ce4ad8c8f6 | 10 | solenoid& solenoid::operator=(char po) |
| uru | 0:31ce4ad8c8f6 | 11 | { |
| uru | 0:31ce4ad8c8f6 | 12 | PORT=po; |
| uru | 0:31ce4ad8c8f6 | 13 | output(); |
| uru | 0:31ce4ad8c8f6 | 14 | return *this; |
| uru | 0:31ce4ad8c8f6 | 15 | } |
| uru | 0:31ce4ad8c8f6 | 16 | void solenoid::Port(char port,char po) |
| uru | 0:31ce4ad8c8f6 | 17 | { |
| uru | 0:31ce4ad8c8f6 | 18 | port= 0b100000000 >> port; |
| uru | 0:31ce4ad8c8f6 | 19 | if(po==0) { |
| uru | 0:31ce4ad8c8f6 | 20 | port ^= 0xFF; |
| uru | 0:31ce4ad8c8f6 | 21 | PORT = PORT & port; |
| uru | 0:31ce4ad8c8f6 | 22 | } else |
| uru | 0:31ce4ad8c8f6 | 23 | PORT = PORT | port; |
| uru | 0:31ce4ad8c8f6 | 24 | output(); |
| uru | 0:31ce4ad8c8f6 | 25 | } |