WeightScaleDisplay.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. /*
  2. This software is subject to the license described in the License.txt file
  3. included with this software distribution. You may not use this file except in compliance
  4. with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2012
  6. All rights reserved.
  7. */
  8. #include "StdAfx.h"
  9. #include "WeightScaleDisplay.h"
  10. /**************************************************************************
  11. * WeightScaleDisplay::ANT_eventNotification
  12. *
  13. * Process ANT channel event
  14. *
  15. * ucEventCode_: code of ANT channel event
  16. * pucEventBuffer_: pointer to buffer containing data received from ANT,
  17. * or a pointer to the transmit buffer in the case of an EVENT_TX
  18. *
  19. * returns: N/A
  20. *
  21. **************************************************************************/
  22. void WeightScaleDisplay::ANT_eventNotification(UCHAR ucEventCode_, UCHAR* pucEventBuffer_)
  23. {
  24. switch(ucEventCode_)
  25. {
  26. case EVENT_RX_BROADCAST:
  27. HandleReceive((UCHAR*) pucEventBuffer_); // Decode current data
  28. break;
  29. default:
  30. break;
  31. }
  32. }
  33. /**************************************************************************
  34. * WeightScaleDisplay::InitializeSim
  35. *
  36. * Initializes simulator variables
  37. *
  38. * returns: N/A
  39. *
  40. **************************************************************************/
  41. void WeightScaleDisplay::InitializeSim()
  42. {
  43. // Initialization of simulation variables
  44. wsPages->usBodyWeight100 = WeightScale::WEIGHT_INVALID;
  45. uprofUndef = gcnew WeightScaleUserProfile();
  46. // Set the display's U.P. to be the same as what is defaulted in the custom boxes
  47. if (this->radioButtonFemale->Checked == TRUE)
  48. {
  49. if(this->radioButtonAthleteTrue->Checked == TRUE)
  50. uprofCustom = gcnew WeightScaleUserProfile((USHORT) this->numericUpDownProfile->Value, WeightScaleUserProfile::GENDER_FEMALE, (UCHAR) this->numericUpDownAge->Value, (UCHAR) this->numericUpDownHeight->Value, (UCHAR) this->numericUpDownActivityLevel->Value, WeightScaleUserProfile::PRIORITY_WATCH, WeightScaleUserProfile::IS_ATHLETE);
  51. else
  52. uprofCustom = gcnew WeightScaleUserProfile((USHORT) this->numericUpDownProfile->Value, WeightScaleUserProfile::GENDER_FEMALE, (UCHAR) this->numericUpDownAge->Value, (UCHAR) this->numericUpDownHeight->Value, (UCHAR) this->numericUpDownActivityLevel->Value, WeightScaleUserProfile::PRIORITY_WATCH, WeightScaleUserProfile::NOT_ATHLETE);
  53. }
  54. else
  55. {
  56. if(this->radioButtonAthleteTrue->Checked == TRUE)
  57. uprofCustom = gcnew WeightScaleUserProfile((USHORT) this->numericUpDownProfile->Value, WeightScaleUserProfile::GENDER_MALE, (UCHAR) this->numericUpDownAge->Value, (UCHAR) this->numericUpDownHeight->Value, (UCHAR) this->numericUpDownActivityLevel->Value, WeightScaleUserProfile::PRIORITY_WATCH, WeightScaleUserProfile::IS_ATHLETE);
  58. else
  59. uprofCustom = gcnew WeightScaleUserProfile((USHORT) this->numericUpDownProfile->Value, WeightScaleUserProfile::GENDER_MALE, (UCHAR) this->numericUpDownAge->Value, (UCHAR) this->numericUpDownHeight->Value, (UCHAR) this->numericUpDownActivityLevel->Value, WeightScaleUserProfile::PRIORITY_WATCH, WeightScaleUserProfile::NOT_ATHLETE);
  60. }
  61. WeightScaleUserProfile::copyProfile(uprofCustom, wsPages->uprofDisplay);
  62. WeightScaleUserProfile::copyProfile(wsPages->uprofDisplay, wsPages->uprofActive);
  63. // Extended
  64. bSentProfile = FALSE;
  65. bRxAdvanced = FALSE;
  66. bRxMain = FALSE;
  67. }
  68. /**************************************************************************
  69. * WeightScaleDisplay::HandleReceive
  70. *
  71. * Decode incoming transmissions
  72. * pucRxBuffer_: pointer to receive buffer
  73. *
  74. * returns: N/A
  75. *
  76. **************************************************************************/
  77. void WeightScaleDisplay::HandleReceive(UCHAR* pucRxBuffer_)
  78. {
  79. UCHAR ucPageNum = pucRxBuffer_[0];
  80. switch(ucPageNum)
  81. {
  82. case WeightScale::PAGE_BODY_WEIGHT:
  83. case WeightScale::PAGE_BODY_COMPOSITION:
  84. case WeightScale::PAGE_METABOLIC_INFO:
  85. case WeightScale::PAGE_BODY_MASS:
  86. case WeightScale::PAGE_USER_PROFILE: // Intentional fall thru
  87. try
  88. {
  89. wsPages->Decode(pucRxBuffer_);
  90. }
  91. catch(CommonData::Error^ errorWeightScale)
  92. {
  93. }
  94. ProcessReceivedMessage(ucPageNum);
  95. break;
  96. case CommonData::PAGE80:
  97. case CommonData::PAGE81: // Intentional fall thru
  98. try
  99. {
  100. commonPages->Decode(pucRxBuffer_);
  101. }
  102. catch(CommonData::Error^ errorCommon)
  103. {
  104. }
  105. break;
  106. default:
  107. break;
  108. }
  109. UpdateDisplay(ucPageNum);
  110. }
  111. /**************************************************************************
  112. * WeightScaleDisplay::HandleTransmit
  113. *
  114. * Encode data into Tx Buffer
  115. * ucPageNum_: Page to transmit
  116. *
  117. * returns: N/A
  118. *
  119. **************************************************************************/
  120. void WeightScaleDisplay::HandleTransmit(UCHAR ucPageNum_)
  121. {
  122. UCHAR aucTxBuffer[8];
  123. memset(aucTxBuffer, 8, 0x00);
  124. if(ucPageNum_ == WeightScale::PAGE_USER_PROFILE) // Encode user profile
  125. {
  126. try
  127. {
  128. wsPages->Encode(ucPageNum_, aucTxBuffer);
  129. }
  130. catch(WeightScale::Error^ errorWeightScale)
  131. {
  132. }
  133. requestBcastMsg(aucTxBuffer); // Send as broadcast message
  134. }
  135. }
  136. /**************************************************************************
  137. * WeightScaleDisplay::ProcessReceivedMessage
  138. *
  139. * Processes capabilities and user profile received from the scale
  140. * Device specific decision tree for personal display
  141. * ucPageNum_: Page where profile was received
  142. *
  143. * returns: N/A
  144. *
  145. **************************************************************************/
  146. void WeightScaleDisplay::ProcessReceivedMessage(UCHAR ucPageNum_)
  147. {
  148. // Weight message?
  149. if(ucPageNum_ == WeightScale::PAGE_BODY_WEIGHT)
  150. {
  151. // Does display support profiles?
  152. if(wsPages->capabDisplay->bDisplayExchange)
  153. {
  154. // Process scale capabilities
  155. wsPages->capabDisplay->bScaleExchange = wsPages->capabScale->bScaleExchange;
  156. wsPages->capabDisplay->bScaleSet = wsPages->capabScale->bScaleSet;
  157. // Is user profile set on scale?
  158. if(wsPages->capabScale->bScaleSet)
  159. {
  160. // Has display sent user profile?
  161. if(bSentProfile)
  162. {
  163. // Does user profile ID match?
  164. // Compare scale user profile ID against profile loaded on display (active profile)
  165. if(wsPages->uprofActive->usID == wsPages->uprofScale->usID)
  166. {
  167. // Display all defined weight data
  168. bRxAdvanced = TRUE;
  169. bRxMain = TRUE;
  170. }
  171. else
  172. {
  173. SendUserProfile(); // Transmit user profile
  174. }
  175. }
  176. else
  177. {
  178. SendUserProfile(); // Transmit user profile
  179. }
  180. }
  181. else
  182. {
  183. if(!bSentProfile)
  184. SendUserProfile(); // Transmit user profile
  185. }
  186. }
  187. else
  188. {
  189. // Display does not support profiles
  190. // Weight only
  191. bRxMain = TRUE;
  192. }
  193. }
  194. // User profile message?
  195. else if(ucPageNum_ == WeightScale::PAGE_USER_PROFILE)
  196. {
  197. // User profile defined on display?
  198. if(wsPages->uprofActive->usID == WeightScaleUserProfile::PROFILE_UNDEF)
  199. {
  200. this->labelStatusProfileNew->Text = L"New User Profile";
  201. // Accept new user profile
  202. WeightScaleUserProfile::copyProfile(wsPages->uprofScale, wsPages->uprofActive);
  203. // Apply a higher priority user ID (display generated) to the new profile
  204. wsPages->uprofActive->usID = 1754;
  205. UpdateDisplayActiveProfile();
  206. }
  207. }
  208. }
  209. /**************************************************************************
  210. * WeightScaleDisplay::SendUserProfile
  211. *
  212. * Send user profile
  213. *
  214. * returns: N/A
  215. *
  216. **************************************************************************/
  217. void WeightScaleDisplay::SendUserProfile()
  218. {
  219. if(wsPages->capabScale->bScaleExchange)
  220. {
  221. HandleTransmit(WeightScale::PAGE_USER_PROFILE);
  222. bSentProfile = TRUE;
  223. this->labelStatusProfileSent->Text = L"User Profile Sent";
  224. UpdateDisplayActiveProfile();
  225. // Disable changes to the user profile after it has been sent
  226. this->numericUpDownProfile->Enabled = FALSE;
  227. this->numericUpDownAge->Enabled = FALSE;
  228. this->numericUpDownHeight->Enabled = FALSE;
  229. this->radioButtonFemale->Enabled = FALSE;
  230. this->radioButtonMale->Enabled = FALSE;
  231. this->numericUpDownActivityLevel->Enabled = FALSE;
  232. this->groupBoxAthlete->Enabled = FALSE;
  233. }
  234. }
  235. /**************************************************************************
  236. * WeightScaleDisplay::UpdateDisplay
  237. *
  238. * Update display of incoming transmissions
  239. *
  240. * returns: N/A
  241. *
  242. **************************************************************************/
  243. void WeightScaleDisplay::UpdateDisplay(UCHAR ucPageNum_)
  244. {
  245. this->labelPage->Text = System::Convert::ToString(ucPageNum_);
  246. switch(ucPageNum_)
  247. {
  248. case WeightScale::PAGE_BODY_WEIGHT:
  249. this->labelPage2->Text = L"MAIN";
  250. // Display capabilities
  251. UpdateDisplayCapabilities();
  252. // Display the recieved weight data
  253. if(wsPages->usBodyWeight100 == WeightScale::WEIGHT_COMPUTING)
  254. this->labelWeight->Text = "Comp";
  255. else if (wsPages->usBodyWeight100 == WeightScale::WEIGHT_INVALID)
  256. this->labelWeight->Text = "Invalid";
  257. else
  258. this->labelWeight->Text = System::Convert::ToString((double) wsPages->usBodyWeight100 / 100); // Weight in kg
  259. this->label_adv_weight->Text = this->labelWeight->Text;
  260. break;
  261. case WeightScale::PAGE_BODY_COMPOSITION:
  262. this->labelPage2->Text = L"BCOMP";
  263. if(bRxAdvanced)
  264. {
  265. if(wsPages->usHydrationP100 == WeightScale::WEIGHT_COMPUTING)
  266. this->label_Hydration->Text = "Comp";
  267. else if (wsPages->usHydrationP100 == WeightScale::WEIGHT_INVALID)
  268. this->label_Hydration->Text = "Invalid";
  269. else
  270. this->label_Hydration->Text = System::Convert::ToString((double) wsPages->usHydrationP100 / 100); // Hydration (%)
  271. if(wsPages->usBodyFatP100 == WeightScale::WEIGHT_COMPUTING)
  272. this->label_BodyFat->Text = "Comp";
  273. else if (wsPages->usBodyFatP100 == WeightScale::WEIGHT_INVALID)
  274. this->label_BodyFat->Text = "Invalid";
  275. else
  276. this->label_BodyFat->Text = System::Convert::ToString((double) wsPages->usBodyFatP100 / 100); // Body Fat (%)
  277. }
  278. else
  279. {
  280. this->label_Hydration->Text = "---";
  281. this->label_BodyFat->Text = "---";
  282. }
  283. this->label_adv_hydration->Text = this->label_Hydration->Text;
  284. this->label_adv_bodyfat->Text = this->label_BodyFat->Text;
  285. break;
  286. case WeightScale::PAGE_METABOLIC_INFO:
  287. this->labelPage2->Text = L"METAB";
  288. if(bRxAdvanced)
  289. {
  290. if(wsPages->usActiveMetRate4 == WeightScale::WEIGHT_COMPUTING)
  291. this->label_ActiveMetRate->Text = "Comp";
  292. else if (wsPages->usActiveMetRate4 == WeightScale::WEIGHT_INVALID)
  293. this->label_ActiveMetRate->Text = "Invalid";
  294. else
  295. this->label_ActiveMetRate->Text = System::Convert::ToString((double) wsPages->usActiveMetRate4 / 4); // Active Metabolic Rate (kcal)
  296. if(wsPages->usBasalMetRate4 == WeightScale::WEIGHT_COMPUTING)
  297. this->label_BasalMetRate->Text = "Comp";
  298. else if (wsPages->usBasalMetRate4 == WeightScale::WEIGHT_INVALID)
  299. this->label_BasalMetRate->Text = "Invalid";
  300. else
  301. this->label_BasalMetRate->Text = System::Convert::ToString((double) wsPages->usBasalMetRate4 / 4); // Basal Metabolic Rate (kcal)
  302. }
  303. else
  304. {
  305. this->label_ActiveMetRate->Text = "---";
  306. this->label_BasalMetRate->Text = "---";
  307. }
  308. this->label_adv_activerate->Text = this->label_ActiveMetRate->Text;
  309. this->label_adv_basalrate->Text = this->label_BasalMetRate->Text;
  310. break;
  311. case WeightScale::PAGE_BODY_MASS:
  312. this->labelPage2->Text = L"MASS";
  313. if(bRxAdvanced)
  314. {
  315. if(wsPages->usMuscleMass100 == WeightScale::WEIGHT_COMPUTING)
  316. this->label_adv_musclemass->Text = "Comp";
  317. else if (wsPages->usMuscleMass100 == WeightScale::WEIGHT_INVALID)
  318. this->label_adv_musclemass->Text = "Invalid";
  319. else
  320. this->label_adv_musclemass->Text = System::Convert::ToString((double) wsPages->usMuscleMass100/100); // Muscle mass (1/100kg)
  321. if(wsPages->ucBoneMass10 == WeightScale::MASS_COMPUTING)
  322. this->label_adv_bonemass->Text = "Comp";
  323. else if (wsPages->ucBoneMass10 == WeightScale::MASS_INVALID)
  324. this->label_adv_bonemass->Text = "Invalid";
  325. else
  326. this->label_adv_bonemass->Text = System::Convert::ToString((double) wsPages->ucBoneMass10/10); // Bone mass (1/10kg)
  327. }
  328. else
  329. {
  330. this->label_adv_musclemass->Text = "---";
  331. this->label_adv_bonemass->Text = "---";
  332. }
  333. break;
  334. case WeightScale::PAGE_USER_PROFILE:
  335. this->labelPage2->Text = L"UPR";
  336. UpdateDisplayCapabilities();
  337. this->labelStatusProfileRx->Text = L"User Profile Received";
  338. break;
  339. case CommonData::PAGE80:
  340. this->labelPage2->Text = L"MFG";
  341. this->labelHwVer->Text = System::Convert::ToString(commonPages->ucHwVersion);
  342. this->labelMfgID->Text = System::Convert::ToString(commonPages->usMfgID);
  343. this->labelModelNum->Text = System::Convert::ToString(commonPages->usModelNum);
  344. break;
  345. case CommonData::PAGE81:
  346. this->labelPage2->Text = L"PRD";
  347. this->labelSwVer->Text = System::Convert::ToString(commonPages->ucSwVersion);
  348. if(commonPages->ulSerialNum != 0xFFFFFFFF)
  349. this->labelSerialNum->Text = System::Convert::ToString((unsigned int) commonPages->ulSerialNum);
  350. else
  351. this->labelSerialNum->Text = "N/A";
  352. break;
  353. default:
  354. break;
  355. }
  356. }
  357. /**************************************************************************
  358. * WeightScaleDisplay::UpdateDisplayCapabilities
  359. *
  360. * Update display of the capabilities received from the scale
  361. *
  362. * returns: N/A
  363. *
  364. **************************************************************************/
  365. void WeightScaleDisplay::UpdateDisplayCapabilities()
  366. {
  367. if(wsPages->capabScale->bScaleSet)
  368. this->labelProfileSetScale->Text = L"Yes";
  369. else
  370. this->labelProfileSetScale->Text = L"No";
  371. if(wsPages->capabScale->bScaleExchange)
  372. this->labelExchangeScale->Text = L"Yes";
  373. else
  374. this->labelExchangeScale->Text = L"No";
  375. if(wsPages->capabScale->bAntfs)
  376. this->labelAntfsRx->Text = L"Yes";
  377. else
  378. this->labelAntfsRx->Text = L"No";
  379. if(wsPages->capabScale->bDisplayExchange)
  380. this->labelExchangeDisplay->Text = L"Yes";
  381. else
  382. this->labelExchangeDisplay->Text = L"No";
  383. }
  384. /**************************************************************************
  385. * WeightScaleDisplay::UpdateDisplayActiveProfile
  386. *
  387. * Update display of the active profile
  388. *
  389. * returns: N/A
  390. *
  391. **************************************************************************/
  392. void WeightScaleDisplay::UpdateDisplayActiveProfile()
  393. {
  394. this->labelProfileActive->Text = System::Convert::ToString(wsPages->uprofActive->usID);
  395. this->labelProfileActive2->Text = System::Convert::ToString(wsPages->uprofActive->usID);
  396. if(wsPages->uprofActive->ucGender == WeightScaleUserProfile::GENDER_FEMALE)
  397. this->labelGenderActive->Text = L"Female";
  398. else
  399. this->labelGenderActive->Text = L"Male";
  400. this->labelAgeActive->Text = System::Convert::ToString(wsPages->uprofActive->ucAge);
  401. this->labelHeightActive->Text = System::Convert::ToString(wsPages->uprofActive->ucHeight);
  402. this->labelDescriptionActive->Text = System::Convert::ToString(wsPages->uprofActive->ucDescription);
  403. if(wsPages->uprofActive->bAthlete == TRUE)
  404. this->labelLifestyle->Text = "Athlete";
  405. else
  406. this->labelLifestyle->Text = "Standard";
  407. }
  408. /**************************************************************************
  409. * WeightScaleDisplay::checkBoxProfileSet_CheckedChanged
  410. *
  411. * Set user profile
  412. *
  413. * returns: N/A
  414. *
  415. **************************************************************************/
  416. System::Void WeightScaleDisplay::checkBoxProfileSet_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  417. {
  418. if(this->checkBoxProfileSet->Checked)
  419. {
  420. // Enable Custom Profile
  421. this->numericUpDownProfile->Enabled = TRUE;
  422. this->numericUpDownAge->Enabled = TRUE;
  423. this->numericUpDownHeight->Enabled = TRUE;
  424. this->radioButtonFemale->Enabled = TRUE;
  425. this->radioButtonMale->Enabled = TRUE;
  426. this->numericUpDownActivityLevel->Enabled = TRUE;
  427. this->groupBoxAthlete->Enabled = TRUE;
  428. // Display current active profile values in Custom Profile
  429. if (wsPages->uprofActive->usID == WeightScaleUserProfile::PROFILE_UNDEF)
  430. wsPages->uprofActive->usID = 1754; // choose random user ID (eg. lowest two bytes of display serial number)
  431. this->numericUpDownProfile->Value = wsPages->uprofActive->usID;
  432. this->numericUpDownAge->Value = wsPages->uprofActive->ucAge;
  433. this->numericUpDownHeight->Value = wsPages->uprofActive->ucHeight;
  434. if(wsPages->uprofActive->ucGender == WeightScaleUserProfile::GENDER_FEMALE)
  435. this->radioButtonFemale->Checked = TRUE;
  436. else
  437. this->radioButtonMale->Checked = TRUE;
  438. if(wsPages->uprofActive->bAthlete == TRUE)
  439. this->radioButtonAthleteTrue->Checked = TRUE;
  440. else
  441. this->radioButtonAthleteFalse->Checked = TRUE;
  442. }
  443. else
  444. { // Unset user profile
  445. WeightScaleUserProfile::copyProfile(uprofUndef, wsPages->uprofActive);
  446. // Disble Custom Profile
  447. this->numericUpDownProfile->Enabled = FALSE;
  448. this->numericUpDownAge->Enabled = FALSE;
  449. this->numericUpDownHeight->Enabled = FALSE;
  450. this->radioButtonFemale->Enabled = FALSE;
  451. this->radioButtonMale->Enabled = FALSE;
  452. this->numericUpDownActivityLevel->Enabled = FALSE;
  453. this->groupBoxAthlete->Enabled = FALSE;
  454. }
  455. UpdateDisplayActiveProfile();
  456. }
  457. /**************************************************************************
  458. * WeightScaleDisplay::buttonReset_Click
  459. *
  460. * Reset session (without modifying user profiles)
  461. *
  462. * returns: N/A
  463. *
  464. **************************************************************************/
  465. System::Void WeightScaleDisplay::buttonReset_Click(System::Object^ sender, System::EventArgs^ e)
  466. {
  467. // Reset session
  468. bSentProfile = FALSE; // Send user profile again after a weight message from the scale
  469. bRxAdvanced = FALSE;
  470. // Clear status
  471. this->labelStatusProfileMatch->Text = "---";
  472. this->labelStatusProfileNew->Text = "---";
  473. this->labelStatusProfileRx->Text = "---";
  474. this->labelStatusProfileSent->Text = "---";
  475. this->labelStatusProfileUpdate->Text = "---";
  476. // Clear Rx data
  477. this->labelWeight->Text = "---";
  478. // Enable custom profile
  479. this->numericUpDownProfile->Enabled = TRUE;
  480. this->numericUpDownAge->Enabled = TRUE;
  481. this->numericUpDownHeight->Enabled = TRUE;
  482. this->radioButtonFemale->Enabled = TRUE;
  483. this->radioButtonMale->Enabled = TRUE;
  484. this->numericUpDownActivityLevel->Enabled = TRUE;
  485. this->groupBoxAthlete->Enabled = TRUE;
  486. }
  487. /**************************************************************************
  488. * WeightScaleDisplay::checkBoxAntfs_CheckedChanged
  489. *
  490. * Enable/disable ANT-FS (not implemented yet, for future capabilities)
  491. *
  492. * returns: N/A
  493. *
  494. **************************************************************************/
  495. System::Void WeightScaleDisplay::checkBoxAntfs_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  496. {
  497. if(this->checkBoxAntfs->Checked)
  498. wsPages->capabDisplay->bAntfs = TRUE;
  499. else
  500. wsPages->capabDisplay->bAntfs = FALSE;
  501. }
  502. /**************************************************************************
  503. * WeightScaleDisplay::checkBoxExchange_CheckedChanged
  504. *
  505. * Enable/disable user profile exchange
  506. *
  507. * returns: N/A
  508. *
  509. **************************************************************************/
  510. System::Void WeightScaleDisplay::checkBoxExchange_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
  511. {
  512. if(this->checkBoxExchange->Checked)
  513. wsPages->capabDisplay->bDisplayExchange = TRUE;
  514. else
  515. wsPages->capabDisplay->bDisplayExchange = FALSE;
  516. }
  517. /**************************************************************************
  518. * WeightScaleDisplay::SelectCustomProfile
  519. *
  520. * Updates custom profile set on display
  521. * Application specific
  522. *
  523. * returns: N/A
  524. *
  525. **************************************************************************/
  526. void WeightScaleDisplay::SelectCustomProfile()
  527. {
  528. // Read user profile from GUI
  529. wsPages->uprofActive->usID = (USHORT) (this->numericUpDownProfile->Value); // ID
  530. wsPages->uprofActive->ucAge = (UCHAR) (this->numericUpDownAge->Value); // Age
  531. wsPages->uprofActive->ucHeight = (UCHAR) (this->numericUpDownHeight->Value); // Height
  532. wsPages->uprofActive->ucDescription = (UCHAR) (this->numericUpDownActivityLevel->Value); // Activity Level
  533. if(this->radioButtonFemale->Checked)
  534. wsPages->uprofActive->ucGender = WeightScaleUserProfile::GENDER_FEMALE; // Gender
  535. else if(this->radioButtonMale->Checked)
  536. wsPages->uprofActive->ucGender = WeightScaleUserProfile::GENDER_MALE;
  537. else
  538. wsPages->uprofActive->ucGender = WeightScaleUserProfile::GENDER_UNDEF;
  539. if (this->radioButtonAthleteTrue->Checked == TRUE) // Lifetime activity
  540. wsPages->uprofActive->bAthlete = TRUE;
  541. else
  542. wsPages->uprofActive->bAthlete = FALSE;
  543. UpdateDisplayActiveProfile();
  544. }