Beispiel #1
0
    def __init__(self):

        if gv.IS_DEBIAN:
            self.thread_sleep = 0.1
        else:
            self.thread_sleep = 0.2

        self.timeout_init = 3  # 3 sec
        self.timeout_init /= self.thread_sleep  # Adjust according to while loop sleep time
        self.timeout = self.timeout_init
        self.display_called = False

        if (gv.USE_HD44780_16x2_LCD or gv.USE_HD44780_20x4_LCD
                or gv.USE_I2C_16X2DISPLAY) and gv.IS_DEBIAN:

            import lcdcustomchars as lcdcc
            import RPi.GPIO as GPIO
            from RPLCD import CharLCD

            if (gv.USE_HD44780_16x2_LCD or gv.USE_HD44780_20x4_LCD):
                self.lcd = CharLCD(pin_rs=gv.GPIO_LCD_RS,
                                   pin_rw=None,
                                   pin_e=gv.GPIO_LCD_E,
                                   pins_data=[
                                       gv.GPIO_LCD_D4, gv.GPIO_LCD_D5,
                                       gv.GPIO_LCD_D6, gv.GPIO_LCD_D7
                                   ],
                                   numbering_mode=GPIO.BCM,
                                   cols=gv.LCD_COLS,
                                   rows=gv.LCD_ROWS,
                                   charmap='A00')

            elif (gv.USE_I2C_16X2DISPLAY):
                self.lcd = CharLCD('PCF8574', gv.I2C_16x2DISPLAY_ADDR)

            self.lcd.create_char(1, lcdcc.block)
            self.lcd.create_char(2, lcdcc.arrow_right_01)
            self.lcd.create_char(3, lcdcc.voice_button_on)
            self.lcd.create_char(4, lcdcc.voice_button_off)

        if (gv.USE_HD44780_16x2_LCD
                or gv.USE_HD44780_20x4_LCD) and gv.SYSTEM_MODE == 2:

            self.STRING_1 = ''
            self.STRING_2 = ''

        self.LCDThread = threading.Thread(target=self.lcd_main)
        self.LCDThread.daemon = True
        self.LCDThread.start()
Beispiel #2
0
def main():
    lcd = CharLCD(numbering_mode=GPIO.BOARD,
                  cols=16,
                  rows=2,
                  pin_rs=37,
                  pin_e=35,
                  pins_data=[33, 31, 29, 23])
    lcd.clear()
    lcd.cursor_pos = (0, 0)
    lcd.write_string(u'Scannez un tube')
    code = ''
    GPIO.setup(3, GPIO.IN)
    GPIO.add_event_detect(3, GPIO.BOTH, callback=close)

    while (True):
        inkey = Getch()
        k = inkey()

        if ord(k) == 27:
            GPIO.cleanup()
            call(['shutdown', 'now'])
            #quit()
        elif k == '\r':
            lcd.clear()
            lcd.cursor_pos = (0, 0)
            lcd.write_string(code)
            sleep(5)
            code = ''
            lcd.cursor_pos = (0, 0)
            lcd.write_string(u'Scannez un tube')

        elif k != '':
            code += k
def main(BUS_STOP_CODE):
    lcd = CharLCD(cols=16,
                  rows=2,
                  pin_rs=37,
                  pin_e=35,
                  pins_data=[33, 31, 29, 23],
                  numbering_mode=GPIO.BOARD)

    bus_api = DatamallApiClient()

    while True:
        buses = bus_api.bus_at_busstop_code(BUS_STOP_CODE)
        for bus_num, bus_timings in buses.items():
            display_string = ''
            if len(bus_timings) == 0:
                display_string = f"Bus {bus_num}: NOT\r\nAVAILABLE"
            if len(bus_timings) == 1:
                display_string = f"Bus {bus_num}: {bus_timings[0]}\r\nLAST BUS"
            if len(bus_timings) == 2:
                display_string = f"Bus {bus_num}: {bus_timings[0]}\r\n{bus_timings[1]}"
            if len(bus_timings) == 3:
                display_string = f"Bus {bus_num}: {bus_timings[0]}\r\n{bus_timings[1]}, {bus_timings[1]}"

            #print(display_string)
            lcd.clear()
            time.sleep(1)  # to make change in info visible in screen
            lcd.write_string(display_string)
            time.sleep(5)

        time.sleep(
            5
        )  # in case of no items, do not send request in loop so fast to DatamallApi.
Beispiel #4
0
    def __init__(self):

        if gv.SYSTEM_MODE == 1 and (gv.USE_HD44780_16x2_LCD or gv.USE_HD44780_20x4_LCD):

            # Timing constants
            self.E_PULSE = 0.0005
            self.E_DELAY = 0.0005

            self.display_called = False
            self.temp_display = False

            if gv.IS_DEBIAN:
                self.thread_sleep = 0.05
            else:
                self.thread_sleep = 0.1

            self.timeout_init = 2  # default timeout reset time
            self.timeout_length = self.timeout_init  # initial timeout length (timeout_custom will override)

            self.STRING_1 = ''
            self.STRING_2 = ''
            self.STRING_3 = ''
            self.STRING_4 = ''
            self.STRING_1_PRIORITY = ''
            self.STRING_2_PRIORITY = ''
            self.STRING_3_PRIORITY = ''
            self.STRING_4_PRIORITY = ''

            self.loop_alive = True

            if gv.IS_DEBIAN:
                import RPi.GPIO as GPIO
                from RPLCD import CursorMode
                from RPLCD import CharLCD

                self.lcd = CharLCD(pin_rs=gv.GPIO_LCD_RS, pin_rw=None, pin_e=gv.GPIO_LCD_E,
                                   pins_data=[gv.GPIO_LCD_D4, gv.GPIO_LCD_D5, gv.GPIO_LCD_D6, gv.GPIO_LCD_D7],
                                   numbering_mode=GPIO.BCM, cols=gv.LCD_COLS, rows=gv.LCD_ROWS, charmap='A00')

                self.lcd.clear()

                # Hide the cursor
                self.lcd._set_cursor_mode(CursorMode.hide)

                # Fill the display with blank spaces
                for i in xrange(1, gv.LCD_ROWS+1):
                    self.lcd_string(' ', i)

                # Write custom codes to the LCD
                self.lcd.create_char(1, lcdcc.block)
                self.lcd.create_char(2, lcdcc.pause)
                self.lcd.create_char(3, lcdcc.voice_button_on)
                self.lcd.create_char(4, lcdcc.voice_button_off)
                self.lcd.create_char(5, lcdcc.block2)
                self.lcd.create_char(6, lcdcc.loading_hour_glass)

        self.LCDThread = threading.Thread(target=self.lcd_main)
        self.LCDThread.daemon = True
        self.LCDThread.start()
Beispiel #5
0
    def __init__(self):
        """Initialize the nRF24 radio and the Raspberry Pi"""

        self.state = IDLE                            # current state
        self.lcd = None                              # LCD
        self.radio = None                            # nRF24 radio
        self.address = None                          # address of Cherry keyboard (CAUTION: Reversed byte order compared to sniffer tools!)
        self.channel = 6                             # used ShockBurst channel (was 6 for all tested Cherry keyboards)
        self.payloads = []                           # list of sniffed payloads
        self.kbd = None                              # keyboard for keystroke injection attacks

        try:
            # disable GPIO warnings
            GPIO.setwarnings(False)

            # initialize LCD
            self.lcd = CharLCD(cols=16, rows=2, pin_rs=15, pin_rw=18, pin_e=16, pins_data=[21, 22, 23, 24])
            self.lcd.clear()
            self.lcd.home()
            self.lcd.write_string(APP_NAME)
            self.lcd.cursor_pos = (1, 0)
            self.lcd.write_string(SYSS_BANNER)

            # use Raspberry Pi board pin numbers
            GPIO.setmode(GPIO.BOARD)

            # set up the GPIO pins
            GPIO.setup(RED_LED, GPIO.OUT, initial = GPIO.LOW)
            GPIO.setup(GREEN_LED, GPIO.OUT, initial = GPIO.LOW)
            GPIO.setup(BLUE_LED, GPIO.OUT, initial = GPIO.LOW)
            GPIO.setup(RECORD_BUTTON, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
            GPIO.setup(REPLAY_BUTTON, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
            GPIO.setup(ATTACK_BUTTON, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
            GPIO.setup(SCAN_BUTTON, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)

            # set callcack functions
            GPIO.add_event_detect(RECORD_BUTTON, GPIO.RISING, callback = self.buttonCallback, bouncetime = 250)
            GPIO.add_event_detect(REPLAY_BUTTON, GPIO.RISING, callback = self.buttonCallback, bouncetime = 250)
            GPIO.add_event_detect(ATTACK_BUTTON, GPIO.RISING, callback = self.buttonCallback, bouncetime = 250)
            GPIO.add_event_detect(SCAN_BUTTON, GPIO.RISING, callback = self.buttonCallback, bouncetime = 250)

            # initialize radio
            self.radio = nrf24.nrf24()

            # enable LNA
            self.radio.enable_lna()

            # show startup info for some time with blinkenlights
            self.blinkenlights()

            # start scanning mode
            self.setState(SCAN)
        except:
            # error when initializing Radio Hack Box
            self.lcd.clear()
            self.lcd.home()
            self.lcd.write_string(u"Error: 0xDEAD")
            self.lcd.cursor_pos = (1, 0)
            self.lcd.write_string(u"Please RTFM!")
Beispiel #6
0
 def __init__(self):
     self.activated = False
     self.lcd = CharLCD(cols=16,
                        rows=2,
                        pin_rs=6,
                        pin_e=5,
                        pins_data=[13, 19, 26, 1],
                        numbering_mode=GPIO.BCM)
Beispiel #7
0
	def __init__(self,cols=16,rows=2):
		self.cols,self.rows= cols,rows
		self.blink=False
		self.data=None
		self.data_name=None
		self.time_last_packet=0
		self.recieve_timeout=None
		GPIO.setmode(GPIO.BCM)
		self.screen = CharLCD(numbering_mode=GPIO.BCM,cols=self.cols, rows=self.rows, pin_rs=16, pin_e=18, pins_data=[23, 24, 2, 3])
Beispiel #8
0
def initLCD():
    lcd = CharLCD(cols=24,
                  rows=2,
                  pin_rs=26,
                  pin_e=24,
                  pins_data=[16, 18, 22, 8],
                  numbering_mode=GPIO.BOARD)
    biglcd.createLcdCustomChar(lcd)
    return lcd
    def __init__(self):

        self.code = None
        self.start_time = time.time()
        self.send_to_db = False
        self.delete_wait_time = 5

        # for BCM Mode
        # lcd_rs = 25
        # lcd_en = 24
        # lcd_d4 = 23
        # lcd_d5 = 17
        # lcd_d6 = 18
        # lcd_d7 = 22
        # lcd_backlight = 4

        # for Board Mode
        lcd_rs = 22
        lcd_en = 18
        lcd_d4 = 16
        lcd_d5 = 11
        lcd_d6 = 12
        lcd_d7 = 15
        lcd_backlight = 4

        # Define LCD column and row size for 16x2 LCD.
        lcd_columns = 16
        lcd_rows = 2

        self.lcd = CharLCD(cols=lcd_columns,
                           rows=lcd_rows,
                           pin_rs=lcd_rs,
                           pin_e=lcd_en,
                           pins_data=[lcd_d4, lcd_d5, lcd_d6, lcd_d7],
                           numbering_mode=GPIO.BOARD)
        self.lcd.clear()

        self.db = MongoDB()

        GPIO.setmode(GPIO.BOARD)
        self.red_light = 40
        self.green_light = 37
        self.buzzer = 38
        self.button_remove = 32

        GPIO.setup(10, GPIO.IN,
                   pull_up_down=GPIO.PUD_DOWN)  # button for delete
        GPIO.setup(self.green_light, GPIO.OUT)  # Green Light
        GPIO.setup(self.red_light, GPIO.OUT)  # Red Light
        GPIO.setup(self.buzzer, GPIO.OUT)  # Buzzer
        GPIO.setup(self.button_remove, GPIO.IN,
                   pull_up_down=GPIO.PUD_DOWN)  # button for remove

        GPIO.add_event_detect(10, GPIO.RISING, callback=self.button_callback)
        GPIO.add_event_detect(self.button_remove,
                              GPIO.RISING,
                              callback=self.remove_item)
Beispiel #10
0
 def setup(self):
     GPIO.setmode(GPIO.BCM)
     self.lcd = CharLCD(cols=16,
                        rows=2,
                        pin_rs=6,
                        pin_e=5,
                        pins_data=[13, 19, 26, 1],
                        numbering_mode=GPIO.BCM)
     self.lcd.cursor_mode = 'hide'
     print("Display setup finished")
Beispiel #11
0
def main():
    # initialize lcd screen
    lcd = CharLCD(cols=16,
                  rows=2,
                  pin_rs=37,
                  pin_e=35,
                  pins_data=[33, 31, 29, 23])

    # DHT22 sensor is only accurate to +/- 2% humidity and +/- 0.5 celsius
    # Poll 10 times and calculate median to get more accurate value
    templist = []
    humidlist = []

    lcd.cursor_pos = (0, 0)
    lcd.write_string("Polling...")
    lcd.cursor_pos = (1, 0)
    bar = "[----------]"
    lcd.write_string(bar)
    lcd.clear()

    for i in range(1, 11):
        data = poll()

        lcd.cursor_pos = (0, 0)
        lcd.write_string("Polling....")
        lcd.cursor_pos = (1, 0)

        bar = list(bar)
        bar[i] = '#'
        bar = ''.join(bar)
        lcd.write_string(bar)

        # Don't poll more often than every 2 seconds
        sleep(3)
        lcd.clear()
        temp = int(round(data[0]))
        humid = int(round(data[1]))
        templist.append(temp)
        humidlist.append(humid)

    lcd.clear()

    # Calculate median value
    temp = (sorted(templist))[5]
    humid = (sorted(humidlist))[5]

    # Display results to LCD
    display(lcd, temp, humid)

    # Write data to CSV file for later analysis
    write_data(temp, humid)

    # Clears the screen / resets cursor position and closes connection
    lcd.clear()
    lcd.close(clear=True)
Beispiel #12
0
def write_to_lcd(ifname):

    lcd = CharLCD()

    lcd.clear()
    lcd.home()
    lcd.write_string(get_hostname())
    lcd.cursor_pos = (1, 0)
    lcd.write_string(get_device_type())
    lcd.cursor_pos = (2, 0)
    lcd.write_string(get_ip_address(ifname))
def getDefaultLCD():
    # Setup 16x2 LCD
    lcd = CharLCD(cols=16,
                  rows=2,
                  pin_rs=15,
                  pin_e=16,
                  pins_data=[36, 33, 31, 29],
                  numbering_mode=GPIO.BOARD,
                  auto_linebreaks=True,
                  charmap="A02")
    return lcd
Beispiel #14
0
def lcd_init():
    global lcd
    pin_rs = 21  # Board: 40
    pin_e = 20  # Board: 38
    pins_data = [16, 26, 19, 13]  # Board: 36, 37, 35, 33
    lcd = CharLCD(numbering_mode=GPIO.BCM,
                  cols=16,
                  rows=2,
                  pin_rs=pin_rs,
                  pin_rw=None,
                  pin_e=pin_e,
                  pins_data=pins_data)
    lcd.clear()
Beispiel #15
0
def LCD_screen():
    while True:
        lcd = CharLCD(cols=16,
                      rows=2,
                      pin_rs=19,
                      pin_e=26,
                      numbering_mode=GPIO.BCM,
                      pins_data=[17, 27, 22, 5, 12, 25, 24, 23])
        string = (subprocess.check_output(["hostname",
                                           "-I"]).split()[1]).decode('ascii')
        lcd.write_string(f'{string}')
        time.sleep(30)
        lcd.clear()
Beispiel #16
0
def refresh():
    lcd = CharLCD(pin_rs=37,
                  pin_rw=22,
                  pin_e=35,
                  pins_data=[33, 40, 38, 36],
                  numbering_mode=GPIO.BOARD,
                  cols=16,
                  rows=2,
                  dotsize=8,
                  auto_linebreaks=True,
                  pin_backlight=None,
                  backlight_enabled=True,
                  backlight_mode=BacklightMode.active_low)
 def __init__(self,
              cols=16,
              rows=2,
              rs=37,
              e=35,
              data_pins=[33, 31, 29, 23],
              mode='BOARD'):
     GPIO.setwarnings(False)
     if mode == 'BCM':
         self.lcd = CharLCD(cols=cols,
                            rows=rows,
                            pin_rs=rs,
                            pin_e=e,
                            pins_data=data_pins,
                            numbering_mode=GPIO.BCM)
     else:
         self.lcd = CharLCD(cols=cols,
                            rows=rows,
                            pin_rs=rs,
                            pin_e=e,
                            pins_data=data_pins,
                            numbering_mode=GPIO.BOARD)
    def __post_init__(self) -> None:
        self.logger = logging.getLogger(__name__)

        self.logger.info("Initiating LCD")
        # Use compatibility mode to avoid driver timing issues https://github.com/dbrgn/RPLCD/issues/70
        self.lcd = CharLCD(compat_mode=True,
                           numbering_mode=GPIO.BCM,
                           cols=16,
                           rows=2,
                           pin_rs=22,
                           pin_e=17,
                           pins_data=[26, 19, 13, 6])
        self.lcd.cursor_mode = 'hide'
        self.lcd.clear()

        self.write_lock = Lock()
Beispiel #19
0
    def stop(self):
        App.logger.info("Requesting stop")
        self.lcd = CharLCD(cols=16,
                           rows=2,
                           pin_rs=11,
                           pin_e=5,
                           pins_data=[6, 13, 19, 26],
                           numbering_mode=GPIO.BCM)
        self.isRunning = False

        if self.ocv:
            self.ocv.stop()

        if self.cvp:
            self.cvp.stop()

        App.logger.info("Stop requested")
Beispiel #20
0
 def __init__(self, system, console=False):
     self.console = console
     if not on_rpi:
         self.console = True
     
     if self.console:
         lcd = None
     else:
         lcd = CharLCD(numbering_mode=GPIO.BCM,cols=16,rows=2,pin_rs=18,pin_e=23,pins_data=[24,25,12,16])
         
     self.display = LCDProxy(lcd=lcd)
     
     self.current_elem = build_menu(system.burner, system.temp, system.wifi_config)
     
     self.prev_menus = []
     
     self.update_display()
     self.event_queue = queue.Queue()
Beispiel #21
0
class HD44780Lcd(Lcd):

    _lines: list = ["", "", "", ""]
    _lcd = CharLCD(pin_rs=18,
                   pin_rw=23,
                   pin_e=24,
                   pins_data=[25, 8, 7, 12],
                   numbering_mode=GPIO.BCM,
                   cols=20,
                   rows=4,
                   dotsize=8)

    def write_line(self, num: int, value: str):
        self._lines[num] = value

    def flush(self):
        self._lcd.clear()
        for row, value in enumerate(self._lines):
            self._lcd.cursor_pos = (row, 0)
            self._lcd.write_string(value)
Beispiel #22
0
def main():

    iterations = 300
    interval = 0.1
    print("starting {} second collection".format(iterations * interval))

    sensor1 = SonicSensor(trig_pin=18, echo_pin=24, numbering_mode=GPIO.BCM)
    sensor2 = SonicSensor(trig_pin=16, echo_pin=12, numbering_mode=GPIO.BCM)
    lcd = CharLCD(numbering_mode=GPIO.BCM,
                  cols=16,
                  rows=2,
                  pin_rs=21,
                  pin_e=20,
                  pins_data=[5, 7, 8, 25, 26, 19, 13, 6])

    results1 = []
    results2 = []

    try:
        for i in range(iterations):
            dist1 = sensor1.get_distance()
            dist2 = sensor2.get_distance()

            results1.append(dist1)
            results2.append(dist2)

            lcd.write_string(u'%.1f cm' % dist2)
            print(u'%.1f cm' % dist2)
            lcd.write_string(u'\n%.1f cm' % dist1)
            print(u'%.1f cm' % dist1)

            time.sleep(interval)
            lcd.clear()

    except KeyboardInterrupt:
        pass

    GPIO.cleanup()

    with open('results.pickle', 'wb') as file:
        pickle.dump((results1, results2), file)
Beispiel #23
0
    def __init__(self):
        # hardcoded PINOUT
        self.sensor_left 	= SonicSensor(trig_pin=16, echo_pin=12, numbering_mode=GPIO.BCM)
        self.sensor_right 	= SonicSensor(trig_pin=18, echo_pin=24, numbering_mode=GPIO.BCM)
        self.lcd 		= CharLCD(numbering_mode=GPIO.BCM, cols=16, rows=2, pin_rs=21, pin_e=20, pins_data=[5,7,8,25,26,19,13,6])
        self.rotary 		= RotaryEncoder(dt_pin=3, clk_pin=4, lower_limit=0, upper_limit=40)
        self.button 		= Button(pin=2)

        # parameters for filtering and smoothing
        # self.interval	= ??	# 
        self.window 	= 30    # for filters and running smoother
        self.threshold 	= 3  	# for filters
        self.weight 	= .3    # for exponential smoother
        self.iterations = 3    # for exponential smoother
        self.lag        = 10 	# for peak detection. Probably not needed as using a simple peak detector
        
        # memory for both sensors
        self.raw_data_left  = deque([-1]*self.window, maxlen=self.window)
        self.raw_data_right = deque([-1]*self.window, maxlen=self.window)
        self.data_left  = deque([-1]*self.window, maxlen=self.window)
        self.data_right = deque([-1]*self.window, maxlen=self.window)


        # parameters and variables for tide
        self.initial_water_level        = -1    # mean measured from past hour
        self.initial_median_dist        = 0     # man measured distance from past readings
        self.current_median_dist        = 0     # 
        self.tide_window                = 1001
        self.points_for_median_dist     = deque(maxlen=self.tide_window)   # used for adding points to running average
        
        # parameters and variables for speed
        self.sensor_spacing     = 10    # cm 
        self.delay              = .3    # time to do one iteration
        self.left_peak          = False
        self.counter            = -1    # used as unit of time

        # misc
        self.calibration_delay = 0  # s   time used after setting water level to move sensor into place
        self.line2 = u'Wave: None'
Beispiel #24
0
    def __init__(self,
                 rsPin,
                 enPin,
                 d4Pin,
                 d5Pin,
                 d6Pin,
                 d7Pin,
                 boardNum=GPIO.BCM,
                 rwPin=None,
                 cols=16,
                 rows=2,
                 warnings=False):

        if warnings is False:
            GPIO.setwarnings(False)

        self.cols = cols
        self.rows = rows

        self.firstRun = True

        self.lcd = CharLCD(cols=cols,
                           rows=rows,
                           pin_rw=rwPin,
                           pin_rs=rsPin,
                           pin_e=enPin,
                           pins_data=[d4Pin, d5Pin, d6Pin, d7Pin],
                           numbering_mode=boardNum)

        self.lcdmem = self._generate_lcd_memory()
        self.curpos = [0, 0]  # [row, column]

        self._warm_up_display()

        sleep(1)
        self.lcd.clear()
        sleep(1)
Beispiel #25
0
def main():
    try:
        rotary = RotaryEncoder(dt_pin=3, clk_pin=4)
        rotary.start()
        button = Button(pin=2)
        lcd = CharLCD(numbering_mode=GPIO.BCM,
                      cols=16,
                      rows=2,
                      pin_rs=21,
                      pin_e=20,
                      pins_data=[5, 7, 8, 25, 26, 19, 13, 6])
        while True:
            if button.pressed():
                break
            lcd.clear()
            lcd.write_string(u'{}'.format(rotary.get_count()))
            time.sleep(0.1)

    except KeyboardInterrupt:  # Ctrl-C to terminate the program
        pass

    print("stopped at {}".format(rotary.get_count()))
    rotary.stop()
    GPIO.cleanup()
Beispiel #26
0
    def reboot_algorithm(self):
        CVProcessor.logger.info("Rebooting...")

        self.working_lock.acquire()

        self.car_names = {}
        self.tracker = Tracker()
        self.count = 0
        self.colors = {}
        self.times = {}
        self.car_detected_count = {}
        self.car_detected_names = {}
        self.last_reboot = time.time()
        self.working_lock.release()
        self.lcd = CharLCD(cols=16,
                           rows=2,
                           pin_rs=11,
                           pin_e=5,
                           pins_data=[6, 13, 19, 26],
                           numbering_mode=GPIO.BCM)
        self.lcd.clear()
        self.lcd.write_string(u'Running..')
        GPIO.output(CVProcessor.output_pin, GPIO.LOW)
        GPIO.output(CVProcessor.output_pin_puerta, GPIO.LOW)
Beispiel #27
0
from threading import Thread, Lock
from sets import Set
from picamera import PiCamera
import qrtools
import requests
from apscheduler.schedulers.background import BackgroundScheduler
import logging
import sys
from RPLCD import CharLCD
import RPi.GPIO as GPIO

lcd = CharLCD(pin_rs=4,
              pin_rw=18,
              pin_e=17,
              pins_data=[18, 22, 23, 24],
              numbering_mode=GPIO.BCM,
              cols=16,
              rows=2,
              dotsize=8,
              auto_linebreaks=True)

logging.basicConfig()
syncInterval = 5.0
syncFile = 'workspace/sync.txt'

queuedMessages = Set([])
submittedMessages = Set([])

qr = qrtools.QR()
offlineMode = False
syncMutex = Lock()
Beispiel #28
0
import os
import glob
import time
from RPLCD import CharLCD

lcd = CharLCD(cols=16, rows=2, pin_rs=22, pin_e=18, pins_data=[16, 11, 40, 15])

os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')

base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'


def read_temp_raw():
    f = open(device_file, 'r')
    lines = f.readlines()
    f.close()
    return lines


#CELSIUS CALCULATION
def read_temp_c():
    lines = read_temp_raw()
    while lines[0].strip()[-3:] != 'YES':
        time.sleep(0.2)
        lines = read_temp_raw()
    equals_pos = lines[1].find('t=')
    if equals_pos != -1:
        temp_string = lines[1][equals_pos + 2:]
Beispiel #29
0
    elif 'server.py' in files:
        device_type = 'server'
    else:
        device_type = 'unknown'
    device_type = 'type: ' + device_type
    return device_type


framebuffer = [
    get_hostname(),
    get_device_type(),
    get_ip_address('eth0'),
    '',
]

lcd = CharLCD()

process = Process()
thread_stop_event = Event()


def write_to_lcd(lcd, framebuffer, num_cols):
    lcd.home()
    #lcd.clear()
    for row in framebuffer:
        lcd.write_string(row.ljust(num_cols)[:num_cols])
        lcd.write_string('\r')


def loop_string(string, lcd, framebuffer, row, num_cols, delay=0.5):
    padding = ' ' * num_cols
Beispiel #30
0
from RPLCD import CharLCD
import RPi.GPIO as GPIO
import time

from pad4pi import rpi_gpio


pins_data=[9, 10, 22, 21]
pins_data2=[21,22,10,9]
pin_e=11
pin_rs=7

GPIO.setmode(GPIO.BCM)
GPIO.setup(pin_rs, GPIO.OUT)
GPIO.setup(pin_e, GPIO.OUT)
for pin in pins_data:
    GPIO.setup(pin, GPIO.OUT)
    GPIO.output(pin, True)

lcd = CharLCD(cols=16, rows=2, pin_rs=7, pin_e=11, pins_data=[9, 10, 21, 22], numbering_mode=GPIO.BCM)

lcd.cursor_pos = (0,0)
lcd.write_string(u'Pinjam/Kembali?')
lcd.cursor_pos = (1,0)
lcd.write_string(u'1:P 2:K 3:Back')
time.sleep(5)
lcd.clear()
GPIO.cleanup()