comparison Discovery/Src/data_exchange_main.c @ 138:cc9c18075e00 FlipDisplay

Removed no longer supported scooter code
author Ideenmodellierer
date Sat, 23 Feb 2019 21:10:51 +0100
parents 9eda5a75c5fd
children 30d855ea60d8
comparison
equal deleted inserted replaced
137:9eda5a75c5fd 138:cc9c18075e00
69 #include "simulation.h" 69 #include "simulation.h"
70 #include "tCCR.h" 70 #include "tCCR.h"
71 #include "timer.h" 71 #include "timer.h"
72 #include "buehlmann.h" 72 #include "buehlmann.h"
73 #include "externLogbookFlash.h" 73 #include "externLogbookFlash.h"
74 #include "bonex_mini.h" // for voltage to battery percentage
75 74
76 75
77 /* Expoted variables --------------------------------------------------------*/ 76 /* Expoted variables --------------------------------------------------------*/
78 uint8_t wasPowerOn = 0; 77 uint8_t wasPowerOn = 0;
79 confirmbit8_Type requestNecessary = { .uw = 0 }; 78 confirmbit8_Type requestNecessary = { .uw = 0 };
80 uint8_t wasUpdateNotPowerOn = 0; 79 uint8_t wasUpdateNotPowerOn = 0;
81 uint8_t scooterFoundThisPowerOnCylce = 0;
82 80
83 /* Private variables with external access ------------------------------------*/ 81 /* Private variables with external access ------------------------------------*/
84 82
85 83
86 /* Private variables ---------------------------------------------------------*/ 84 /* Private variables ---------------------------------------------------------*/
194 192
195 dataOut.footer.checkCode[0] = 0xF4; 193 dataOut.footer.checkCode[0] = 0xF4;
196 dataOut.footer.checkCode[1] = 0xF3; 194 dataOut.footer.checkCode[1] = 0xF3;
197 dataOut.footer.checkCode[2] = 0xF2; 195 dataOut.footer.checkCode[2] = 0xF2;
198 dataOut.footer.checkCode[3] = 0xF1; 196 dataOut.footer.checkCode[3] = 0xF1;
199
200
201 pStateReal->lifeData.scooterType = 0xFF;
202 pStateReal->lifeData.scooterWattstunden = 0;
203 pStateReal->lifeData.scooterRestkapazitaet = 0;
204 pStateReal->lifeData.scooterDrehzahl = 0;
205 pStateReal->lifeData.scooterSpannung = 0;
206 pStateReal->lifeData.scooterTemperature = 0;
207 pStateReal->lifeData.scooterAmpere = 0;
208 pStateReal->lifeData.scooterRestkapazitaetWhBased = 0;
209 pStateReal->lifeData.scooterRestkapazitaetVoltageBased = 0;
210 pStateReal->lifeData.scooterAgeInMilliSeconds = 0;
211 197
212 systick_last = HAL_GetTick() - 100; 198 systick_last = HAL_GetTick() - 100;
213 } 199 }
214 200
215 201
1243 } 1229 }
1244 } 1230 }
1245 } 1231 }
1246 } 1232 }
1247 */ 1233 */
1248 // new: Bonex 1234
1249 float scooterSpeedFloat;
1250 int32_t scooterRemainingBattCapacity;
1251
1252 for(int i=0;i<4;i++)
1253 {
1254 if((wirelessData[i][0]))// && (wirelessData[i][2]) && (wirelessData[i][2] < 60000))
1255 {
1256 pStateReal->lifeData.scooterType = (pStateReal->lifeData.wireless_data[i].data[0] >> 4) & 0x07;
1257 pStateReal->lifeData.scooterWattstunden = ((uint16_t)((((uint16_t)(pStateReal->lifeData.wireless_data[i].data[0] & 0x0F) << 8) | (pStateReal->lifeData.wireless_data[i].data[1]))));
1258 // pStateReal->lifeData.scooterWattstunden = pStateReal->lifeData.wireless_data[i].data[0] & 0x0F;
1259 // pStateReal->lifeData.scooterWattstunden *= 256;
1260 // pStateReal->lifeData.scooterWattstunden += pStateReal->lifeData.wireless_data[i].data[1];
1261 pStateReal->lifeData.scooterRestkapazitaet = pStateReal->lifeData.wireless_data[i].data[2];
1262 pStateReal->lifeData.scooterDrehzahl = ((uint16_t)( (int16_t)((pStateReal->lifeData.wireless_data[i].data[4] << 8) | (pStateReal->lifeData.wireless_data[i].data[3]))));
1263 pStateReal->lifeData.scooterSpannung = ((float)(pStateReal->lifeData.wireless_data[i].data[5])) / 5.0f;
1264 pStateReal->lifeData.scooterTemperature = ((uint16_t)( (int16_t)((pStateReal->lifeData.wireless_data[i].data[7] << 8) | (pStateReal->lifeData.wireless_data[i].data[6]))));
1265 pStateReal->lifeData.scooterAmpere = pStateReal->lifeData.wireless_data[i].data[9] >> 1;
1266 pStateReal->lifeData.scooterAgeInMilliSeconds = pStateReal->lifeData.wireless_data[i].ageInMilliSeconds;
1267
1268 if(pStateReal->lifeData.scooterWattstunden > 0)
1269 scooterRemainingBattCapacity = settingsGetPointer()->scooterBattSize / pStateReal->lifeData.scooterWattstunden;
1270 else
1271 scooterRemainingBattCapacity = 100;
1272
1273
1274 if(scooterRemainingBattCapacity < 0)
1275 scooterRemainingBattCapacity = 0;
1276 if(scooterRemainingBattCapacity > 100)
1277 scooterRemainingBattCapacity = 100;
1278 pStateReal->lifeData.scooterRestkapazitaetWhBased = scooterRemainingBattCapacity;
1279
1280 // BONEX_calc_new_ResidualCapacity(&pStateReal->lifeData.scooterRestkapazitaetVoltageBased, (uint32_t)(1000 * pStateReal->lifeData.scooterSpannung),1000,1);
1281 pStateReal->lifeData.scooterRestkapazitaetVoltageBased = BONEX_mini_ResidualCapacityVoltageBased(pStateReal->lifeData.scooterSpannung, pStateReal->lifeData.scooterAgeInMilliSeconds);
1282
1283 scooterSpeedFloat = (float)pStateReal->lifeData.scooterDrehzahl;
1284 scooterSpeedFloat /= (37.0f / 1.1f); // 3700 rpm = 110 m/min
1285 switch(settingsGetPointer()->scooterDrag)
1286 {
1287 case 1:
1288 scooterSpeedFloat *= 0.95f;
1289 break;
1290 case 2:
1291 scooterSpeedFloat *= 0.85f;
1292 break;
1293 case 3:
1294 scooterSpeedFloat *= 0.75f;
1295 break;
1296 default:
1297 break;
1298 }
1299 switch(settingsGetPointer()->scooterLoad)
1300 {
1301 case 1:
1302 scooterSpeedFloat *= 0.90f;
1303 break;
1304 case 2:
1305 scooterSpeedFloat *= 0.80f;
1306 break;
1307 case 3:
1308 scooterSpeedFloat *= 0.70f;
1309 break;
1310 case 4:
1311 scooterSpeedFloat *= 0.60f;
1312 break;
1313 default:
1314 break;
1315 }
1316 if(scooterSpeedFloat < 0)
1317 pStateReal->lifeData.scooterSpeed = 0;
1318 else
1319 if(scooterSpeedFloat > 255)
1320 pStateReal->lifeData.scooterSpeed = 255;
1321 else
1322 pStateReal->lifeData.scooterSpeed = (uint16_t)scooterSpeedFloat;
1323
1324 if(!scooterFoundThisPowerOnCylce && (pStateReal->lifeData.scooterAgeInMilliSeconds > 0))
1325 scooterFoundThisPowerOnCylce = 1;
1326 }
1327 }
1328 1235
1329 /* PIC data 1236 /* PIC data
1330 */ 1237 */
1331 for(int i=0;i<4;i++) 1238 for(int i=0;i<4;i++)
1332 { 1239 {
1367 return 0; 1274 return 0;
1368 } 1275 }
1369 } 1276 }
1370 1277
1371 1278
1372 uint8_t DataEX_scooterDataFound(void)
1373 {
1374 return scooterFoundThisPowerOnCylce;
1375 }
1376
1377
1378 uint8_t DataEX_scooterFoundAndValidLicence(void)
1379 {
1380 if(getLicence() != LICENCEBONEX)
1381 return 0;
1382 else
1383 return scooterFoundThisPowerOnCylce;
1384 //return 0xFF;
1385 //return LICENCEBONEX;
1386 }
1387
1388 /* Private functions ---------------------------------------------------------*/ 1279 /* Private functions ---------------------------------------------------------*/
1389 1280
1390 /* Check if there is an empty frame providec by RTE (all 0) or even no data provided by RTE (all 0xFF) 1281 /* Check if there is an empty frame providec by RTE (all 0) or even no data provided by RTE (all 0xFF)
1391 * If that is not the case the DMA is somehow not in sync 1282 * If that is not the case the DMA is somehow not in sync
1392 */ 1283 */