-dg said:
casainho said:
There is an important issue: we can't use static variables with initial values, liker 5 for instance, other way compilation fails. Because of this I am using a lot of global variables and this makes the code hard to read/understand.
Can you explain more about this so I understand the issue better? I'll try to test with newer sdcc and since I'm giving them bug reports already, maybe I can get them to look at that too.
The one kind of bad thing about using Modbus the way I am proposing is that the easy way to do it is to gather all the variables into one giant struct or array. I think. I'm still researching this and still learning my way around STM8 and sdcc etc. Give me a bit of time to explore this.
Are we currently using the EEPROM? Because I think that might be a neat way to deal with writable configuration. Just build it pre-initialized from the Modbus map definition and then let Modbus updates maintain it from there. However, I'm really unclear on this yet, need to do more research.
I noticed some people posting settings.ini type files that contain just raw data items. Is that format documented or coded somewhere I can look at it? I might use it to make an example Modbus map to help show what it would look like.
A favor to ask, I have asked several questions in the recent flurry of posts, could you (and also stancecoke) please go back and look at the questions and try to give me some clues. Thanks!
// Sometimes I got the following error when compiling the firmware: motor.asm:750: Error: <r> relocation error
// when I have this code inside a function: "static uint8_t ui8_cruise_counter = 0;"
// and the solution was define the variable as global instead
This are the variables stored on EEPROM on the motor controller KT, this way it can run without LCD and being previous configure with the LCD connected:
DEFAULT_VALUE_ASSIST_LEVEL,
DEFAULT_VALUE_MOTOR_CHARACTARISTIC,
DEFAULT_VALUE_WHEEL_SIZE,
DEFAULT_VALUE_MAX_SPEED,
DEFAULT_VALUE_POWER_ASSIST_CONTROL_MODE,
DEFAULT_VALUE_CONTROLLER_MAX_CURRENT
And on LCD3 I am using much more the EEPROM:
DEFAULT_VALUE_ASSIST_LEVEL,
DEFAULT_VALUE_WHEEL_PERIMETER_0,
DEFAULT_VALUE_WHEEL_PERIMETER_1,
DEFAULT_VALUE_MAX_SPEED,
DEFAULT_VALUE_UNITS_TYPE,
DEFAULT_VALUE_WH_OFFSET,
DEFAULT_VALUE_WH_OFFSET,
DEFAULT_VALUE_WH_OFFSET,
DEFAULT_VALUE_WH_OFFSET,
DEFAULT_VALUE_HW_X10_100_PERCENT,
DEFAULT_VALUE_HW_X10_100_PERCENT,
DEFAULT_VALUE_HW_X10_100_PERCENT,
DEFAULT_VALUE_HW_X10_100_PERCENT,
DEAFULT_VALUE_SHOW_NUMERIC_BATTERY_SOC,
DEFAULT_VALUE_ODOMETER_FIELD_STATE,
DEFAULT_VALUE_BATTERY_MAX_CURRENT,
DEFAULT_VALUE_TARGET_MAX_BATTERY_POWER