Skip to content

Instantly share code, notes, and snippets.

View barwis's full-sized avatar

Bartosz Wisniewski barwis

  • United Kingdom
View GitHub Profile
"start:server": "CHOKIDAR_USEPOLLING=true nodemon index.js"
@barwis
barwis / AiEsp32RotaryEncoder
Last active November 8, 2022 09:47
AiEsp32RotaryEncoder setup
#include <pins_arduino.h>
#include "AiEsp32RotaryEncoder.h"
#define KY040_SW D3
#define KY040_CLK D4
#define KY040_DT D5
#define KY040_VCC -1 // -1 if rotary encoder is connected directly to 3.3V
#define KY040_STEPS 4 //depending on your encoder - try 1,2 or 4 to get expected behaviour
@barwis
barwis / Adafruit_SSD1306.ino
Last active November 8, 2022 10:12
Adafruit_SSD1306 128x32 OLED display on custom pins
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <pins_arduino.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
#define OLED_SDA D6
#define OLED_SCL D7
@barwis
barwis / gist:6eda44673dc8238a639083038766ac70
Created July 28, 2016 11:27
[WIP] adding descriptions to dial segments
for (let a = 0; a < angles.length; a++) {
let angle;
const strokeColor = 'rgba(255, 255, 255, 0.6)';
if (a === angles.length - 1) {
angle = (angles[0] + 360 - angles[a]) / 2 + angles[a];
} else {
angle = (angles[a + 1] - angles[a]) / 2 + angles[a];
@barwis
barwis / DownloadFile.cs
Last active August 29, 2015 14:27 — forked from nboubakr/DownloadFile.cs
Simple function in C# to download a file from the internet, supports to resume the download.
public static void downloadFile(string sourceURL, string destinationPath)
{
long fileSize = 0;
int bufferSize = 1024;
bufferSize *= 1000;
long existLen = 0;
System.IO.FileStream saveFileStream;
if (System.IO.File.Exists(destinationPath))
{