Skip to content

Instantly share code, notes, and snippets.

View TamojitSaha's full-sized avatar
💭
tamojitsaha.info

Tamojit Saha TamojitSaha

💭
tamojitsaha.info
  • India
View GitHub Profile
@TamojitSaha
TamojitSaha / index.html
Created July 16, 2021 07:17 — forked from KentaYamada/index.html
Python Flask + JavaScript XMLHttpRequest
<!DOCTYPE html>
<html>
<head>
<title>Practice AJAX</title>
<script type="text/javascript">
function do_ajax() {
var req = new XMLHttpRequest();
var result = document.getElementById('result');
req.onreadystatechange = function()
{
@TamojitSaha
TamojitSaha / bmp2array.py
Last active July 15, 2021 15:56
bmp2array.py - A python script for genarting image arrays from 1-bit bitmaps for DPEG0290RW series Epaper display. This display has unique scannning method. The bits should be written vertically, but the data should be present horizontally in the image array.
'''
Test image 1: https://imgur.com/ZL9xyBy
Test image 2: https://imgur.com/MtHCRrb
Test image 3: https://imgur.com/J4ULXO0
Test image 4: https://imgur.com/jHyfTJa
@author: Tamojit Saha <https://github.com/TamojitSaha>
'''
from PIL import Image
// Pin definition
#define RST_PIN 2
#define DC_PIN 4
#define CS_PIN 15
#define BUSY_PIN 5
#define SCK_PIN 14
#define SDI_PIN 13
#define SWRESET 0x12
#define ACT_DISPLAY_UPDATE 0x20
#include <Arduino.h>
TaskHandle_t Task1, Task2;
int count1 = 0, count2 = 0;
#define BTN_1 GPIO_NUM_10
#define BTN_2 GPIO_NUM_11
#define LED_1 GPIO_NUM_12
#define LED_2 GPIO_NUM_13
@TamojitSaha
TamojitSaha / AWS_Python_Subscribe.py
Created September 12, 2020 13:10
Use AWS IoT Device SDK for Python to subscribe to a topic
from awscrt import io, mqtt, auth, http
from awsiot import mqtt_connection_builder
import time as t
import json
import threading
# Define ENDPOINT, CLIENT_ID, PATH_TO_CERT, PATH_TO_KEY, PATH_TO_ROOT, MESSAGE, TOPIC, and RANGE
ENDPOINT = "xxxxxxxxxx-ats.iot.us-east-2.amazonaws.com"
CLIENT_ID = "testDevice"
PATH_TO_CERT = "your_cert.crt"
@TamojitSaha
TamojitSaha / hcsr04.ino
Created July 3, 2020 19:31 — forked from wolph/hcsr04.ino
Simple arduino HC-SR04 (HCSR04) distance detection using interrupts for low latency measurements
#include <Arduino.h>
// Uses https://github.com/PaulStoffregen/TimerOne for sending on a regular interval
#include <TimerOne.h>
// ECHO pin, needs to be a pin that supports interrupts!
#define ULTRASONIC_PIN_INPUT 2
// TRIG pin, can be any output pin
#define ULTRASONIC_PIN_OUTPUT 3
// update interval, make sure to keep it above 20ms
#define ULTRASONIC_TIMER_US 50000
@TamojitSaha
TamojitSaha / Attiny85_ADC_Watchdog_Sleep.ino
Last active June 27, 2020 19:05
Reading ADC and configuring watchdog in ATtiny85
/*
Update 27 Jun 20
Implemented NRFLite Library for 2pin communication with NRF24L01
Refer to https://github.com/dparson55/NRFLite for more information.
@author: Tamojit Saha
@website: https://www.tamojitsaha.info
*/
#include <avr/sleep.h> // Sleep Modes
#include <avr/power.h>
#include <stdio.h>
void merge(int *arr, int l, int m, int r)
{
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
int L[n1], R[n2];
for (i = 0; i < n1; i++)
L[i] = arr[l + i];
#include "color.h"
#include "utilities.h"
#include <math.h>
/*
* Algorithm adapted from https://gist.github.com/hdznrrd/656996. Uses a little libmath.
* */
void color_HSV2RGB(struct color_ColorHSV const *hsv, struct color_ColorRGB *rgb) {
int i;
@TamojitSaha
TamojitSaha / ternary.c
Created April 26, 2020 08:35
demonstartion of ternary operator without if condition in C
#include <stdio.h>
int i=1;
int main()
{
(i) ?: 1;
printf("%d",i);
return 0;