This commit is contained in:
2021-05-23 17:43:44 +02:00
parent facbbcf798
commit d27eb54fe3
2 changed files with 59 additions and 58 deletions

View File

@@ -44,13 +44,7 @@
#define BAT_CALIB_REAL_VOLTAGE 3970 // input voltage measured by multimeter (multiplied by 100). For example 43.00 V * 100 = 4300
#define BAT_CALIB_ADC 1492 // adc-value measured by mainboard (value nr 5 on UART debug output)
#define BAT_CELLS 10 // battery number of cells. Normal Hoverboard battery: 10s
#define BAT_LOW_LVL1_ENABLE 0 // to beep or not to beep, 1 or 0
#define BAT_LOW_LVL2_ENABLE 1 // to beep or not to beep, 1 or 0
#define BAT_LOW_LVL1 (360 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE // gently beeps at this voltage level. [V*100/cell]. In this case 3.60 V/cell
#define BAT_LOW_LVL2 (350 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE // your battery is almost empty. Charge now! [V*100/cell]. In this case 3.50 V/cell
#define BAT_LOW_DEAD (337 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE // undervoltage poweroff. (while not driving) [V*100/cell]. In this case 3.37 V/cell
#define BAT_CELLS 12 // battery number of cells. Normal Hoverboard battery: 10s
/* Board overheat detection: the sensor is inside the STM/GD chip.
* It is very inaccurate without calibration (up to 45°C). So only enable this funcion after calibration!

View File

@@ -1567,8 +1567,8 @@ void applyIncomingCanMessage()
using namespace bobbycar::can;
case MotorController<isBackBoard, false>::Command::Enable: left .enable = *((bool *)buf); break;
case MotorController<isBackBoard, true> ::Command::Enable: right.enable = *((bool *)buf); break;
case MotorController<isBackBoard, false>::Command::InpTgt: timeoutCntLeft = 0; left.rtU.r_inpTgt = *((int16_t*)buf); break;
case MotorController<isBackBoard, true>::Command::InpTgt: timeoutCntRight = 0; right.rtU.r_inpTgt = *((int16_t*)buf); break;
case MotorController<isBackBoard, false>::Command::InpTgt: left. rtU.r_inpTgt = *((int16_t*)buf); timeoutCntLeft = 0; break;
case MotorController<isBackBoard, true> ::Command::InpTgt: right.rtU.r_inpTgt = *((int16_t*)buf); timeoutCntRight = 0; break;
case MotorController<isBackBoard, false>::Command::CtrlTyp: left .rtP.z_ctrlTypSel = *((uint8_t*)buf); break;
case MotorController<isBackBoard, true> ::Command::CtrlTyp: right.rtP.z_ctrlTypSel = *((uint8_t*)buf); break;
case MotorController<isBackBoard, false>::Command::CtrlMod: left .rtU.z_ctrlModReq = *((uint8_t*)buf); break;
@@ -1587,14 +1587,21 @@ void applyIncomingCanMessage()
case MotorController<isBackBoard, true> ::Command::CruiseCtrlEna: right.rtP.b_cruiseCtrlEna = *((bool*)buf); break;
case MotorController<isBackBoard, false>::Command::CruiseMotTgt: left .rtP.n_cruiseMotTgt = *((int16_T*)buf); break;
case MotorController<isBackBoard, true> ::Command::CruiseMotTgt: right.rtP.n_cruiseMotTgt = *((int16_T*)buf); break;
case MotorController<isBackBoard, false>::Command::BuzzerFreq: buzzer.freq = *((uint8_t*)buf); break;
case MotorController<isBackBoard, false>::Command::BuzzerFreq:
case MotorController<isBackBoard, true> ::Command::BuzzerFreq: buzzer.freq = *((uint8_t*)buf); break;
case MotorController<isBackBoard, false>::Command::BuzzerPattern: buzzer.pattern = *((uint8_t*)buf); break;
case MotorController<isBackBoard, false>::Command::BuzzerPattern:
case MotorController<isBackBoard, true> ::Command::BuzzerPattern: buzzer.pattern = *((uint8_t*)buf); break;
case MotorController<isBackBoard, false>::Command::Led: break;
case MotorController<isBackBoard, true>::Command::Led: break;
case MotorController<isBackBoard, false>::Command::Poweroff: break;
case MotorController<isBackBoard, true>::Command::Poweroff: break;
case MotorController<isBackBoard, false>::Command::Led:
case MotorController<isBackBoard, true> ::Command::Led:
HAL_GPIO_WritePin(LED_PORT, LED_PIN, *((bool*)buf) ? GPIO_PIN_SET : GPIO_PIN_RESET);
break;
case MotorController<isBackBoard, false>::Command::Poweroff:
case MotorController<isBackBoard, true>::Command::Poweroff:
#ifdef FEATURE_BUTTON
if (*((bool*)buf))
poweroff();
#endif
break;
default:
#ifndef CAN_LOG_UNKNOWN_ADDR
if constexpr (false)