test demo
Dependencies: PinDetect libmDot mbed-rtos mbed-src
Fork of mDot_LoRa_Connect_Woodstream_Demo by
Revision 2:a61b09bc91ea, committed 2015-11-07
- Comitter:
- tmulrooney
- Date:
- Sat Nov 07 01:15:29 2015 +0000
- Parent:
- 1:535366982662
- Child:
- 3:34d92fdfbe06
- Commit message:
- three channels working
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Nov 06 00:35:06 2015 +0000
+++ b/main.cpp Sat Nov 07 01:15:29 2015 +0000
@@ -17,14 +17,19 @@
#include "PinDetect.h"
#define MIN_CHANGE_BATTERY_VOLTAGE 0
+#define BATTERY_TIME 2.0
+#define KILL_STATUS_TIME 2.0
+#define POWER_ON_TIME 2.0
mDot* dot;
Ticker ledTimer;
Ticker batteryTimer;
+Ticker killStatusTimer;
+Ticker powerOnTimer;
AnalogIn batteryVoltage(PB_1);
-//DigitalIn mt_pwron(PA_4);
-//DigitalIn mt_caught(PA_5);
+DigitalIn powerOn(PA_4);
+//DigitalIn KillStatus(PA_5);
DigitalOut transmitLED(PA_0);
// Configuration variables
@@ -36,11 +41,15 @@
bool readyToSend;
uint16_t lastBatteryVoltage;
float currentBatteryVoltage;
+uint8_t lastKillStatus;
+uint8_t lastPowerOn;
//Function prototypes
void ledWrite();
void periodicSendTock();
void batteryRead();
+void killStatusRead();
+void powerOnRead();
void printError(mDot* dot, int32_t returnCode);
void printVersion();
bool setFrequencySubBand(uint8_t subBand);
@@ -60,9 +69,11 @@
readyToSend = false;
lastBatteryVoltage = 0;
currentBatteryVoltage = 0.0;
-
+ lastKillStatus = transmitLED;
+ lastPowerOn = powerOn;
+
//Start LED startup sequence
- ledTimer.attach(&ledWrite, 0.5);
+ ledTimer.attach(&ledWrite, 1.5);
printf("\r\n\r\n");
printf("=====================================\r\n");
@@ -110,17 +121,18 @@
}
// Stop LED startup sequence & configure them for operation
- ledTimer.detach();
transmitLED = 1;
- batteryTimer.attach(&batteryRead, 2.0);
+ batteryTimer.attach(batteryRead, BATTERY_TIME);
+ killStatusTimer.attach(killStatusRead, KILL_STATUS_TIME);
+ powerOnTimer.attach(powerOnRead, POWER_ON_TIME);
while (1)
{
// is there anything to send
if(readyToSend)
{
- sprintf(latestData,"%2.2f 100 3.2",(double)currentBatteryVoltage);
- printf("%s\r\n",latestData);
+ sprintf(latestData,"%2.2f %d %d",(double)currentBatteryVoltage,lastKillStatus,lastPowerOn);
+ printf("Battery Voltage: %2.2fV Kill Status: %d Power: %d\r\n",(double)currentBatteryVoltage,lastKillStatus,lastPowerOn);
send(latestData);
readyToSend = false;
}
@@ -149,6 +161,24 @@
}
}
+void killStatusRead()
+{
+ if(transmitLED != lastKillStatus)
+ {
+ lastKillStatus = transmitLED;
+ readyToSend = true;
+ }
+}
+
+void powerOnRead()
+{
+ if(powerOn != lastPowerOn)
+ {
+ lastPowerOn = powerOn;
+ readyToSend = true;
+ }
+}
+
void printVersion()
{
printf("%s Built on: %s %s\r\n\r\n", dot->getId().c_str(),__DATE__,__TIME__);
