Skip to content

Commit

Permalink
为 SimPad v2 提供灯光速度调整选项
Browse files Browse the repository at this point in the history
  • Loading branch information
iamapig120 committed Aug 9, 2019
1 parent 61001de commit 3258360
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 4 deletions.
39 changes: 39 additions & 0 deletions app/devices/simpadv2/page3.html
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,45 @@ <h4 data-lang-key="changeLights">changeLights</h4>
>
</p>
</div>
<div>
<p>
<span class="titleP" data-lang-key="lightsDelay">lightsDelay</span>
</p>
<p>
<span class="titleP withAfter"
><label for="easeLightDelayInput" data-lang-key="easeLightDelay"
>easeLightDelay</label
></span
>
<span class="rightP">
<input
type="number"
id="easeLightDelayInput"
value="1280"
min="10"
max="65535"
/>
</span>
</p>
<p>
<span class="titleP withAfter"
><label
for="rainbowLightDelayInput"
data-lang-key="rainbowLightDelay"
>rainbowLightDelay</label
></span
>
<span class="rightP">
<input
type="number"
id="rainbowLightDelayInput"
value="2560"
min="10"
max="65535"
/>
</span>
</p>
</div>
<div>
<p>
<span class="titleP" data-lang-key="colorAndBrightness"
Expand Down
48 changes: 45 additions & 3 deletions app/devices/simpadv2/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ let sendData, page4Fin, page4Init, jumpPage
* 8: 灯光模式
* 9: 防抖设定
* 10: 极速模式
* 11: 保留
* 11: 灯光速度
*/
const settingsSet = new Array(12).fill(0).map(() => new Array(8))

Expand Down Expand Up @@ -109,6 +109,7 @@ const getAllSettings = (dev = device) => {
.then(() => getSettings(8, dev))
.then(() => getSettings(9, dev))
.then(() => getSettings(10, dev))
.then(() => getSettings(11, dev)) // 灯光速度
.then(
() =>
new Promise(r => {
Expand Down Expand Up @@ -271,6 +272,28 @@ const initSettings = () => {
radio.checked = true
}
})

// 灯光速度
const DEFAULT_LIGHT_DELAY = 0x0a00
const easeLightDelayInput = document.getElementById('easeLightDelayInput')
easeLightDelayInput.value = (settingsSet[11][0] << 8) | settingsSet[11][1]
if (
easeLightDelayInput.value === 0x10000 ||
easeLightDelayInput.value < 0x0a
) {
easeLightDelayInput.value = DEFAULT_LIGHT_DELAY
}
const rainbowLightDelayInput = document.getElementById(
'rainbowLightDelayInput'
)
rainbowLightDelayInput.value = (settingsSet[11][2] << 8) | settingsSet[11][3]
if (
rainbowLightDelayInput.value === 0x10000 ||
rainbowLightDelayInput.value < 0x0a
) {
rainbowLightDelayInput.value = DEFAULT_LIGHT_DELAY
}

countChanges()
}

Expand Down Expand Up @@ -422,6 +445,24 @@ const initSettingsFunction = () => {
countChanges()
})
})

// 灯光速度
const easeLightDelayInput = document.getElementById('easeLightDelayInput')
easeLightDelayInput.addEventListener('change', e => {
const trueValue = easeLightDelayInput.value
settingChanged[11][0] = (trueValue & 0xff00) >> 8
settingChanged[11][1] = trueValue & 0x00ff
countChanges()
})
const rainbowLightDelayInput = document.getElementById(
'rainbowLightDelayInput'
)
rainbowLightDelayInput.addEventListener('change', e => {
const trueValue = rainbowLightDelayInput.value
settingChanged[11][2] = (trueValue & 0xff00) >> 8
settingChanged[11][3] = trueValue & 0x00ff
countChanges()
})
}

// 默认数据
Expand All @@ -433,9 +474,10 @@ const templeData = [
[0x05, 0x00, 0x3b, 0x00, 0x00], //F3
[0x06, 0x00, 0xff, 0x00, 0x04], //#00FF00 100%(4)
[0x07, 0x00, 0x00, 0xff, 0x04], //#0000FF 100%(4)
[0x08, 0x00, 0x00, 0x00, 0x00], //Mode 0
[0x08, 0x06, 0x00, 0x00, 0x00], //Mode 6 彩虹
[0x09, 0x00, 0x00, 0x00, 0x60], //0x60 => 96 (MAX 16^6-1)
[0x0a, 0x00, 0x00, 0x00, 0x40] //0x00 极速模式处于关闭
[0x0a, 0x00, 0x00, 0x00, 0x40], //0x00 极速模式处于关闭,夜灯打开
[0x0b, 0x05, 0x00, 0x0a, 0x00] //0x0A00 延迟设置
]
templeData.forEach(arr => {
arr[5] = arr[1] ^ arr[2] ^ arr[3] ^ arr[4]
Expand Down
2 changes: 1 addition & 1 deletion app/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var app = require('electron').app
const path = require('path')
var AdmZip = require('adm-zip')

const APP_VERSION = 'v0.159'
const APP_VERSION = 'v0.160'

var clearAllTimeout = () => {
for (var i = setTimeout(() => {}, 0); i; i--) {
Expand Down

0 comments on commit 3258360

Please sign in to comment.