You are reading a single comment by @Mark_M and its replies.
Click here to read the full conversation.
-
Has anyone implemented this function so that you can send the CAS commands without having to work out the checksum by hand all the time.
yes, I've done.
AT6558.prototype.checksum = function(val) { var cs = 0; for (const c of val) { cs = cs ^ c.charCodeAt(0); //XOR } return cs.toString(16).toUpperCase().padStart(2, '0'); }; AT6558.prototype.sendCommand = function(command) { cmd = "P" + command; cs = this.checksum(cmd); cmd = "$" + cmd + "*" + cs; print(cmd); Serial1.println(cmd); }; AT6558.prototype.setBaudRate = function(v) { var br = ""; switch (v) { case 4800: br = "0"; break; case 9600: br = "1"; break; case 19200: br = "2"; break; case 38400: br = "3"; break; case 57600: br = "4"; break; case 115200: br = "5"; break; default: return; } this.baudRate = v; sendCommand("CAS01," + br); };
For Bangle 1 someone wrote this code - but I think the format is different for this chip.
Also the DATASHEET has a different checksum method.
Has anyone implemented this function so that you can send the CAS commands without having to work out the checksum by hand all the time.