Exemple #1
0
def print_to_LCDScreen (message):
    try:
        lcd = Adafruit_CharLCD()
        lcd.begin(16,2)
        for x in range(0, 16):
            for y in range(0, 2):
                lcd.setCursor(x, y)
                lcd.message('>')
                time.sleep(.025)
        lcd.noDisplay()
        lcd.clear()
        lcd.message(str(message))
        for x in range(0, 16):
            lcd.DisplayLeft()
        lcd.display()
        for x in range(0, 16):
            lcd.scrollDisplayRight()
            time.sleep(.05)
        # lcd.noDisplay()
        # lcd.display()
        # lcd.blink()
        # lcd.noCursor()
        # lcd.clear()
        # lcd.noBlink()
        # lcd.begin(16, 2)
        # lcd.setCursor(7, 0)
        # lcd.message('123')
        # lcd.message('x')
        # lcd.clear()
        return 'ok'
    except Exception,e:
        return e
Exemple #2
0
class LCD:

    __line1 = ""
    __line2 = ""
    def __init__(self):
        self.lcd = Adafruit_CharLCD()
        self.lcd.clear()
        self.logger = LoggerModule.Logger("LCD Module")

    def hello(self):
        self.lcd.message("  Welcome to \n Kinderbox ")

    def turn_off(self):
        self.lcd.noDisplay()

    def display_pause(self):
        self.message("", "Pause")

    def display_ready(self):
        self.message("", "Ready")

    def display_volume(self, message):
        self.message("", message)


    def message(self, line1, line2):
        if self.__line1 == line1 and self.__line2 == line2:
            return
        try:
            n_line1 = normalization.remove_unicode(line1)
        except:
            n_line1 = "unkown"
        try:
            n_line2 = normalization.remove_unicode(line2)
        except:
            n_line2 = "unkown"

        self.lcd.clear()
        sleep(0.5)
        message = "%s\n%s" %(n_line1,n_line2)
        self.lcd.message(message)
        self.__line1 = line1
        self.__line2 = line2

    def scroll_to_left(self):
        #Check size message. If over 16 character --> move
        if len(self.__line1) > 16 or len(self.__line2) > 16:
            self.lcd.DisplayLeft()
Exemple #3
0
mcp = MCP230XX_GPIO(bus, address, gpio_count)

# Initialize the LCD plate.  Should auto-detect correct I2C bus.  If not,
# pass '0' for early 256 MB Model B boards or '1' for all later versions
lcd = Adafruit_CharLCD(pin_rs=1, pin_e=2, pins_db=[3,4,5,6], GPIO=mcp)

# turn lcd off
lcd.display()

# prepare next message and set LED red
led.clear()
led.message("ahutest")
led.backlight(led.RED)

# turn lcd back on
lcd.noDisplay()
sleep(3)

# change lcd mesasge
led.clear()
led.autoscroll()
led.message("Daniel ist doof! super doof! mega doof! hyper doof!")
led.autoscroll()
sleep(3)
led.backlight(led.GREEN)
sleep(3)

# turn lcd and led off
led.backlight(led.OFF)
lcd.display()
sleep(3)
Exemple #4
0
class LCD:

    __line1 = ""
    __line2 = ""
    __isLock = False
    __wait = 3 #seconds
    def __init__(self):
        self.lcd = Adafruit_CharLCD()
        self.lcd.clear()
        self.logger = LoggerModule.Logger("LCD Module")

    def hello(self):
        self.lcd.message("  Welcome to \n Kinderbox ")

    def turn_off(self):
        self.lcd.noDisplay()

    def display_ip(self):
        cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1"
        p = Popen(cmd, shell=True, stdout=PIPE)
        ipaddr = p.communicate()[0]
        self.message("Ready to scan", "IP: %s" %ipaddr, True)

    def display_pause(self):
        self.message("", "Pause", True)

    def display_ready(self):
        #self.message("", "Ready", True)
        self.display_ip()

    def display_volume(self, message):
        self.message("", message, True)
        self.__isLock = True
        self.__locked_time = time()


    def message(self, line1, line2, force = False):
        if force:
            self.__isLock = False

        if self.__isLock:
            current_time = time()
            if current_time - self.__locked_time >= self.__wait:
                self.__isLock == False
            else:
                return

        if self.__line1 == line1 and self.__line2 == line2:
            return

        try:
            n_line1 = normalization.remove_unicode(line1)
        except Exception, e1:
            print "Line1: %s" %e1
            n_line1 = "unkown"

        try:
            n_line2 = normalization.remove_unicode(line2)
        except Exception, e2:
            print "Line2: %s" %e2
            n_line2 = "unkown"
Exemple #5
0
class LCD:

    __line1 = ""
    __line2 = ""
    __isLock = False
    __wait = 3  #seconds

    def __init__(self):
        self.lcd = Adafruit_CharLCD()
        self.lcd.clear()
        self.logger = LoggerModule.Logger("LCD Module")

    def hello(self):
        self.lcd.message("  Welcome to \n Kinderbox ")

    def turn_off(self):
        self.lcd.noDisplay()

    def display_ip(self):
        cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1"
        p = Popen(cmd, shell=True, stdout=PIPE)
        ipaddr = p.communicate()[0]
        self.message("Ready to scan", "IP: %s" % ipaddr, True)

    def display_pause(self):
        self.message("", "Pause", True)

    def display_ready(self):
        #self.message("", "Ready", True)
        self.display_ip()

    def display_volume(self, message):
        self.message("", message, True)
        self.__isLock = True
        self.__locked_time = time()

    def message(self, line1, line2, force=False):
        if force:
            self.__isLock = False

        if self.__isLock:
            current_time = time()
            if current_time - self.__locked_time >= self.__wait:
                self.__isLock == False
            else:
                return

        if self.__line1 == line1 and self.__line2 == line2:
            return

        try:
            n_line1 = normalization.remove_unicode(line1)
        except Exception, e1:
            print "Line1: %s" % e1
            n_line1 = "unkown"

        try:
            n_line2 = normalization.remove_unicode(line2)
        except Exception, e2:
            print "Line2: %s" % e2
            n_line2 = "unkown"