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: libmDot-mbed5 DOGS102 ISL29011 MMA845x MPL3115A2 NCP5623B X_NUCLEO_IKS01A1 Senet_Packet
Fork of MTDOT-UDKDemo_Senet by
Diff: main.cpp
- Revision:
- 17:162e42587b4d
- Parent:
- 14:07ff01da6bbf
- Child:
- 18:856ebfac428b
diff -r f165e104ec2e -r 162e42587b4d main.cpp
--- a/main.cpp Wed Aug 24 13:59:39 2016 -0400
+++ b/main.cpp Wed Aug 24 15:15:39 2016 -0400
@@ -44,27 +44,27 @@
#include "font_6x8.h"
#include "MultiTech_Logo.h"
-// Min send delay from end of RX2
-#define MIN_SEND_DELAY 0
+// Added period delay
+#define PERIOD_DELAY 0
-// Send frame period for unchanged sensor value
-#define MIN_SEND_PERIOD pckt_time
+// Fast send period
+#define FAST_SEND_PERIOD pckt_time
-// Send frame period for unchanged sensor value
-#define MAX_SEND_PERIOD 100
+// Send frame period
+#define SEND_PERIOD 100
#elif defined(MTDOT_UDK)
#include "x_nucleo_iks01a1.h"
-// Min send delay from end of RX2
-#define MIN_SEND_DELAY 2000
+// Added period delay
+#define PERIOD_DELAY 3000
-// Min send period (limits sending to fast)
-#define MIN_SEND_PERIOD 1
+// Fast send period
+#define FAST_SEND_PERIOD 1
-// Max send period (max time between sends)
-#define MAX_SEND_PERIOD 12
+// Send frame period
+#define SEND_PERIOD 12
@@ -230,10 +230,7 @@
ReceiveData(frame);
}
-#ifndef DOWNLINK_REFLECT
position_changed = false;
- reflected_value = position_value;
-#endif
}
}
@@ -246,7 +243,6 @@
if(reflected_value == position_value)
{
evbBackLight->setLEDCurrent(16);
- position_changed = false;
}
else
{
@@ -453,7 +449,7 @@
position_value= 0x00;
}
- if(changed)
+ if(position_changed)
evbBackLight->setLEDCurrent(0);
/*
* Trigger a Pressure reading
@@ -528,7 +524,11 @@
{
frame.clear();
- if((reflected_value != position_value)|| position_changed || ( ( sample_period % MAX_SEND_PERIOD ) == 0 ) )
+#ifdef REFLECT_FAST_TX
+ if((reflected_value != position_value)|| position_changed || ( ( sample_period % SEND_PERIOD ) == 0 ) )
+#else
+ if( position_changed || ( ( sample_period % SEND_PERIOD ) == 0 ) )
+#endif
{
// we will send a simple byte descriptor of the current position of the device: 01 is laying flat, 02 is vertically oriented
frame.push_back(0x00);
@@ -677,7 +677,6 @@
if(value == position_value)
{
reflected_value = value;
- position_changed = false;
}
}
}
@@ -787,7 +786,11 @@
// Sensor packet type serialized to the LMIC frame buffer
SensorPacket packet(buffer, sizeof(buffer));
- if( position_changed || (reflected_value != position_value) || ( ( sample_period % MAX_SEND_PERIOD ) == 0 ) )
+#ifdef REFLECT_FAST_TX
+ if( position_changed || (reflected_value != position_value) || ( ( sample_period % SEND_PERIOD ) == 0 ) )
+#else
+ if( position_changed || ( ( sample_period % SEND_PERIOD ) == 0 ) )
+#endif
{
packet.setPrimarySensor(position_value);
packet.setTemperature(data.temperature);
@@ -962,11 +965,11 @@
*/
while(!checkForExit(false))
{
- if( MIN_SEND_DELAY > 0 )
- osDelay( MIN_SEND_DELAY );
+ if( PERIOD_DELAY > 0 )
+ osDelay( PERIOD_DELAY );
// Minimum delay between sampling
- if( ( sample_period % MIN_SEND_PERIOD ) == 0 )
+ if( ( sample_period % FAST_SEND_PERIOD ) == 0 )
{
// Acquire sensor values
ReadSensors(sensorData);
