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: edge_utils/edge_mgr.cpp
- Revision:
- 9:f958fa2cdc74
- Parent:
- 8:5590f55bdf41
- Child:
- 12:4c0bd7fce2fd
diff -r 5590f55bdf41 -r f958fa2cdc74 edge_utils/edge_mgr.cpp
--- a/edge_utils/edge_mgr.cpp Thu Dec 07 10:13:13 2017 +0000
+++ b/edge_utils/edge_mgr.cpp Fri Dec 08 08:31:30 2017 +0000
@@ -24,33 +24,34 @@
#define NUM_MAX_SENSOR 5
+bool verbos = true ;
edge_sensor *sensor[NUM_MAX_SENSOR] ;
-int num_sensor = 0 ;
-int sensor_index = 0 ;
-edge_accel *accel = 0 ;
-edge_color *color[2] = {0, 0} ;
-edge_temp *temp = 0 ;
-edge_pressure *pressure = 0 ;
-PwmOut *led[3] = {0, 0, 0} ;
-uint16_t pwm[3] = { 0x5FA2, 0xB09B, 0x83DF } ;
+int num_sensor = 0 ;
+
+edge_accel *accel = 0 ;
+edge_color *color[2] = {0, 0} ;
+edge_temp *temp = 0 ;
+edge_pressure *pressure = 0 ;
-I2C *edge_i2c0 = 0 ;
-I2C *edge_i2c1 = 0 ;
-SO1602A *display = 0 ; /* OLED display on I2C */
-MMA8451Q *mma8451q = 0 ;
+PwmOut *led[3] = {0, 0, 0} ;
+uint16_t pwm[3] = { 0x5FA2, 0xB09B, 0x83DF } ;
+I2C *edge_i2c0 = 0 ;
+I2C *edge_i2c1 = 0 ;
+SO1602A *display = 0 ; /* OLED display on I2C */
+MMA8451Q *mma8451q = 0 ;
VEML6040 *veml6040[2] = { 0, 0 } ;
-LM75B *lm75b0 = 0 ; /* for temp1 */
-AnalogIn *an0 = 0 ; /* for temp2 */
-SMTC502AT *smtc502at0 = 0 ;
-AnalogIn *an1 = 0 ; /* for temp3 */
-SMTC502AT *smtc502at1 = 0 ;
-LM75B *lm75b1 = 0 ; /* for temp4 */
-AnalogIn *an2 = 0 ; /* for gas pressure */
-PSE530 *pse530 = 0 ;
+LM75B *lm75b0 = 0 ; /* for temp1 */
+AnalogIn *an0 = 0 ; /* for temp2 */
+SMTC502AT *smtc502at0 = 0 ;
+AnalogIn *an1 = 0 ; /* for temp3 */
+SMTC502AT *smtc502at1 = 0 ;
+LM75B *lm75b1 = 0 ; /* for temp4 */
+AnalogIn *an2 = 0 ; /* for gas pressure */
+PSE530 *pse530 = 0 ; /* gas pressure sensor */
-static int loop_interval = 1000 ;
-static int accel_interval = 10 ;
-int first_loop = 1 ;
+static int loop_interval = 100 ; // 1000 ;
+static int accel_interval = 10 ;
+int first_loop = 1 ;
int init_edge_attribute(void)
{
@@ -60,7 +61,7 @@
first_loop = 0 ;
printf("Sensor loop started!\n") ;
if (display) {
- display->clearDisplay() ;
+ display->cls() ;
display->locate(0, 0) ;
display->putStr("Sensor Loop") ;
display->locate(2, 1) ;
@@ -80,9 +81,6 @@
if (sensor[sensor_index]) {
afero->setAttributeBool(ATTR_COLOR0_PRESENT, true) ;
afero->setAttributeBool(ATTR_COLOR0_ENABLE, true) ;
-// afero->setAttribute32(ATTR_COLOR0_PWM_R, color0_pwm[0]) ;
-// afero->setAttribute32(ATTR_COLOR0_PWM_G, color0_pwm[1]) ;
-// afero->setAttribute32(ATTR_COLOR0_PWM_B, color0_pwm[2]) ;
afero->getAttribute(ATTR_COLOR0_PWM_R) ;
afero->getAttribute(ATTR_COLOR0_PWM_G) ;
afero->getAttribute(ATTR_COLOR0_PWM_B) ;
@@ -94,9 +92,6 @@
if (sensor[sensor_index]) {
afero->setAttributeBool(ATTR_COLOR1_PRESENT, true) ;
afero->setAttributeBool(ATTR_COLOR1_ENABLE, true) ;
-// afero->setAttribute32(ATTR_COLOR1_PWM_R, color1_pwm[0]) ;
-// afero->setAttribute32(ATTR_COLOR1_PWM_G, color1_pwm[1]) ;
-// afero->setAttribute32(ATTR_COLOR1_PWM_B, color1_pwm[2]) ;
afero->getAttribute(ATTR_COLOR1_PWM_R) ;
afero->getAttribute(ATTR_COLOR1_PWM_G) ;
afero->getAttribute(ATTR_COLOR1_PWM_B) ;
@@ -105,16 +100,16 @@
}
break ;
case 3: /* temp */
- if (lm75b0) {
+ if (lm75b0) { /* temp with color1 */
afero->setAttributeBool(ATTR_TEMP0_PRESENT, true) ;
afero->setAttributeBool(ATTR_TEMP0_ENABLE, true) ;
} else {
afero->setAttributeBool(ATTR_TEMP0_PRESENT, false) ;
}
- afero->setAttributeBool(ATTR_TEMP1_PRESENT, true) ;
- afero->setAttributeBool(ATTR_TEMP2_PRESENT, true) ;
+ afero->setAttributeBool(ATTR_TEMP1_PRESENT, true) ; /* before */
+ afero->setAttributeBool(ATTR_TEMP2_PRESENT, true) ; /* after */
- if (lm75b1) {
+ if (lm75b1) { /* temp with color2 Note: Obsolete */
afero->setAttributeBool(ATTR_TEMP3_PRESENT, true) ;
afero->setAttributeBool(ATTR_TEMP3_ENABLE, true) ;
} else {
@@ -139,6 +134,7 @@
void edge_loop(uint32_t count_robin)
{
+ static int sensor_index = 0 ;
if ((count_robin % accel_interval) == 0) {
if (accel) {
accel->accum() ; /* get and accum accel data */
@@ -198,7 +194,7 @@
printf("SO1602A is absent\n") ;
}
if (display) {
- display->clearDisplay() ;
+ display->cls() ;
display->locate(3, 0) ;
display->putStr("Suntory") ;
display->locate(0, 1) ;
@@ -260,18 +256,18 @@
printf("LM75B on I2C0 is absent\n") ;
}
#endif
- an0 = new AnalogIn(PIN_AN0) ;
+ an0 = new AnalogIn(PIN_AN0) ;
smtc502at0 = new SMTC502AT(an0) ;
- an1 = new AnalogIn(PIN_AN1) ;
+ an1 = new AnalogIn(PIN_AN1) ;
smtc502at1 = new SMTC502AT(an1) ;
- temp = new edge_temp(lm75b0, smtc502at0, smtc502at1, lm75b1) ;
- sensor[3] = temp ;
+ temp = new edge_temp(lm75b0, smtc502at0, smtc502at1, lm75b1) ;
+ sensor[3] = temp ;
num_sensor++ ;
- an2 = new AnalogIn(PIN_AN2) ;
- pse530 = new PSE530(an2) ;
- pressure = new edge_pressure(pse530) ;
- sensor[4] = pressure ;
+ an2 = new AnalogIn(PIN_AN2) ;
+ pse530 = new PSE530(an2) ;
+ pressure = new edge_pressure(pse530) ;
+ sensor[4] = pressure ;
num_sensor++ ;
#if 0
@@ -286,7 +282,7 @@
printf("%d edge_sensor(s) registered\n", num_sensor) ;
printf("Edge is waiting for ASR to link\n") ;
if (display) {
- display->clearDisplay() ;
+ display->cls() ;
display->locate(0, 0) ;
display->putStr("Waiting for") ;
display->locate(0, 1) ;