Skip to content

Instantly share code, notes, and snippets.

@sankarcheppali
sankarcheppali / blinking_led.c
Created August 25, 2017 12:51
blink task on esp32
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
void blink_task(void *pvParameter)
{
//GPIO_NUM_16 is G16 on board
gpio_set_direction(GPIO_NUM_16,GPIO_MODE_OUTPUT);
@sankarcheppali
sankarcheppali / AndroidManifest.xml
Created July 1, 2017 10:35
Android Connecting WiFi programmatically
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="example.siva.com.hellokotlin">
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE">
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">
</uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE">
</uses-permission>
<application
@sankarcheppali
sankarcheppali / MainActivity.kt
Created July 1, 2017 10:26
Connecting WiFi programmatically
package example.siva.com.hellokotlin
import android.content.BroadcastReceiver
import android.content.Context
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import kotlinx.android.synthetic.main.activity_main.*
import org.jetbrains.anko.toast
import android.net.wifi.WifiConfiguration
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="example.siva.com.hellokotlin.MainActivity">
<Button
android:id="@+id/helloMe"
package example.siva.com.hellokotlin
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import org.jetbrains.anko.toast
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
local function consume_data( payload )
--we will parse the payload and excute it,publish the return value
print(payload)
msg=cjson.decode(payload)
loadNumber=msg.ln
targetStatus=msg.ts
if(targetStatus==0) then loadStatus=bit.clear(loadStatus,loadNumber)
else loadStatus = bit.set(loadStatus,loadNumber) end
serialOut(loadStatus)
print ("Status of the loads : ")
@sankarcheppali
sankarcheppali / ShiftOut
Created June 16, 2017 06:22
The following function can push 16 bits of data to the shift registers (assuming two shifts registers cascaded)
serOut=2 --SER pin
clk=1 --shift register clock (SRCLK)
latch=3 -- Storage register clock (RCLK)
loadStatus=0 --use only 16 bits
gpio.mode(clk,gpio.OUTPUT)
gpio.mode(serOut,gpio.OUTPUT)
gpio.mode(latch,gpio.OUTPUT)
local function sendClk()
#Load a cascade file for detecting faces
face_cascade = cv2.CascadeClassifier('/home/pi/Desktop/opencv/haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('/home/pi/Desktop/opencv/haarcascade_eye.xml')
#Convert to grayscale
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
#Look for faces in the image using the loaded cascade file
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
import io
import picamera
import cv2
import numpy
#Create a memory stream so photos doesn't need to be saved in a file
stream = io.BytesIO()
#Get the picture (low resolution, so it should be quite fast)
#Here you can also specify other parameters (e.g.:rotate the image)