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@0:31ce4ad8c8f6, 2017-09-08 (annotated)
- Committer:
- uru
- Date:
- Fri Sep 08 06:58:17 2017 +0000
- Revision:
- 0:31ce4ad8c8f6
- Child:
- 1:a04fadd675dc
???
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 | 0:31ce4ad8c8f6 | 4 | i2c.write(adr<<1,&PORT,1); |
| uru | 0:31ce4ad8c8f6 | 5 | } |
| uru | 0:31ce4ad8c8f6 | 6 | solenoid::solenoid(PinName sda,PinName scl,char adr_):i2c(sda,scl) |
| uru | 0:31ce4ad8c8f6 | 7 | { |
| uru | 0:31ce4ad8c8f6 | 8 | adr=adr_; |
| uru | 0:31ce4ad8c8f6 | 9 | } |
| uru | 0:31ce4ad8c8f6 | 10 | solenoid::solenoid(I2C& I2c,char adr_):i2c(I2c) |
| uru | 0:31ce4ad8c8f6 | 11 | { |
| uru | 0:31ce4ad8c8f6 | 12 | adr=adr_; |
| uru | 0:31ce4ad8c8f6 | 13 | } |
| uru | 0:31ce4ad8c8f6 | 14 | solenoid& solenoid::operator=(char po) |
| uru | 0:31ce4ad8c8f6 | 15 | { |
| uru | 0:31ce4ad8c8f6 | 16 | PORT=po; |
| uru | 0:31ce4ad8c8f6 | 17 | output(); |
| uru | 0:31ce4ad8c8f6 | 18 | return *this; |
| uru | 0:31ce4ad8c8f6 | 19 | } |
| uru | 0:31ce4ad8c8f6 | 20 | void solenoid::Port(char port,char po) |
| uru | 0:31ce4ad8c8f6 | 21 | { |
| uru | 0:31ce4ad8c8f6 | 22 | port= 0b100000000 >> port; |
| uru | 0:31ce4ad8c8f6 | 23 | if(po==0) { |
| uru | 0:31ce4ad8c8f6 | 24 | port ^= 0xFF; |
| uru | 0:31ce4ad8c8f6 | 25 | PORT = PORT & port; |
| uru | 0:31ce4ad8c8f6 | 26 | } else |
| uru | 0:31ce4ad8c8f6 | 27 | PORT = PORT | port; |
| uru | 0:31ce4ad8c8f6 | 28 | output(); |
| uru | 0:31ce4ad8c8f6 | 29 | } |