[email protected] wrote: > > I have a number of #define commands in my current code. I now need > to provide for two or more possible definitions, depending upon the > value of a particular eeprom byte. > > For example, > if eeprom byte #0x22 =0, define "Hysteresis" as 15 > if eeprom byte #0x22 =1, define "Hysteresis" as 11 > > It seems to me that I have seen a one line function that would work > for this where the "selection byte" would indicate a location in a > following list of numbers, something kinda like this: > > temp = I2C_EEPROM_read(0x00, 0x22); > #define Hysteresis (temp: 15,11,9) > > Sorry if this is a 'no-brainer', but I'm really rusty & I'm just not > coming up with anything in my C books... > > Thx > Scott Kelley >
I am assuming that I2C_EEPROM_read(0x00, 0x22) returns the contents of byte 0x22 in the eeprom (I am not sure what the 0x00 is all about). Anyway, if my assumption is correct you could do the following: #define Hysteresis (I2C_EEPROM_read(0x00, 0x22)==0 ? 15 : 11)
