@@ -97,8 +97,10 @@ void HyperXDRAMController::SetAllColors(unsigned char red, unsigned char green,
9797 | Loop through all slots and only set those which are |
9898 | active. |
9999 \*-----------------------------------------------------*/
100- for (int slot = 0 ; slot < 4 ; slot ++)
100+ for (unsigned int slot_idx = 0 ; slot_idx < 4 ; slot_idx ++)
101101 {
102+ unsigned char slot = slot_map[slot_idx];
103+
102104 if ((slots_valid & (1 << slot)) != 0 )
103105 {
104106 unsigned char base = slot_base[slot];
@@ -136,16 +138,18 @@ void HyperXDRAMController::SetLEDColor(unsigned int led, unsigned char red, unsi
136138 \*-----------------------------------------------------*/
137139 int led_slot = led / 5 ;
138140 int slot_id = -1 ;
139- int slot;
141+ unsigned char slot;
140142
141143 led -= (led_slot * 5 );
142144
143145 /* -----------------------------------------------------*\
144146 | Loop through all possible slots and only count those |
145147 | which are active. |
146148 \*-----------------------------------------------------*/
147- for (slot = 0 ; slot < 4 ; slot ++)
149+ for (unsigned int slot_idx = 0 ; slot_idx < 4 ; slot_idx ++)
148150 {
151+ slot = slot_map[slot_idx];
152+
149153 if ((slots_valid & ( 1 << slot)) != 0 )
150154 {
151155 slot_id++;
@@ -157,21 +161,7 @@ void HyperXDRAMController::SetLEDColor(unsigned int led, unsigned char red, unsi
157161 }
158162 }
159163
160- unsigned char base = slot_base[slot];
161- unsigned char red_base = base + 0x00 ;
162- unsigned char green_base = base + 0x01 ;
163- unsigned char blue_base = base + 0x02 ;
164- unsigned char bright_base = base + 0x10 ;
165-
166- bus->i2c_smbus_write_byte_data (dev, HYPERX_REG_APPLY, 0x01 );
167-
168- bus->i2c_smbus_write_byte_data (dev, red_base + (3 * led), red );
169- bus->i2c_smbus_write_byte_data (dev, green_base + (3 * led), green);
170- bus->i2c_smbus_write_byte_data (dev, blue_base + (3 * led), blue );
171- bus->i2c_smbus_write_byte_data (dev, bright_base + (3 * led), 0x64 );
172-
173- bus->i2c_smbus_write_byte_data (dev, HYPERX_REG_APPLY, 0x02 );
174- bus->i2c_smbus_write_byte_data (dev, HYPERX_REG_APPLY, 0x03 );
164+ SetLEDColor (slot, led, red, green, blue);
175165}
176166
177167
0 commit comments