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.
Fork of Can_sniffer_BMS4 by
Diff: main.cpp
- Revision:
- 30:1bc79ae58a42
- Parent:
- 29:3af76325f86a
- Child:
- 31:6427569cadbe
--- a/main.cpp Tue Oct 25 08:24:50 2016 +0000 +++ b/main.cpp Tue Oct 25 12:50:07 2016 +0000 @@ -142,16 +142,12 @@ bool key_switch = 0; -void flip() +void refresh() { key_switch = !key_switch; - led = key_switch; - + // led = key_switch; to_send=1; //printf("controller switch\r\n"); - - - // to_send = 1; } @@ -165,7 +161,7 @@ } -Ticker flipper; +Ticker refresher; Ticker printer; typedef union can_union { @@ -174,7 +170,9 @@ float f[2]; } data; -bool to_charge_or_not_to_charge=true; // false = discharge +//bool to_charge_or_not_to_charge=true; // false = discharge +bool charging = false; + uint8_t motostate=0; int main() @@ -182,7 +180,7 @@ { can.frequency(1000000); // set bit rate to 1Mbps can.attach(&onMsgReceived); // attach 'CAN receive-complete' interrupt handler - flipper.attach(&flip, 30); // turn on or off + refresher.attach(&refresh, 5); // turn on or off printer.attach(&cvprint, 20); // turn on o led=key_switch; @@ -226,7 +224,7 @@ txMsg.clear(); txMsg.id = 9; //BMS1=>ID:11; BMS2=>ID:12; BMS3=>ID:13. txMsg.len = 1; - motostate = (0b00000001 & key_switch)|((0b00000001 & to_charge_or_not_to_charge)<<1); + motostate = (0b00000001 & key_switch)|((0b00000001 & charging)<<1); txMsg.data[0] = motostate; //------------------------------------------------