Show Posts
Pages: [1] 2 3 ... 7
1  International / Portugues / Re: Ajuda com redução de código on: April 16, 2014, 06:33:12 pm
O código estava com alguns erros e de cara logo notei eles, foram fácil de resolver.....logo após isso introduzi mais algumas linhas de comando para terminar de implementar o código, mas muito obrigado pela ajuda

Notou erros e cometeu um pior.

Code:
for(int x = 8; x >= 0; x--)

Isso conta 9 pinos mas, aqui só tem 8.

Code:
int led[8] = {1, 2, 3, 4, 5, 6, 7, 8};

Acho que falta um pouco de humildade e gratidão.
2  International / Portugues / Re: Ajuda com redução de código on: April 16, 2014, 09:41:45 am
Mudou mais alguma coisa... o interessante é que a mudança introduziu um erro no código...

Isso por acaso funciona? Ou apenas parece funcionar? O meu código tinha pequenos pormenores intencionais... como não repetir a piscadela no último LED ao subir.

Seu código tem um pequeno erro aqui:

Code:
for (up = 0; up < 7; up++) {

Só vai ligar 7 LEDs.

Acho que estava preocupado com o pino 1.

Quote
o pino 1 é usado como porta de transmissão... se calhar é melhor mudar

De resto é praticamente a mesma coisa.
3  International / Portugues / Re: Problemas com Buttons on: April 15, 2014, 08:54:04 pm
O que quer dizer com lâmpada "temporisada"?
Usando a função "delay" não vai conseguir fazer outra coisa.
Use a função millis().
4  International / Portugues / Re: Ajuda com redução de código on: April 15, 2014, 06:21:33 pm
Aprendeu a mudar o nome da variável?

O código é o mesmo que o bubulinho escreveu.
5  Using Arduino / Project Guidance / Re: "External" memory for program memory? on: April 14, 2014, 05:59:59 am
Rewrite the program (in Python, or whatever) to run on a PC (or a RaspberryPi or a Yun) and just use the Arduino to interface with the hardware.

...R

Hi!

Thank you by reply.

I haven't knowledge to it.

I spend 8 months to write this program.

I'll have that study hard to do what suggest me.

Best regards.
6  Using Arduino / Project Guidance / Re: "External" memory for program memory? on: April 14, 2014, 05:55:25 am
I can't find the definition for the cor_canalX objects but if you had them in an array the desenhar_barras_periodo() function could be reduced to something like this

Code:
void desenhar_barras_periodo () {
int x = (setor_selecionado * 38)+5;
int y = (setor_selecionado * 38)+39

for (int i = 1; i < 5; i++) {
if (bitRead(cor_selecionada,i) == true) {
myGLCD.setColor(cor_canals[i][0], cor_canals[i][1],cor_canals[i][2]);
myGLCD.drawRect(x, 80, y, 195);
desenhar_barras(cor_canals[i][0], cor_canals[i][1], cor_canals[i][2], x, 80, y, 195);
}
}
}

______
Rob

Hi!

Thank you by reply.

In the tab "ferduino" have definitions.

Code:
//*****************************************************************************************
//************************* LED design ****************************************************
//*****************************************************************************************     
const byte cor_canal1[] = {255, 255, 255};  // Branco
const byte cor_canal2[] = {9, 184, 255};    // Azul
const byte cor_canal3[] = {58, 95, 205};    // Azul Royal
const byte cor_canal4[] = {255, 0, 0};      // Vermelho
const byte cor_canal5[] = {224, 102, 255};  // Violeta

It's very simple. You think that a matrix of two dimensions is better on this case?
It draw only a color of each time.



I can make this:
Code:
if((bitRead(cor_selecionada,1) == true) || (bitRead(cor_selecionada,2) == true) || ((bitRead(cor_selecionada,3) == true) || (bitRead(cor_selecionada,4) == true) || (bitRead(cor_selecionada,5) == true))
{
}

Best regards.
7  Using Arduino / Project Guidance / Re: "External" memory for program memory? on: April 09, 2014, 09:48:35 am
Yep, not to mention the near 14k saved elsewhere, keep that up and the program will fit in a UNO smiley

______
Rob

Haha!

Impossible because now i can't find another place to change.

I tested the changes above and work very fine.

I sent changes to Github if someone have a bit of time to see.

Suggestions are welcome.

Best regards.
8  Using Arduino / Project Guidance / Re: "External" memory for program memory? on: April 09, 2014, 06:47:12 am
Hi!

Using the that told above and it for dosing pumps, I managed reduce 13.84 KB.

Code:
      if((bitRead(segunda_dosagem_personalizada,1) == t.dow)|| (terca_dosagem_personalizada_1 == t.dow) || (quarta_dosagem_personalizada_1 == t.dow)
        || (quarta_dosagem_personalizada_1 == t.dow) || (quinta_dosagem_personalizada_1 == t.dow) || (sexta_dosagem_personalizada_1 == t.dow)
        || (sabado_dosagem_personalizada_1 == t.dow) || (domingo_dosagem_personalizada_1 == t.dow))
      {
        if(file.open(&root, "HDP1.TXT", O_READ))
        {
          while ((n = file.read(buf, sizeof(buf))) > 0)
          {
            minuto01 = atoi(buf);
            if(minuto01 ==  NumMins(t.hour,t.min))
            {
              tempo_dosagem = map (((dose_dosadora_1_personalizada/quantidade_dose_dosadora_1_personalizada)*2), 0, fator_calib_dosadora_1, 0, 60000);
              tempo_dosagem /= 2;                 
              digitalWrite(dosadora1, HIGH);
              delay(tempo_dosagem);
              digitalWrite(dosadora1, LOW);
            }
          }
        }
        file.close();
      }

Quote
Setup() has a gazillion pinModes() in a row, use an array of pin numbers and a loop.

Using a FOR as this:

Code:

  for(int i = 8; i < 18; i++)
  {
    pinMode(i, OUTPUT);
  }

Reduces only 220 bytes.

Best regards.
9  Using Arduino / Project Guidance / Re: "External" memory for program memory? on: April 08, 2014, 08:00:20 pm
Hi!

Quote
With AFAIKT identical code for every day, why not put that code into a function so it only appears once, and why compare hours, mins and tpa every time when it's just the day that changes?

I can make it by example?

Code:
  if ((segunda==t.dow) || (terca==t.dow) || (quarta==t.dow) || (quinta==t.dow) || (sexta==t.dow) || (sabado==t.dow) || (domingo==t.dow))
  {
    if((hora==t.hour) && (minuto==t.min) && (tpa == 0))
    {
      tpa = 1;
      if ((4294967295ul - tempo) < millis())
      {
        marcadoriniciotpa= millis() - (tempo*2);
      }
      else
      {
        marcadoriniciotpa= millis();
      }
    }
  }

Quote
Just put the strings in an array to start with.

I don't understand it.

Quote
Then there are a lot of near duplications
This could be split to "ALTERAR POTENCIA DOS LEDS " (is the "S" needed on the first string?) and the colour string, that way the large part of the string will only occupy space a single time.

You are right, no need of the "S".
Here i can make it by example:

Code:
prog_char nomecanal1 [] PROGMEM = "ALTERAR POTENCIA DOS LEDS";
prog_char nomecanal2 [] PROGMEM = "BRANCOS";
prog_char nomecanal3 [] PROGMEM = "AZUIS";

But on moment of print, i have that call two strings to each sentence.

Quote
The value assigned to these variables is exactly the same but you repeat the humungous map() code for each one.

Here i can make it?
Code:
bled_out = wled_out = rbled_out  = rled_out = uvled_out = map(NumMins(t.hour,t.min),(NumMins(led_on_hora,led_on_minuto) - amanhecer_anoitecer), NumMins(led_on_hora,led_on_minuto), 0, pwm_pre_definido);

Quote
The entire code is rife with this sort of thing, it should be totally refactored, but as you say "my programming knowledge does not allow me to do it." so the only options I can see are to learn better programming technique, pay someone to modify the code, or get a larger platform.

The way more easy to me is find an IC to expand the memory or use an Arduino due but on this case I'll have problem with hardware.

Thank you very much.

Best regards

Sorry for english.
10  Using Arduino / Project Guidance / Re: "External" memory for program memory? on: April 08, 2014, 01:16:05 pm
Quote
Binary sketch size: 234.528 bytes (of a 258.048 byte maximum)
This is FLASH space, not RAM, but I think you knew that already.
I bet arrays could be used to shrink things down too.

Hi!

You was talking about this: http://174.136.57.214/html/quadram.html

This doesn't serve me.

Best regards
11  Using Arduino / Project Guidance / Re: "External" memory for program memory? on: April 08, 2014, 11:50:30 am
I'm struggling to imagine how you have ended up with such an enormous sketch for a project which does not sound as if it ought to be especially complex. However, I haven't had time to download and review the code yet so I don't know what it's doing - perhaps it involves something complicated that I haven't thought of. How much of this program space taken up by your own code, by library code, by initialised data?

Hi!

I'm not sure that understand well your question.

Quote

Binary sketch size: 234.528 bytes (of a 258.048 byte maximum)

I have 3 KB of RAM free.

Best regards.
12  Using Arduino / Project Guidance / Re: "External" memory for program memory? on: April 08, 2014, 08:54:15 am
Hi!

Code:
      stash.println((millis()/1000)/60);
      stash.print("Z,"); // Potência aparente

This will be changed. Now i haven't an energy monitor working.

Code:
if ((segunda==t.dow) && (hora==t.hour) && (minuto==t.min) && (tpa == 0))

if ((terca==t.dow) && (hora==t.hour) && (minuto==t.min) && (tpa == 0))

Here i have an IF to each day of the week.

Quote
I'm sure this code could be substantially reduced, but unless you have finished it it will just grow too big again so a more capable platform may still be the answer.

Missing a few things to finish. Now I need to implement a webserver.

I know that's possible reduce the code but, my programming knowledge does not allow me to do it.

Best regards.
13  Using Arduino / Project Guidance / Re: "External" memory for program memory? on: April 08, 2014, 07:18:46 am
Quote
use to expand flash memory of the my arduino mega 2560?
The Rugged Circuits expansion board was for RAM not flash, on an AVR there is no way to execute program from external memory AFAIK.

If your program really needs to be that big you better start looking at a different platform. It maybe that you could optimise it a lot, but at that size I'm not going to suggest that you post your code smiley

______
Rob

Hello!

I've posted, see link above.

Suggestion on how to optimize are welcome.

Best regards.
14  Using Arduino / Project Guidance / Re: "External" memory for program memory? on: April 07, 2014, 08:19:28 pm
Yes, Rugged Circuits makes an expansion board.

http://www.ruggedcircuits.com/products/

Er, they used to anyway!

Hi!

Where?

I not found.

I know that ruggedcircuits have external SRAM.

Best regards.
15  Using Arduino / Project Guidance / Re: "External" memory for program memory? on: April 07, 2014, 08:16:56 pm
That sounds like an enormous sketch. Just out of curiosity, what's it doing that needs all that code space? If it's all genuinely needed, it suggests to me that the Arduino is probably not the right platform for whatever it is you're trying to do.

Hi!

Is an aquarium controller.

https://github.com/FernandoGarcia/Ferduino_Portuguese/tree/master/Ferduino_Portuguese

The question is that when i started it, had no idea of the target final.

Sorry for english

Best regards

Pages: [1] 2 3 ... 7