View previous topic :: View next topic |
Author |
Message |
TSEYFARTH
Joined: 01 Jul 2006 Posts: 1054
|
Posted: Thu Sep 04, 2014 2:09 am Post subject: Data - is there any way to use a variable, or programmed var |
|
|
Hello all,
Can anyone tell me or provide a clue how to make some or all elements in a command like:
Code: |
RFM24_START_RX:
data 8
data &h32 , 0 , 0, 0 , 44 , 8, 3, 8
|
Where one or more of the elements need to be changed? In the example above the first '0' indicates a channel number. If the user selects a channel different than 0, then this (and other) code will need to be changed too. And if Channel Hopping is utilized, it must be automated. Other than having a huge Select case set of options, how can this be achieved?
Thanks in advance!
Tim
(BASCOM-AVR version : 2.0.7.7 ) |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Thu Sep 04, 2014 6:41 am Post subject: Re: Data - is there any way to use a variable, or programmed |
|
|
Depends on, where the change should take place: in the source code, or dynamically.
The latter needs some additional program logic, the first could look like that:
Code: | Const ch_nr = 1
'...
RFM24_START_RX:
data 8
data &h32 , ch_nr , 0, 0 , 44 , 8, 3, 8 |
This way key values can be changed at only one place, and used at many parts in the code, that's what a Const is for. |
|
Back to top |
|
|
TSEYFARTH
Joined: 01 Jul 2006 Posts: 1054
|
Posted: Thu Sep 04, 2014 7:22 am Post subject: |
|
|
Hi MWS,
Thanks for your reply!
Ultimately, it really needs to by dynamic. When the device "hops" channels, all of the code needs to follow. So using a Const is really the same; other than making it easier to make a single change to multiple places - when hard coded.
The docs specifically eliminate variables. I was just hoping that there was a work around. Mark?
Thanks again MWS! I appreciate your feed back.
Tim |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Thu Sep 04, 2014 11:17 am Post subject: |
|
|
If you use eram array variables in the correct order you can refer to them. You then load the data into the eeprom to line up with the eram variables you can then refer to the variables in order eg channel 1 is x=1 chan(x) you then send out the values.
Its best I have found to start looking at eeprom like we do with ram variables now that we can make them into arrays.
With a bit more code if I can see what you want to do I could write some more of what I am trying to get at.
Regards Paul |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|