Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API nRF51822 mbed
Fork of KS7 by
Diff: main.cpp
- Branch:
- KS3
- Revision:
- 27:8c3c29b3f704
- Parent:
- 25:da723b86c60b
- Child:
- 28:d8c652994988
--- a/main.cpp Tue Mar 29 02:48:17 2016 +0000
+++ b/main.cpp Mon Apr 04 03:39:08 2016 +0000
@@ -5,6 +5,8 @@
#include "common.h"
#include <stdlib.h>
+#define DISPLAY_DEMO // display random number for demo & LED check
+
// BLE
#define INTERVAL_500MSEC (500UL)
#define CONNTIMEOUT_3000MSEC (3000UL)
@@ -42,8 +44,8 @@
// Properties
//io io;
-//io io(P0_15, P0_13); // HX711's CLK & DAT
-io io(P0_5, P0_4); // HX711's CLK & DAT
+io io(P0_15, P0_13); // HX711's CLK & DAT
+//io(P0_5, P0_4); // HX711's CLK & DAT for BLEnano debug
uint32_t weight_data;
float32_t weight = 0.0;
uint32_t scale = 0;
@@ -249,7 +251,13 @@
BleInitialize();
AppInit();
+
led_mode = MODE_OFF;
+#ifdef DISPLAY_DEMO
+ uint16_t d = 0;
+ uint8_t demo_count = 0;
+ led_mode = MODE_START; // for debug mode
+#endif
for (;; ) {
// 100msec waitForEvent
t.reset();
@@ -288,6 +296,13 @@
// pc.printf("%d %d %.2f\r\n", io.get_switch(), io.get_weight_raw(), io.get_weight());
#endif
io.analog_pow(1);
+#ifdef DISPLAY_DEMO
+ demo_count++;
+ if (demo_count == 10){
+ demo_count = 0;
+ io.display_value = d++; // increment display value for every 1s in demo mode
+ }
+#else
if(io.get_switch()) {
led_mode = MODE_END;
if(ble.getGapState().connected) {
@@ -314,7 +329,6 @@
#ifdef UART_DEBUG
// pc.printf("%d\r\n", io._get_adc_raw(0));
// pc.printf("weight=%f %d / %d\r\n", weight, io.display_value, io._adc0);
-// pc.printf("%02x %02x %02x %02x\r\n", io._seg[0], io._seg[1], io._seg[2], io._seg[3]);
#endif
if(++update_counter >= 5) {
weight_data = quick_ieee11073_from_float(weight);
@@ -324,6 +338,7 @@
update_counter = 0;
}
}
+#endif
break;
case MODE_END:
led_brightness -= BRIGHTNESS_ADDVALUE;
