The codebase to run the *spark d-fuser controller www.sparkav.co.uk/dvimixer

Dependencies:   SPK-TVOne DMX DmxArtNet NetServicesMin OSC PinDetect mRotaryEncoder iniparser mbed spk_oled_ssd1305 filter

Files at this revision

API Documentation at this revision

Comitter:
tobyspark
Date:
Sat Oct 06 12:40:24 2012 +0000
Parent:
15:4b394c64b461
Child:
17:fc68d40b8b1f
Commit message:
Resolution support added to SPKSettings, and menu will display a 'revert to defaults' if SPKSettings has loaded in custom settings. Still all in theory while iniparser isn't working / or chose yet another parsing library.

Changed in this revision

SPK-TVOne.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
spk_settings.h Show annotated file Show diff for this revision Revisions of this file
--- a/SPK-TVOne.lib	Sun Sep 30 13:41:06 2012 +0000
+++ b/SPK-TVOne.lib	Sat Oct 06 12:40:24 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/tobyspark/code/SPK-TVOne/#03e7e7b7a870
+http://mbed.org/users/tobyspark/code/SPK-TVOne/#3faabbbf0ecf
--- a/main.cpp	Sun Sep 30 13:41:06 2012 +0000
+++ b/main.cpp	Sat Oct 06 12:40:24 2012 +0000
@@ -113,8 +113,8 @@
 //// DEBUG
 
 // Comment out one or the other...
-//Serial *debug = new Serial(USBTX, USBRX); // For debugging via USB serial
-Serial *debug = NULL; // For release (no debugging)
+Serial *debug = new Serial(USBTX, USBRX); // For debugging via USB serial
+//Serial *debug = NULL; // For release (no debugging)
 
 //// SOFT RESET
 
@@ -160,7 +160,7 @@
 SPKMenuPayload commsMenu;
 enum { commsNone, commsOSC, commsArtNet, commsDMXIn, commsDMXOut};
 int commsMode = commsNone;
-enum { advancedHDCPOn, advancedHDCPOff, advancedSelfTest };
+enum { advancedHDCPOn, advancedHDCPOff, advancedLoadDefaults, advancedSelfTest };
 
 // RJ45 Comms
 enum { rj45Ethernet = 0, rj45DMX = 1}; // These values from circuit
@@ -322,8 +322,10 @@
     screen.sendBuffer();
     
     // Load saved settings
+    bool settingsAreCustom = false;
 /* CRAZY, see note in spk_settings.h   
-    if (settings.load(kSPKDFSettingsFilename)) 
+    settingsAreCustom = settings.load(kSPKDFSettingsFilename);
+    if (settingsAreCustom)
     {screen.textToBuffer("Settings Read",2); screen.sendBuffer();}
     else 
     {screen.textToBuffer("Settings NOT Read",2); screen.sendBuffer();}
@@ -337,16 +339,10 @@
     }
  
     resolutionMenu.title = "Resolution";
-    resolutionMenu.addMenuItem(kTV1ResolutionDescriptionVGA, kTV1ResolutionVGA, 5);
-    resolutionMenu.addMenuItem(kTV1ResolutionDescriptionSVGA, kTV1ResolutionSVGA, 5);
-    resolutionMenu.addMenuItem(kTV1ResolutionDescriptionXGAp60, kTV1ResolutionXGAp60, 5);
-    resolutionMenu.addMenuItem(kTV1ResolutionDescriptionWSXGAPLUSp60, kTV1ResolutionWSXGAPLUSp60, 5);
-    resolutionMenu.addMenuItem(kTV1ResolutionDescriptionWUXGAp60, kTV1ResolutionWUXGAp60, 5);
-    resolutionMenu.addMenuItem(kTV1ResolutionDescription720p60, kTV1Resolution720p60, 5);
-    resolutionMenu.addMenuItem(kTV1ResolutionDescription1080p60, kTV1Resolution1080p60, 5);
-    resolutionMenu.addMenuItem(kTV1ResolutionDescriptionDualHeadSVGAp60, kTV1ResolutionDualHeadSVGAp60, 0);
-    resolutionMenu.addMenuItem(kTV1ResolutionDescriptionDualHeadXGAp60, kTV1ResolutionDualHeadXGAp60, 0);
-    resolutionMenu.addMenuItem(kTV1ResolutionDescriptionTripleHeadVGAp60, kTV1ResolutionTripleHeadVGAp60, 0);
+    for (int i=0; i < settings.resolutionsCount(); i++)
+    {
+        resolutionMenu.addMenuItem(settings.resolutionName(i), settings.resolutionIndex(i), settings.resolutionEDIDIndex(i));
+    }
 
     commsMenu.title = "Network Mode"; 
     commsMenu.addMenuItem("None", commsNone, 0);
@@ -358,6 +354,7 @@
     advancedMenu.title = "Troubleshooting"; 
     advancedMenu.addMenuItem("HDCP Off", advancedHDCPOff, 0);
     advancedMenu.addMenuItem("HDCP On", advancedHDCPOn, 0);
+    if (settingsAreCustom) advancedMenu.addMenuItem("Revert to defaults", advancedLoadDefaults, 0);
     advancedMenu.addMenuItem("Start Self-Test", advancedSelfTest, 0);
 
     mainMenu.title = "Main Menu";
@@ -661,10 +658,17 @@
                     screen.clearBufferRow(kTVOneStatusLine);
                     screen.textToBuffer(sendOK, kTVOneStatusLine);
                 }
+                else if (advancedMenu.selectedPayload1() == advancedLoadDefaults)
+                {
+                    settings.loadDefaults();
+                    
+                    screen.clearBufferRow(kTVOneStatusLine);
+                    screen.textToBuffer("Controller reverted", kTVOneStatusLine);
+                }
                 else if (advancedMenu.selectedPayload1() == advancedSelfTest)
                 {
                     /* SELF TEST - Pixels
-                     * Clicking ‘self-test’ menu will display a solid lit screen. Check all pixels lit. 
+                     * Clicking &#65533;self-test&#65533; menu will display a solid lit screen. Check all pixels lit. 
                      * Verified: Display
                      */
                     
@@ -709,7 +713,7 @@
                     }
                     
                     /* SELF TEST - RS232
-                     * Click the controller menu control. Should see ‘RS232 test’ prompt and test message. Ensure PC is displaying the test message. 
+                     * Click the controller menu control. Should see &#65533;RS232 test&#65533; prompt and test message. Ensure PC is displaying the test message. 
                      * Verified: RS232 connection.
                      */
                      
@@ -724,7 +728,7 @@
                     }
                     
                     /* SELF TEST - DMX
-                     * Click the controller menu control. Should see ‘DMX test’ prompt and test message. Ensure PC is displaying the test message. 
+                     * Click the controller menu control. Should see &#65533;DMX test&#65533; prompt and test message. Ensure PC is displaying the test message. 
                      * Verified: RS485 connection and DMX library.
                      */
                      
@@ -739,7 +743,7 @@
                     }
                     
                     /* SELF TEST - OSC
-                     * Click the controller menu control. Should see ‘OSC test’ prompt and test message. Ensure PC is displaying the test message. 
+                     * Click the controller menu control. Should see &#65533;OSC test&#65533; prompt and test message. Ensure PC is displaying the test message. 
                      * Verified: Ethernet connection and OSC library.
                      */
                      
--- a/spk_settings.h	Sun Sep 30 13:41:06 2012 +0000
+++ b/spk_settings.h	Sat Oct 06 12:40:24 2012 +0000
@@ -1,9 +1,3 @@
-// Parameter Set: minY, maxY, minU, maxU, minV, maxV
-#define kKeyerParam1Name    "Lumakey"
-#define kKeyerParam1Set     0, 18, 128, 129, 128, 129
-#define kKeyerParam2Name    "Chromakey - Blue"
-#define kKeyerParam2Set     30, 35, 237, 242, 114, 121
-
 #include "mbed.h"
 #include <string>
 #include <vector>
@@ -19,13 +13,63 @@
 public:
     SPKSettings()
     {
-        int paramSet1[6] = {kKeyerParam1Set};
-        keyerParamNames.push_back(kKeyerParam1Name);
+        loadDefaults();
+    }
+    
+    void loadDefaults()
+    {
+        //// KEYS
+        
+        // Parameter Set: minY, maxY, minU, maxU, minV, maxV
+        int paramSet1[6] = {0, 18, 128, 129, 128, 129};
+        keyerParamNames.push_back("Lumakey");
         keyerParamSets.push_back(paramSet1);
         
-        int paramSet2[6] = {kKeyerParam2Set};
-        keyerParamNames.push_back(kKeyerParam2Name);
+        int paramSet2[6] = {30, 35, 237, 242, 114, 121};
+        keyerParamNames.push_back("Chromakey - Blue");
         keyerParamSets.push_back(paramSet2);
+        
+        //// RESOLUTIONS
+        
+        resolutionNames.push_back(kTV1ResolutionDescriptionVGA);
+        resolutionIndexes.push_back(kTV1ResolutionVGA);
+        resolutionEDIDIndexes.push_back(5);
+    
+        resolutionNames.push_back(kTV1ResolutionDescriptionSVGA);
+        resolutionIndexes.push_back(kTV1ResolutionSVGA);
+        resolutionEDIDIndexes.push_back(5);
+        
+        resolutionNames.push_back(kTV1ResolutionDescriptionXGAp60);
+        resolutionIndexes.push_back(kTV1ResolutionXGAp60);
+        resolutionEDIDIndexes.push_back(5);
+        
+        resolutionNames.push_back(kTV1ResolutionDescriptionWSXGAPLUSp60);
+        resolutionIndexes.push_back(kTV1ResolutionWSXGAPLUSp60);
+        resolutionEDIDIndexes.push_back(5);
+        
+        resolutionNames.push_back(kTV1ResolutionDescriptionWUXGAp60);
+        resolutionIndexes.push_back(kTV1ResolutionWUXGAp60);
+        resolutionEDIDIndexes.push_back(5);
+        
+        resolutionNames.push_back(kTV1ResolutionDescription720p60);
+        resolutionIndexes.push_back(kTV1Resolution720p60);
+        resolutionEDIDIndexes.push_back(5);
+        
+        resolutionNames.push_back(kTV1ResolutionDescription1080p60);
+        resolutionIndexes.push_back(kTV1Resolution1080p60);
+        resolutionEDIDIndexes.push_back(5);
+        
+        resolutionNames.push_back(kTV1ResolutionDescriptionDualHeadSVGAp60);
+        resolutionIndexes.push_back(kTV1ResolutionDualHeadSVGAp60);
+        resolutionEDIDIndexes.push_back(5);
+        
+        resolutionNames.push_back(kTV1ResolutionDescriptionDualHeadXGAp60);
+        resolutionIndexes.push_back(kTV1ResolutionDualHeadXGAp60);
+        resolutionEDIDIndexes.push_back(5);
+        
+        resolutionNames.push_back(kTV1ResolutionDescriptionTripleHeadVGAp60);
+        resolutionIndexes.push_back(kTV1ResolutionTripleHeadVGAp60);
+        resolutionEDIDIndexes.push_back(5);   
     }
     
     string keyerParamName (int index)
@@ -44,6 +88,27 @@
         return keyerParamSets.size();
     }
     
+        string resolutionName (int index)
+    {
+        // TODO: Bounds check and return out of bounds name
+        return resolutionNames[index];
+    }
+     
+    int32_t     resolutionIndex(int index)
+    {
+        return resolutionIndexes[index];
+    }
+    
+    int32_t     resolutionEDIDIndex(int index)
+    {
+        return resolutionEDIDIndexes[index];
+    }
+    
+    int         resolutionsCount()
+    {
+        return resolutionNames.size();
+    }
+    
     bool        load(string filename)
     {
         bool success = false;
@@ -124,6 +189,62 @@
             }
         }        
 
+        // RESOLUTIONS
+        {
+            int counter = 1;
+            
+            bool resolutionReadOK = true;
+            bool resolutionCleared = false;
+            
+            char* failString = "Failed to read";
+            int failInt = -1;
+            
+            // Loop through [Key1,2,...,99] sections
+            while(resolutionReadOK)
+            {
+                char*   resolutionName;
+                int     resolutionIndex;
+                int     resolutionEDIDIndex;
+                
+                char key[18];
+        
+                sprintf(key, "Resolution%i:Name", counter);
+                resolutionName = iniparser_getstring(settings, key, failString);
+                resolutionReadOK = resolutionReadOK && strcmp(resolutionName, failString);
+                       
+                sprintf(key, "Resolution%i:Number", counter);
+                resolutionIndex = iniparser_getint(settings, key, failInt);
+                resolutionReadOK = resolutionReadOK && (resolutionIndex != failInt);
+
+                sprintf(key, "Resolution%i:EDIDNumber", counter);
+                resolutionEDIDIndex = iniparser_getint(settings, key, failInt);
+                resolutionReadOK = resolutionReadOK && (resolutionEDIDIndex != failInt);
+                
+                // If all parameters have been read successfully
+                if (resolutionReadOK)
+                {
+                    // If this is the first time through, clear old values
+                    if (!resolutionCleared)
+                    {
+                        resolutionNames.clear();
+                        resolutionIndexes.clear();
+                        resolutionEDIDIndexes.clear();
+                        resolutionCleared = true;
+                    }
+                
+                    // Apply settings
+                    resolutionNames.push_back(resolutionName);
+                    resolutionIndexes.push_back(resolutionIndex);
+                    resolutionEDIDIndexes.push_back(resolutionEDIDIndex);
+                    
+                    // We've successfully read a resolution, so should return true;
+                    success = true;
+                }
+                
+                counter++;
+            }
+        }
+
         iniparser_freedict(settings);
         
         delete local;
@@ -133,6 +254,9 @@
     
 protected:
     LocalFileSystem *local;
-    vector<int*> keyerParamSets;
-    vector<string> keyerParamNames;
-};
+    vector<int*>    keyerParamSets;
+    vector<string>  keyerParamNames;
+    vector<string>  resolutionNames;
+    vector<int32_t> resolutionIndexes;
+    vector<int32_t> resolutionEDIDIndexes;
+};
\ No newline at end of file