Skip to content

Instantly share code, notes, and snippets.

View parasquid's full-sized avatar

Tristan parasquid

View GitHub Profile
@shayne
shayne / !Tailscale Unraid Setup.bash
Last active June 9, 2023 16:02
Tailscale Unraid Setup
########################################################################
#### DEPRECATED in favor of https://github.com/deasmi/unraid-tailscale
########################################################################
# /boot/config/go
# add the following...
# Tailscale
bash /boot/config/tailscale/install.sh
@fanoush
fanoush / DK08.js
Last active May 27, 2021 07:49
DK08 demo
function KickWd(){
if(!BTN1.read())E.kickWatchdog();
}
var wdint=setInterval(KickWd,5000); // 5 secs
E.enableWatchdog(20, false); // 20 secs
E.kickWatchdog();
/*
// MIT License (c) 2020 fanoush https://github.com/fanoush
// see full license text at https://choosealicense.com/licenses/mit/
var SPI2 = E.compiledC(`
// -- 1. copy paste methods for flash writing and verification below to Espruino WebIDE left side
E.setFlags({unsafeFlash:1});
var fl=require("Flash");
var ladd=0;var lpg=0;var nadd=0;// last address, last page addr, next addr
var flash=function(a,d){
if (nadd>0 && nadd<a) console.log("Hole in data, got "+a.toString(16)+", expected "+nadd.toString(16));
var p=fl.getPage(a).addr;
if (p>lpg) {fl.erasePage(p);lpg=p;console.log("Erasing page 0x"+p.toString(16));}
p=fl.getPage(a+d.length-1).addr;
if (p>lpg) {fl.erasePage(p);lpg=p;console.log("Erasing page 0x"+p.toString(16));}
diff --git a/targets/nrf5x/bluetooth.c b/targets/nrf5x/bluetooth.c
index e5aa77d5..5f15e041 100644
--- a/targets/nrf5x/bluetooth.c
+++ b/targets/nrf5x/bluetooth.c
@@ -2489,6 +2489,7 @@ void jsble_restart_softdevice() {
jshUtilTimerDisable(); // don't want the util timer firing during this!
JsSysTime lastTime = jshGetSystemTime();
jsble_kill();
+ jsvUnLock(jspEvaluate("if(typeof(NRF.onRestart)=='function')NRF.onRestart();",true));
jsble_init();
@atc1441
atc1441 / UpdateProtocolDafit.txt
Last active September 10, 2023 21:32
DaFit App Update Protocol manual
Basic Manual for DaFit Fitness Tracker firmware update protocol, works for nearly any nRF52832 tracker from Company DaFit
The minimum size of update file is 0x10000(can be filled with garbage to get to size) and the maximum size is 0x2F000
the update will first get stored onto the external flash at position 0x3D1000 by the stock firmware(not by the bootloader)
the size of the update will get stored at 0x3D0000 on external flash with 4 bytes uint32_t
when bootloader gets activated it will copy the update from external flash to 0x23000 of the nRF52 internal flash.
Connect to device,
@fanoush
fanoush / espruino-FPU-mandel-bench.js
Last active August 27, 2020 04:29
this is benchmark of Mandelbrot set in JS, compiled JS and inline C. compiler output inside comments can be used instead of code above it, if you don't have EspruinoCompiler enabled
function mandelCompJS(x,y) {
"compiled";
var Xr = 0;
var Xi = 0;
var i = 0;
var Cr=(4*x/64)-2;
var Ci=(4*y/64)-2;
while ((i<32) & ((Xr*Xr+Xi*Xi)<4)) {
var t=Xr*Xr - Xi*Xi + Cr;
Xi=2*Xr*Xi+Ci;
// https://www.espruino.com/Reference#l_NRF_setServices
// https://github.com/gfwilliams/workshop-thingy52/blob/master/step5.md
// http://forum.espruino.com/conversations/322805/
var atf={};
var user="";
atf.USER=function(p,t){
if(p){
user=p;
}
@fanoush
fanoush / HX03W.js
Last active January 1, 2020 18:58
//manual watchdog pinging mode is dangerous for Espruino Web IDE upload with 'reset() before upload' enabled
//you can brick your device with partial upload caused by watchdog reboot in the middle of upload
//E.enableWatchdog(6, false);
//var wdint=setInterval(function(){if(!BTN1.read())E.kickWatchdog();},1000);
var log=console.log;
Modules.addCached("HX03WLCD",function(){
// commands sent when initialising the display
var initCmds = new Uint8Array([
0xAE, // 0 disp off
0xD5, // 1 clk div
first console:
pi@raspberrypi:~ $ sudo openocd -d2 -f interface/stlink.cfg -f target/nrf52.cfg
Open On-Chip Debugger 0.10.0+dev-00637-gb3ed97a4 (2019-01-03-22:45)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
@vshymanskyy
vshymanskyy / M5Stack_Espruino.js
Last active February 6, 2024 19:53
M5Stack Espruino initialization example
/*
Also, need to change in ILI9341pal.js:
var LCD_WIDTH = 320;
var LCD_HEIGHT = 240;
*/
BTN1 = D39
BTN2 = D38
BTN3 = D37
SPKR = D25