Skip to content

Instantly share code, notes, and snippets.

@nmk456
nmk456 / flash_pico
Last active February 3, 2022 20:04
Bash script for WSL to put Raspberry Pi Pico into BOOTSEL mode and copy .uf2 file over automatically
#!/usr/bin/bash
if [[ $1 == "-h" ]] || [[ $# -eq 0 ]]; then
echo "Usage: flash_pico file.uf2 port drive";
exit;
fi
# Serial command to trigger BOOTSEL mode
serialcmd="\$port= new-Object System.IO.Ports.SerialPort $2,1200,None,8,one
try {\$port.open()} catch {}"
@nmk456
nmk456 / uart_fifo_test.c
Created January 27, 2022 18:35
Code to test RP2040 UART FIFO level trigger settings
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/time.h"
#include "pico/multicore.h"
#include "hardware/irq.h"
#include "hardware/uart.h"
#define UART_TX_ID uart1
#define UART_TX 4
#define UART_RX_ID uart0
@nmk456
nmk456 / tune_period.py
Last active May 3, 2020 04:14
Tune orbital period of spacecraft using kRPC
import krpc, time
target_period = 7435 # The target orbital period in seconds
conn = krpc.connect()
vessel = conn.space_center.active_vessel
period = conn.add_stream(getattr, vessel.orbit, 'period')
vessel.control.throttle = 0.0
autopilot = vessel.auto_pilot
#include <Arduino.h>
#define clk_out 10
#define clk_in 9
uint8_t data;
unsigned long count;
elapsedMillis time;
#include <Arduino.h>
#define clk 10 // PWM Clock Pin - First timer, first channel
#define testpin 9
uint32_t count = 0;
// Timer stuff
IRQ_NUMBER_t irq = IRQ_QTIMER1;
IMXRT_TMR_t* tmr = &IMXRT_TMR1;
import pprint
def tleparse(line1, line2):
"""
Parses a TLE (two line elements) and returns a dictionary containing the data from the TLE.
For more information on TLE format: https://en.wikipedia.org/wiki/Two-line_element_set
Args:
# This code is written at BigVision LLC. It is based on the OpenCV project. It is subject to the license terms in the LICENSE file found in this distribution and at http://opencv.org/license.html
# Usage example: python3 object_detection_yolo.py --video=run.mp4
# python3 object_detection_yolo.py --image=bird.jpg
import cv2 as cv
import argparse
import sys
import numpy as np
import os, os.path
# This code is written at BigVision LLC. It is based on the OpenCV project. It is subject to the license terms in the LICENSE file found in this distribution and at http://opencv.org/license.html
# Usage example: python3 object_detection_yolo.py --video=run.mp4
# python3 object_detection_yolo.py --image=bird.jpg
import cv2 as cv
import argparse
import sys
import numpy as np
import os.path
@nmk456
nmk456 / pi_rc.py
Last active December 20, 2017 13:26
Control RC with Pi.
from .xbox import Joystick
import time
import Adafruit_PCA9685
"""
Dependencies:
https://github.com/adafruit/Adafruit_Python_PCA9685
https://github.com/FRC4564/Xbox
https://github.com/ynsta/steamcontroller

Keybase proof

I hereby claim:

  • I am nmk456 on github.
  • I am nmk456 (https://keybase.io/nmk456) on keybase.
  • I have a public key ASBYSfFovYvUwyz21Zf0aA8C18QIKsbKvHkI1rxCYzEJ2go

To claim this, I am signing this object: