mirror of
https://github.com/dexterbg/Twizy-Virtual-BMS.git
synced 2024-11-08 12:25:42 +00:00
- New API calls stateName(), stateName(state)
- No out of bounds error messages in TWIZY_DEBUG_LEVEL 0 - Donors update
This commit is contained in:
parent
ee4e5ae7a2
commit
ce7c6e8311
10 changed files with 45 additions and 23 deletions
1
API.md
1
API.md
|
@ -173,6 +173,7 @@ See [protocol documentation](extras/Protocol.ods) for details.
|
|||
|
||||
__API:__
|
||||
- `TwizyState state()` -- Query current state
|
||||
- `FLASHSTRING *stateName([state])` -- Query name of current state / specific state
|
||||
- `bool inState(TwizyState state1 [, … state5])` -- Test for 1-5 states
|
||||
- `void enterState(TwizyState newState)` -- Force a state change
|
||||
- Call `enterState(StopCharge)` to stop a running charge process. Note that `setChargeCurrent(0)` will do so as well.
|
||||
|
|
|
@ -9,6 +9,8 @@ Add a comment to your donation if you want to stay anonymous.
|
|||
|
||||
*The following people have won our eternal love and respect by kindly supporting this project:*
|
||||
|
||||
- Bryce Nash
|
||||
- Michael Langerhorst
|
||||
- **Andreas Schmidt**
|
||||
- Philip Despriet
|
||||
- **Błażej Błaszczyk** :)
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
# History
|
||||
|
||||
## Version 1.2.1 (2017-08-17)
|
||||
|
||||
- New API calls stateName(), stateName(state)
|
||||
- No out of bounds error messages in TWIZY_DEBUG_LEVEL 0
|
||||
|
||||
|
||||
## Version 1.2.0 (2017-07-29)
|
||||
|
||||
- Ticker increments clockCnt on exit (first hook call with clockCnt=0)
|
||||
|
|
|
@ -351,7 +351,7 @@ void bmsTicker(unsigned int clockCnt) {
|
|||
// bmsTicker: Output state to bluetooth port
|
||||
//
|
||||
|
||||
bt.print(FS(twizyStateName[twizy.state()]));
|
||||
bt.print(twizy.stateName());
|
||||
bt.print(F(" -- "));
|
||||
bt.print(temp, 1); bt.print(F(" °C -- "));
|
||||
bt.print(soc, 1); bt.print(F(" %SOC -- "));
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#define _TwizyVirtualBMS_config_h
|
||||
|
||||
// Serial debug output:
|
||||
// Level 0 = none, only output init & error messages
|
||||
// Level 1 = log state transitions & CAN statistics
|
||||
// Level 0 = none, only output init message
|
||||
// Level 1 = log state transitions, errors & CAN statistics
|
||||
// Level 2 = log CAN frame dumps (10 second interval)
|
||||
#define TWIZY_DEBUG_LEVEL 1
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#define _TwizyVirtualBMS_config_h
|
||||
|
||||
// Serial debug output:
|
||||
// Level 0 = none, only output init & error messages
|
||||
// Level 1 = log state transitions & CAN statistics
|
||||
// Level 0 = none, only output init message
|
||||
// Level 1 = log state transitions, errors & CAN statistics
|
||||
// Level 2 = log CAN frame dumps (10 second interval)
|
||||
#define TWIZY_DEBUG_LEVEL 1
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#define _TwizyVirtualBMS_config_h
|
||||
|
||||
// Serial debug output:
|
||||
// Level 0 = none, only output init & error messages
|
||||
// Level 1 = log state transitions & CAN statistics
|
||||
// Level 0 = none, only output init message
|
||||
// Level 1 = log state transitions, errors & CAN statistics
|
||||
// Level 2 = log CAN frame dumps (10 second interval)
|
||||
#define TWIZY_DEBUG_LEVEL 1
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ sendMsg KEYWORD2
|
|||
setCanFilter KEYWORD2
|
||||
|
||||
state KEYWORD2
|
||||
stateName KEYWORD2
|
||||
inState KEYWORD2
|
||||
enterState KEYWORD2
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name=Twizy Virtual BMS
|
||||
version=1.1.0
|
||||
version=1.2.1
|
||||
author=Michael Balzer
|
||||
maintainer=Michael Balzer <dexter@dexters-web.de>
|
||||
sentence=Emulation of Renault Twizy BMS (battery management system)
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#ifndef _TwizyVirtualBMS_h
|
||||
#define _TwizyVirtualBMS_h
|
||||
|
||||
#define TWIZY_VBMS_VERSION "V1.2.0 (2017-07-29)"
|
||||
#define TWIZY_VBMS_VERSION "V1.2.1 (2017-08-16)"
|
||||
|
||||
#ifndef TWIZY_TAG
|
||||
#define TWIZY_TAG "twizy."
|
||||
|
@ -93,7 +93,6 @@ enum TwizyState {
|
|||
};
|
||||
|
||||
// Twizy state names:
|
||||
#if TWIZY_DEBUG_LEVEL >= 1
|
||||
const char twizyStateName[13][13] PROGMEM = {
|
||||
"Off",
|
||||
"Init",
|
||||
|
@ -109,7 +108,6 @@ const char twizyStateName[13][13] PROGMEM = {
|
|||
"Trickle",
|
||||
"StopTrickle"
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
// Known error codes for setError():
|
||||
|
@ -139,6 +137,7 @@ typedef void (*TwizyProcessCanMsgCallback)(unsigned long rxId, byte rxLen, byte
|
|||
#define FLASHSTRING const __FlashStringHelper
|
||||
#define FS(x) (__FlashStringHelper*)(x)
|
||||
|
||||
#if TWIZY_DEBUG_LEVEL >= 1
|
||||
// Parameter boundary check with error output:
|
||||
#define CHECKLIMIT(var, minval, maxval) \
|
||||
if (var < minval || var > maxval) { \
|
||||
|
@ -149,6 +148,13 @@ if (var < minval || var > maxval) { \
|
|||
Serial.println(F(" out of bounds [" #minval "," #maxval "]")); \
|
||||
return false; \
|
||||
}
|
||||
#else
|
||||
// Parameter boundary check with quiet error:
|
||||
#define CHECKLIMIT(var, minval, maxval) \
|
||||
if (var < minval || var > maxval) { \
|
||||
return false; \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// -----------------------------------------------------
|
||||
|
@ -216,6 +222,12 @@ public:
|
|||
TwizyState state() {
|
||||
return twizyState;
|
||||
}
|
||||
FLASHSTRING *stateName(TwizyState state) {
|
||||
return FS(twizyStateName[state]);
|
||||
}
|
||||
FLASHSTRING *stateName() {
|
||||
return FS(twizyStateName[twizyState]);
|
||||
}
|
||||
bool inState(TwizyState state1) {
|
||||
return (twizyState==state1);
|
||||
}
|
||||
|
@ -851,7 +863,7 @@ void TwizyVirtualBMS::debugInfo() {
|
|||
Serial.println(F("\n" TWIZY_TAG "debugInfo:"));
|
||||
|
||||
Serial.print(F("- twizyState="));
|
||||
Serial.println(FS(twizyStateName[twizyState]));
|
||||
Serial.println(stateName());
|
||||
|
||||
Serial.print(F("- clockCnt="));
|
||||
Serial.println(clockCnt);
|
||||
|
@ -905,7 +917,7 @@ void TwizyVirtualBMS::enterState(TwizyState newState) {
|
|||
|
||||
#if TWIZY_DEBUG_LEVEL >= 1
|
||||
Serial.print(F(TWIZY_TAG "enterState: newState="));
|
||||
Serial.println(FS(twizyStateName[newState]));
|
||||
Serial.println(stateName(newState));
|
||||
#endif
|
||||
|
||||
switch (newState) {
|
||||
|
|
Loading…
Reference in a new issue