| 1067 | } |
| 1068 | |
| 1069 | void ApplyOptions(DeviceOptions& options, std::vector<RGBController *>& rgb_controllers) |
| 1070 | { |
| 1071 | RGBController* device = rgb_controllers[options.device]; |
| 1072 | |
| 1073 | /*---------------------------------------------------------*\ |
| 1074 | | Set mode first, in case it's 'direct' (which affects | |
| 1075 | | SetLED below) | |
| 1076 | \*---------------------------------------------------------*/ |
| 1077 | unsigned int mode = ParseMode(options, rgb_controllers); |
| 1078 | |
| 1079 | /*---------------------------------------------------------*\ |
| 1080 | | If the user has specified random colours and the device | |
| 1081 | | supports that colour mode then swich to it before | |
| 1082 | | evaluating if a colour needs to be set | |
| 1083 | \*---------------------------------------------------------*/ |
| 1084 | if(options.random_colors && (device->modes[mode].flags & MODE_FLAG_HAS_RANDOM_COLOR)) |
| 1085 | { |
| 1086 | device->modes[mode].color_mode = MODE_COLORS_RANDOM; |
| 1087 | } |
| 1088 | |
| 1089 | /*---------------------------------------------------------*\ |
| 1090 | | If the user has specified random colours and the device | |
| 1091 | | supports that colour mode then swich to it before | |
| 1092 | | evaluating if a colour needs to be set | |
| 1093 | \*---------------------------------------------------------*/ |
| 1094 | if((device->modes[mode].flags & MODE_FLAG_HAS_BRIGHTNESS)) |
| 1095 | { |
| 1096 | unsigned int new_brightness = device->modes[mode].brightness_max - device->modes[mode].brightness_min; |
| 1097 | new_brightness *= options.brightness; |
| 1098 | new_brightness /= brightness_percentage; |
| 1099 | |
| 1100 | device->modes[mode].brightness = device->modes[mode].brightness_min + new_brightness; |
| 1101 | } |
| 1102 | |
| 1103 | /*---------------------------------------------------------*\ |
| 1104 | | Determine which color mode this mode uses and update | |
| 1105 | | colors accordingly | |
| 1106 | \*---------------------------------------------------------*/ |
| 1107 | switch(device->modes[mode].color_mode) |
| 1108 | { |
| 1109 | case MODE_COLORS_NONE: |
| 1110 | break; |
| 1111 | |
| 1112 | case MODE_COLORS_RANDOM: |
| 1113 | break; |
| 1114 | |
| 1115 | case MODE_COLORS_PER_LED: |
| 1116 | if(options.colors.size() != 0) |
| 1117 | { |
| 1118 | std::size_t last_set_color = 0; |
| 1119 | |
| 1120 | RGBColor* start_from; |
| 1121 | unsigned int led_count; |
| 1122 | if(options.zone < 0) |
| 1123 | { |
| 1124 | start_from = &device->colors[0]; |
| 1125 | led_count = device->leds.size(); |
| 1126 | } |
no test coverage detected