Skip to content

Instantly share code, notes, and snippets.

View sourceperl's full-sized avatar

l.lefebvre sourceperl

  • Hauts-de-France
View GitHub Profile
@sourceperl
sourceperl / rpi_panel.py
Last active September 23, 2015 19:58
Manage a Rpi Panel with pygame and framebuffer interface
import os
import pygame
import time
import signal
#some const
BLACK = (0, 0, 0)
RED = (200, 0, 0)
WHITE = (255,255,255)
@sourceperl
sourceperl / tk_modbus_hmi.py
Created December 2, 2015 17:35
A little industrial HMI with a backgroung img and an overlay of modbus data
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from tkinter import *
from pyModbusTCP.client import ModbusClient
import time
# some const
SERVER_HOST = "192.168.0.64"
SERVER_PORT = 502
@sourceperl
sourceperl / lcd_clock.py
Created February 26, 2016 15:51
Clock on a Rpi with a 4x20 LCD on I2C port
#!/usr/bin/env python3
import time
import schedule
import RPi_I2C_LCD
# global var
lcd = RPi_I2C_LCD.LCD()
def update_lcd():
@sourceperl
sourceperl / sigfox.conf
Last active November 4, 2016 17:31
RPISIGFOX board with PLC modbus export (+ min/max/avg stats)
[program:sigfox]
command=sigfox_xxxxx.py
user=pi
directory=/home/pi/
autostart=true
autorestart=false
environment=PYTHONUNBUFFERED=1
@sourceperl
sourceperl / say_cpu_temp.py
Last active February 18, 2021 14:45
Text to speak software with espeak and mbrola. Test on Raspberry Pi2 (Raspbian/jessie) and Pi4 (Raspbian/buster).
#!/usr/bin/env python3
import os, time
while True:
with open('/sys/class/thermal/thermal_zone0/temp', 'r') as f:
cpu_temp = round(float(f.read()) / 1000)
os.system('espeak -v mb-fr1 -s 95 \'La température de la CPU est de %s degrés.\'' % cpu_temp)
time.sleep(2.0)
@sourceperl
sourceperl / track_cap.py
Created June 14, 2016 15:00
Track a water bottle cap view by USB cam (use Python2 with open_cv 2 and numpy)
import cv2
import numpy as np
# open_cv track test :
#
# track blue object and check there are in circle area
# for test: object is a blue water bottle cap (color H,S,V = 202 (101 after normalized, 64, 59)
# some class
@sourceperl
sourceperl / rpi_timelapse.py
Created June 24, 2016 16:13
Tool for timelapse with PiCamera on Raspberry Pi
#!/usr/bin/env python
# shoot jpg images at regular interval for timelapse (store to img/)
#
# build MPEG4 video with jpg files :
# ffmpeg -framerate 10 -i img/image%04d.jpg -c:v libx264 -r 10 video/timelapse.mp4
#or
# ffmpeg -framerate 2 -i img/image%04d.jpg video/timelapse2.mp4
import time
@sourceperl
sourceperl / add_usb_src_for_raspbian.sh
Created August 17, 2016 08:39
Create a new sources list for use APT with an USB source mirror
#!/bin/bash
# create a new sources list for use APT with this USB source mirror
USB_LIST=/etc/apt/sources.list.d/usb_source.list
# check root level
if [ $EUID -ne 0 ]
then
echo "This script must be run as root" 1>&2
exit 1
@sourceperl
sourceperl / cp2redis.py
Created October 18, 2016 08:56
CP modbus data to redis DB
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# retrieve modbus data from CP4900 device and store it to a redis DB
from pyHMI.DS_ModbusTCP import ModbusTCPDevice
from pyHMI.Tag import Tag
import redis
import time
@sourceperl
sourceperl / redis_test.php
Created November 2, 2016 11:57
Simple example of Redis usage with PHP
<!DOCTYPE html>
<?php
require 'Predis/Autoloader.php';
Predis\Autoloader::register();
$r = new Predis\Client();
?>
<html>
<head>
<title>Test REDIS</title>
</head>