Skip to content

Instantly share code, notes, and snippets.

View codelectron's full-sized avatar

codelectron

View GitHub Profile
@codelectron
codelectron / first.py
Last active March 15, 2019 14:16
This luma oled example code is part of the article http://codelectron.com/setup-oled-display-raspberry-pi-python/
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
import time
serial = i2c(port=1, address=0x3C)
device = ssd1306(serial, rotate=0)
# Box and text rendered in portrait mode
with canvas(device) as draw:
@codelectron
codelectron / pixels.py
Last active April 14, 2018 18:36
This luma oled example code is part of the article http://codelectron.com/setup-oled-display-raspberry-pi-python/
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
import time
serial = i2c(port=1, address=0x3C)
device = ssd1306(serial, rotate=0)
# Box and text rendered in portrait mode
with canvas(device) as draw:
@codelectron
codelectron / lineoled.py
Last active April 14, 2018 18:35
This luma oled example code is part of the article http://codelectron.com/setup-oled-display-raspberry-pi-python/
from PIL import ImageFont, ImageDraw
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
import time
serial = i2c(port=1, address=0x3C)
device = ssd1306(serial, rotate=0)
# Box and text rendered in portrait mode
@codelectron
codelectron / hellofontoled.py
Last active April 14, 2018 18:35
This luma oled example code is part of the article http://codelectron.com/setup-oled-display-raspberry-pi-python/
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
import time
from PIL import ImageFont, ImageDraw
serial = i2c(port=1, address=0x3C)
device = ssd1306(serial, rotate=0)
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO_TRIGGER = 23
GPIO_ECHO = 24
GPIO.setup(GPIO_TRIGGER, GPIO.OUT)
GPIO.setup(GPIO_ECHO, GPIO.IN)
import RPi.GPIO as GPIO
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
import time
GPIO.setmode(GPIO.BCM)
GPIO_TRIGGER = 23
GPIO_ECHO = 24
import RPi.GPIO as GPIO
import pyaudio
from numpy import linspace,sin,pi,int16
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
import time
RATE = 4400
FREQ = 261.6
from RPi import GPIO
from time import sleep
clk = 17
dt = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(clk, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(dt, GPIO.IN, pull_up_down=GPIO.PUD_UP)
counter = 0
clkLastState = GPIO.input(clk)
from RPi import GPIO
from time import sleep
clk = 17
dt = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(clk, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(dt, GPIO.IN, pull_up_down=GPIO.PUD_UP)
from RPi import GPIO
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
from time import sleep
import socket
import sys_info
clk = 17
dt = 18