Skip to content

Instantly share code, notes, and snippets.

View aleksas's full-sized avatar

Aleksas Pielikis aleksas

View GitHub Profile
@aleksas
aleksas / download_github_assets.py
Last active September 22, 2021 10:10
Download github release assets
import os
import urllib.request
import os.path
import json
def download_asset(url, filename, token=None):
headers = {}
headers["Accept"] = 'application/octet-stream'
if token:
@aleksas
aleksas / DS8830_Single_channel_alpha.ino
Last active October 2, 2022 11:53
ADS8330 Manual Trigger Single Channel read (Arduino Due)
#include <SPI.h>
#define ADC_CS_PIN 2
#define ADC_CONVERSION_PIN 3
#define ADC_EOC_PIN 4
enum Command : uint16_t {
SEL_AN_IN_CHANNEL_0 = 0b0000 << 12,
SEL_AN_IN_CHANNEL_1 = 0b0001 << 12,
WAKE_UP = 0b1011 << 12,
@aleksas
aleksas / ADS8319.ino
Last active September 12, 2020 07:24
Simplified Dual Channel Read in auto mode (default) p. 14.
// BY: yiipmann
// SOURCE: https://arduino.stackexchange.com/questions/17296/interfacing-ads8319-with-arduino-uno
#include <SPI.h>
#define CONVPIN 7
#define SELPIN 8
#define SELPIN2 4
#define MISOPIN 12
#define SCLKPIN 13
/*
Render a Horizontal Percentage Bar
Drains left to right normally, if width is negative it will drain right to left.
Percent is clamped 0.0f - 1.0f
*/
void RenderHPBar(int x, int y, int w, int h, float Percent, SDL_Color FGColor, SDL_Color BGColor) {
Percent = Percent > 1.f ? 1.f : Percent < 0.f ? 0.f : Percent;
#include <SPI.h>
// Generated using https://www.daycounter.com/Calculators/Triangle-Wave-Generator-Calculator.phtml
// max value 2^9
// num values 128
// val 0-4096 | mA 0-300
//
int16_t* pValues = NULL;
int valuesCount = 0;
@aleksas
aleksas / LITE ON LTLD505T 5mW 650nm SPEC SHEET 1.ipynb
Last active April 17, 2020 21:20
LITE ON LTLD505T 5mW 650nm SPEC SHEET
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import argparse
import traceback
import pickle
import logging
import logging.handlers
@aleksas
aleksas / self-mixing-equations.ipynb
Last active August 27, 2024 11:36
self-mixing-equations.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aleksas
aleksas / absolute_distance.m
Last active March 16, 2020 06:55
MATLAB (Octave) code from "Solving self-mixing equations for arbitrary feedback levels: a concise algorithm" (https://scihub.bban.top/10.1364/AO.53.003723)
% Example self-mixing signal generation for a modulated laser - Kliese et al., 2014
c = 299792458; % Speed of light in vacuum (m/s)
C = 2; % Feedback parameter
alpha = 4.6; % Linewidth enhancement factor
T = 29.3e-3; % Simulation time (s)
N = 1000; % Number of samples
beta = 0.1; % Laser power modulation coefficient
lambda0 = 845e-9; % Laser wavelength (m)
L = 0.024 + 0.5e-6; % Target distance (m)
deltaf = - 46e9; % Frequency modulation coefficient (Hz)
@aleksas
aleksas / linux_run.sh
Last active March 4, 2020 09:28
Service for copying POP3 incoming mail to IMAP (adapted from https://github.com/kyokuheki/gmail-importer3)
export POP3_SERVER = 'pop3.host.com'
export POP3_PORT = '110'
export POP3_USER = 'pop3_username'
export POP3_PASS = 'pop3_password'
export IMAP_SERVER = 'imap.host.com'
export IMAP_PORT = '993'
export IMAP_USER = 'imap_username'
export IMAP_PASS = 'imap_password'
export IMAP_DST_MBOX = 'INBOX'