Browse Source

Cleaned up code a bit - web app still needs to save interface type

- Cleaned up code a bit
- web app still needs to save interface type
- Submit changes causes a reset.
WoodsterDK 8 years ago
parent
commit
3a10265c7a

+ 1 - 1
data/web/index.html

@@ -124,7 +124,7 @@
   <script lang="text/javascript">
     var FORM_SETTINGS = [
       "admin_username", "admin_password", "ce_pin", "csn_pin", "reset_pin","packet_repeats",
-      "http_repeat_factor", "auto_restart_period"
+      "http_repeat_factor", "auto_restart_period","radio_interface_type"
     ];
 
     var FORM_SETTINGS_HELP = {

+ 3 - 12
lib/MiLight/MiLightRadioPL1167_LT8900.h

@@ -17,15 +17,7 @@
 #include <MiLightButtons.h>
 #include <MiLightRadioInterface.h>
 
-/*
-#define MODE_RGB			0
-#define MODE_DUAL_WHITE		1
-#define MODE_DUAL_WHITE_RGB 2
-
-#define MILIGHT_SYNCWORD_RGB 0x258B00000000147A
-#define MILIGHT_SYNCWORD_DUAL_WHITE 0x55AA00000000050A
-#define MILIGHT_SYNCWORD_DUALWHITE_RGB 0x1809000000007236
-*/
+
 // Register defines
 #define REGISTER_READ       0b10000000  //bin
 #define REGISTER_WRITE      0b00000000  //bin
@@ -50,7 +42,7 @@
 #define R_SYNCWORD4         39
 
 #define DEFAULT_TIME_BETWEEN_RETRANSMISSIONS_uS	350
-// #define DEBUG_PRINTF
+
 
 #ifndef MILIGHTRADIOPL1167_LT8900_H_
 #define MILIGHTRADIOPL1167_LT8900_H_
@@ -71,7 +63,6 @@ class MiLightRadioPL1167_LT8900 : public MiLightRadioInterface{
 
 
         void vInitRadioModule(MiLightRadioType type);
-        //void vSetSyncWord(uint64_t syncWord);
         void vSetSyncWord(uint16_t syncWord3, uint16_t syncWord2, uint16_t syncWord1, uint16_t syncWord0);
         uint16_t uiReadRegister(uint8_t reg);
         void regWrite16(byte ADDR, byte V1, byte V2, byte WAIT);
@@ -91,7 +82,7 @@ class MiLightRadioPL1167_LT8900 : public MiLightRadioInterface{
       	byte _csPin;
 
     const MiLightRadioConfig& config;
-    uint32_t _prev_packet_id;
+    //uint32_t _prev_packet_id;
     uint8_t _channel = 0;
     uint8_t _packet[10];
     uint8_t _out_packet[10];

+ 15 - 15
lib/MiLight/MiLightRadioPL1197_LT8900.cpp

@@ -267,7 +267,9 @@ void MiLightRadioPL1167_LT8900::vStartListening(uint uiChannelToListenTo)
 {
   _dupes_received = 0;
   vSetSyncWord(config.syncword3, 0,0,config.syncword0);
-	vSetChannel(uiChannelToListenTo);
+	//vSetChannel(uiChannelToListenTo);
+
+  _channel = uiChannelToListenTo;
 
 	uiWriteRegister(R_CHANNEL, _channel & CHANNEL_MASK);   //turn off rx/tx
 	delay(3);
@@ -447,7 +449,6 @@ bool MiLightRadioPL1167_LT8900::available()
             else
             {
               byaFramesReceivedCount[byFrameCounter-1]++;
-              //Serial.print(".");
             }
           }
           else
@@ -468,25 +469,25 @@ bool MiLightRadioPL1167_LT8900::available()
         ulElapsedTime = millis();
         yield();
         ulElapsedTime = ulElapsedTime - ulTimeStamp;
-      }while (ulElapsedTime <1000 );
+      }while (ulElapsedTime < 1000 );
 
       Serial.print("ElapsedRX: ");
       Serial.println(iUpdateStamp - iStartTime);
 
       if (byFrameCounter != 0)
       {
-      Serial.println("");
-      Serial.print(F("Packets received: "));
-      Serial.print(byFrameCounter);
-
-      for (byte byCounterFrame = 0; byCounterFrame < byFrameCounter; byCounterFrame++)
-      {
-        _dupes_received = byaFramesReceivedCount[byCounterFrame];
         Serial.println("");
-        Serial.print(F("Packet read OK, rec: "));
-        Serial.print(byaFramesReceivedCount[byCounterFrame]);
-        Serial.println(F(" Frame: "));
-        //dump the packet.
+        Serial.print(F("Packets received: "));
+        Serial.print(byFrameCounter);
+
+        for (byte byCounterFrame = 0; byCounterFrame < byFrameCounter; byCounterFrame++)
+        {
+          _dupes_received = byaFramesReceivedCount[byCounterFrame];
+          Serial.println("");
+          Serial.print(F("Packet read OK, rec: "));
+          Serial.print(byaFramesReceivedCount[byCounterFrame]);
+          Serial.println(F(" Frame: "));
+          //dump the packet.
 
           _packet[0]=byaFramesSizes[byCounterFrame];
           for (int iByteCounter = 0; iByteCounter < byaFramesSizes[byCounterFrame]; iByteCounter++)
@@ -504,7 +505,6 @@ bool MiLightRadioPL1167_LT8900::available()
             stringToWrite += stringOne;
             stringToWrite += " ";
 
-
             Serial.print(stringToWrite);
           }