Skip to content

Instantly share code, notes, and snippets.

@g7uvw
g7uvw / intstuff.py
Created August 13, 2023 12:00
Broken int conversion
# data is a number from a sensor - it's either in base 10 or 16. Default is base 10, but it's sometimes 16.
# I want to return a decimal value no matter that the input base is.
# Thsi is micropython and I get this error
# ValueError: invalid syntax for integer with base 16
def uint_le(data,base = 10):
val = struct.unpack('<H', data)
if (base == 10):
return (int(val[0]))
if (base == 16):
return int('val[0]',base)
@g7uvw
g7uvw / tomo.py
Last active March 20, 2018 16:37
Not quite working tomo recon from images
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
from skimage.io import imread
from skimage.transform import radon, iradon
from scipy.ndimage import zoom
basename = "projection_"
extention = ".jpeg"
@g7uvw
g7uvw / gist:8c8627f5ab7b7a367289
Created December 20, 2015 13:19
STMF401RE Nucleo issue
#include "stm32f4xx.h"
int main (void)
{
RCC->AHB1RSTR |= RCC_AHB1RSTR_GPIODRST; // Reset GPIOD
RCC->AHB1RSTR = 0; // Exit reset state
RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; // Enable GPIOD clock
GPIOD->MODER |= GPIO_MODER_MODER13_0; // Enable Output on D13