Example #1
0
    def __init__(self):
        self.deploy_button = Button(DEPLOY_BUTTON_PORT, self.deploy)
        self.select_repo_next_button = Button(
            REPO_BUTTON_NEXT_PORT,
            lambda on: self.select_change('repo next', on))
        self.select_repo_prev_button = Button(
            REPO_BUTTON_PREV_PORT,
            lambda on: self.select_change('repo prev', on))
        self.select_pr_next_button = Button(
            PR_BUTTON_NEXT_PORT, lambda on: self.select_change('pr next', on))
        self.select_pr_prev_button = Button(
            PR_BUTTON_PREV_PORT, lambda on: self.select_change('pr prev', on))
        self.lcd = LCD()
        self.button_matchers = [
            NetworkInfo(self.lcd, LOG_IN_MESSAGE),
            RestartApp(self.lcd)
        ]

        self.selected_repo_index = 0
        self.selected_pr_index = 0
        self.repo_list = []
        self.pull_requests = []

        self.rfid = RFID(self.startup)
        self.listen_for_rfid()
Example #2
0
    def __init__(self, WS=False):
        L1 = LEnergy()
        L2 = Layout_EUR()
        L3 = LTemplate(image='tap-water1.jpg',
                       unit='Lit',
                       format_string="{}",
                       ppu=0.0011)
        L4 = LTemplate(image='gas_32x32.png',
                       unit="m" + u'\u00B3',
                       format_string="{0:.2f}",
                       ppu=0.80025)
        L5 = LTemplate(image='plug1.png',
                       unit='kW',
                       format_string="{0:.3f}",
                       ppu=0.24)
        L6 = LWeather()

        self.Layout = [L1, L2, L3, L4, L5, L6]  # Used when displaying
        self.L_SIZE = len(self.Layout)
        self.L_IDX = 0

        self.L1 = self.Layout[0]  # Ref used when updating data
        self.L2 = self.Layout[1]  # Eur
        self.L3 = self.Layout[2]  # Water
        self.L4 = self.Layout[3]  # Gas
        self.L5 = self.Layout[4]  # Electricity
        self.L6 = self.Layout[5]  # Weather

        L6.update()

        self.lcd = LCD(WS)
        self.draw_display()
Example #3
0
    def __init__(self, symbol: str) -> None:
        self.symbol = symbol

        print("init BTC ticker...")
        self.lcd = LCD()
        self.client = Client(api_key=API_KEY, api_secret=API_SECRET)

        # init screen
        self.lcd.clear()
        self.lcd.writeLine1("BTC / EUR")

        self.running: bool = False
        self.currentPrice: float = 0
Example #4
0
class PyDMG:
    def __init__(self,
                 boot_romfile_path=None,
                 cartridge_romfile_path=None,
                 clocked=True,
                 renderer=False):
        self.last_cycle_start_time = 0
        self.total_clock_cycles_ran = 0
        self.clocked = clocked
        self.lcd = LCD()
        if renderer:
            self.renderer = LCDRenderer(self.lcd)
            self.lcd.renderer = self.renderer
        self.sound = Sound()
        self.memory = DMGMemory(self.lcd, self.sound, boot_romfile_path,
                                cartridge_romfile_path)
        self.lcd.memory = self.memory
        self.sound.memory = self.memory
        self.cpu = CPU(self.memory)

    # DMG CPU instructions take at least 4 clocks
    def cpu_step(self):
        self.clock()
        self.clock()
        self.clock()
        self.clock()
        while self.cpu.loaded_instruction_descriptor is not None:
            self.clock()

    def clock(self):
        if self.clocked:
            while self.time_since_last_cycle() < DMG_SECONDS_PER_CLOCK:
                time_to_sleep = DMG_SECONDS_PER_CLOCK - self.time_since_last_cycle(
                )
                if time_to_sleep > 0:
                    time.sleep(time_to_sleep)
            self.last_cycle_start_time = time.monotonic()
        # First increase, then run as first instruction needs cycles to run
        self.total_clock_cycles_ran += 1
        self.lcd.clock()
        if self.total_clock_cycles_ran % 4 == 0:
            self.cpu.tick()

    def time_since_last_cycle(self):
        time_since_last_cycle = time.monotonic() - self.last_cycle_start_time
        return time_since_last_cycle

    def run(self):
        while True:
            self.clock()
Example #5
0
    def __init__(self):
        self.BUTTON = Button(
            pin=11,
        )
        GPIO.setup(
            self.WAITING_PIN,
            GPIO.OUT,
        )

        self.LCD = LCD(
            pin_rs=4,
            pin_e=25,
            pins_d=[24,23,22,27],
        )

        self.TRAFFIC = Traffic(
            pin_red=14,
            pin_amber=3,
            pin_green=2,
            lcd=self.LCD,
            lcd_line=2,
        )

        self.RGB = RGB(
            pin_red=9,
            pin_green=10,
            pin_blue=15,
            lcd=self.LCD,
            lcd_line=3,
        )
        self.RGB.show_colour(self.RGB_MAX, self.RGB_MIN, self.RGB_MIN)
Example #6
0
	def do_test(self):
		self._lcd = LCD()
		self._lcd.init()

		rec = SpeechRec(debug = True)
		rec.start()
		rec.listen(self.callback, progress = self.progress)
Example #7
0
    def __init__(self):
        self.memory = Memory(width=16, depth=256)
        self.ext_port = LCD()

        def send_cmd(cmd):
            return [
                # Command: function set
                MOVL(R1, cmd),
                STX(R1, R0, 0),
                # Wait for busy flag to reset
                LDX(R1, R0, 0),
                CMP(R1, 0),
                JNZ(-3),
            ]

        self.memory.init = [
            *([0] * 8),
            *assemble([
                NOP(),
                NOP(),

                # Address for STX/LDX
                MOVL(R0, 0),

                # Command: function set
                *send_cmd(0b00111000),

                # Command: display on
                *send_cmd(0b00001110),

                # Command: entry mode set
                *send_cmd(0b00000110),

                # Command: clear display
                *send_cmd(0b00000001),

                # Print string
                # Address of string
                MOVL(R3, 44),
                'print_str',
                MOVH(R1, 1),
                LD(R2, R3, 0),
                CMP(R2, 0),
                JE('halt'),
                OR(R1, R1, R2),
                STX(R1, R0, 0),

                # Wait for busy flag to reset
                LDX(R1, R0, 0),
                CMP(R1, 0),
                JNZ(-3),
                ADDI(R3, 1),
                J('print_str'),
                'halt',
                J('halt'),
                'str',
            ]),
            *[ord(c) for c in 'Hello, boneless!'],
            0
        ]
Example #8
0
def load_flow_handler():
    prevButton = Button("prevbutton", 21, 26)
    nextButton = Button("nextbutton", 17, None)
    okButton = Button("okButton", 6, 8)
    spdt = SPDT("spdt", 4, 27)
    lcd = LCD(rs=16, en=14, d4=25, d5=11, d6=23, d7=22, bl=19)
    return PhysicalFlowHandler(prevButton, nextButton, okButton, spdt, lcd)
Example #9
0
 def __init__(self,
              boot_romfile_path=None,
              cartridge_romfile_path=None,
              clocked=True,
              renderer=False):
     self.last_cycle_start_time = 0
     self.total_clock_cycles_ran = 0
     self.clocked = clocked
     self.lcd = LCD()
     if renderer:
         self.renderer = LCDRenderer(self.lcd)
         self.lcd.renderer = self.renderer
     self.sound = Sound()
     self.memory = DMGMemory(self.lcd, self.sound, boot_romfile_path,
                             cartridge_romfile_path)
     self.lcd.memory = self.memory
     self.sound.memory = self.memory
     self.cpu = CPU(self.memory)
Example #10
0
def main():
    try:
        lcd = LCD()
        lcd.send_text(get_home_conditions(), 1)
        lcd.send_text(get_weather(), 2)
        # sleep(30)
        # lcd.send_text(get_buses(), 2)
        # sleep(30)
    except Exception, e:
        print e
        lcd._clean_up()
        quit()
Example #11
0
def run(args):
    with open(args.cart, "rb") as fp:
        data = fp.read()
    cart = Cart(data)
    cpu = CPU(cart, debug=args.debug_cpu)

    lcd = None
    if not args.headless:
        lcd = LCD(cpu, debug=args.debug_gpu)

    running = True
    clock = 0
    while running:
        try:
            if not cpu.halt and not cpu.stop:
                clock += cpu.tick()
            else:
                clock += 4
            #if cpu.halt:
            #    print("CPU halted, waiting for interrupt")
            #    break
            #if cpu.stop:
            #    print("CPU stopped, waiting for button")
            #    break

        except OpNotImplemented as e:
            running = False
            # print(cpu)
            print(e, file=sys.stderr)
        except (Exception, KeyboardInterrupt) as e:
            running = False
            dump(cpu, str(e))

        # 4MHz / 60FPS ~= 70000 instructions per frame
        if clock > 70224 or clock > 1000:
            # print(last_frame - time.time())
            clock = 0
            if lcd and not lcd.update():
                running = False

    if lcd:
        lcd.close()
Example #12
0
def buttons():
    global thread_finished
    buttonShutdown = 11
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(buttonShutdown, GPIO.IN)

    while True:
        if (GPIO.input(buttonShutdown)):
            lcd = LCD()
            lcd.clear()
            lcd.begin(16,1)
            lcd.message("Reiniciando\nSistema...")
            sleep(2)
            lcd.clear()
            reboot()
    	sleep(4)
    thread_finished = True
Example #13
0
def main():
    try:
        lcd = LCD()
        lcd.blight(0)
    except Exception, e:
        print e
        lcd._clean_up()
        quit()
Example #14
0
def OnCommand(args):   
    if GetThermList(args) is not None:
        factory = ThermocoupleFactory()
        PrintList(factory.ListTypes(), "Supported thermocouple types")
    elif GetInterfaceList(args) is not None:
        factory = RelayInterfaceFactory()
        PrintList(factory.ListTypes(), "Supported interface types")
    else:
        kwargs = ArgsToDict(args)
        tcf = ThermocoupleFactory()       
        rif = RelayInterfaceFactory()
        _relay = rif.GetInstance(GetInterface(args), kwargs)
        _lcd = LCD()
        reflowCtl = ReflowStateMachine(
            reflowProfile = GetProfile(args),
            thermocouple = tcf.GetInstance(GetTherm(args), kwargs),
            relay = _relay,
            lcd = _lcd)
        try:
            reflowCtl.Reflow()
        except KeyboardInterrupt:
            _relay.SwitchRelay(RelayInterface.OFF)
        _lcd.Cleanup()
Example #15
0
class Test:
	def __init__(self):
		self._last_update = None

	def callback(self, text):
		print("[Message] %s" % text)

		return False	

	def progress(self, rec, chunk):
		now = time.time()

		if not self._last_update or (now - self._last_update) > 0.5:
			self._lcd.line2("%s %d/%d" % (('R' if rec.recording else ' '), rec._intensity(chunk), rec._silence_threshold))

			self._last_update = now

	def do_test(self):
		self._lcd = LCD()
		self._lcd.init()

		rec = SpeechRec(debug = True)
		rec.start()
		rec.listen(self.callback, progress = self.progress)
Example #16
0
def main():
   #Create unix pipe
   main_pipe, fingerpint_pipe = Pipe()
   LCD_IN, LCD_OUT = Pipe()
   
   # Initializes LCD and LED
   LCD.init()
   LED.init()
   # Create an object of the class Parser and Poller
   parser = Parser()
   poller = Poller(parser, fingerpint_pipe, 1)
   # Create child process
   pid = os.fork()

   # Parent process
   if pid:
      try:
         # start the individual threads for LCD, NFC and poller
         lcd_thread = threading.Thread(target=LCD.new_start, args=(LCD_IN,))
         lcd_thread.daeomon = True
         lcd_thread.start()
         nfc_thread = threading.Thread(target=nfcread.readNFC, args=(parser, fingerpint_pipe, LCD_OUT,))
         nfc_thread.daeomon = True
         nfc_thread.start()
         poll_thread = threading.Thread(target=poller.startPolling)
         poll_thread.daeomon = True
         poll_thread.start()
      except:
         print "Error: unable to start thread"
      try:
         # Poll fingerprint pipe
         while 1:
            if fingerpint_pipe.poll(1):
               parser.course_id = fingerpint_pipe.recv()
      # Kill the threads and clears the LCD screen
      except KeyboardInterrupt:
         LCD.clear()
         os.kill(pid, signal.SIGKILL)
         os.kill(os.getpid(), signal.SIGKILL)
         sys.exit()
         
         
   else:
      # Start fingerprint on child procces
      try:
         fingerprint = Fingerprint()
         fingerprint.start(parser, main_pipe, LCD_OUT)
      # Clear the screen
      except KeyboardInterrupt:
         LCD.clear()
         sys.exit()
Example #17
0
def cron_lcd():
    hum, temp = get_hum_and_temp()
    time = datetime.now().strftime('%H:%M')
    weather_dict = weather.get_weather()
    line1 = "{0:0.1f} C and {1:0.1f}%".format(temp, hum)
    line2 = time + " Feels %d" % (int(weather_dict['feels_like']))
    try:
        lcd = LCD()
        sleep(0.5)
        lcd.send_text(line1, 1)
        lcd.send_text(line2, 2)
    except Exception:
        lcd._clean_up()
        raise
Example #18
0
def loop():
    global lcd
    lcd = LCD()
    us = Ultrasonic(GPIO_TRIGGER, GPIO_ECHO)
    while True:
        distance = us.distance()
        if distance:
            lcd.message('distance:\n                ')
            print('distance:%0.2fcm' % distance)
            #lcd.clear()
            lcd.message('distance:\n%0.2fcm' % distance)
        else:
            print('Error')
        time.sleep(0.2)
Example #19
0
    def __init__(self):
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)

        for id in GPIO_OUT.values():
            GPIO.setup(id, GPIO.OUT)

        for id in GPIO_IN.values():
            GPIO.setup(id, GPIO.IN)

        self.is_green = False
        self.is_orange = False
        self.is_red = False
        self.is_red_buzzer = False

        self.lcd = LCD()

        self.reset_all()

        self.listener_thread = threading.Thread(target=self._button_listener)
        self.listener_thread.start()
Example #20
0
class DisplayController():
    def __init__(self):
        self.lcd = LCD()

    def welcome(self):
        welcome_animation = [
            'ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ',
            'ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ',
            'ÿÿÿÿÿÿÿÿ  ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ th ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ     ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ   ÿÿÿÿÿÿÿÿÿ',
            'ÿÿÿÿÿÿÿ     ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ather ÿÿÿÿÿÿÿÿÿÿÿÿÿ       ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ     ÿÿÿÿÿÿÿÿ',
            'ÿÿÿÿÿÿ       ÿÿÿÿÿÿÿÿÿÿÿÿ eatherP ÿÿÿÿÿÿÿÿÿÿÿ         ÿÿÿÿÿÿÿÿÿÿÿÿ       ÿÿÿÿÿÿÿ',
            'ÿÿÿÿÿ         ÿÿÿÿÿÿÿÿÿÿ WeatherPi ÿÿÿÿÿÿÿÿÿ           ÿÿÿÿÿÿÿÿÿÿ         ÿÿÿÿÿÿ',
            'ÿÿÿÿ           ÿÿÿÿÿÿÿÿ  WeatherPi  ÿÿÿÿÿÿÿ             ÿÿÿÿÿÿÿÿ           ÿÿÿÿÿ',
            'ÿÿÿ             ÿÿÿÿÿÿ   WeatherPi   ÿÿÿÿÿ               ÿÿÿÿÿÿ             ÿÿÿÿ',
            'ÿÿ               ÿÿÿÿ    WeatherPi    ÿÿÿ                 ÿÿÿÿ               ÿÿÿ',
            'ÿ                 ÿÿ     WeatherPi     ÿ                   ÿÿ                 ÿÿ',
            '                         WeatherPi                                              '
        ]
        for frame in welcome_animation:
            self.lcd.message(frame)

    def update(self, data):
        if not data:
            display_string = [_no_data()]
        else:
            display_string = [
                _date_time(),
                _max_temp(data),
                _min_temp(data),
                _precip_type(data),
                _precip_intensity(data),
                _precip_probability(data),
                _wind_bearing(data),
                _wind_speed(data),
                _summary(data)
            ]

        self.lcd.message(' '.join(display_string))

    def scroll(self):
        self.lcd.scroll()
Example #21
0
if __name__ == '__main__':

    from lcd import LCD

    # Display Layout instance
    L2 = Layout_EUR()

    # Random values for test
    L2.ewv.set(0.3)
    L2.egv.set(2.64)
    L2.eev.set(0.0)
    L2.update_total()

    # LCD instance
    lcd = LCD(False)
    lcd.draw(L2)

    for i in range(18):
        L2.ewv.add(0.01)
        L2.egv.add(1)
        L2.eev.add(0.17)
        L2.update_total()

        L2.set_date_time()
        lcd.update(L2)

    raw_input()

    for _ in range(10):
        L2.i.set_image(L2.ch1 - 6, L2.ch1 - 6, 'purple_r.jpg')
Example #22
0
import RPi.GPIO as GPIO
import time
from lcd import LCD

mylcd = LCD(13, 26, 5, 0, 0, 0, 0, 16, 12, 19, 6)
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

pulse = 0
distance = 0.00
rpm = 0.00
speed = 0.00
wheel_c = 0.15708
multiplier = 0
hall = 21
elapse = 0.00

start = time.time()

GPIO.setup(hall, GPIO.IN, pull_up_down=GPIO.PUD_UP)


def get_pulse(number):
    global elapse, distance, start, pulse, speed, rpm, multiplier
    cycle = 0
    pulse += 1
    cycle += 1
    if pulse > 0:
        elapse = time.time() - start
        pulse -= 1
    if cycle > 0:
Example #23
0
from flask import Flask, request
from flask_cors import CORS, cross_origin
import json
from lcd import LCD

lcd = LCD()
lcd.LCDinit()

app = Flask(__name__)
CORS(app, supports_credentials=True)


@app.route("/data", methods=['GET', 'POST', 'OPTIONS'])
def script():
    global lcd
    d = json.loads(request.get_data())
    for x in d:
        if x['pin'] == 'RW':
            lcd.setRW(x['val'])
        if x['pin'] == 'A0':
            lcd.setA0(x['val'])
        if x['pin'] == 'E1':
            lcd.setE1(x['val'])
        if x['pin'] == 'E2':
            lcd.setE2(x['val'])
        if x['pin'] == 'E':
            lcd.setE(x['val'])
        if x['pin'] == 'RES':
            lcd.setRES(x['val'])
        if x['pin'] == 'D':
            lcd.setD(x['val'])
def main():
	global thread_finished
	logger.info('Player started!')

	# Read arguments
	if len(sys.argv) >= 3:	
		url = sys.argv[1]
		# Read the title of the streaming
		if len(sys.argv) > 3:
			title = sys.argv[2]
			for x in xrange(3,len(sys.argv)):
				title = title + " " + sys.argv[x]
		else:
			title = sys.argv[2]
	else:
		print "Usage: player.py {url} {title}";
		logger.error("Usage: player.py {url} {title}")
		return

	print "The url of the streaming is:",colored(url, "green")
	print "The name of the radio is:", colored(title, "green")
	logger.info('The url of the streaming is: ' + url)
	logger.info('The name of the radio is: ' + title)

	# Initialize variables
	
	# Basic commands for play the music
	cmd_play_streaming = "mpg123 " + url + " &"
	currentBackup = ""

	# Initialize LCD
	lcd = LCD()
	lcd.clear()
	lcd.begin(16,1)

	# Stop all players
	run_cmd(cmd_stop_all, False)

	# Start radio or backup
	ledConnection = 2
	ledCheck = 3

	GPIO.setmode(GPIO.BCM)
	GPIO.setup(ledConnection, GPIO.OUT)
	GPIO.setup(ledCheck, GPIO.OUT)

	playingRadio = True
	if checkInternetConnection():
		run_cmd(cmd_play_streaming, False)
		logger.info("Playing streamming from " + url)
	else:
		playBackup()
		playingRadio = False

	# Start the main program in an infinite loop

	while 1:
		lcd.clear()
		lcd.message("ExeaMusicPlayer")
		sleep(2)
		
		if playingRadio:
			# Check Internet status
			if checkInternetConnection():
				lcd.clear()
				lcd.message("Escuchas:\n")
				lcd.message(title)
				sleep(2)
				pass
			else:
				# Play backup
				lcd.clear()
				lcd.message("Reproduciendo\nrespaldo")
				sleep(1)
				currentBackup = playBackup()
				lcd.clear()
				lcd.message("Respaldo\n")
				lcd.message(currentBackup)
				sleep(2)
				playingRadio = False
				pass
			pass
		else:
			# Restore streaming radio or show status of "backup"
			if checkInternetConnection():
				run_cmd(cmd_stop_all, False)
				run_cmd(cmd_play_streaming, False)
				logger.info('Playing streamming from ' + url)
				playingRadio = True
				pass
			else:
				lcd.clear()
				lcd.message("Respaldo\n")
				lcd.message(currentBackup)
				sleep(2)
		#Check connection of internet
		GPIO.output(ledConnection, 1)
		if checkInternetConnection():
			GPIO.output(ledConnection, 0)
			sleep(0.5)

		#Check Play the Backup or Stream
		if playingRadio == True:
			GPIO.output(ledCheck, 1)
		else:
			GPIO.output(ledCheck, 0)

		#Show IP info 
		lcd.clear()
		ipaddr = run_cmd(cmd_ip)
		if not ipaddr:
			lcd.message('Sin Internet\n')
		else:
			lcd.message('IP %s' % ( ipaddr ))

		#Show date for 10 seconds
		i = 0
		while i<10:
			lcd.message(datetime.now().strftime('%b %d  %H:%M:%S\n'))
			sleep(1)
			i = i+1
			pass

	thread_finished = True
Example #25
0
class RPiInterface(object):
    def __init__(self):
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)

        for id in GPIO_OUT.values():
            GPIO.setup(id, GPIO.OUT)

        for id in GPIO_IN.values():
            GPIO.setup(id, GPIO.IN)

        self.is_green = False
        self.is_orange = False
        self.is_red = False
        self.is_red_buzzer = False

        self.lcd = LCD()

        self.reset_all()

        self.listener_thread = threading.Thread(target=self._button_listener)
        self.listener_thread.start()

    def reset_all(self):
        for id in GPIO_OUT.values():
            GPIO.output(id, OFF)
        self.is_green = False
        self.is_orange = False
        self.is_red = False
        self.is_red_buzzer = False
        self.buzz()

    def set_green(self):
        if self.is_green: return
        self.reset_all()
        self.is_green = True
        GPIO.output(ID_LED_GREEN, ON)

    def set_orange(self):
        if self.is_orange: return
        self.reset_all()
        self.is_orange = True
        GPIO.output(ID_LED_ORANGE, ON)

    def set_red(self):
        if self.is_red: return
        self.reset_all()
        self.is_red = True
        self.is_red_buzzer = True
        thr = threading.Thread(target=self._red_subroutine, args=(conf.TIME_BUZZER_DURATION, ))
        thr.start()

    def _red_subroutine(self, period):
        while self.is_red:
            time.sleep(period)
            GPIO.output(ID_LED_RED, ON)
            if self.is_red_buzzer:
                GPIO.output(ID_BUZZER, ON)
            time.sleep(period)
            GPIO.output(ID_LED_RED, OFF)
            GPIO.output(ID_BUZZER, OFF)

    def buzz(self):
        thr = threading.Thread(target=self._buzz, args=(conf.TIME_BUZZER_DURATION, ))
        thr.start()

    def _buzz(self, duration):
        GPIO.output(ID_BUZZER, ON)
        time.sleep(duration)
        GPIO.output(ID_BUZZER, OFF)

    def _button_listener(self):
        while True:
            if GPIO.input(ID_BUTTON):
                self.is_red_buzzer = False
            time.sleep(0.10)

    def lcd_out(self, string, line, justify="left"):
        self.lcd.string_out(string, line, justify)
Example #26
0
            for i in range(0, len(rects)):
                if weights[i] > 0.4:
                    result.append(rects[i])
            result = np.array([[x, y, x + w, y + h]
                               for (x, y, w, h) in result])
            result = non_max_suppression(result,
                                         probs=None,
                                         overlapThresh=0.65)
            outbox.put((result, rgb))


try:
    inbox = Queue(maxsize=1)
    outbox = Queue(maxsize=1)
    frame_queue = Queue()
    screen = LCD()
    screen.display(
        " People counter\n    made by\n Zajac&Wieczorek\n\n Initializing...")
    time.sleep(1)

    # initializing detector
    hog = cv2.HOGDescriptor()
    hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())

    p = Process(target=detection_task, args=(
        hog,
        inbox,
        outbox,
    ))
    p.daemon = True
    p.start()
Example #27
0
class Super(object):
    def __init__(self):
        self.BUTTON = Button(
            pin=11,
        )
        GPIO.setup(
            self.WAITING_PIN,
            GPIO.OUT,
        )

        self.LCD = LCD(
            pin_rs=4,
            pin_e=25,
            pins_d=[24,23,22,27],
        )

        self.TRAFFIC = Traffic(
            pin_red=14,
            pin_amber=3,
            pin_green=2,
            lcd=self.LCD,
            lcd_line=2,
        )

        self.RGB = RGB(
            pin_red=9,
            pin_green=10,
            pin_blue=15,
            lcd=self.LCD,
            lcd_line=3,
        )
        self.RGB.show_colour(self.RGB_MAX, self.RGB_MIN, self.RGB_MIN)

    def update(self):
        self._update_lcd()
        self._update_button()
        self._update_traffic()
        self._update_rgb()

    LCD_LAST_TIME = ''
    def _update_lcd(self):
        # Show the current time
        lcd_time = datetime.now().strftime('%H:%M:%S    %d/%m/%y')
        if lcd_time != self.LCD_LAST_TIME:
            self.LCD_LAST_TIME = lcd_time
            self.LCD.output_line(lcd_time, 0)

    WAITING_PIN = 8
    PREV_WAIT_STATE = None
    def _update_button(self):
        if self.BUTTON.was_pushed():
            self.TRAFFIC.push_the_button()

        wait_state = self.TRAFFIC.is_waiting
        if wait_state != self.PREV_WAIT_STATE:
            if wait_state:
                self.LCD.output_line('Waiting...', 1)
            else:
                self.LCD.output_line('', 1)
            GPIO.output(
                self.WAITING_PIN,
                wait_state,
            )
            self.PREV_WAIT_STATE = wait_state

    def _update_traffic(self):
        # Make the traffic lights work
        self.TRAFFIC.update()

    RGB_MIN = 0.0
    RGB_MAX = 100.0
    RGB_STEP = 0
    RGB_STEPS = (
        (RGB_MAX, RGB_MIN, RGB_MIN),
        (RGB_MAX, RGB_MAX, RGB_MIN),
        (RGB_MIN, RGB_MAX, RGB_MIN),
        (RGB_MIN, RGB_MAX, RGB_MAX),
        (RGB_MIN, RGB_MIN, RGB_MAX),
        (RGB_MAX, RGB_MIN, RGB_MAX),
    )
    def _update_rgb(self):
        # Make a rainbow
        # If the current step is finished, move to the next
        if not self.RGB.goto_colour_active:
            # Show the next step
            self.RGB_STEP = (self.RGB_STEP + 1) % len(self.RGB_STEPS)
            self.RGB.goto_colour(*self.RGB_STEPS[self.RGB_STEP])

        # But always update
        self.RGB.update()
Example #28
0
def volumeCallback(direction):
	if direction == "right":
		radio.decreaseVolume()
	else:
		radio.increaseVolume()

def powerOffButtonCallback():
	radio.stop()
	display.disable()
	os.system("shutdown -h now")

config = configparser.ConfigParser()
config.read("tube.cfg")

display = LCD(config["display"]["address"])
display.enable()

radio = Radio(config["radio"]["stations"].splitlines())
trackDataThread = _thread.start_new_thread(updateTrackData, ())

powerOffButton = Button(int(config["button"]["pinNumber"]),config["button"]["pinName"],int(config["button"]["pullupNumber"]),config["button"]["pullupName"], powerOffButtonCallback)
powerOffButton.enable()

stationRotary = RotaryEncoder(int(config["rightRotary"]["aPinNumber"]),config["rightRotary"]["aPinName"],int(config["rightRotary"]["aPullupNumber"]),config["rightRotary"]["aPullupName"],int(config["rightRotary"]["bPinNumber"]),config["rightRotary"]["bPinName"],int(config["rightRotary"]["bPullupNumber"]),config["rightRotary"]["bPullupName"],stationCallback)
stationRotary.enable()

volumeRotary = RotaryEncoder(int(config["leftRotary"]["aPinNumber"]),config["leftRotary"]["aPinName"],int(config["leftRotary"]["aPullupNumber"]),config["leftRotary"]["aPullupName"],int(config["leftRotary"]["bPinNumber"]),config["leftRotary"]["bPinName"],int(config["leftRotary"]["bPullupNumber"]),config["leftRotary"]["bPullupName"],volumeCallback)
volumeRotary.enable()

radio.play()
Example #29
0
gpio.setup(5, gpio.IN)
gpio.setup(12, gpio.IN)

run = True


def on_exit(a, b):
    global run
    run = False


sig.signal(sig.SIGINT, on_exit)
print("Ctrl+C to exit")

# see comments in lcd.py
lcd = LCD(22, 21, 17, 23, 25, 24)

# change these line to test
# 1st line = 0
# 2nd line = 1
# lcd.set_cursor(0,2) # line,column
# lcd.send_string('Xander Newlun')

screen = Screen(["Dog", "Cat", "Moose", "Potatoes"], lcd)
screen.display()

is_press = False

while run:
    if gpio.input(5) == False:
        if is_press == False:
Example #30
0
import signal as sig
from time import  sleep
from lcd import LCD
run = True

def on_exit(a,b):
    global run
    run = False
    
sig.signal(sig.SIGINT,on_exit)
print("Ctrl+C to exit")

# see comments in lcd.py
lcd = LCD(22,21,17,23,25,24)

# change these line to test
# 1st line = 0
# 2nd line = 1
#lcd.set_cursor(0,2) # line,column
#lcd.send_string('Xander Newlun')
lcd.set_cursor(0,2)
lcd.send_string('Hello World')
while run:
    sleep(1)
    
lcd.close()
print('Done')
Example #31
0
def main():
    logger.info('Player started!')
    # Initialize LCD
    lcd = LCD()
    lcd.clear()
    lcd.begin(16,1)
    # Start the main program in an infinite loop
    while True:
        status = run_cmd(cmd_check_device, True)
        status = status[:4]
        lcd.clear()
        lcd.message("ExeaMusicPlayer\n")
        lcd.message( 'Estado: ' + status )
        sleep(2)

        lcd.clear()
        lcd.message("Escuchas:\n")
        lcd.message(title)
        sleep(2)

        #Show Serial
        lcd.clear()
        lcd.message("Serial:\n")
        lcd.message(serial)
        sleep(3)

        #Show IP info
        lcd.clear()
        ipaddr = run_cmd(cmd_ip)

        if not ipaddr:
            lcd.message('Sin Internet\n')
        else:
            lcd.message( ipaddr )

	#Show date for 10 seconds
        i = 0
        while i<10:
            lcd.message(datetime.now().strftime('%b %d  %H:%M:%S\n'))
            sleep(1)
            i = i+1
            pass
    thread_finished = True
Example #32
0
tft = display.TFT()
tft.tft_setspeed(4000000)
tft.init(tft.ST7789,bgr=False,rot=tft.PORTRAIT, miso=17,backl_pin=4,backl_on=1, mosi=19, clk=18, cs=5, dc=16, color_bits=tft.COLOR_BITS16, splash=False)
tft.setwin(52,40,240, 320)
#tft.set_bg(0xff00)
#tft.clear()
t1= time.time()

import page
t2= time.time()
from lcd import LCD
t3= time.time()
import gpio_esp32
t4= time.time()

lcd = LCD(False)
period = .1
sleeptime = time.time()

import machine, micropython
#machine.freq(80000000)

vbatt = machine.ADC(34)
vbatt.atten(3) # only one that works!!

gpio_esp32.init(lcd)

t5= time.time()
print ('loaded', t5-t0, ':',t1-t0, t2-t1, t3-t2, t4-t3, t5-t4)

sleepmode = 0
Example #33
0
from lcd import LCD

display = LCD("0x3f")
display.enable()
display.display("HELLO",1)
display.display("WORLD!",2)
display.display("WHATS",3)
display.display("UP?",4)
         largestArea = cv2.contourArea(c)
         largestObject = c
 if largestObject is not None:
     M = cv2.moments(largestObject)
     X = int(M["m10"] / M["m00"])
     Y = int(M["m01"] / M["m00"])
     if Y >= lev and TTLactive:
         cv2.circle(frame, (X, Y), radius, (0, 255, 0), thickness + 1)
         counter = counter + 1
     elif Y < lev and not (arduino.isWaiting()):
         cv2.circle(frame, (X, Y), radius, (0, 0, 255), thickness + 1)
         counter = 0
         TTLactive = True
         ttl = 0
         # LCD - REFRESH DISPLAY
         lcd.flip()
     else:
         if arduino.isWaiting():
             if ttl == 'left':  # or ttl=='vert' or ttl=='many':
                 cv2.putText(frame, ttl,
                             (int((resolution[0] / 2) - 60), 40),
                             cv2.FONT_HERSHEY_PLAIN, 1, (0, 255, 255), 2,
                             cv2.LINE_AA)
             elif ttl == 'right':  # or ttl=='hor' or ttl=='few':
                 cv2.putText(frame, ttl,
                             (int((resolution[0] / 2) + 40), 40),
                             cv2.FONT_HERSHEY_PLAIN, 1, (0, 255, 255), 2,
                             cv2.LINE_AA)
         cv2.circle(frame, (X, Y), radius, (255, 0, 0), thickness + 1)
         counter = 0
     if posTracker:
Example #35
0
#!/usr/bin/python
# -*- coding: utf-8 -*- 
import sys
import signal
from lcd import LCD
from subprocess import *
import time
import datetime
import atexit
import psutil

cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1"
lcd = LCD()

lcd.message("Booting.........", 4, 0.5)

signal.signal(signal.SIGINT, lambda x, y: sys.exit(0))


def run_cmd(cmd):
    p = Popen(cmd, shell=True, stdout=PIPE)
    output = p.communicate()[0]
    return output


def exit_handler():
    lcd.clear()


atexit.register(exit_handler)
Example #36
0
class MY_GUI(object):
    def __init__(self, WS=False):
        L1 = LEnergy()
        L2 = Layout_EUR()
        L3 = LTemplate(image='tap-water1.jpg',
                       unit='Lit',
                       format_string="{}",
                       ppu=0.0011)
        L4 = LTemplate(image='gas_32x32.png',
                       unit="m" + u'\u00B3',
                       format_string="{0:.2f}",
                       ppu=0.80025)
        L5 = LTemplate(image='plug1.png',
                       unit='kW',
                       format_string="{0:.3f}",
                       ppu=0.24)
        L6 = LWeather()

        self.Layout = [L1, L2, L3, L4, L5, L6]  # Used when displaying
        self.L_SIZE = len(self.Layout)
        self.L_IDX = 0

        self.L1 = self.Layout[0]  # Ref used when updating data
        self.L2 = self.Layout[1]  # Eur
        self.L3 = self.Layout[2]  # Water
        self.L4 = self.Layout[3]  # Gas
        self.L5 = self.Layout[4]  # Electricity
        self.L6 = self.Layout[5]  # Weather

        L6.update()

        self.lcd = LCD(WS)
        self.draw_display()

    def draw_display(self):
        self.lcd.draw(self.Layout[self.L_IDX])

    def update_display(self):
        self.lcd.update(self.Layout[self.L_IDX])

    def layout_next(self):
        self.L_IDX = (self.L_IDX + 1) % self.L_SIZE
        self.draw_display()

    def layout_prev(self):
        self.L_IDX = (self.L_IDX - 1) % self.L_SIZE
        self.draw_display()

    # TODO: duplicate ppu
    def update_water(self, value):
        self.L1.wv.set(value)  # Litter
        self.L2.ewv.set(round(0.0011 * value, 2))  # per Liter
        self.L3.update(value)

    def update_water_hour(self, index, value):
        self.L1.wg.set_bar(index, value)  # Liters
        self.L3.update_hour_data(index, value)

    def update_gas(self, value):
        self.L1.gv.set(value)  # m3
        self.L2.egv.set(round(0.80025 * value, 2))  # per m3 (2017-2918)
        self.L4.update(value)

    def update_gas_hour(self, index, value):
        self.L1.gg.set_bar(index, value)  # Liters
        self.L4.update_hour_data(index, value)

    def update_electricity(self, value):
        self.L1.ev.set(value)  # kWh
        self.L2.eev.set(round(0.24 * value, 2))  # per kW (2017-2918)
        self.L5.update(value)

    def update_electricity_hour(self, index, value):
        self.L1.eg.set_bar(index, value)  # kWh
        self.L5.update_hour_data(index, value)

    def update_eur_total(self):
        self.L2.update_total()

    def set_date_time(self):
        self.L1.set_date_time()
        self.L2.set_date_time()
        self.L3.set_date_time()
        self.L4.set_date_time()
        self.L5.set_date_time()
        self.L6.set_date_time()

    def hour_data_next(self):
        self.L3.hour_data_next()
        self.L4.hour_data_next()
        self.L5.hour_data_next()
        self.update_display()

    def hour_data_prev(self):
        self.L3.hour_data_prev()
        self.L4.hour_data_prev()
        self.L5.hour_data_prev()
        self.update_display()
Example #37
0
# -*- coding: utf-8 -*-

import board
import socket
import digitalio
import time

from lcd import LCD
from rfid import RFID

lcd = LCD()

led = digitalio.DigitalInOut(board.D13)
led.direction = digitalio.Direction.OUTPUT


def get_ip_address():
    ip_address = ''
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.connect(("8.8.8.8", 80))
    ip_address = s.getsockname()[0]
    s.close()
    return ip_address


rfid = RFID()

host_ip = get_ip_address()

while True:
def buttons():
	global thread_finished
	
	buttonReboot = 9
	buttonRestart = 10 
	buttonShutdown = 11
	
	GPIO.setmode(GPIO.BCM)

	GPIO.setup(buttonReboot, GPIO.IN)
	GPIO.setup(buttonShutdown, GPIO.IN)
	GPIO.setup(buttonRestart, GPIO.IN)

	while True:

		# if the last reading was low and this one high, print
		if (GPIO.input(buttonReboot)):
			lcd = LCD()
			lcd.clear()
			lcd.begin(16,1)
			lcd.message("Reiniciando\nSistema")
			sleep(3)
			lcd.clear()
			reboot()
			sleep(0.5)
			
			
		if (GPIO.input(buttonShutdown)):
			lcd = LCD()
			lcd.clear()
			lcd.begin(16,1)
			lcd.message("Apagando\nSistema...")
			sleep(3)
			lcd.clear()
			shutdown()
			sleep(0.5)
			

		if (GPIO.input(buttonRestart)):
			lcd = LCD()
			lcd.clear()
			lcd.begin(16,1)
			lcd.message("Reiniciando\nReproductor")
			sleep(3)
			lcd.clear()
			restart()
			sleep(0.5)

	thread_finished = True
from flask import Flask, request, redirect, abort, jsonify, send_from_directory
from waitress import serve
from threading import Thread, Event
import time
from random import randint
import ndsctl
from lcd import LCD
import json

app = Flask(__name__)
lcd = LCD()

stop_event = Event()
auth_number = None


def gen_number():
    return ''.join([str(randint(0, 9)) for _ in range(6)])


@app.route("/check")
def check():
    code = request.args.get('code')
    ip = request.remote_addr

    client = ndsctl.get_client_by(ip)
    if client['state'] == 'Authenticated':
        return redirect('https://google.es', code=302)

    if code == auth_number:
        try:
Example #40
0
#RUNS AT BEGINNING
start_server = "mkdir /tmp/stream; raspistill --nopreview -w 640 -h 480 -q 5 -o /tmp/stream/pic.jpg -tl 100 -t 9999999 -th 0:0:0 &"
subprocess.call(start_server, shell=True)

start_stream = "LD_LIBRARY_PATH=/usr/local/lib mjpg_streamer -i \"input_file.so -f /tmp/stream -n pic.jpg\" -o \"output_http.so -w /usr/local/www\" &"
subprocess.call(start_stream, shell=True)

#Commands to start and stop stream
#start_server_command = "raspistill --nopreview -w 640 -h 480 -q 5 -o /tmp/stream/pic.jpg -tl 100 -t 9999999 -th 0:0:0"
start_stream_command = "LD_LIBRARY_PATH=/usr/local/lib mjpg_streamer -i \"input_file.so -f /tmp/stream -n pic.jpg\" -o \"output_http.so -w /usr/local/www\" &"
kill_server_command = "pkill raspistill"
kill_stream_command = "pkill mjpg_streamer"
stream_flag = 0

display = LCD()
creds = service_account.Credentials.from_service_account_file(
    './.google-cloud-creds.json')
client = vision.ImageAnnotatorClient(credentials=creds)

# --------------------------- FUNCTIONS --------------------------- #
#def start_stream():
#print("Starting stream...")
#global stream_flag
#stream_flag = 1
#camera.rotation = 180
#camera.start_preview(fullscreen = False, window = (0, 0, 720, 720))
#subprocess.call(start_server_command, shell = True)
#subprocess.call(start_stream_command, shell = True)

Example #41
0
File: modem.py Project: tgb20/HAB
import sys
import time
import rockBlock
from rockBlock import rockBlockProtocol
from lcd import LCD

lcdDisplay = LCD()


def print_out_waiting(conn, msg):
    buffer_size = str(conn.outWaiting())
    logging.info(msg + buffer_size)


class SatModem(rockBlockProtocol):
    devPath = "/dev/tty.usbserial-FT0DJGSK"

    def __init__(self, satPath, logger=None):
        self.devPath = satPath
        self.modem = None
        self.connect()

    def connect(self):
        print("Attempting to connect to satellite")
        try:
            print self.devPath
            self.modem = rockBlock.rockBlock(self.devPath, self)
            print(self.modem.s, 'connect():AFTER DEFAULT CONNECT:')
            dir(self.modem)
        except Exception as e:
            print('Satellite failed to initialize')
Example #42
0
import board
import digitalio
import displayio
import time
from lcd import LCD

displayio.release_displays()

spi = board.SPI()

display_bus = displayio.FourWire(spi,
                                 command=board.LCD_DC,
                                 chip_select=board.LCD_CS,
                                 reset=board.LCD_RST)

display = LCD(display_bus,
              width=240,
              height=240,
              rowstart=80,
              rotation=90,
              backlight_pin=board.LCD_BL)
Example #43
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import signal
from lcd import LCD
from subprocess import *
import time
import datetime
import atexit
import psutil

cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1"
lcd = LCD()

lcd.message("Booting.........", 4, 0.5)

signal.signal(signal.SIGINT, lambda x, y: sys.exit(0))


def run_cmd(cmd):
    p = Popen(cmd, shell=True, stdout=PIPE)
    output = p.communicate()[0]
    return output


def exit_handler():
    lcd.clear()


atexit.register(exit_handler)
Example #44
0
class DeployModule(object):
    bob_api = None
    deployed = False
    logout_time = None

    def __init__(self):
        self.deploy_button = Button(DEPLOY_BUTTON_PORT, self.deploy)
        self.select_repo_next_button = Button(
            REPO_BUTTON_NEXT_PORT,
            lambda on: self.select_change('repo next', on))
        self.select_repo_prev_button = Button(
            REPO_BUTTON_PREV_PORT,
            lambda on: self.select_change('repo prev', on))
        self.select_pr_next_button = Button(
            PR_BUTTON_NEXT_PORT, lambda on: self.select_change('pr next', on))
        self.select_pr_prev_button = Button(
            PR_BUTTON_PREV_PORT, lambda on: self.select_change('pr prev', on))
        self.lcd = LCD()
        self.button_matchers = [
            NetworkInfo(self.lcd, LOG_IN_MESSAGE),
            RestartApp(self.lcd)
        ]

        self.selected_repo_index = 0
        self.selected_pr_index = 0
        self.repo_list = []
        self.pull_requests = []

        self.rfid = RFID(self.startup)
        self.listen_for_rfid()

    def listen_for_rfid(self):
        self.bob_api = None
        print(LOG_IN_MESSAGE)
        self.lcd.clear()
        self.lcd.write(LOG_IN_MESSAGE, 0)

    def startup(self, tag):
        print('Got tag ' + tag)
        [button_matcher.reset() for button_matcher in self.button_matchers]
        self.bob_api = BobApi(tag)
        self.refresh_repos(show_welcome=True)
        if self.repo_list:
            self.bump_logout_time()
        else:
            self.listen_for_rfid()

    def is_logged_in(self):
        return self.bob_api is not None

    def bump_logout_time(self):
        self.logout_time = datetime.now() + timedelta(
            minutes=LOGOUT_IN_MINUTES)

    def logout_time_expired(self):
        return self.logout_time < datetime.now()

    def logout(self):
        self.logout_time = None
        self.listen_for_rfid()

    def refresh_repos(self, show_welcome=False):
        self.lcd.clear()
        self.lcd.write('Loading...', 0)
        self.fetch_repos(show_welcome)
        self.update_repo()

    def fetch_repos(self, show_welcome):
        try:
            data = self.bob_api.get_repos_and_user_name()

            if data.get('user') and show_welcome:
                self.lcd.write('Welcome {name}!'.format(name=data.get('user')),
                               0)
                sleep(2)

            self.repo_list = data.get('repos')
            if self.repo_list and len(self.repo_list) is 0:
                self.repo_list = [
                    {
                        'display_name': '-- No repos found'
                    },
                ]
        except Exception:
            self.lcd.write('Repo loading err', 0)
            self.lcd.write('Please try again', 1)
            sleep(2)

    def fetch_pull_requests(self):
        self.pull_requests = self.bob_api.get_pull_requests(
            self.repo_list[self.selected_repo_index]['id'])
        self.selected_pr_index = 0

        if len(self.pull_requests) is 0:
            self.pull_requests = [
                {
                    'id': 0,
                    'title': '-- No PRs'
                },
            ]

    def update_repo(self):
        if self.repo_list:
            self.lcd.write(
                self.repo_list[self.selected_repo_index]['display_name'], 0)
            self.lcd.write('Loading...', 1)
            self.fetch_pull_requests()
            self.update_pr()

    def update_pr(self):
        self.lcd.write(self.pull_requests[self.selected_pr_index]['title'], 1)

    def handle_after_deploy_input(self):
        self.bump_logout_time()
        self.deployed = False
        self.refresh_repos()

    def deploy(self, pressed_down):
        if self.is_logged_in() and pressed_down:
            if self.deployed:
                self.handle_after_deploy_input()
            elif len(self.pull_requests
                     ) and not self.pull_requests[0]['id'] == 0:
                self.bump_logout_time()
                pr = self.pull_requests[self.selected_pr_index]
                print('Deploying ' + pr['title'])
                self.lcd.clear()
                self.lcd.write('Deploying...', 0)
                response = self.bob_api.deploy(
                    self.repo_list[self.selected_repo_index]['id'], pr['id'])
                self.lcd.write(response['message'], 1)
                self.deployed = True

    def create_select_change_handler(self, type):
        def handler(on):
            self.select_change(type, on)

        return handler

    def select_change(self, type, on):
        if on:
            if not self.is_logged_in():
                [
                    button_matcher.button_changed(type)
                    for button_matcher in self.button_matchers
                ]
            elif self.deployed:
                self.handle_after_deploy_input()
            else:
                self.bump_logout_time()
                if type == 'repo prev':
                    if self.selected_repo_index is 0:
                        self.selected_repo_index = len(self.repo_list) - 1
                    else:
                        self.selected_repo_index -= 1
                elif type == 'repo next':
                    if self.selected_repo_index is len(self.repo_list) - 1:
                        self.selected_repo_index = 0
                    else:
                        self.selected_repo_index += 1
                elif type == 'pr prev':
                    if self.selected_pr_index is 0:
                        self.selected_pr_index = len(self.pull_requests) - 1
                    else:
                        self.selected_pr_index -= 1
                elif type == 'pr next':
                    if self.selected_pr_index is len(self.pull_requests) - 1:
                        self.selected_pr_index = 0
                    else:
                        self.selected_pr_index += 1

                if 'repo' in type:
                    self.update_repo()
                elif 'pr' in type:
                    self.update_pr()

    def process(self):
        self.deploy_button.read_input()
        self.select_repo_next_button.read_input()
        self.select_repo_prev_button.read_input()
        self.select_pr_next_button.read_input()
        self.select_pr_prev_button.read_input()
        if (not self.is_logged_in()) and int(time() % 1 * 100) == 0:
            self.rfid.read()
        elif self.is_logged_in() and self.logout_time_expired():
            self.logout()

    def destroy(self):
        self.lcd.clear()
        self.lcd.write('Shutdown', 0)
        self.lcd.destroy()
Example #45
0
        

# Init buttons
btnUp = ButtonPin('X3', Pin.IN, Pin.PULL_UP)
btnDown = ButtonPin('X2', Pin.IN, Pin.PULL_UP)
btnOk = ButtonPin('X1', Pin.IN, Pin.PULL_UP)

# Init relays
rele1 = Pin('Y9', Pin.OUT_PP)
rele2 = Pin('Y10', Pin.OUT_PP)
rele3 = Pin('Y11', Pin.OUT_PP)
rele4 = Pin('Y12', Pin.OUT_PP)

# Init display
spi = SPI(1)
lcd = LCD(TriumMars(spi, 'X5', 'X7'), False)
lcd.contrast(25)

# Init OneWire
ow = OneWire('X4')
ds = DS18B20(ow)

resourses = None

class Resourses(object):
    def __init__(self):
        self.mainImage = BMP('images/main.bmp') #self.load_image('images/main.bmp')
        self.btn1Image = BMP('images/btn1.bmp') # self.load_image('images/btn1.bmp')
        self.btn2Image = BMP('images/btn2.bmp') #self.load_image('images/btn2.bmp')
        self.btn3Image = BMP('images/btn3.bmp') #self.load_image('images/btn3.bmp')  
        self.fn_numsmile = Font('fonts/nums_smile', True)
Example #46
0
 def setUp(self):
     self.lcd = LCD()
     self.memory = DMGMemory(self.lcd)
     self.lcd.memory = self.memory
     self.cpu = CPU(self.memory)
Example #47
0
def main():
        global thread_finished
#	logger.info('Player started!')
	
	# Basic commands for play the music
#	currentBackup = ""

	# Initialize LCD
	lcd = LCD()
	lcd.clear()
	lcd.begin(16,1)

        # Stop all players
        run_cmd(cmd_stop_all, False)

	# Start radio or backup
#	ledConnection = 2
#	ledCheck = 3

	GPIO.setmode(GPIO.BCM)
#	GPIO.setup(ledConnection, GPIO.OUT)

	# Start the main program in an infinite loop
	while True: 
		lcd.clear()
		lcd.message("ExeaMusicPlayer")
		sleep(2)
		
		lcd.clear()
		lcd.message("Escuchas:\n")
		lcd.message(title)
		sleep(2)
		
		#Check connection of internet
#		GPIO.output(ledConnection, 1)
		if checkInternetConnection():
#			GPIO.output(ledConnection, 0)
			#sleep(0.5)
                        lcd.clear()
                        lcd.message("Estas conectado\na Internet")
                        sleep(3)
		#Show IP info 
		lcd.clear()
		ipaddr = run_cmd(cmd_ip)
		if not ipaddr:
			lcd.message('Sin Internet\n')
		else:
			lcd.message('IP%s' % ( ipaddr ))

		#Show date for 10 seconds
		i = 0
		while i<10:
			lcd.message(datetime.now().strftime('%b %d  %H:%M:%S\n'))
			sleep(1)
			i = i+1
			pass

	thread_finished = True