The firmware of the Grove Node
Dependencies: BLE_API color_pixels mbed-src-nrf51822 nRF51822
Fork of BLE_LoopbackUART by
Revision 11:c0885b74a63a, committed 2015-06-04
- Comitter:
- yihui
- Date:
- Thu Jun 04 12:39:32 2015 +0000
- Parent:
- 10:f34ff4e47741
- Commit message:
- fixed direct control bug
Changed in this revision
diff -r f34ff4e47741 -r c0885b74a63a main.cpp --- a/main.cpp Thu Jun 04 09:34:13 2015 +0000 +++ b/main.cpp Thu Jun 04 12:39:32 2015 +0000 @@ -21,7 +21,7 @@ #include "nrf_delay.h" #include "battery.h" -#define DEBUG 1 +#define DEBUG 0 #if DEBUG // for Arch BLE #define LOG(...) { printf(__VA_ARGS__); }
diff -r f34ff4e47741 -r c0885b74a63a node.cpp --- a/node.cpp Thu Jun 04 09:34:13 2015 +0000 +++ b/node.cpp Thu Jun 04 12:39:32 2015 +0000 @@ -6,7 +6,7 @@ #include "UARTService.h" #include "color_pixels.h" -#define LOG(...) { printf(__VA_ARGS__); } +#define LOG(...) // { printf(__VA_ARGS__); } #define MAX_INIT_DATA 4 #define MAX_SENOSR_DIMENSION 9 @@ -86,14 +86,14 @@ { sensor_index = 0; sensor = sensor_list[sensor_index]; - sensor_init_data[0] = p3; - sensor_init_data[1] = p4; + sensor_init_data[0] = p1; + sensor_init_data[1] = p2; sensor->init(&sensor_object, sensor_init_data); actuator_index = 2; actuator = actuator_list[actuator_index]; - actuator_init_data[0] = p1; - actuator_init_data[1] = p2; + actuator_init_data[0] = p3; + actuator_init_data[1] = p4; actuator_init_data[2] = 30; actuator->init(&actuator_object, actuator_init_data); } @@ -143,31 +143,31 @@ void node_parse(int argc, char *argv[]) { - if (2 == argc) { + if (0 == strcmp(argv[0], "s")) { int param1 = atoi(argv[1]); - if (0 == strcmp(argv[0], "s")) { - if (param1 != sensor_index) { - sensor_index = param1; - sensor->fini(&sensor_object); - sensor = sensor_list[param1]; - sensor->init(&sensor_object, sensor_init_data); + if (param1 != sensor_index) { + sensor_index = param1; + sensor->fini(&sensor_object); + sensor = sensor_list[param1]; + sensor->init(&sensor_object, sensor_init_data); - task_mask = 0; - } + task_mask = 0; + } - LOG("select sensor [%d]\n", sensor_index); - } else if (0 == strcmp(argv[0], "a")) { - if (param1 != actuator_index) { - actuator_index = param1; - actuator->fini(&actuator_object); - actuator = actuator_list[param1]; - actuator->init(&actuator_object, actuator_init_data); - - task_mask = 0; - } + LOG("select sensor [%d]\n", sensor_index); + } else if (0 == strcmp(argv[0], "a")) { + int param1 = atoi(argv[1]); + if (param1 != actuator_index) { + actuator_index = param1; + actuator->fini(&actuator_object); + actuator = actuator_list[param1]; + actuator->init(&actuator_object, actuator_init_data); + + task_mask = 0; + } - LOG("select actuator [%d]\n", actuator_index); - } + LOG("select actuator [%d]\n", actuator_index); + } else if (0 == strcmp(argv[0], "o")) {
diff -r f34ff4e47741 -r c0885b74a63a udriver/color_led_strip.cpp --- a/udriver/color_led_strip.cpp Thu Jun 04 09:34:13 2015 +0000 +++ b/udriver/color_led_strip.cpp Thu Jun 04 12:39:32 2015 +0000 @@ -33,6 +33,7 @@ uint8_t blue = params[2]; uint8_t mode = params[3]; + // printf("r: %d, g: %d, b: %d, mode: %d\n", red, green, blue, mode); if (mode == 0) { pixels->set_all_color(red, green, blue); } else if (mode == 1) {
diff -r f34ff4e47741 -r c0885b74a63a udriver/led.cpp --- a/udriver/led.cpp Thu Jun 04 09:34:13 2015 +0000 +++ b/udriver/led.cpp Thu Jun 04 12:39:32 2015 +0000 @@ -31,6 +31,8 @@ pwm->period(period); } + // printf("pulse: %f, period: %f\n", pulse_width, period); + return 0; }
diff -r f34ff4e47741 -r c0885b74a63a udriver/relay.cpp --- a/udriver/relay.cpp Thu Jun 04 09:34:13 2015 +0000 +++ b/udriver/relay.cpp Thu Jun 04 12:39:32 2015 +0000 @@ -31,6 +31,8 @@ out->output(); out->write(value); + // printf("relay: %d\n", value); + return 0; }