Browse Source

bug fixes

subDesTagesMitExtraKaese 4 years ago
parent
commit
b1e4893d6e
7 changed files with 19 additions and 23 deletions
  1. 2 2
      graphic-eq.py
  2. 4 9
      include/config.hpp
  3. 1 0
      lib/RedFly/RedFly.cpp
  4. 1 0
      lib/RedFly/RedFly.h
  5. 2 3
      src/main.cpp
  6. 6 7
      src/matrix.cpp
  7. 3 2
      src/redFlyClient.cpp

+ 2 - 2
graphic-eq.py

@@ -45,6 +45,7 @@ audio.agcFftSetLimits(60/60, 300/60)
 maxVolRow = [0] * N_COLS
 maxVolAge = [0] * N_COLS
 intervalTime = time.time()
+data = [0] * 50
 
 while True:
   if audio.hasNewData():
@@ -70,9 +71,8 @@ while True:
         for row in range(curRow, N_ROWS):
           data[row*N_COLS+col] = 15-curRow-row
     data[49] = int(data[49]/2)
-    #print(data)
-    matrix.send(b'A' + bytes(data))
 
+  matrix.send(b'A' + bytes(data))
   time.sleep(1/30)
 
   if time.time() - intervalTime > 60:

+ 4 - 9
include/config.hpp

@@ -7,15 +7,10 @@
 #include <EEPROM.h>
 
 struct config_t {
-  union {
-    struct{
-      char ssid[16];
-      char pass[16];
-      char host[24];
-      int port;
-    };
-    uint8_t bytes[16+16+24];
-  };
+  char ssid[16];
+  char pass[16];
+  char host[24];
+  int port;
 };
 
 extern config_t config;

+ 1 - 0
lib/RedFly/RedFly.cpp

@@ -258,6 +258,7 @@ uint8_t REDFLY::getip(char *host, uint8_t *ip) //return IP addr from host/domain
 
   for(uint8_t i=3; i!=0; i--) //try 3 times
   {
+    wdt_reset();
     memset(buffer, 0, sizeof(buffer));
     ret = cmd(buffer, sizeof(buffer), PSTR(CMD_DNSGET), (uint8_t*)host, strlen(host)); //OKx...
     if(ret == 0)

+ 1 - 0
lib/RedFly/RedFly.h

@@ -5,6 +5,7 @@
 #include <inttypes.h>
 #if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR))
 # include <avr/pgmspace.h>
+# include <avr/wdt.h>
 #endif
 
 

+ 2 - 3
src/main.cpp

@@ -18,7 +18,7 @@ void setup() {
   delay(10);
 
   Serial.begin(38400);
-  printf("boot\n");
+  Serial.println("boot");
   delay(10);
   
   wdt_enable(WDTO_8S);
@@ -29,8 +29,7 @@ void setup() {
   
   if(RedFly.init(38400, HIGH_POWER)) {
     debugout("INIT ERR\n"); //there are problems with the communication between the Arduino and the RedFly
-    memset(matrix.bytes, 0xf, sizeof(matrix_t));
-    for(;;);
+    mode = 'S';
   }
   delay(200);
 }

+ 6 - 7
src/matrix.cpp

@@ -39,18 +39,17 @@ void matrix_init() {
 }
 
 ISR(TIMER1_COMPA_vect) {
+  //stop on reboot
+  if(n == 0) {
+    noInterrupts();
+    TIMSK1 &= ~(1 << OCIE1A);
+    interrupts();
+  }
   if(++currentRow >= N_ROWS) {
     currentRow = 0;
     
     if(++currentVal >= 15) {
       currentVal = 0;
-
-      //stop on reboot
-      if(n == 0) {
-        noInterrupts();
-        TIMSK1 &= ~(1 << OCIE1A);
-        interrupts();
-      }
     }
 
     OCR1A = cieCycles[currentVal];

+ 3 - 2
src/redFlyClient.cpp

@@ -17,7 +17,8 @@ void debugout(const char* fmt, ...) {
 
 int8_t extractIpAddress(char *sourceString, byte *ipAddress) {
   byte len=0;
-  char cnt=0,cnt1=0,i,buf[5];
+  char buf[5];
+  byte cnt=0,cnt1=0,i;
 
   len=strlen(sourceString);
   for(i=0;i<len;i++)
@@ -44,7 +45,7 @@ int8_t connect() {
   wdt_reset();
   {
     size_t len = strnlen(config.ssid, sizeof(config.ssid));
-    if(len == 0 && len == sizeof(config.ssid)) {
+    if(len == 0 || len == sizeof(config.ssid)) {
       debugout("CONF ERR\n");
       return 1;
     }