Eugene Mwangi
/
mbed-os-example-ble-WEIGHT-public
test code
Diff: source/main.cpp
- Revision:
- 81:883a1a95f20b
- Parent:
- 80:167f8aabffca
- Child:
- 82:d40c223b65f9
--- a/source/main.cpp Mon Jun 24 03:57:20 2019 +0000 +++ b/source/main.cpp Mon Jun 24 14:17:40 2019 +0000 @@ -35,6 +35,7 @@ WEIGHTDemo(BLE &ble, events::EventQueue &event_queue) : _ble(ble), _event_queue(event_queue), +// _alive_led(LED1, 1), _weight_uuid(WEIGHTService::WEIGHT_SERVICE_UUID), _weight_service(NULL), _adv_data_builder(_adv_buffer) { } @@ -124,19 +125,21 @@ { if (_ble.gap().getState().connected) { +// _alive_led = !_alive_led; scale.setScale(calibration_factor); - _current_weight = scale.getGram(); - WeightType_t *weight; - weight->integer = (uint16_t)_current_weight; - float f_decimal = _current_weight - weight->integer; - weight->decimal = (uint8_t)(f_decimal* 100.0f); +// _current_weight = scale.getGram(); + _current_weight = 456.87; + WeightType_t weight; + weight.integer = (int32_t)_current_weight; + float f_decimal = _current_weight - weight.integer; + weight.decimal = (uint8_t)(f_decimal* 100.0f); // if(_current_weight <= 0.00f) // { // _current_weight = 0.00; // } _weight_service->updateWeight(_current_weight); pc.printf("Reading: %.2f\n", _current_weight); - pc.printf("Reading: %d.%d\n", weight->integer,weight->decimal); + pc.printf("Reading: %d.%d\n", weight.integer,weight.decimal); } } @@ -151,7 +154,7 @@ private: BLE &_ble; events::EventQueue &_event_queue; - +// DigitalOut _alive_led; UUID _weight_uuid; float _current_weight;