Skip to content

Instantly share code, notes, and snippets.

View minimum-necessary-change's full-sized avatar

minimum-necessary-change

View GitHub Profile
@minimum-necessary-change
minimum-necessary-change / gpioblnk.ino
Created July 24, 2019 07:33 — forked from RickKimball/gpioblnk.ino
c++ template blink using register level gpio access
// more fun with c++ classes and templates
// http://www.stm32duino.com/viewtopic.php?f=18&t=303
class GPIOPort :
public gpio_reg_map {
public:
void high(const uint32_t pin) {
BSRR = 1 << pin;
}
void low(const uint32_t pin) {
BRR = 1 << pin;
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <sys/resource.h>
#include <sys/types.h>
typedef struct s_block* t_block;
struct s_block {
size_t size;
@minimum-necessary-change
minimum-necessary-change / howto-build-avrdude.txt
Created June 23, 2019 09:06
Build avrdude from truck (latest)
How to build avrdude from SVN:
1. svn co svn://svn.savannah.nongnu.org/avrdude/trunk
2. cd trunk/avrdude
3. ./bootstrap
4. ./configure
@minimum-necessary-change
minimum-necessary-change / atmel_adc_oversample.c
Last active June 20, 2019 09:33
Atmel ADC Oversampling
/*****************************************************************************
*
* Atmel Corporation
*
* File : main.c
* Compiler : IAR EWAAVR 2.28a/3.10c
* Revision : $Revision: 1.1 $
* Date : $Date: Wednesday, July 13, 2005 10:43:44 UTC $
* Updated by : $Author: omella $
*
@minimum-necessary-change
minimum-necessary-change / Build_ESP32_toolchain_for_ARM.txt
Created June 4, 2019 06:43
Build ESP32 toolchain for ARM (Linux)
https://github.com/espressif/arduino-esp32/issues/1024#issuecomment-360324759
Got it working!
I will post here my notes and results so others know what to expect!
I did this in a Pine64+ ARM (a 64bit ARM SBC).
Before running this I had installed Arduino IDE with this script: https://github.com/pfeerick/pine64-scripts/blob/master/install-arduino-ide.sh
To install ESP32 toolchain on Armbian:
See: http://esp-idf.readthedocs.io/en/latest/get-started/linux-setup-scratch.html
@minimum-necessary-change
minimum-necessary-change / RCWL-0516.ino
Created April 30, 2019 11:38
Radar Microwave Sensor - RCWL-0516
/*
* Arduino Microwave Radar Motion Sensor Interface
* https://Circuits4you.com
* Oct 2018
*/
int Sensor = 2; //Input Pin
int LED = 13; // Led pin for Indication
int flg = 0; //Change detection flag
/*
Features
Module supports external voltage input of the 4-way acquisition (voltage input range of 0-5v)
integrated photoresistor
integrated thermistor
integrated potentiometer
Modules power indicator
Modules with DA output indicator, when the module DA output interface voltage reaches a certain value, will be lit panel the DA output indicator, the higher the voltage, the more obvious indicator brightness
Remove shunts to bypass on board integrated devices
The left connector
@minimum-necessary-change
minimum-necessary-change / high-frequency-square-wave-generator-esp8266.ino
Created April 24, 2019 07:44 — forked from Jamesits/high-frequency-square-wave-generator-esp8266.ino
High-accuracy square wave generator (up to 250KHz) based on ESP8266, with runtime adjustable frequency, PWM width and offset.
// High-accuracy square wave generator
// based on ESP8266
// with runtime adjustable frequency, PWM width and offset
// Output wave at pin 5 (configurable from 0 to 15, but not 16)
// by James Swineson <github@public.swineson.me>, 2017-10
// https://gist.github.com/Jamesits/92394675c0fe786467b26f90e95d3904
// See https://blog.swineson.me/implementation-of-6mbps-high-speed-io-on-esp8266-arduino-ide/
// for more information (article in Chinese)
// Arduino UNO version: https://gist.github.com/Jamesits/8d164818946a65d0cafcd6203e3e5049
@minimum-necessary-change
minimum-necessary-change / rgb565.pde
Created April 19, 2019 11:41 — forked from companje/rgb565.pde
rgb565 to rgb888
//convert RGB565 to RGB888
byte src[] = loadBytes("ui.bin");
byte dst[] = new byte[src.length/2*3];
for (int i=0, j=0; i<src.length; i+=2) {
int c = src[i] + (src[i+1]<<8);
byte r = byte(((c & 0xF800) >> 11) << 3);
byte g = byte(((c & 0x7E0) >> 5) << 2);
byte b = byte(((c & 0x1F)) << 3);
@minimum-necessary-change
minimum-necessary-change / 2ddda.c
Last active June 4, 2019 08:28
Image Scaling
/**************************************************************************
** ResizeDDA -- Reads an image from file 'f' one scan line at a time,
** outputs the image resized by the 'zoom' factor.
*/
void ResizeDDA(FILE *f, int rows, int cols, double zoom)
{
unsigned char *aspline, *line;
int x, y;
int ddax, dday, izoom, i, k;
extern int getline(FILE *, int, unsigned char *);