feat: 2in9_ssd1680a_296x128 (#1)

This commit is contained in:
susabolca
2024-03-22 16:34:40 +08:00
committed by GitHub
parent 708293aeff
commit 046b7c5cb8
50 changed files with 18273 additions and 4182 deletions

74
tools/cc2640r2_etag.html Normal file
View File

@@ -0,0 +1,74 @@
<html lang="zh-CN">
<script>
let bleDevice;
let gattServer;
let Theservice;
let epdService;
let epochCharacter;
async function doConnect() {
if (gattServer != null && gattServer.connected) {
if (bleDevice != null && bleDevice.gatt.connected)
bleDevice.gatt.disconnect();
}
else {
bleDevice = await navigator.bluetooth.requestDevice({
filters: [{ namePrefix: ['C26_'] }],
optionalServices: [
0xfff0,
],
//acceptAllDevices: true
});
await bleDevice.addEventListener('gattserverdisconnected', disconnect);
await connect();
}
}
async function connect() {
if (epochCharacter == null) {
info("Connect to " + bleDevice.name)
gattServer = await bleDevice.gatt.connect();
info('> Found GATT server');
epdService = await gattServer.getPrimaryService(0xfff0);
info('> Found EPD service');
epochCharacter = await epdService.getCharacteristic(0xfff1);
document.getElementById("btnConnect").innerHTML = 'Disconnect';
}
}
function disconnect() {
bleDevice = null;
epdService = null;
epochCharacter = null;
info('Disconnected.');
document.getElementById("btnConnect").innerHTML = 'Connect';
}
async function doSetTime() {
var epoch = Date.now() / 1000 | 0;
var buf = new ArrayBuffer(4);
var arr = new Uint32Array(buf);
arr[0] = epoch;
await epochCharacter.writeValueWithResponse(arr);
info("Write unix epoch: " + epoch);
}
function info(logTXT) {
var today = new Date();
var time = ("0" + today.getHours()).slice(-2) + ":" + ("0" + today.getMinutes()).slice(-2) + ":" + ("0" + today.getSeconds()).slice(-2) + " : ";
document.getElementById("log").innerHTML += time + logTXT + '<br>';
console.log(time + logTXT);
while ((document.getElementById("log").innerHTML.match(/<br>/g) || []).length > 10) {
var logs_br_position = document.getElementById("log").innerHTML.search("<br>");
document.getElementById("log").innerHTML = document.getElementById("log").innerHTML.substring(logs_br_position + 4);
}
}
</script>
<button id="btnConnect" type="button" onclick="doConnect()">Connect</button>
<button id="btnSetTime" type="button" onclick="doSetTime()">SetTime</button>
<div id="log"></div>
</html>