Basic LED Demo for nexpaq development kit

Dependencies:   nexpaq_mdk

Fork of LED_Demo by Maxim nexpaq

LED 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. This project demonstrates sending button information back to the application running on the phone, and the phone controlling the on board RGB LED.

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

Resources

Revision:
3:9d15891f9352
Parent:
2:3842948024ca
Child:
4:494741f7f5b2
--- a/main.cpp	Mon Sep 19 09:06:46 2016 +0000
+++ b/main.cpp	Mon Sep 19 13:13:32 2016 +0000
@@ -16,8 +16,7 @@
 /***** Definitions *****/
 #define		FUNCTION_TABLE_NUM					1
 #define		UUID_NUM							16			//UUID number is 16, don't change it
-#define     BUTTON_DEBOUNCE                     5
-#define     DBG_MSG
+#define     LOOP_DELAY                          250
 
 /***** Globals *****/
 void my_function_CMD_2700(unsigned char *pData, unsigned char len);
@@ -25,8 +24,7 @@
 		{0x2700, my_function_CMD_2700},		// Command -> function
 };
 
-int btnCnt = 0;
-int btnSts = 0;
+int lastBtn = 1;
 unsigned char btnPress = 0x01;
 
 /***** Functions *****/
@@ -36,9 +34,6 @@
 	ledG = (pData[1]>0) ? LED_ON : LED_OFF ;
 	ledB = (pData[2]>0) ? LED_ON : LED_OFF ;
 	np_api_upload(0x2701, &response, 1);
-#ifdef DBG_MSG            
-    printf("LED Command Received\n\r");  
-#endif            
 }
 
 /******************************************************************************/
@@ -48,78 +43,25 @@
 		// Register failed handle code
 		error("MDK Register Failed");
 	}
-#ifdef DBG_MSG            
-    printf("MDK Commands Registered\n\r");  
-#endif            
 }
 
 void app_loop() {
-	if (btnSts) {
-		btnCnt = (button) ? 0 : (btnCnt + 1);
-		if (btnCnt >= BUTTON_DEBOUNCE) {
-			np_api_upload(0x2800, &btnPress, 1);
-			btnSts = !btnSts;
-			btnCnt = 0;
-#ifdef DBG_MSG            
-      		printf("Button Pressed\n\r");  
-#endif            
-		}
-	} else {
-		btnCnt = (!button) ? 0 : (btnCnt + 1);
-		if (btnCnt >= BUTTON_DEBOUNCE) {
-			btnSts = !btnSts;
-			btnCnt = 0;
-		}	
-	}
+	if (!button && lastBtn) {
+        np_api_upload(0x2800, &btnPress, 1);
+	}	
+	lastBtn = button;	
 }
 
 int main(void){
 	
-	uint32_t cnt, i;
-	
-	cnt = 500;
-	ledR = 1;
-	ledG = 0;
-	ledB = 1;
-
 	np_api_init();
 	app_setup();
 	np_api_start();	
 	//Thread::wait(5000);
 	while(1){
+    	Thread::wait(LOOP_DELAY);
 		app_loop();	
 		np_api_bsl_chk();
-    	Thread::wait(50);
-    	
-    	if (cnt) {
-    		cnt--;
-			if (cnt == 0) {
-				ledR = 1;
-				ledG = 1;
-				ledB = 1;	
-				Thread::wait(50);
-				cnt = 1000;	
-				//NVIC_SystemReset();
-			}
-		}
-		
-		i = cnt%30;
-		if (i == 10)
-		{
-			ledR = 1;
-			ledG = 1;
-			ledB = 1;
-		}
-		else if (i == 20){
-			ledR = 1;
-			ledG = 0;
-			ledB = 1;	
-		}
-		else if (i == 0) {
-			ledR = 1;
-			ledG = 1;
-			ledB = 0;
-		}
 	}
 
 	return 0;