Skip to content

Commit

Permalink
Add configurable refresh rate
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorGrycuk committed Apr 28, 2023
1 parent 7de54c1 commit 55f7772
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
8 changes: 7 additions & 1 deletion streamdeck-magnifier/streamdeck-magnifier/Magnifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Magnifier(SDConnection connection, InitialPayload payload) : base(connect
? MagnifierSettings.CreateDefaultSettings()
: payload.Settings.ToObject<MagnifierSettings>();

Timer = new Timer(10);
Timer = new Timer(settings.RefreshRate);
Timer.Elapsed += new ElapsedEventHandler(UpdateKey);
Timer.Enabled = false;
Timer.Start();
Expand Down Expand Up @@ -75,6 +75,7 @@ public override void ReceivedSettings(ReceivedSettingsPayload payload)
{
Tools.AutoPopulateSettings(settings, payload.Settings);
ParseZoomLevel();
UpdateRefreshRate();
SaveSettings();
}

Expand All @@ -96,5 +97,10 @@ private void ParseZoomLevel()
Logger.Instance.LogMessage(TracingLevel.ERROR, "Cannot parse: " + settings.PIZoomLevel);
}
}

private void UpdateRefreshRate()
{
Timer.Interval = settings.RefreshRate;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal class MagnifierSettings
{
public static MagnifierSettings CreateDefaultSettings()
{
var instance = new MagnifierSettings { ZoomLevel = 2 };
var instance = new MagnifierSettings { ZoomLevel = 2, RefreshRate = 100 };
return instance;
}

Expand All @@ -17,5 +17,8 @@ public static MagnifierSettings CreateDefaultSettings()
public bool UseCrosshair { get; set; }

public int ZoomLevel { get; set; }

[JsonProperty(PropertyName = "refreshRate")]
public int RefreshRate { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
<div class="sdpi-item" id="dvZoomLevel">
<div class="sdpi-item-label">Select Type</div>
<select class="sdpi-item-value select sdProperty" id="zoomLevel" oninput="setSettings()">
<option value="2">2x</option>
<option value="4">4x</option>
<option value="8">8x</option>
<option value="16">16x</option>
<option value="32">32x</option>
<option value="2">2x</option>
<option value="4">4x</option>
<option value="8">8x</option>
<option value="16">16x</option>
<option value="32">32x</option>
</select>
</div>
<div class="sdpi-item" id="dvInterval">
<div class="sdpi-item-label">Refresh Rate</div>
<input class="sdpi-item-value sdProperty" value="100" id="refreshRate" placeholder="in milliseconds" required pattern="\d+" oninput="setSettings()">
</div>
<div type="checkbox" class="sdpi-item" id="crosshair">
<div class="sdpi-item-label">Show Crosshair</div>
<div class="sdpi-item-value min100">
Expand Down

0 comments on commit 55f7772

Please sign in to comment.