Stránka 1 z 2

Datová sekce přesahuje dostupné místo na desce

Napsal: 21 črc 2021, 11:32
od Arthur
Používám dotykový displej Stone pro komunikaci s Arduino uno a když dokončím psaní kódu pro Arduino a zkompiluju ho, dojde k této chybě, když ho nahraju.

Kód: Vybrat vše

Arduino:1.8.12 (Windows 10), vývojová deska: "Arduino Uno"

Projekt využívá 6336 bajtů, což zabírá (19 %) úložného prostoru programu. Maximum je 32256 bajtů. datová část přesahuje dostupné místo na desce

Globální proměnné zabírají 3046 bajtů, (148 %) dynamické paměti, takže pro lokální proměnné zbývá -998 bajtů. Maximum je 2048 bajtů.
Není dostatek paměti; navštivte následující adresu URL a postupujte podle pokynů ke snížení využití paměti.
http://www.arduino.cc/en/Guide/Troubleshooting#size
Chyba při kompilaci pro vývojovou desku Arduino Uno.

Zapněte v nabídce Soubor -> Předvolby
"Zobrazit podrobný výstup během kompilace" možnost
Toto hlášení bude obsahovat více informací.

Re: Datová sekce přesahuje dostupné místo na desce

Napsal: 21 črc 2021, 11:44
od jankop
Arthure, Arthure ...!? To se ptáš, nebo nám to oznamuješ? Možná by ti někdo dovedl pomoci optimalizovat globální proměnné a ušetřit RAM. Ale to ty asi nechceš, protože by ses na to zeptal a přiložil svůj program, bez kterého jaksi nikdo nemůže dát radu.
Tedy, pokud to není z výše uvedeného zcela jasné, pro tebou napsaný program se nedostává paměti RAM.

Re: Datová sekce přesahuje dostupné místo na desce

Napsal: 21 črc 2021, 13:56
od gilhad
Tak použij nějaké MCU co má víc paměti, nebo to napiš líp, víc se k tomu říct nedá...

Re: Datová sekce přesahuje dostupné místo na desce

Napsal: 21 črc 2021, 20:41
od martinius96
Mohol by si ukázať ten program...

Re: Datová sekce přesahuje dostupné místo na desce

Napsal: 23 črc 2021, 04:30
od Arthur
Oto mój kod

Kód: Vybrat vše

unsigned int r_flag1 = 0;
uint8_t   RecievedTemp1[30]       = {0};

uint8_t   cout_i = 0;
unsigned int quan_hang1 = 0;
unsigned int quan_hang2 = 0;
unsigned int quan_hang3 = 0;
unsigned int quan_lie1 = 0;
unsigned int quan_lie2 = 0;
unsigned int quan_lie3 = 0;
unsigned int quan_zuoxia = 0;
unsigned int quan_youxia = 0;


unsigned int cha_hang1 = 0;
unsigned int cha_hang2 = 0;
unsigned int cha_hang3 = 0;
unsigned int cha_lie1 = 0;
unsigned int cha_lie2 = 0;
unsigned int cha_lie3 = 0;
unsigned int cha_zuoxia = 0;
unsigned int cha_youxia = 0;
unsigned int cha[8]={0};
void setup()
{
   Serial.begin(115200);
   for(int i=3; i<=8; i++) 
   pinMode(i,OUTPUT);
}

void loop(){

  if(Serial.available() != 0)
  {
//    for(cout_i = 0; cout_i < 30; cout_i ++)
//    {
//        //RecievedTemp1[cout_i] = Serial.readBytes(RecievedTemp1, 15);
//        Serial.readBytes(RecievedTemp1, 20);
//        //Serial.println(RecievedTemp1[cout_i]);
//    }
    Serial.readBytes(RecievedTemp1, 20);
//    for(cout_i = 0; cout_i < 19; cout_i ++)
//    {
//    Serial.println(RecievedTemp1[cout_i]);
//    }
    switch(RecievedTemp1[13])
  {
  case 49:
        if((r_flag1 == 0)&&(RecievedTemp1[14]==2))
        {
        Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image2\",\"image\":\"circle\"}>ET");
        r_flag1 = 1;
        quan_hang1++;
        quan_lie1++;
        quan_youxia++;
//        quan[0]++;
//        quan[3]++;
//        quan[7]++;
        Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button1\",\"enable\":false}>ET");
        }
        else if((r_flag1 == 1)&&(RecievedTemp1[14]==2))
        {
          Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image2\",\"image\":\"x\"}>ET");
         r_flag1 = 0;
            cha_hang1++;
            cha_lie1++;
            cha_youxia++;
//        cha[0]++;
//        cha[3]++;
//        cha[7]++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button1\",\"enable\":false}>ET");
        }
        
        break;
  case 50:
        if((r_flag1 == 0)&&(RecievedTemp1[14]==2))
        {
        Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image3\",\"image\":\"circle\"}>ET");
        r_flag1 = 1;
        quan_hang1++;
            quan_lie2++;
//        quan[0]++;
//        quan[4]++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button2\",\"enable\":false}>ET");
        }
        else if((r_flag1 == 1)&&(RecievedTemp1[14]==2))
        {
          Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image3\",\"image\":\"x\"}>ET");
         r_flag1 = 0;
         cha_hang1++;
           cha_lie2++;
//        cha[0]++;
//        cha[4]++;
           Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button2\",\"enable\":false}>ET");
        }
        break;
  case 51:
        if((r_flag1 == 0)&&(RecievedTemp1[14]==2))
        {
        Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image4\",\"image\":\"circle\"}>ET");
        r_flag1 = 1;
        quan_hang1++;
            quan_lie3++;
            quan_zuoxia++;
//        quan[0]++;
//        quan[5]++;
//        quan[6]++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button3\",\"enable\":false}>ET");
        }
        else if((r_flag1 == 1)&&(RecievedTemp1[14]==2))
        {
          Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image4\",\"image\":\"x\"}>ET");
         r_flag1 = 0;
         cha_hang1++;
           cha_lie3++;
            cha_zuoxia++;
//        cha[0]++;
//        cha[5]++;
//        cha[6]++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button3\",\"enable\":false}>ET");
        }
        break;
  case 52:
        if((r_flag1 == 0)&&(RecievedTemp1[14]==2))
        {
        Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image5\",\"image\":\"circle\"}>ET");
        r_flag1 = 1;
        quan_hang2++;
            quan_lie1++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button4\",\"enable\":false}>ET");
        }
        else if((r_flag1 == 1)&&(RecievedTemp1[14]==2))
        {
          Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image5\",\"image\":\"x\"}>ET");
         r_flag1 = 0;
         cha_hang2++;
           cha_lie1++;
           Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button4\",\"enable\":false}>ET");
        }
        break;
  case 53:
        if((r_flag1 == 0)&&(RecievedTemp1[14]==2))
        {
        Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image6\",\"image\":\"circle\"}>ET");
        r_flag1 = 1;
        quan_hang2++;
            quan_lie2++;
            quan_zuoxia++;
            quan_youxia++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button5\",\"enable\":false}>ET");
        }
        else if((r_flag1 == 1)&&(RecievedTemp1[14]==2))
        {
          Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image6\",\"image\":\"x\"}>ET");
          r_flag1 = 0;
          cha_hang2++;
            cha_lie2++;
            cha_zuoxia++;
            cha_youxia++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button5\",\"enable\":false}>ET");
        }
        break;       
  case 54:
        if((r_flag1 == 0)&&(RecievedTemp1[14]==2))
        {
        Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image7\",\"image\":\"circle\"}>ET");
        r_flag1 = 1;
        quan_hang2++;
            quan_lie3++;
//        quan[1]++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button6\",\"enable\":false}>ET");
        }
        else if((r_flag1 == 1)&&(RecievedTemp1[14]==2))
        {
          Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image7\",\"image\":\"x\"}>ET");
         r_flag1 = 0;
         cha_hang2++;
           cha_lie3++;
           Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button6\",\"enable\":false}>ET");
        }
        break;       
  case 55:
        if((r_flag1 == 0)&&(RecievedTemp1[14]==2))
        {
        Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image8\",\"image\":\"circle\"}>ET");
        r_flag1 = 1;
        quan_hang3++;
            quan_lie1++;
            quan_zuoxia++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button7\",\"enable\":false}>ET");
        }
        else if((r_flag1 == 1)&&(RecievedTemp1[14]==2))
        {
          Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image8\",\"image\":\"x\"}>ET");
         r_flag1 = 0;
         cha_hang3++;
           cha_lie1++;
            cha_zuoxia++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button7\",\"enable\":false}>ET");
        }
        break;        
  case 56:
        if((r_flag1 == 0)&&(RecievedTemp1[14]==2))
        {
        Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image9\",\"image\":\"circle\"}>ET");
        r_flag1 = 1;
        quan_hang3++;
            quan_lie2++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button8\",\"enable\":false}>ET");
        }
        else if((r_flag1 == 1)&&(RecievedTemp1[14]==2))
        {
          Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image9\",\"image\":\"x\"}>ET");
         r_flag1 = 0;
         cha_hang3++;
           cha_lie2++;
           Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button8\",\"enable\":false}>ET");
        }
        break;       
  case 57:
        if((r_flag1 == 0)&&(RecievedTemp1[14]==2))
        {
        Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image10\",\"image\":\"circle\"}>ET");
        r_flag1 = 1;
        quan_hang3++;
            quan_lie3++;
            quan_youxia++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button9\",\"enable\":false}>ET");
        }
        else if((r_flag1 == 1)&&(RecievedTemp1[14]==2))
        {
          Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image10\",\"image\":\"x\"}>ET");
         r_flag1 = 0;
         quan_hang3++;
           quan_lie3++;
            quan_youxia++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button9\",\"enable\":false}>ET");
        }
        break;
  }
  if((quan_hang1==3)||(cha_hang1==3))
      {
            Serial.println("ST<{\"cmd_code\":\"set_visible\",\"type\":\"widget\",\"widget\":\"gif4\",\"visible\":true}>ET");
      }
      else if((quan_hang2==3)||(cha_hang2==3))
      {
            Serial.println("ST<{\"cmd_code\":\"set_visible\",\"type\":\"widget\",\"widget\":\"gif5\",\"visible\":true}>ET");
      }
      else if((quan_hang3==3)||(cha_hang3==3))
      {
            Serial.println("ST<{\"cmd_code\":\"set_visible\",\"type\":\"widget\",\"widget\":\"gif6\",\"visible\":true}>ET");
      }
      else if((quan_lie1==3)||(cha_lie1==3))
      {
            Serial.println("ST<{\"cmd_code\":\"set_visible\",\"type\":\"widget\",\"widget\":\"gif7\",\"visible\":true}>ET");
      }
      else if((quan_lie2==3)||(cha_lie2==3))
      {
            Serial.println("ST<{\"cmd_code\":\"set_visible\",\"type\":\"widget\",\"widget\":\"gif8\",\"visible\":true}>ET");
      }
      else if((quan_lie3==3)||(cha_lie3==3))
      {
            Serial.println("ST<{\"cmd_code\":\"set_visible\",\"type\":\"widget\",\"widget\":\"gif9\",\"visible\":true}>ET");
      }
      else if((quan_zuoxia==3)||(cha_zuoxia==3))
      {
            Serial.println("ST<{\"cmd_code\":\"set_visible\",\"type\":\"widget\",\"widget\":\"gif10\",\"visible\":true}>ET");
      }
      else if((quan_youxia==3)||(cha_youxia==3))
      {
            Serial.println("ST<{\"cmd_code\":\"set_visible\",\"type\":\"widget\",\"widget\":\"gif11\",\"visible\":true}>ET");
      }
  }
}

Re: Datová sekce přesahuje dostupné místo na desce

Napsal: 23 črc 2021, 07:41
od AstroMiK
Kód jsem moc nestudoval, ale první, co mě praštilo do očí, byla ta spousta textů.
To nejjednodušší řešení je, že se na texty použije makro F(). Tím se ušetří nějakých 70 bajtů RAM z každé takto upravené řádky.

Příklad:

Původní řádka:

Kód: Vybrat vše

Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button5\",\"enable\":false}>ET");
se změní na:

Kód: Vybrat vše

Serial.println(F("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button5\",\"enable\":false}>ET"));

Popis makra je tady na konci stránky:
https://www.arduino.cc/reference/en/lan ... s/progmem/


Možná tam ale bude možnost i další optimalizace a úspory RAM.

Re: Datová sekce přesahuje dostupné místo na desce

Napsal: 23 črc 2021, 16:38
od kiRRow
Já čekal nějaké šílené několika rozměrné pole, 4 stránky globálních proměnný nebo něco takového a ono to je zapráskané textem uloženým v operační paměti :D

Re: Datová sekce přesahuje dostupné místo na desce

Napsal: 23 črc 2021, 17:22
od jankop
Když se dá ten text makrem do PROGMEM, tak není co řešit. AstroMiK má pravdu. Snadná náprava.

Re: Datová sekce přesahuje dostupné místo na desce

Napsal: 26 črc 2021, 04:22
od Arthur
AstroMiK píše:
23 črc 2021, 07:41
Kód jsem moc nestudoval, ale první, co mě praštilo do očí, byla ta spousta textů.
To nejjednodušší řešení je, že se na texty použije makro F(). Tím se ušetří nějakých 70 bajtů RAM z každé takto upravené řádky.

Příklad:

Původní řádka:

Kód: Vybrat vše

Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button5\",\"enable\":false}>ET");
se změní na:

Kód: Vybrat vše

Serial.println(F("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button5\",\"enable\":false}>ET"));

Popis makra je tady na konci stránky:
https://www.arduino.cc/reference/en/lan ... s/progmem/


Možná tam ale bude možnost i další optimalizace a úspory RAM.
Ano, moc vám děkuji! Fungovalo to.

Re: Datová sekce přesahuje dostupné místo na desce

Napsal: 26 črc 2021, 11:30
od KamilV
AstroMiK píše:
23 črc 2021, 07:41
Kód jsem moc nestudoval, ale první, co mě praštilo do očí, byla ta spousta textů.
To nejjednodušší řešení je, že se na texty použije makro F(). Tím se ušetří nějakých 70 bajtů RAM z každé takto upravené řádky.
A pak ještě: ty texty jsou sobě hodně podobné a liší se mnohdy jen v jednom znaku. Oplatilo by se uchovat si v konstantě to co je stejné a doplňovat jen ty změny...