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.
Diff: driverLifiRx.cpp
- Revision:
- 3:ae1f53883bc0
- Parent:
- 2:e1fd30fce2f8
- Child:
- 5:5fe30df87772
diff -r e1fd30fce2f8 -r ae1f53883bc0 driverLifiRx.cpp
--- a/driverLifiRx.cpp Mon Apr 01 05:03:34 2019 +0000
+++ b/driverLifiRx.cpp Tue Apr 02 07:24:39 2019 +0000
@@ -72,6 +72,16 @@
//the curve from datasheet seems y=2x+0, so lux = 2 * I[uA] = 2 * 100 * V[V/ohm]
return 2*(100*vol);
}
+
+float meas_v1_max=0;
+float meas_v1_min=3300;
+float meas_v2_max=0;
+float meas_v2_min=3300;
+float meas_v3_max=0;
+float meas_v3_min=3300;
+float meas_v4_max=0;
+float meas_v4_min=3300;
+
void LifiRx_PdTunning()
{
float meas_r1;
@@ -83,6 +93,15 @@
float meas_r4;
float meas_v4;
+ meas_v1_max=0;
+ meas_v1_min=3300;
+ meas_v2_max=0;
+ meas_v2_min=3300;
+ meas_v3_max=0;
+ meas_v3_min=3300;
+ meas_v4_max=0;
+ meas_v4_min=3300;
+
// note myvalues for "office light" (ca. 200 lux) and direct sunlight, clear day (ca 50000lux)
@@ -108,16 +127,27 @@
meas_v3 = meas_r3 * 3300; // Converts value in the 0V-3.3V range
meas_r4 = adc_4.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
meas_v4 = meas_r4 * 3300; // Converts value in the 0V-3.3V range
+
+ if( meas_v1_min > meas_v1 ) meas_v1_min = meas_v1;
+ if( meas_v1_max < meas_v1 ) meas_v1_max = meas_v1;
+ if( meas_v2_min > meas_v2 ) meas_v2_min = meas_v2;
+ if( meas_v2_max < meas_v2 ) meas_v2_max = meas_v2;
+ if( meas_v3_min > meas_v3 ) meas_v3_min = meas_v3;
+ if( meas_v3_max < meas_v3 ) meas_v3_max = meas_v3;
+ if( meas_v4_min > meas_v4 ) meas_v4_min = meas_v4;
+ if( meas_v4_max < meas_v4 ) meas_v4_max = meas_v4;
+
// Display values
- printf("measure 1 = %f = %4.0f mV = %5.0f uA = %5.0f lux \n", meas_r1, meas_v1, meas_v1/10.0, meas_v1/5.0 );
- printf("measure 2 = %f = %4.0f mV = %5.0f uA = %5.0f lux \n", meas_r2, meas_v2, meas_v2/10.0, meas_v2/5.0 );
- printf("measure 3 = %f = %4.0f mV = %5.0f uA = %5.0f lux \n", meas_r3, meas_v3, meas_v3/10.0, meas_v3/5.0 );
- printf("measure 4 = %f = %4.0f mV = %5.0f uA = %5.0f lux \n", meas_r4, meas_v4, meas_v4/10.0, meas_v4/5.0 );
+ printf("measure 1 = %f = %4.0f mV = %5.0f uA = %5.0f lux delta = %5.0f \n", meas_r1, meas_v1, meas_v1/10.0, meas_v1/5.0, meas_v1_max - meas_v1_min);
+ printf("measure 2 = %f = %4.0f mV = %5.0f uA = %5.0f lux delta = %5.0f \n", meas_r2, meas_v2, meas_v2/10.0, meas_v2/5.0, meas_v2_max - meas_v2_min);
+ printf("measure 3 = %f = %4.0f mV = %5.0f uA = %5.0f lux delta = %5.0f \n", meas_r3, meas_v3, meas_v3/10.0, meas_v3/5.0, meas_v3_max - meas_v3_min);
+ printf("measure 4 = %f = %4.0f mV = %5.0f uA = %5.0f lux delta = %5.0f \n", meas_r4, meas_v4, meas_v4/10.0, meas_v4/5.0, meas_v4_max - meas_v4_min);
printf("\033[4A");
wait(0.1);
}
}
+
int LifiRx_AdcRead(int num)
{
//floor(x) - round down
@@ -200,16 +230,18 @@
if( buttonCanSkipLoop() ) return;
LifiRx_LoopOOK();
//printf("4");
- wait_ms(50);
+ //wait_ms(50);
+
}
}
//////////////
+#if USE_MBED_OS5
// https://os.mbed.com/blog/entry/Simplify-your-code-with-mbed-events/
// create an event queue
+#if USE_LIFI_RX_CHECK_QUEUE
EventQueue queue;
-#if USE_LIFI_RX_CHECK_QUEUE
EventQueue lifi_tx_check_queue(32 * EVENTS_EVENT_SIZE);
#endif
@@ -233,7 +265,7 @@
//Thread eventThread;
eventThread.start(callback(&queue, &EventQueue::dispatch_forever));
-#if USE_LIFI_RX_CHECK_QUEUE
+#if (USE_MBED_OS5 && USE_LIFI_RX_CHECK_QUEUE)
Thread lifiRxCheckThread(osPriorityNormal);
lifiRxCheckThread.start(callback(&lifi_tx_check_queue, &EventQueue::dispatch_forever));
#endif
@@ -264,3 +296,4 @@
}
}
+#endif
\ No newline at end of file