Skip to content

Commit a3da48e

Browse files
committed
added identify to led layout right click
1 parent e9cbced commit a3da48e

14 files changed

Lines changed: 55 additions & 20 deletions

File tree

assets/webconfig/content/light_source.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ <h4 class="card-title"><i class="fa fa-search fa-fw"></i><span data-i18n="conf_l
595595
<div class="dropdown-menu dropdown-menu-sm" style="display: none;" id="creator-context-menu">
596596
<a class="dropdown-item" href="#" id="CMD_MOVE"><i class="fa fa-arrows fa-fw"></i><span data-i18n="led_editor_context_move">Move</span></a>
597597
<a class="dropdown-item" href="#" id="CMD_PROPERTIES"><i class="fa fa-edit fa-fw"></i><span data-i18n="led_editor_context_properties">Properties</span></a>
598+
<a class="dropdown-item" href="#" id="CMD_IDENTIFY"><i class="fa fa-eye-slash fa-fw"></i><span data-i18n="led_editor_context_identify">Identify</span></a>
598599
<a class="dropdown-item" href="#" id="CMD_ENABLE"><i class="fa fa-lightbulb-o fa-fw"></i><span id="cmd_dis_enable_text" data-i18n="led_editor_context_enable">Enable</span></a>
599600
<a class="dropdown-item" href="#" id="CMD_DELETE"><i class="fa fa-remove fa-fw"></i><span data-i18n="led_editor_context_delete">Delete</span></a>
600601
</div>

assets/webconfig/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@
11861186
"led_editor_context_move": "Move",
11871187
"led_editor_context_properties": "Properties",
11881188
"led_editor_context_delete": "Delete",
1189+
"led_editor_context_identify": "Identify",
11891190
"led_editor_context_enable": "Enable",
11901191
"led_editor_context_disable": "Disable",
11911192
"led_editor_context_moving": "Left click the mouse to accept the position",

assets/webconfig/js/hyperhdr.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,10 @@ function requestPlayEffect(effectName, duration)
447447
{
448448
sendToHyperhdr("effect", "", '"effect":{"name":"' + effectName + '"},"priority":' + window.webPrio + ',"duration":' + validateDuration(duration) + ',"origin":"' + window.webOrigin + '"');
449449
}
450-
451-
function requestSetColor(r, g, b, duration)
450+
function requestSetColor(r, g, b, duration,indexOfLed=-1)
452451
{
453-
sendToHyperhdr("color", "", '"color":[' + r + ',' + g + ',' + b + '], "priority":' + window.webPrio + ',"duration":' + validateDuration(duration) + ',"origin":"' + window.webOrigin + '"');
452+
let msg=`"color":[${r},${g},${b}],"indexofled":${indexOfLed},"priority":${window.webPrio},"duration":${validateDuration(duration)},"origin":"${window.webOrigin}"`;
453+
sendToHyperhdr("color", "", msg);
454454
}
455455

456456
function requestSetImage(data, duration, name)

assets/webconfig/js/light_source.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,12 @@ $(document).ready(function()
11691169

11701170
selectedObject = null;
11711171
}
1172+
if (this.id == "CMD_IDENTIFY")
1173+
{
1174+
identify(parsedIndex);
1175+
1176+
selectedObject = null;
1177+
}
11721178
else if (this.id == "CMD_DELETE")
11731179
{
11741180
finalLedArray[parsedIndex] = undefined;
@@ -1362,3 +1368,21 @@ $(document).ready(function()
13621368
$("#leddevices").trigger("change");
13631369

13641370
});
1371+
1372+
function identify(index) {
1373+
// // clear current effect, should be called also on exit
1374+
requestPriorityClear();
1375+
// set color
1376+
setTimeout(function(){
1377+
// rgb and duration: 0 = inf.
1378+
requestSetColor(255, 0, 0,1,index);
1379+
setTimeout(function () {
1380+
requestSetColor(0, 255, 0,1,index);
1381+
},1000);
1382+
setTimeout(function () {
1383+
requestSetColor(0, 0, 255,1,index);
1384+
requestSetComponentState('LEDDEVICE',true);
1385+
},2000);
1386+
// turn on led device if disabled
1387+
}, 100);
1388+
}

include/api/API.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ class API : public QObject
7676
/// @brief Set a single color
7777
/// @param[in] priority The priority of the written color
7878
/// @param[in] ledColor The color to write to the leds
79+
/// @param[in] indexOfLed The index of the led or -1 to write to all
7980
/// @param[in] timeout_ms The time the leds are set to the given color [ms]
8081
/// @param[in] origin The setter
8182
///
82-
void setColor(int priority, const std::vector<uint8_t>& ledColors, int timeout_ms = -1, const QString& origin = "API", hyperhdr::Components callerComp = hyperhdr::COMP_INVALID);
83+
void setColor(int priority, const std::vector<uint8_t>& ledColors,int indexOfLed=-1, int timeout_ms = -1, const QString& origin = "API", hyperhdr::Components callerComp = hyperhdr::COMP_INVALID);
8384

8485
///
8586
/// @brief Set a image

include/base/HyperHdrInstance.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,12 @@ public slots:
168168
///
169169
/// @param[in] priority The priority of the written color
170170
/// @param[in] ledColors The color to write to the leds
171+
/// @param[in] indexOfLed The index of the led or -1 to write to all
171172
/// @param[in] timeout_ms The time the leds are set to the given color [ms]
172173
/// @param[in] origin The setter
173174
/// @param clearEffect Should be true when NOT called from an effect
174175
///
175-
void setColor(int priority, const std::vector<ColorRgb>& ledColors, int timeout_ms = -1, const QString& origin = "System", bool clearEffects = true);
176+
void setColor(int priority, const std::vector<ColorRgb>& ledColors,int indexOfLed=-1, int timeout_ms = -1, const QString& origin = "System", bool clearEffects = true);
176177

177178
///
178179
/// @brief Set the given priority to inactive

include/proto-nano-server/ProtoNanoClientConnection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ProtoNanoClientConnection : public QObject
7575
///
7676
/// @brief Forward requested color
7777
///
78-
void setGlobalInputColor(int priority, const std::vector<ColorRgb> &ledColor, int timeout_ms, const QString& origin = "ProtoBuffer" ,bool clearEffects = true);
78+
void setGlobalInputColor(int priority, const std::vector<ColorRgb> &ledColor,int indexOfLed = -1, int timeout_ms = -1, const QString& origin = "ProtoBuffer" ,bool clearEffects = true);
7979

8080
///
8181
/// @brief Emits whenever the client disconnected

include/utils/GlobalSignals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class GlobalSignals : public QObject
8181
/// @param[in] origin The setter
8282
/// @param clearEffect Should be true when NOT called from an effect
8383
///
84-
void setGlobalColor(int priority, const std::vector<ColorRgb>& ledColor, int timeout_ms, const QString& origin = "External", bool clearEffects = true);
84+
void setGlobalColor(int priority, const std::vector<ColorRgb>& ledColor,int indexOfLed = -1, int timeout_ms = -1, const QString& origin = "External", bool clearEffects = true);
8585

8686
///////////////////////////////////////
8787
///////////////// FROM ////////////////

sources/api/API.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void API::init()
9696
}
9797
}
9898

99-
void API::setColor(int priority, const std::vector<uint8_t>& ledColors, int timeout_ms, const QString& origin, hyperhdr::Components callerComp)
99+
void API::setColor(int priority, const std::vector<uint8_t>& ledColors,int indexOfLed, int timeout_ms, const QString& origin, hyperhdr::Components callerComp)
100100
{
101101
std::vector<ColorRgb> fledColors;
102102
if (ledColors.size() % 3 == 0)
@@ -105,7 +105,7 @@ void API::setColor(int priority, const std::vector<uint8_t>& ledColors, int time
105105
{
106106
fledColors.emplace_back(ColorRgb{ ledColors[i], ledColors[i + 1], ledColors[i + 2] });
107107
}
108-
QMetaObject::invokeMethod(_hyperhdr, "setColor", Qt::QueuedConnection, Q_ARG(int, priority), Q_ARG(std::vector<ColorRgb>, fledColors), Q_ARG(int, timeout_ms), Q_ARG(QString, origin));
108+
QMetaObject::invokeMethod(_hyperhdr, "setColor", Qt::QueuedConnection, Q_ARG(int, priority), Q_ARG(std::vector<ColorRgb>, fledColors),Q_ARG(int,indexOfLed), Q_ARG(int, timeout_ms), Q_ARG(QString, origin));
109109
}
110110
}
111111

sources/api/JSONRPC_schema/schema-color.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
"maximum" : 253,
1717
"required": true
1818
},
19+
"indexofled": {
20+
"type": "integer",
21+
"required": false
22+
},
1923
"duration": {
2024
"type": "integer",
2125
"required": false

0 commit comments

Comments
 (0)