Show Posts
Pages: [1] 2 3 ... 152
1  Using Arduino / Programming Questions / Re: typedef visible for variables but not for function parameters on: September 29, 2014, 05:01:11 am
The IDE may not be generating a function prototype for the printFrame() function. You may need to define your own.

The problem is the IDE is generating a prototype, but it is placed above the include. The link I posted shows how to prevent a prototype from being generated. Your method of adding one ( below the includes ) is also a solution.
2  Using Arduino / Programming Questions / Re: typedef visible for variables but not for function parameters on: September 29, 2014, 04:51:52 am
Quote
What gives? Why is the type known in one place but not in another? Have I lost all of my programming knowledge over night or is there a more rational explanation?

Haha you can calm down, there is an explanation (down the bottom is an easy fix for your functions),
http://arduino.land/FAQ/content/2/13/en/my-class_reference-won_t-work-in-the-sketch.html
3  Using Arduino / Programming Questions / Re: Arduino 1.5.7 - error: using temporary as lvalue [-fpermissive] on: September 29, 2014, 04:48:12 am
Why the cast:

Code:
((DCF77::time_data_t)decoded_time).leap_second_scheduled = true;

You have a reference, then you cast it to a value. A temporary is created, and they are const, you can't write to it!

Why not just access it below ( apart from the reference, the cast type is the same type! )
Code:
decoded_time.leap_second_scheduled = true;

But wait, oops, you have not remembered you declared the parameter as 'const':
Code:
void process_1_Hz_tick(const DCF77::time_data_t &decoded_time) {

Why did you pass it as a constant if your code needs to modify it?
4  Using Arduino / Programming Questions / Re: Where does 93 bytes of RAM go? on: September 29, 2014, 02:56:25 am
Quote
I read that as adding on another 22 bytes. So we still have 93 - 22 = 71 to go.

Everything seems accounted for:

malloc6
hardware serial16
foo1
Serial157
millis9
total189

The same size as what the IDE stated.
5  Using Arduino / Programming Questions / Re: compile error: invalid use of non-static data member on: September 29, 2014, 02:45:43 am
Yeah, not like you have it, your code will have to change. Constexpr will allow you to use return values / parameters as compile time constants. However your constructor has nothing to do with the line of code that sizes the array.

As the input is constant, there may be no need for a class as you can do quite a bit using constexpr functions. However if the storage is required ( can't act on data as it happens ) then there is not much you can do unless you want to start using dynamic memory.
6  Using Arduino / Programming Questions / Re: Where does 93 bytes of RAM go? on: September 29, 2014, 02:19:13 am
6 bytes are reserved for dynamic memory.

Quote from: what uses ram
00800100 00000002 D __malloc_heap_end
00800102 00000002 D __malloc_heap_start
00800104 00000002 D __malloc_margin
00800106 00000010 V _ZTV14HardwareSerial
00800116 B __bss_start
00800116 D __data_end
00800116 D _edata
00800116 00000001 B foo
00800117 0000009d B Serial
008001b4 00000001 b timer0_fract
008001b5 00000004 B timer0_millis
008001b9 00000004 B timer0_overflow_count

EDIT: The length of serial is different also, which probably accounts for the 10 extra bytes.
Whatever the overhead was, it must have been resolved.
7  Using Arduino / Programming Questions / Re: Where does 93 bytes of RAM go? on: September 29, 2014, 02:15:08 am
Using 1.5.7 & compiled for uno I get 189 bytes, still ten over though.
8  Using Arduino / Programming Questions / Re: compile error: invalid use of non-static data member on: September 29, 2014, 12:31:19 am
Like it says, your element isn't a compile time constant ( different to a variable simply marked const ).

Using consexpr in C++11 you can have a constant constructor, however not without messing with the IDE ( will be default hopefully in 1.5.8 ).

What you can use is a template, then your code boils down to an almost empty class:
Code:
template< unsigned N >
  class Row{
    private:
int samples[ N ];
};

Row< 2 > row;

void setup()
{
}

void loop()
{
}

The constructor, nor the variable to hold the length is needed. You can add the constructor back in for other purposes.
9  Using Arduino / Programming Questions / Re: "error: 'byte' has not been declared" when in header, not elsewhere on: September 28, 2014, 01:56:51 am
You can take the advice PaulS offered, or use uint8_t instead of byte.

If inside a library, you will either have to include Arduino.h, or stdint.h to use the aliases like uint8_t.
10  Using Arduino / Programming Questions / Re: boolean return values from base classes not returning up through child classes on: September 28, 2014, 01:10:53 am
Quote
and it still works correctly and compiles, but I don't know how to get rid of the one remaining "->" between "RCmc->SetM2VelocityPID"

If its a pointer, you have to use it ( or use * first ). There is also no reason whatsoever to remove the use if the 'this' pointer. You are better off getting into the habit of using it, as it takes a far more learning to know where its actually important, which is a problem a not so lazy programmer will never encounter.

By the way, this-> is almost never used by real programmers.

lol, real programmers would slap you.

Also, if the members are part of 'ROSArdRoboclaw' its fine to use 'ROSArdRoboclaw::' to keep the identifier fully qualified.
11  Using Arduino / Programming Questions / Re: bool vs boolean on: September 27, 2014, 12:05:53 am
You can use both, Arduino created boolean to have a bool like variable which is compatible between C & C++.

So then does bool still operate the same as boolean?
No, in your code its best to just use bool.
For a little extra reading: http://forum.arduino.cc/index.php?topic=252120.0
https://github.com/arduino/Arduino/issues/2147
12  Using Arduino / Programming Questions / Re: Need help on shrinking my code! Only need to cut off 12 bytes on: September 26, 2014, 09:06:28 pm
@ Pyro...
Thank You, That is truly amazing...

You're welcome!
The library is a bit of an accident, I was only trying to learn about the memory sections, and saw some great savings.
Probably one of the only libraries that reduces a sketch size when its added, even an empty sketch.
13  Using Arduino / Programming Questions / Re: Need help on shrinking my code! Only need to cut off 12 bytes on: September 26, 2014, 08:03:59 pm
@Rob, you removed char db[4], but still use it:
Code:
alpha4.writeDigitAscii(d/10 + '0' , db[2]);

If the second param is the decimal place, I guess we can just drop it ( and add the two ):
Code:
alpha4.writeDigitAscii(2, d/10 + '0');

@op, what happened to the rest of the space? Or is there a bootloader on the tinkerkit?
What version of the IDE do you use? 1.5.7 will not compile without removing at least the dtostrf call.

With Robs change I get:
Quote
Sketch uses 3,958 bytes (48%) of program storage space. Maximum is 8,192 bytes.

I also have an additional method of reducing the size. The total savings could allow more stuff!

Visit my page here http://arduino.land/Code/SmallSetup/ and install the SmallSetup library ( just updated it for the tiny chips ), then use the second method to use it. Result now is (including Robs savings):
Quote
Sketch uses 3,678 bytes (44%) of program storage space. Maximum is 8,192 bytes.
14  Using Arduino / Programming Questions / Re: Need help on shrinking my code! Only need to cut off 12 bytes on: September 26, 2014, 09:34:43 am
what chip is it for?
15  Using Arduino / Programming Questions / Re: Array error. w/ Class on: September 25, 2014, 08:53:45 pm
you can also just delete the line.

The default/empty constructor is implicitly called for each item during initialization of the array: `PlantClass test_array[4];`.
Pages: [1] 2 3 ... 152