LED Demo with proximity sensor support for nexpaq development system

Dependencies:   MAX44000 nexpaq_mdk

Fork of LED_Prox_Demo by Maxim nexpaq

LED Prox Demo

MAX32625NEXPAQ development module

This project is a demonstration application for the MAX32625NEXPAQ development module. You will need the nexpaq application and a compatible phone to run this demo, along with the MAX44000PMB1# peripheral module. This project demonstrates polling the proximity sensor to use it like a button and sending the information back to the application running on the phone, and the phone controlling the on board RGB LED to create different colors.

Go to the nexpaq developers hub for details on how to load the code for the tile into the application.

Resources

Revision:
8:42704f06a339
Parent:
7:85c8f02ae327
Child:
9:ab02ac0fe404
--- a/main.cpp	Fri Sep 23 18:53:57 2016 +0000
+++ b/main.cpp	Sat Oct 15 18:50:12 2016 +0000
@@ -2,14 +2,6 @@
 #include "nexpaq_mdk.h"
 #include "MAX44000.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern volatile uint8_t flag_jump_bsl;
-#ifdef __cplusplus
-}
-#endif
-
 MAX44000 max44000(P1_6, P1_7);
 PwmOut ledR(P2_4);
 PwmOut ledG(P2_5);
@@ -25,7 +17,7 @@
 /***** Globals *****/
 void my_function_CMD_2700(unsigned char *pData, unsigned char len);
 const MDK_REGISTER_CMD my_cmd_func_table[FUNCTION_TABLE_NUM] = {
-		{0x2700, my_function_CMD_2700},		// Command -> function
+    {0x2700, my_function_CMD_2700},		// Command -> function
 };
 
 int lastPrx = 0;
@@ -34,55 +26,59 @@
 unsigned char btnPress = 0x01;
 
 /***** Functions *****/
-void my_function_CMD_2700(unsigned char *pData, unsigned char len){
-	unsigned char response = 0x00;
+void my_function_CMD_2700(unsigned char *pData, unsigned char len)
+{
+    unsigned char response = 0x00;
     ledR = 1.0f - (pData[0] / 255.0f);
     ledG = 1.0f - (pData[1] / 255.0f);
     ledB = 1.0f - (pData[2] / 255.0f);
-	np_api_upload(0x2701, &response, 1);
+    np_api_upload(0x2701, &response, 1);
 }
 
 /******************************************************************************/
-void app_setup(){
-	if ( np_api_register((MDK_REGISTER_CMD*)my_cmd_func_table, FUNCTION_TABLE_NUM) == MDK_REGISTER_FAILD ) {
-		// Register failed handle code
-		error("MDK Register Failed");
-	}
-    max44000.init(MAX44000::MODE_ALS_PROX, MAX44000::ALSTIM_64X, MAX44000::ALSPGA_1X, MAX44000::DRV_110);	
+void app_setup()
+{
+    if ( np_api_register((MDK_REGISTER_CMD*)my_cmd_func_table, FUNCTION_TABLE_NUM) == MDK_REGISTER_FAILD ) {
+        // Register failed handle code
+        error("MDK Register Failed");
+    }
+    max44000.init(MAX44000::MODE_ALS_PROX, MAX44000::ALSTIM_64X, MAX44000::ALSPGA_1X, MAX44000::DRV_110);
     ledR = 1.0f;
     ledG = 1.0f;
     ledB = 1.0f;
 }
 
-void app_loop() {
+void app_loop()
+{
     int proxData = max44000.readReg(MAX44000::REG_PRX_DATA);
     if (proxData > PROX_THRESHOLD) {
-    	if (!lastPrx) {
+        if (!lastPrx) {
             np_api_upload(0x2800, &prxPress, 1);
         }
         lastPrx = 1;
     } else {
-    	lastPrx = 0;
+        lastPrx = 0;
     }
 
-	if (!button && lastBtn) {
+    if (!button && lastBtn) {
         np_api_upload(0x2800, &btnPress, 1);
-	}	
-	lastBtn = button;	
+    }
+    lastBtn = button;
 }
 
-int main(void){
-	
-	np_api_init();
-	app_setup();
-	np_api_start();	
+int main(void)
+{
+
+    np_api_init();
+    app_setup();
+    np_api_start();
 
-	while(1){
-    	Thread::wait(LOOP_DELAY);
-		app_loop();	
-		np_api_bsl_chk();
-	}
+    while(1) {
+        Thread::wait(LOOP_DELAY);
+        app_loop();
+        np_api_bsl_chk();
+    }
 
-	return 0;
+    return 0;
 }