Here is a little info for people that are low on memory.
I like to divide my program into logical modules.
F.ex. The Can-Bus code in 1 module and other logic in another.
I used this code to send 40 packets from logic module:
modCan.SendPacket(array as byte(B0,b1))
Then I tried to add a Sub to send the packets:
private Sub SendCanMsg(Data() As Byte)
modCAN.SendMessage(Data)
End Sub
and changed the 40 calls to this:
SendCanMsg(array as byte(109,StateVal))
It did
not change anything!
Then I changed the sub to this:
private Sub SendCanMsg2(Packet As Byte,B1 As Byte)
modCAN.SendMessage(Array As Byte(Packet,B1))
End Sub
and I changed the 40 calls to this:
SendCanMsg2(109,StateVal)
This saved me 1510 bytes of memory (4.6% on a UNO) and the program is still doing the same thing !!
If anyone have other tips to save memory, I would be glad to know how.
Jan