Beispiel #1
0
def main():
    try:
        # init UDP socket
        UDP_IP = ''  # recieve from all IPs
        UDP_PORT = 8008
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sock.bind((UDP_IP, UDP_PORT))
        print('Bind UDP socket on %d' % UDP_PORT)

        # init control object for OLED display
        oled = OLED(rst=24, i2c_addr=0x3C)
        oled.on()  # turn on display
        # set font face and size
        """
        for font face you can use the path of your ttf file(just with name if in current dir)
        or you can use truetype fonts in /usr/share/fonts/truetype
        """
        oled.set_text_style('FreeMono.ttf', fontsize=20, position=(10, 10))
        print('OLED init finished')

        # --- recieve loop ---
        while True:
            data, addr = sock.recvfrom(1024)
            oled.display_text(data)  # display text on OLED

    except KeyboardInterrupt:
        print('\nKeyboardInterrupt, exit')
        oled.off()  # turn off display
        exit(0)

    finally:
        # turn off display
        oled = OLED(rst=24, i2c_addr=0x3C)
        oled.off()
        exit(0)
Beispiel #2
0
    def __init__(self):
        print('Loading the ForkPi database...')
        self.db = ForkpiDB()

        print('Loading options...')
        attempt_limit = self.load_option('attempt_limit')
        lockout_time = self.load_option('lockout_time_minutes')
        self.lockout_table = LockoutTable(attempt_limit, lockout_time)
        self.keypad_timeout = self.load_option('keypad_timeout_seconds')
        self.max_transaction_time = self.load_option(
            'max_transaction_time_seconds')
        self.lock_release_time = self.load_option('lock_release_time_seconds')

        print('Loading (F)ingerprint Scanner...')
        self.fingerprint_thread = FingerprintThread(lambda: ForkpiDB())
        print('Loading (O)LED...')
        self.led = OLED()
        print('Loading (R)FID Reader...')
        self.rfid_thread = RfidThread()
        print('Loading (K)eypad...')
        self.keypad_thread = KeypadThread()

        print('Connecting to (dummy) door lock...')
        self.door_lock = DoorLock()

        # maps RFID UIDs to incorrect streak and remaining lockout time
        self.transaction_timer = self.new_timer()

        # start polling for cards and fingers
        self.rfid_thread.start()
        self.fingerprint_thread.start()
        self.keypad_thread.start()
Beispiel #3
0
    def __init__(self, revision=1):
        # Connect to the display on /dev/i2c-1
        self.dis = OLED(revision)
        Graphics.clearLine = self._clearLine
        Font.print_string = _print_string

        # Start communication
        self.dis.begin()

        # Start basic initialization
        self.dis.initialize()

        # Do additional configuration
        self.dis.set_memory_addressing_mode(0)
        self.dis.set_column_address(0, 127)
        # Eight pages
        self.dis.set_page_address(0, 7)
        self.dis.set_scan_direction(0)
        self.dis.set_inverse_display(False)  # Black on white
        self.clear()
        self.stop_scroll()

        # Set font scale to 1
        self.f = Font(1)
        return
Beispiel #4
0
    def __init__(self):
        root = Tk()
        root.geometry('480x320')
        # root.configure(bg = BG_COLOR)
        root.title('Synth GUI')
        # root.attributes("-fullscreen", True)

        self.oled = OLED(root)
        #self.oled.pack(fill=X)
        self.oled.pack()

        frame = ttk.Frame(root)
        frame.pack(side=BOTTOM, fill=X)

        ttk.Button(frame, text='aux').pack(side=LEFT)
        ttk.Button(frame, text='up').pack(side=LEFT)
        ttk.Button(frame, text='down').pack(side=LEFT)
        ttk.Button(frame, text='sel').pack(side=LEFT)
        ttk.Button(frame, text='quit', command=root.destroy).pack(side=LEFT)

        try:
            # Create server
            server = liblo.ServerThread(4001)

            self.oled.add_osc_methods(server)

            # Register a fallback for unhandled messages
            server.add_method(None, None, self.fallback)

            # Start server
            server.start()
        except liblo.ServerError as err:
            print(err)
            sys.exit()

        root.mainloop()
Beispiel #5
0
from oled import OLED
from oled import Font
from oled import Graphics

# Connect to the display on /dev/i2c-0
dis = OLED(0)

# Start communication
dis.begin()

# Start basic initialization
dis.initialize()

# Do additional configuration
dis.set_memory_addressing_mode(0)
dis.set_column_address(0, 127)
dis.set_page_address(0, 7)

# Clear display
dis.clear()

# Set font scale x2
f = Font(2)

# Print some large text
f.print_string(6, 0, "OLIMEX LTD")

# Change font to 5x7
f.scale = 1
f.print_string(0, 24, "MOD-OLED-128x64")
f.print_string(0, 32, "olimex.com")
Beispiel #6
0
# task3a.py

import time
from machine import Pin
from oled import OLED
from rotary_irq_esp import RotaryIRQ

oled = OLED()
oled.init_display()

r = RotaryIRQ(pin_num_clk=23,
              pin_num_dt=19,
              min_val=-100,
              max_val=100,
              reverse=True,
              range_mode=RotaryIRQ.RANGE_BOUNDED)

val_old = r.value()

while True:
    val_new = r.value()

    if val_old != val_new:
        val_old = val_new
        oled.draw_text(32, 32, "{:4d}".format(val_new), size=2, space=2)
        oled.display()
        time.sleep_ms(20)
Beispiel #7
0
 def __init__(self):
     self.bat = Battery()
     self.pisys = Pisys()
     self.oled = OLED()
     self.key = Key(self.keyCallback, self.shutdown)
     self.haha = 1
Beispiel #8
0
#           The authors shall not be liable for any loss or damage however caused.
#
# Adapted from hello world program from Olimex Limited, www.olimex.com
# See https://github.com/SelfDestroyer/pyMOD-OLED.git
#

from oled import OLED
from oled import Font
from oled import Graphics
import pdb, sys
import time, datetime
from time import strftime

#dis = OLED(0)  # Original Raspberry Pi only
# Connect to the display on /dev/i2c-1
dis = OLED(1)

# Start communication
#pdb.set_trace()
dis.begin()

# Start basic initialization
dis.initialize()

# Do additional configuration
dis.set_memory_addressing_mode(0)
dis.set_column_address(0, 127)
dis.set_page_address(0, 7)

# Clear display
dis.clear()
Beispiel #9
0
from oled import OLED  # load oled module from flash memory

oled = OLED()  # Instantiate an OLED object
oled.poweron()
oled.init_display()  # initialise the OLED display

#  Simple Hello world message
oled.draw_text(0, 0, 'Hello World!')  # each character is 6x8 pixels
oled.display()  # flush display# Write your code here :-)