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.
Switch.cpp@25:90f7a34c253a, 2018-06-20 (annotated)
- Committer:
- jasminealice
- Date:
- Wed Jun 20 09:41:20 2018 +0000
- Revision:
- 25:90f7a34c253a
- Parent:
- 23:bb57966cb776
- Child:
- 31:9d973398554f
Code from 19/6
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jasminealice | 19:72b14c6cc845 | 1 | #include "Switch.h" |
| jasminealice | 19:72b14c6cc845 | 2 | |
| jasminealice | 20:32ba0a5f2d02 | 3 | Switch::Switch(const unsigned int newaddress, const unsigned int newinst) |
| jasminealice | 19:72b14c6cc845 | 4 | { |
| jasminealice | 19:72b14c6cc845 | 5 | //ctor |
| jasminealice | 19:72b14c6cc845 | 6 | address = newaddress; |
| jasminealice | 20:32ba0a5f2d02 | 7 | inst = newinst; |
| jasminealice | 25:90f7a34c253a | 8 | nrPacket = 20; |
| jasminealice | 20:32ba0a5f2d02 | 9 | if(inst == 0x82) |
| jasminealice | 25:90f7a34c253a | 10 | nrPacket = 50; |
| jasminealice | 23:bb57966cb776 | 11 | if(inst == 0x84)// || inst == 0x81) |
| jasminealice | 23:bb57966cb776 | 12 | switchOn(); |
| jasminealice | 23:bb57966cb776 | 13 | else |
| jasminealice | 23:bb57966cb776 | 14 | switchOff(); |
| jasminealice | 21:31647d80614f | 15 | |
| jasminealice | 19:72b14c6cc845 | 16 | } |
| jasminealice | 19:72b14c6cc845 | 17 | |
| jasminealice | 19:72b14c6cc845 | 18 | Switch::~Switch() |
| jasminealice | 19:72b14c6cc845 | 19 | { |
| jasminealice | 19:72b14c6cc845 | 20 | //dtor |
| jasminealice | 19:72b14c6cc845 | 21 | } |
| jasminealice | 20:32ba0a5f2d02 | 22 | |
| jasminealice | 20:32ba0a5f2d02 | 23 | void Switch::switchOn(){ |
| jasminealice | 20:32ba0a5f2d02 | 24 | DCC_send_command(address, inst, nrPacket); |
| jasminealice | 20:32ba0a5f2d02 | 25 | } |
| jasminealice | 20:32ba0a5f2d02 | 26 | |
| jasminealice | 20:32ba0a5f2d02 | 27 | void Switch::switchOff() { |
| jasminealice | 20:32ba0a5f2d02 | 28 | DCC_send_command(address, inst, nrPacket); |
| jasminealice | 20:32ba0a5f2d02 | 29 | unsigned int off = 0x80; |
| jasminealice | 20:32ba0a5f2d02 | 30 | DCC_send_command(address, off, nrPacket); |
| jasminealice | 20:32ba0a5f2d02 | 31 | } |
