// pattern2 : bling each led in random frequency and random duration void pattern2() { gMSec = 99; float dOffsetRed = offsetForRotation(); volatile long dRedEndAt = 0; float radianRed = 0.0; float dOffsetGreen = offsetForRotation(); long dGreenEndAt = 0; float radianGreen = 0.0; float dOffsetBlue = offsetForRotation(); long dBlueEndAt = 0; float radianBlue = 0.0; float dMultiplyRed = 0.0; float dMultiplyGreen = 0.0; float dMultiplyBlue = 0.0; while (gMSec < 30000) { // 1 min if (gMSec > dRedEndAt) { dMultiplyRed = multiplyForRotation(); dRedEndAt = endAt(); } if (gMSec > dGreenEndAt) { dMultiplyGreen = multiplyForRotation(); dGreenEndAt = endAt(); } if (gMSec > dBlueEndAt) { dMultiplyBlue = multiplyForRotation(); dBlueEndAt = endAt(); } putRed( calcSin(dOffsetRed, dMultiplyRed, radianRed) ); putGreen( calcSin(dOffsetGreen, dMultiplyGreen, radianGreen)); putBlue( calcSin(dOffsetBlue, dMultiplyBlue, radianBlue) ); radianRed += 0.03; radianGreen += 0.03; radianBlue += 0.03; wait_ms(10); // pwm needs delay } }
double QArrow::getAngle() { return _arrowAngle; } /** * Overloaded paint-method from QGraphicsItem. * Basically it draws a line with an arrowhead consisting of two short lines at the end */ void QArrow::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { Q_UNUSED (option) Q_UNUSED (widget) double ddeltaX = calcCos(_arrowAngle) * _arrowLength; double ddeltaY = calcSin(_arrowAngle) * _arrowLength; double theta = atan(ddeltaY / ddeltaX); double theta2 = (ddeltaX < 0.0) ? (theta + PI) : theta; int lengthdeltaX = -static_cast<int>(cos(theta2) * _headLength); int lengthdeltaY = -static_cast<int>(sin(theta2) * _headLength); int widthdeltaX = static_cast<int>(sin(theta2) * _headWidth); int widthdeltaY = static_cast<int>(cos(theta2) * _headWidth); int deltaX = static_cast<int>(ddeltaX); int deltaY = static_cast<int>(ddeltaY); painter->setPen(_arrowPen); painter->drawLine(0, 0, deltaX, deltaY); painter->drawLine(deltaX, deltaY, deltaX + lengthdeltaX + widthdeltaX, deltaY + lengthdeltaY - widthdeltaY); painter->drawLine(deltaX,