| 124 | } |
| 125 | |
| 126 | void Effect::run() |
| 127 | { |
| 128 | int left = (_timeout >= 0) ? std::max(static_cast<int>(_endTime - InternalClock::now()), 0) : -1; |
| 129 | |
| 130 | if (_interrupt || (left == 0 && _timeout > 0) || _effect->isStop()) |
| 131 | { |
| 132 | stop(); |
| 133 | return; |
| 134 | } |
| 135 | |
| 136 | if (_visiblePriority < _priority) |
| 137 | return; |
| 138 | |
| 139 | bool hasLedData = false; |
| 140 | |
| 141 | if (!_effect->hasOwnImage()) |
| 142 | { |
| 143 | _effect->Play(_image); |
| 144 | |
| 145 | hasLedData = _effect->hasLedData(_ledBuffer); |
| 146 | } |
| 147 | |
| 148 | if (_effect->hasOwnImage()) |
| 149 | { |
| 150 | Image<ColorRgb> image(80, 45); |
| 151 | |
| 152 | if (_effect->getImage(image)) |
| 153 | emit SignalSetImage(_priority, image, left, false); |
| 154 | } |
| 155 | else if (hasLedData) |
| 156 | { |
| 157 | ledShow(left); |
| 158 | } |
| 159 | else |
| 160 | { |
| 161 | imageShow(left); |
| 162 | } |
| 163 | |
| 164 | int sleepTime = std::min(_effect->GetSleepTime(), 100); |
| 165 | if (sleepTime != _timer.interval()) |
| 166 | { |
| 167 | _timer.setInterval(sleepTime); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | void Effect::stop() |
| 172 | { |
no test coverage detected