Release 1.01

Dependents:   mbed_escm2000

Revision:
5:9f4d4f8ffc00
Parent:
4:7226c43320b5
--- a/EditAddressMenu.cpp	Thu Sep 12 11:27:50 2019 +0000
+++ b/EditAddressMenu.cpp	Tue Sep 17 13:48:22 2019 +0000
@@ -1,3 +1,25 @@
+/**************************************************************************
+ * @file     EditAddressMenu.cpp
+ * @brief    Base class for implementing the Edit Address Menu display
+ * @version: V1.0
+ * @date:    9/17/2019
+
+ *
+ * @note
+ * Copyright (C) 2019 E3 Design. All rights reserved.
+ *
+ * @par
+ * E3 Designers LLC is supplying this software for use with Cortex-M3 LPC1768
+ * processor based microcontroller for the ESCM 2000 Monitor and Display.  
+ *  *
+ * @par
+ * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
+ * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
+ * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
+ * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+ *
+ ******************************************************************************/
 #include "mbed.h"
 #include "EditAddressMenu.h"
 #include "TimeUtilities.h"
@@ -8,8 +30,9 @@
 #define EDIT_ADDRESS    2
 
 
-string valid_characters = {"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 " };
+string valid_characters = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_ " };
 
+/******************************************************************************/
 EditAddressMenu::EditAddressMenu(char* id): Menu(id)
 {
 
@@ -23,8 +46,7 @@
 
 }
 
-
-
+/******************************************************************************/
 void EditAddressMenu::init()
 {
     active_selection = 0;
@@ -36,6 +58,7 @@
     bottom  = active_address +2;
 }
 
+/******************************************************************************/
 void EditAddressMenu::display(LCD * lcd) 
 {
     // paging
@@ -133,24 +156,18 @@
                     }
                 }
                 
-                if (strlen(addressMap.addresses[active_address].description) > 0)
-                {
-                    escmController.say("%s is open" , 
-                        addressMap.addresses[active_address].description );
-                }
-                else
-                {
-                    escmController.say("Unit %d is open" , 
-                        addressMap.addresses[active_address].address );
-                }
-
                 break;
         };
+        
+        lcd->locate(2,20);
+        //lcd->printf("%02d,%02d,%02d,%02d",active_address,active_position,top,bottom);
         update_needed=0;
     }
+    
     displayCurrentTime(lcd);
 }
 
+/******************************************************************************/
 void EditAddressMenu::pressMode()
 {
     // toggle active menu 
@@ -185,6 +202,7 @@
     update_needed = 1;
 }
 
+/******************************************************************************/
 void EditAddressMenu::pressSet()
 {
     // set button advances to next character position OR
@@ -231,22 +249,24 @@
 }
 
 
+/******************************************************************************/
 void EditAddressMenu:: nextValidChar (char * value , int direction)
 {
     char c = *value;
     
-    size_t index = valid_characters.find(c); 
+    int index = (int)valid_characters.find(c); 
 
     if ( index ==  string::npos )
     {
-        index = 0;
+        index = 0;  ///invalid charcter
     }
     else 
     {
         index += direction;
         
-        if (index<0) 
+        if (index< 0) 
             index = valid_characters.size()-1;
+            
         if (index >= valid_characters.size())
             index = 0;
         
@@ -256,6 +276,7 @@
 }
 
 
+/******************************************************************************/
 void EditAddressMenu::pressUp()
 {
     // either advances the pointer to current object in list OR
@@ -277,11 +298,17 @@
 
     }
     
-    LIMIT(active_address  , 0, MAX_ADDRESSES  - 1);
-    LIMIT(active_position , 0, MAX_ADDR_LENGTH -1);  
-
+    // ---------------------------------------------
+    // wrap around
+    if ( active_address < 0 )
+    {   
+        active_address = MAX_ADDRESSES-1;
+    }
+    
+    
 }
 
+/******************************************************************************/
 void EditAddressMenu::pressDown()
 {
     // either advances the pointer to current object in list OR
@@ -295,7 +322,6 @@
 
         case EDIT_ADDRESS:
             nextValidChar (&tmp_description[active_position],-1);
-            //active_position--;
             update_needed = 1;
             break;
 
@@ -306,9 +332,12 @@
 
     }
     
-    
-    
-    LIMIT(active_address  , 0, MAX_ADDRESSES  - 1);
-    LIMIT(active_position , 0, MAX_ADDR_LENGTH -1);
+    // ---------------------------------------------
+    // wrap around
+    if ( active_address >= MAX_ADDRESSES )
+    {   
+        active_address = 0;
+    }
+}
 
-}
+/******************************************************************************/
\ No newline at end of file