@@ -90,7 +90,7 @@ unsigned short PolychromeController::ReadFirmwareVersion()
9090{
9191 // The firmware register holds two bytes, so the first read should return 2
9292 // If not, report invalid firmware revision FFFF
93- if (bus->i2c_smbus_read_byte_data (dev, POLYCHROME_REG_FIRMWARE_VER ) == 0x02 )
93+ if (bus->i2c_smbus_read_byte_data (dev, ASROCK_REG_FIRMWARE_VER ) == 0x02 )
9494 {
9595 std::this_thread::sleep_for (1ms);
9696 unsigned char major = bus->i2c_smbus_read_byte (dev);
@@ -107,22 +107,24 @@ unsigned short PolychromeController::ReadFirmwareVersion()
107107
108108void PolychromeController::ReadLEDConfiguration ()
109109{
110- // The LED configuration register holds 6 bytes, so the first read should return 6
111- // If not, set all zone sizes to zero
110+ /* ---------------------------------------------------------------------------------*\
111+ | The LED configuration register holds 6 bytes, so the first read should return 6 |
112+ | If not, set all zone sizes to zero |
113+ \*---------------------------------------------------------------------------------*/
112114 if (bus->i2c_smbus_read_byte_data (dev, POLYCHROME_REG_LED_CONFIG) == 0x06 )
113115 {
114116 std::this_thread::sleep_for (1ms);
115- zone_led_count[POLYCHROME_ZONE_RGB_LED_0_HDR] = bus->i2c_smbus_read_byte (dev);
117+ zone_led_count[POLYCHROME_ZONE_1] = bus->i2c_smbus_read_byte (dev);
116118 std::this_thread::sleep_for (1ms);
117- zone_led_count[POLYCHROME_ZONE_RGB_LED_1_HDR] = bus->i2c_smbus_read_byte (dev);
119+ zone_led_count[POLYCHROME_ZONE_2] = bus->i2c_smbus_read_byte (dev);
118120 std::this_thread::sleep_for (1ms);
119- zone_led_count[POLYCHROME_ZONE_AUDIO ] = bus->i2c_smbus_read_byte (dev);
121+ zone_led_count[POLYCHROME_ZONE_3 ] = bus->i2c_smbus_read_byte (dev);
120122 std::this_thread::sleep_for (1ms);
121- zone_led_count[POLYCHROME_ZONE_PCH] = bus->i2c_smbus_read_byte (dev);
123+ zone_led_count[POLYCHROME_ZONE_4] = bus->i2c_smbus_read_byte (dev);
122124 std::this_thread::sleep_for (1ms);
123- zone_led_count[POLYCHROME_ZONE_IO_COVER] = bus->i2c_smbus_read_byte (dev);
125+ zone_led_count[POLYCHROME_ZONE_5] = bus->i2c_smbus_read_byte (dev);
124126 std::this_thread::sleep_for (1ms);
125- zone_led_count[POLYCHROME_ZONE_ADDRESSABLE] = bus->i2c_smbus_read_byte (dev);
127+ zone_led_count[POLYCHROME_ZONE_ADDRESSABLE] = bus->i2c_smbus_read_byte (dev);
126128 }
127129 else
128130 {
@@ -143,11 +145,10 @@ void PolychromeController::SetColorsAndSpeed(unsigned char led, unsigned char re
143145 switch (asrock_type)
144146 {
145147 case ASROCK_TYPE_ASRLED:
146- case ASROCK_TYPE_POLYCHROME_V1:
147148 /* -----------------------------------------------------*\
148149 | Select LED |
149150 \*-----------------------------------------------------*/
150- bus->i2c_smbus_write_block_data (dev, POLYCHROME_REG_LED_SELECT , 1 , select_led_pkt);
151+ bus->i2c_smbus_write_block_data (dev, ASROCK_REG_LED_SELECT , 1 , select_led_pkt);
151152 std::this_thread::sleep_for (1ms);
152153
153154 switch (active_mode)
@@ -156,7 +157,7 @@ void PolychromeController::SetColorsAndSpeed(unsigned char led, unsigned char re
156157 | These modes take 4 bytes in R/G/B/S order |
157158 \*-----------------------------------------------------*/
158159 case ASRLED_MODE_BREATHING:
159- case ASRLED_MODE_FLASHING :
160+ case ASRLED_MODE_STROBE :
160161 case ASRLED_MODE_SPECTRUM_CYCLE:
161162 bus->i2c_smbus_write_block_data (dev, active_mode, 4 , color_speed_pkt);
162163 break ;
@@ -187,17 +188,70 @@ void PolychromeController::SetColorsAndSpeed(unsigned char led, unsigned char re
187188 std::this_thread::sleep_for (1ms);
188189 break ;
189190
191+ case ASROCK_TYPE_POLYCHROME_V1:
192+ /* -----------------------------------------------------*\
193+ | Select LED |
194+ \*-----------------------------------------------------*/
195+ bus->i2c_smbus_write_block_data (dev, ASROCK_REG_LED_SELECT, 1 , select_led_pkt);
196+ std::this_thread::sleep_for (1ms);
197+
198+ switch (active_mode)
199+ {
200+ /* -----------------------------------------------------*\
201+ | These modes take 4 bytes in R/G/B/S order |
202+ \*-----------------------------------------------------*/
203+ case POLYCHROME_V1_MODE_BREATHING:
204+ case POLYCHROME_V1_MODE_STROBE:
205+ case POLYCHROME_V1_MODE_SPECTRUM_CYCLE:
206+ case POLYCHROME_V1_MODE_SPRING:
207+ case POLYCHROME_V1_MODE_METEOR:
208+ case POLYCHROME_V1_MODE_STACK:
209+ case POLYCHROME_V1_MODE_CRAM:
210+ case POLYCHROME_V1_MODE_SCAN:
211+ case POLYCHROME_V1_MODE_NEON:
212+ case POLYCHROME_V1_MODE_WATER:
213+
214+ bus->i2c_smbus_write_block_data (dev, active_mode, 4 , color_speed_pkt);
215+ break ;
216+
217+ /* -----------------------------------------------------*\
218+ | These modes take 3 bytes in R/G/B order |
219+ \*-----------------------------------------------------*/
220+ default :
221+ case POLYCHROME_V1_MODE_STATIC:
222+ case POLYCHROME_V1_MODE_MUSIC:
223+ bus->i2c_smbus_write_block_data (dev, active_mode, 3 , color_speed_pkt);
224+ break ;
225+
226+ /* -----------------------------------------------------*\
227+ | These modes take 1 byte - speed |
228+ \*-----------------------------------------------------*/
229+ case POLYCHROME_V1_MODE_RANDOM:
230+ case POLYCHROME_V1_MODE_WAVE:
231+ case POLYCHROME_V1_MODE_RAINBOW:
232+ bus->i2c_smbus_write_block_data (dev, active_mode, 1 , &active_speed);
233+ break ;
234+
235+ /* -----------------------------------------------------*\
236+ | These modes take no bytes |
237+ \*-----------------------------------------------------*/
238+ case POLYCHROME_V1_MODE_OFF:
239+ break ;
240+ }
241+ std::this_thread::sleep_for (1ms);
242+ break ;
243+
190244 case ASROCK_TYPE_POLYCHROME_V2:
191245 /* -----------------------------------------------------*\
192246 | Select LED |
193247 \*-----------------------------------------------------*/
194- bus->i2c_smbus_write_block_data (dev, POLYCHROME_REG_LED_SELECT , 1 , select_led_pkt);
248+ bus->i2c_smbus_write_block_data (dev, ASROCK_REG_LED_SELECT , 1 , select_led_pkt);
195249 std::this_thread::sleep_for (1ms);
196250
197251 /* -----------------------------------------------------*\
198252 | Polychrome firmware always writes color to fixed reg |
199253 \*-----------------------------------------------------*/
200- bus->i2c_smbus_write_block_data (dev, POLYCHROME_REG_COLOR , 3 , color_speed_pkt);
254+ bus->i2c_smbus_write_block_data (dev, POLYCHROME_V2_REG_COLOR , 3 , color_speed_pkt);
201255 std::this_thread::sleep_for (1ms);
202256 break ;
203257 }
@@ -212,38 +266,38 @@ void PolychromeController::SetMode(unsigned char mode, unsigned char speed)
212266 switch (asrock_type)
213267 {
214268 case ASROCK_TYPE_ASRLED:
215- bus->i2c_smbus_write_block_data (dev, ASRLED_REG_MODE , 1 , &active_mode);
269+ bus->i2c_smbus_write_block_data (dev, ASROCK_REG_MODE , 1 , &active_mode);
216270 std::this_thread::sleep_for (1ms);
217271 break ;
218272
219273 case ASROCK_TYPE_POLYCHROME_V1:
220- bus->i2c_smbus_write_block_data (dev, ASRLED_REG_MODE , 1 , &active_mode);
274+ bus->i2c_smbus_write_block_data (dev, ASROCK_REG_MODE , 1 , &active_mode);
221275 std::this_thread::sleep_for (1ms);
222276
223277 /* -----------------------------------------------------*\
224278 | Select a single LED |
225279 \*-----------------------------------------------------*/
226- bus->i2c_smbus_write_block_data (dev, POLYCHROME_REG_LED_COUNT , 0 , led_count_pkt);
280+ bus->i2c_smbus_write_block_data (dev, POLYCHROME_V1_REG_SET_ALL , 0 , led_count_pkt);
227281 std::this_thread::sleep_for (1ms);
228282 break ;
229283
230284 case ASROCK_TYPE_POLYCHROME_V2:
231- bus->i2c_smbus_write_block_data (dev, POLYCHROME_REG_MODE , 1 , &active_mode);
285+ bus->i2c_smbus_write_block_data (dev, ASROCK_REG_MODE , 1 , &active_mode);
232286 std::this_thread::sleep_for (1ms);
233287
234288 /* -----------------------------------------------------*\
235289 | Select a single LED |
236290 \*-----------------------------------------------------*/
237- bus->i2c_smbus_write_block_data (dev, POLYCHROME_REG_LED_COUNT , 0 , led_count_pkt);
291+ bus->i2c_smbus_write_block_data (dev, POLYCHROME_V2_REG_LED_COUNT , 0 , led_count_pkt);
238292 std::this_thread::sleep_for (1ms);
239293
240294 switch (active_mode)
241295 {
242296 /* -----------------------------------------------------*\
243297 | These modes don't take a speed |
244298 \*-----------------------------------------------------*/
245- case POLYCHROME_MODE_OFF :
246- case POLYCHROME_MODE_STATIC :
299+ case POLYCHROME_V2_MODE_OFF :
300+ case POLYCHROME_V2_MODE_STATIC :
247301 break ;
248302
249303 /* -----------------------------------------------------*\
0 commit comments