Skip to content

Commit 9ff3017

Browse files
zone is matrix without lcd
1 parent df7e14b commit 9ff3017

File tree

8 files changed

+156
-5
lines changed

8 files changed

+156
-5
lines changed

src/devices/devices.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import (
8181
"OpenLinkHub/src/devices/scimitarSEWU"
8282
"OpenLinkHub/src/devices/scimitarW"
8383
"OpenLinkHub/src/devices/scimitarWU"
84+
"OpenLinkHub/src/devices/scimitarprorgb"
8485
"OpenLinkHub/src/devices/scimitarrgbelite"
8586
"OpenLinkHub/src/devices/slipstream"
8687
"OpenLinkHub/src/devices/st100"
@@ -96,14 +97,13 @@ import (
9697
"OpenLinkHub/src/rgb"
9798
"OpenLinkHub/src/smbus"
9899
"OpenLinkHub/src/usb"
100+
101+
"github.com/sstallion/go-hid"
99102
"os"
100103
"path/filepath"
101104
"reflect"
102105
"slices"
103106
"strconv"
104-
105-
"OpenLinkHub/src/devices/scimitarprorgb"
106-
"github.com/sstallion/go-hid"
107107
)
108108

109109
const (
@@ -140,6 +140,7 @@ const (
140140
productTypeK60RgbPro = 120
141141
productTypeK70PMW = 121
142142
productTypeK70PMWU = 122
143+
productTypeK70Max = 123
143144
productTypeKatarPro = 201
144145
productTypeIronClawRgb = 202
145146
productTypeIronClawRgbW = 203
@@ -215,7 +216,7 @@ var (
215216
interfaceId = 0
216217
devices = make(map[string]*common.Device)
217218
products = make(map[string]Product)
218-
keyboards = []uint16{7127, 7165, 7166, 7110, 7083, 11024, 11025, 11015, 7109, 7091, 7124, 7036, 7037, 6985, 6997, 7019, 11009, 11010, 11028, 7097, 7027, 7076, 7073, 6973, 6957, 7072, 7094}
219+
keyboards = []uint16{7127, 7165, 7166, 7110, 7083, 11024, 11025, 11015, 7109, 7091, 7124, 7036, 7037, 6985, 6997, 7019, 11009, 11010, 11028, 7097, 7027, 7076, 7073, 6973, 6957, 7072, 7094, 7104}
219220
mouses = []uint16{7059, 7005, 6988, 7096, 7139, 7131, 11011, 7024, 7038, 7040, 7152, 7154, 11016, 7070, 7029, 7006, 7084, 7090, 11042, 7093, 7126, 7163, 7064, 7051, 7004, 7033, 6974}
220221
pads = []uint16{7067, 7113}
221222
headsets = []uint16{2658, 2660, 2667, 2696}
@@ -1257,6 +1258,25 @@ func UpdateRgbProfile(deviceId string, channelId int, profile string) uint8 {
12571258
return 0
12581259
}
12591260

1261+
// UpdateGlobalRgbProfile will update device RGB profile
1262+
func UpdateGlobalRgbProfile(profile string) uint8 {
1263+
channelId := -1
1264+
for _, device := range devices {
1265+
methodName := "UpdateRgbProfile"
1266+
method := reflect.ValueOf(GetDevice(device.Serial)).MethodByName(methodName)
1267+
if !method.IsValid() {
1268+
logger.Log(logger.Fields{"method": methodName}).Warn("Method not found")
1269+
continue
1270+
} else {
1271+
var reflectArgs []reflect.Value
1272+
reflectArgs = append(reflectArgs, reflect.ValueOf(channelId))
1273+
reflectArgs = append(reflectArgs, reflect.ValueOf(profile))
1274+
method.Call(reflectArgs)
1275+
}
1276+
}
1277+
return 1
1278+
}
1279+
12601280
// UpdateLinkAdapterRgbProfile will update LINK adapter RGB profile
12611281
func UpdateLinkAdapterRgbProfile(deviceId string, channelId, adapterId int, profile string) uint8 {
12621282
if device, ok := devices[deviceId]; ok {

src/devices/lsh/lsh.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3416,7 +3416,7 @@ func (d *Device) setupOpenRGBController() {
34163416
zone := common.OpenRGBZone{
34173417
Name: d.Devices[k].Name,
34183418
NumLEDs: uint32(d.Devices[k].LedChannels),
3419-
ZoneType: common.ZoneTypeMatrix,
3419+
ZoneType: common.ZoneTypeLinear,
34203420
}
34213421

34223422
if d.Devices[k].ContainsPump && d.Devices[k].AIO {
@@ -3430,6 +3430,8 @@ func (d *Device) setupOpenRGBController() {
34303430
NumLEDs: uint32(lcdLedChannels),
34313431
}
34323432
controller.Zones = append(controller.Zones, lcdZone)
3433+
} else {
3434+
zone.ZoneType = common.ZoneTypeMatrix
34333435
}
34343436
} else {
34353437
controller.Zones = append(controller.Zones, zone)

src/server/requests/requests.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,26 @@ func ProcessChangeColor(r *http.Request) *Payload {
17721772
return &Payload{Message: language.GetValue("txtUnableToChangeRgbProfile"), Code: http.StatusOK, Status: 0}
17731773
}
17741774

1775+
// ProcessGlobalChangeColor will process POST request from a client for global RGB profile change
1776+
func ProcessGlobalChangeColor(r *http.Request) *Payload {
1777+
req := &Payload{}
1778+
err := json.NewDecoder(r.Body).Decode(&req)
1779+
if err != nil {
1780+
logger.Log(map[string]interface{}{"error": err}).Error("Unable to decode JSON")
1781+
return &Payload{
1782+
Message: language.GetValue("txtUnableToValidateRequest"),
1783+
Code: http.StatusOK,
1784+
Status: 0,
1785+
}
1786+
}
1787+
1788+
if len(req.Profile) < 1 {
1789+
return &Payload{Message: language.GetValue("txtNonExistingSpeedProfile"), Code: http.StatusOK, Status: 0}
1790+
}
1791+
devices.UpdateGlobalRgbProfile(req.Profile)
1792+
return &Payload{Message: language.GetValue("txtDeviceRgbProfileChanged"), Code: http.StatusOK, Status: 1}
1793+
}
1794+
17751795
// ProcessChangeLinkAdapterColor will process POST request from a client for RGB LINK adapter profile change
17761796
func ProcessChangeLinkAdapterColor(r *http.Request) *Payload {
17771797
req := &Payload{}

src/server/server.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,17 @@ func setDeviceColor(w http.ResponseWriter, r *http.Request) {
703703
resp.Send(w)
704704
}
705705

706+
// setGlobalDeviceColor handles global color changes
707+
func setGlobalDeviceColor(w http.ResponseWriter, r *http.Request) {
708+
request := requests.ProcessGlobalChangeColor(r)
709+
resp := &Response{
710+
Code: request.Code,
711+
Status: request.Status,
712+
Message: request.Message,
713+
}
714+
resp.Send(w)
715+
}
716+
706717
// setLinkAdapterColor handles LINK adapter color changes
707718
func setLinkAdapterColor(w http.ResponseWriter, r *http.Request) {
708719
request := requests.ProcessChangeLinkAdapterColor(r)
@@ -1231,6 +1242,24 @@ func uiIndex(w http.ResponseWriter, _ *http.Request) {
12311242
web.GpuTemp = dashboard.GetDashboard().TemperatureToString(temperatures.GetGpuTemperature())
12321243
web.Dashboard = dashboard.GetDashboard()
12331244
web.BatteryStats = stats.GetBatteryStats()
1245+
web.RGBModes = []string{
1246+
"circle",
1247+
"circleshift",
1248+
"colorpulse",
1249+
"colorshift",
1250+
"colorwarp",
1251+
"cpu-temperature",
1252+
"flickering",
1253+
"gpu-temperature",
1254+
"off",
1255+
"rainbow",
1256+
"rotator",
1257+
"spinner",
1258+
"static",
1259+
"storm",
1260+
"watercolor",
1261+
"wave",
1262+
}
12341263
web.Page = "index"
12351264

12361265
// Add all devices to the list
@@ -1536,6 +1565,7 @@ func setRoutes() http.Handler {
15361565
handleFunc(r, "/api/speed", http.MethodPost, setDeviceSpeed)
15371566
handleFunc(r, "/api/speed/manual", http.MethodPost, setManualDeviceSpeed)
15381567
handleFunc(r, "/api/color", http.MethodPost, setDeviceColor)
1568+
handleFunc(r, "/api/color/global", http.MethodPost, setGlobalDeviceColor)
15391569
handleFunc(r, "/api/color/linkAdapter", http.MethodPost, setLinkAdapterColor)
15401570
handleFunc(r, "/api/color/linkAdapter/bulk", http.MethodPost, setLinkAdapterBulkColor)
15411571
handleFunc(r, "/api/color/getOverride", http.MethodPost, getRgbOverride)

src/templates/templates.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type Web struct {
5050
Languages map[string]language.Language
5151
LanguageCode string
5252
BatteryStats interface{}
53+
RGBModes []string
5354
}
5455

5556
// Lang is called from template files

static/js/index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,35 @@ document.addEventListener("DOMContentLoaded", function () {
146146
}
147147
});
148148
});
149+
150+
$('.allDevicesRgb').on('change', function () {
151+
const profile = $(this).val();
152+
if (profile === "none") {
153+
return false;
154+
}
155+
156+
const pf = {
157+
"profile": profile
158+
};
159+
160+
const json = JSON.stringify(pf, null, 2);
161+
162+
$.ajax({
163+
url: '/api/color/global',
164+
type: 'POST',
165+
data: json,
166+
cache: false,
167+
success: function(response) {
168+
try {
169+
if (response.status === 1) {
170+
toast.success(response.message);
171+
} else {
172+
toast.warning(response.message);
173+
}
174+
} catch (err) {
175+
toast.warning(response.message);
176+
}
177+
}
178+
});
179+
});
149180
});

static/js/overview.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,38 @@ document.addEventListener("DOMContentLoaded", function () {
15331533
});
15341534
});
15351535

1536+
$('.allDevicesRgb').on('change', function () {
1537+
const profile = $(this).val();
1538+
if (profile === "none") {
1539+
return false;
1540+
}
1541+
1542+
const pf = {
1543+
"profile": profile
1544+
};``
1545+
1546+
const json = JSON.stringify(pf, null, 2);
1547+
1548+
$.ajax({
1549+
url: '/api/color/global',
1550+
type: 'POST',
1551+
data: json,
1552+
cache: false,
1553+
success: function(response) {
1554+
try {
1555+
if (response.status === 1) {
1556+
toast.success(response.message);
1557+
$("#selectedRgb_" + parseInt(profile[0])).html(profile[1]);
1558+
} else {
1559+
toast.warning(response.message);
1560+
}
1561+
} catch (err) {
1562+
toast.warning(response.message);
1563+
}
1564+
}
1565+
});
1566+
});
1567+
15361568
$('.linkAdapterRgbProfile').on('change', function () {
15371569
const deviceId = $("#deviceId").val();
15381570
const profile = $(this).val().split(";");

web/footer.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,20 @@
2323
</tbody>
2424
</table>
2525
</div>
26+
{{ if gt (len .RGBModes) 0 }}
27+
<button title="Global RGB" class="btn btn-secondary-empty dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false" style="float: right;margin-right: 20px;margin-top: 5px;">
28+
<i class="bi bi-lightbulb-fill svg-icon svg-icon-sm svg-icon-heavy"></i>
29+
</button>
30+
<ul class="dropdown-menu dropdown-menu-dark shadow-sm" style="">
31+
<li>
32+
<select class="form-select allDevicesRgb">
33+
<option value="none">None</option>
34+
{{ range $key, $mode := .RGBModes }}
35+
<option value="{{ $mode }}">{{ $mode }}</option>
36+
{{ end }}
37+
</select>
38+
</li>
39+
</ul>
40+
{{ end }}
2641
</footer>
2742
{{ end }}

0 commit comments

Comments
 (0)