Initialising an array
Mightor
Posts: 338
Hey there,
I'm looking to use an array to hold servo speed data. Is there a way to initialise it C style, e.g. something like this:
right_servo[noparse]/noparse = { 790, 715, 820, 680, 850, 650}
left_servo[noparse]/noparse = { 713, 790, 687, 817, 667, 829 }
I am aware of the DATA directive, but I'm keen to use an array for fast lookup purposes, I've found the EEPROM to be quite slow and that won't leave me with a lot of time to do more important things, like checking my sensors, etc.
Gr,
Mightor
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
| What the world needs is more geniuses with humility, there are so few of us left.
I'm looking to use an array to hold servo speed data. Is there a way to initialise it C style, e.g. something like this:
right_servo[noparse]/noparse = { 790, 715, 820, 680, 850, 650}
left_servo[noparse]/noparse = { 713, 790, 687, 817, 667, 829 }
I am aware of the DATA directive, but I'm keen to use an array for fast lookup purposes, I've found the EEPROM to be quite slow and that won't leave me with a lot of time to do more important things, like checking my sensors, etc.
Gr,
Mightor
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
| What the world needs is more geniuses with humility, there are so few of us left.
Comments
I know nothing about C, so is this fixed or variable data? In other words, will it be changed during the course of program execution?
I don't know what sort of algorithm you are using to access the EEPROM tables, but that can have as much, or more, to do with the access speed as anything else.
Rgards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PBASIC doesn't have any other array constructors.
-Phil
I am looking to read the data a bit like this (not necessarily working code):
This seems a lot more code than for example something like this (this is not working code, of course):
That way just looks cleaner and would be a lot faster; there is no EEPROM access and a lot less code. I suppose I could initialise the values in those arrays by one by one, but if there is a way around that, that'd be great [noparse]:)[/noparse]
Gr,
Mightor
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
| What the world needs is more geniuses with humility, there are so few of us left.
Gr,
Mightor
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
| What the world needs is more geniuses with humility, there are so few of us left.
Gr,
Mightor
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
| What the world needs is more geniuses with humility, there are so few of us left.
Reading from a EEPROM is MUCH faster than writing to it.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔