This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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?) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 : ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import numpy | |
import cv2 | |
face_cascade = cv2.CascadeClassifier('/home/pi/Desktop/opencv/haarcascade_frontalface_default.xml') | |
eye_cascade = cv2.CascadeClassifier('/home/pi/Desktop/opencv/haarcascade_eye.xml') | |
img = cv2.imread('sachin.jpg') | |
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | |
faces = face_cascade.detectMultiScale(gray, 1.3, 5) | |
for (x,y,w,h) in faces: | |
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |