Skip to content

Instantly share code, notes, and snippets.

View nkenna's full-sized avatar

Ugwumsinachi Nnadi nkenna

  • Abuja
View GitHub Profile
@nkenna
nkenna / gist:9287033c22364407c9450b07b4e72945
Created August 28, 2017 11:09
fillables in Worker model
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Worker extends Authenticatable
{
@nkenna
nkenna / Webview Video
Last active June 21, 2018 08:31
Code snippet on webview video streaming
private WebView webSurface;
String vidAddress = "http://192.168.43.25/view";
........
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
.........
//pubnub channels
String GARAGE_DOOR = "GARAGE_DOOR";
String FRONT_DOOR = "FRONT_DOOR";
String CAMERA = "CAMERA";
.........
// payloads
@nkenna
nkenna / Pubnub Publish and Subcribe threads
Created June 21, 2018 08:49
Pubnub Publish and Subscribe thread
.................
PubConSubThread pubConSubThread;//connect and subscribe
PubPublishThread pubPublishThread;//Publish
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@nkenna
nkenna / Request for Data on Startup
Created June 21, 2018 09:26
Code snippet: Requesting for Data on Startup
..........
//payloads
String sensors_Data = "get data";
else if (status.getCategory() == PNStatusCategory.PNConnectedCategory){
pp.pubnubPublish(sensors_Data, SENSORS);
if (status.getCategory() == PNStatusCategory.PNConnectedCategory){
connectProgress(Color.GREEN, "Connected");
@nkenna
nkenna / Seperate Process
Created June 21, 2018 09:40
Creating seperate process for while loop
import multiprocessing
def continueScript():
try:
while True:
sleep(0.3)
except KeyboardInterrupt:
# stop all servos
CServo.stop_servo(pinCServo)
@nkenna
nkenna / Lights controlled by PWM
Last active June 21, 2018 09:48
Lights controlled by PWM
import RPi.GPIO as GPIO
from numpy import interp
p = GPIO.PWM(pinNetwork, 50) # set Frequece to 1KHz
p.start(0)
bedroom = GPIO.PWM(pinBedroomLight, 50) # set Frequece to 1KHz
bedroom.start(0)
sittingroom = GPIO.PWM(pinSittingRoomLight, 50) # set Frequece to 1KHz
@nkenna
nkenna / controlling and tracking Servo position
Created June 21, 2018 09:59
controlling and tracking Servo position
from RPIO import PWM
CServo = PWM.Servo()
# move servo to your desired default position and give it time to arrive there
CServo.set_servo(pinCServo, 1500)
sleep(1)
fDoorServo = PWM.Servo()
@nkenna
nkenna / Mption sensors
Created June 21, 2018 10:06
motion sensors events
def garageMotion(pinPIR_garage):
if sm.securityStatus:
if GPIO.input(pinPIR_garage):
print('pinPIR_garage motion detected')
GPIO.output(pinAlarm , GPIO.HIGH)
GPIO.output(pinGarageLight, GPIO.HIGH)
sleep(1)
CServo.set_servo(pinCServo, 1500)
pubnub.publish().channel(SENSORS).message(MOTION_PIR2).async(my_publish_callback)
// Create Gpio Controller
GpioController gpio = GpioFactory.getInstance();