Esempio n. 1
0
def clock_loop(bg=None, fg=None):
    update_display_period = 1  # number of seconds to wait before updating display
    floor = math.floor  # minor optimization
    
    if bg is None:
        bg = BackgroundColours.BLACK
    if fg is None:
        fg = TextColours.GREEN
    
    line_num = 3

    d = LCDSysInfo()
    d.clear_lines(TextLines.ALL, bg)
    d.dim_when_idle(False)
    d.set_brightness(127)
    d.save_brightness(127, 255)
    d.set_text_background_colour(bg)

    while 1:
        clock_str = str(datetime.datetime.now()).split('.')[0]
        d.display_text_on_line(line_num, clock_str, False, None, fg)
        
        # Work out when to wake up for the next round/whole (non-fractional) time
        start_time = time.time()
        future_time = floor(start_time) + update_display_period  # pure float math
        sleep_time = future_time - start_time
        time.sleep(sleep_time)
def displayErrorScreen(e):  
    # set up to write to the LCD screen
    # Init the LCD screen
    display = LCDSysInfo()
    display.dim_when_idle(False)
    display.set_brightness(255)
    display.save_brightness(100, 255)
    
    # Always clear the whole screen
    display.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
    display.display_text_on_line(3, "Error: Check Miner", True, (TextAlignment.LEFT), TextColours.RED)
    display.display_text_on_line(4, e, True, (TextAlignment.LEFT), TextColours.RED)
Esempio n. 3
0
def displayErrorScreen(e):
      
    # set up to write to the LCD screen
    #
    # Init the LCD screen
    display = LCDSysInfo()
    display.dim_when_idle(False)
    display.set_brightness(255)
    display.save_brightness(100, 255)
    
    # Always clear the whole screen
    display.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
    display.display_text_on_line(3, "Error: Check Miner", True, (TextAlignment.LEFT), TextColours.RED)
    display.display_text_on_line(4, e, True, (TextAlignment.LEFT), TextColours.RED)
def showSimplifiedScreen(firstTime, summary):

    # extract just the data we want from the API result
    hardwareErrors = str(summary['SUMMARY'][0]['Hardware Errors'])
    avg = int(summary['SUMMARY'][0]['MHS av'])
    avgStr = convertSize(avg * 1000000.0)
    avgMhs = "Average: " + avgStr

    # set up to write to the LCD screen
    #
    # Init the LCD screen
    display = LCDSysInfo()
    display.dim_when_idle(False)
    display.set_brightness(255)
    display.save_brightness(100, 255)

    if (firstTime == True):
        display.clear_lines(TextLines.ALL, BackgroundColours.BLACK)

    display.display_text_on_line(1, str(poolURL), True, (TextAlignment.LEFT),
                                 TextColours.LIGHT_BLUE)
    display.display_text_on_line(2, "Uptime: \t" + upTime, True,
                                 (TextAlignment.LEFT, TextAlignment.RIGHT),
                                 TextColours.LIGHT_BLUE)
    display.display_text_on_line(3, avgMhs + "h/s", True, TextAlignment.LEFT,
                                 TextColours.LIGHT_BLUE)
    display.display_text_on_line(4, "HW Errors: " + hardwareErrors, True,
                                 TextAlignment.LEFT, TextColours.LIGHT_BLUE)
Esempio n. 5
0
def main():
	uptime = getUptime()

	bg = BackgroundColours.BLACK
	fb = TextColours.WHITE

	
	d = LCDSysInfo()
	d.clear_lines(TextLines.ALL, bg)
	d.dim_when_idle(False)
	d.set_brightness(127)
	d.save_brightness(127, 255)
	d.set_text_background_colour(bg)

	d.display_text_on_line(3, "Uptime:", False, None, fb)
	d.display_text_on_line(4, uptime, False, None, fb)
Esempio n. 6
0
class Screen():
    def __init__(self):
        self.lcd = LCDSysInfo()
        self.lcd.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
        self.lcd.dim_when_idle(False)
        self.lcd.set_brightness(127)
        self.lcd.save_brightness(127, 127)

    def clear(self):
        self.lcd.clear_lines(TextLines.ALL, BackgroundColours.BLACK)

    def printc(self, data, sensors_to_display):
        line = 1
        for key in sensors_to_display:
            for sensor in data:
                if sensor['id'] == key:
                    value = str(sensor['value'])
                    txt = unicode(sensor['name'] + "\t " + value + "" + sensor['unit'])
                    txt = txt.replace(u"\u00B0", "^")
                    txt = unicodedata.normalize('NFKD', txt).encode('ascii', 'ignore')
                    print(txt)
                    self.lcd.display_text_on_line(line, txt, False, TextAlignment.LEFT, TextColours.LAVENDER)
                    line +=1
def showSimplifiedScreen(firstTime, summary):

    # extract just the data we want from the API result
    hardwareErrors  = str(summary['SUMMARY'][0]['Hardware Errors'])
    avg             = int(summary['SUMMARY'][0]['MHS av'])
    avgStr          = convertSize(avg*1000000.0)
    avgMhs          = "Average: " + avgStr
    
    # set up to write to the LCD screen
    # Init the LCD screen
    display = LCDSysInfo()
    display.dim_when_idle(False)
    display.set_brightness(255)
    display.save_brightness(100, 255) 
    
    if (firstTime == True):
        display.clear_lines(TextLines.ALL, BackgroundColours.BLACK)

    display.display_text_on_line(1, str(poolURL), True, (TextAlignment.LEFT), TextColours.LIGHT_BLUE)
    display.display_text_on_line(2, "Uptime: \t" + upTime, True, (TextAlignment.LEFT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)
    display.display_text_on_line(3, avgMhs + "h/s", True, TextAlignment.LEFT, TextColours.LIGHT_BLUE)
    display.display_text_on_line(4, "HW Errors: " + hardwareErrors, True, TextAlignment.LEFT, TextColours.LIGHT_BLUE)
def showDefaultScreen(firstTime, summary, mtgoxLastPrice, mtgoxDirectionCode, toggleSinceLast, mtgoxToggleState):

    # extract just the data we want from the API result and
    #  build up display strings for each using the data
        
    avg = float(summary['SUMMARY'][0]['MHS av'])
    avgMhs = convertSize(avg*1000000.0)
    foundBlocks = str(int(summary['SUMMARY'][0]['Found Blocks']))    
    difficultyAccepted = "A:" + str(int(summary['SUMMARY'][0]['Difficulty Accepted']))
    if 'Pool Rejected%' in summary['SUMMARY'][0]:
        rej = str(summary['SUMMARY'][0]['Pool Rejected%'])
        if (rej == '0'):
            rejp = rej + "%"
        else:
            rejp = rej.split('.')[0] + "." + rej.split('.')[1][:2] + "%"
    else:
        rejp = str(int(summary['SUMMARY'][0]['Difficulty Rejected']))
    reject = "R:" + rejp
    if 'Device Hardware%' in summary['SUMMARY'][0]:
        hw = str(summary['SUMMARY'][0]['Device Hardware%'])
        if (hw == '0'):
            hwp = hw + "%"
        else:
            hwp = hw.split('.')[0] + "." + hw.split('.')[1][:2] + "%"
    else:
        hwp = str(int(summary['SUMMARY'][0]['Hardware Errors']))
    hardware = "HW:" + hwp
    bestShare = "S:" + convertSize(int(summary['SUMMARY'][0]['Best Share']))
    workUtility = "WU:" + str(summary['SUMMARY'][0]['Work Utility']) + "/m"
   
    # get current time, and format it per user selection
    theTime = ""   
    time.ctime() # formatted like this: 'Mon Oct 18 13:35:29 2010'
    if timeDisplayFormat == '12':
        theTime = time.strftime("%I:%M%p")  # 12 hour display
    else:    
        theTime = time.strftime("%H:%M:%S")  # 24 hour display

    # strip common prefixes and suffixes off of the pool URL (to save display space) 
    # TODO add code to remove all ":dddd" instead of adding port numbers to ignore
    commonStringPattern = ['http://', 'stratum+tcp://', 'stratum.', 'www.', '.com', 'mining.', ':3333', ':3334', ':8330']  
    shortPoolURL = str(poolURL)
    for i in commonStringPattern:
        shortPoolURL = shortPoolURL.replace(i, '', 1).rstrip()   
      
    # build the display strings
    line1String = shortPoolURL + "\t" + theTime
    line2String = "Uptime:  " + upTime
    line3String = "Avg:" + avgMhs + "h/s" + "  B:" + foundBlocks
    if int(foundBlocks) > 0:
        line3Colour = TextColours.RED
    else:
        line3Colour = TextColours.GREEN

    #line3String = "Avg:" + avgMhs + "\tB:" + foundBlocks
    line4String = difficultyAccepted + "  " + bestShare
    line5String = reject + "  " + hardware
    
    if mtgoxToggleState: # if we have MtGox data, get ready to display it
        line6String = "MtGox: " + mtgoxLastPrice 
    else:
        line6String = workUtility
        
    # set up to write to the LCD screen
    #
    # Init the LCD screen
    display = LCDSysInfo()
    display.dim_when_idle(False)
    display.set_brightness(255)
    display.save_brightness(100, 255)
    
    if (firstTime == True):
        # clear screen
        display.clear_lines(TextLines.ALL, BackgroundColours.BLACK)

    # write all lines
    display.display_text_on_line(1, line1String, True, (TextAlignment.LEFT, TextAlignment.RIGHT), TextColours.YELLOW)
    display.display_text_on_line(2, line2String, True, (TextAlignment.LEFT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)    
    display.display_text_on_line(3, line3String, True, (TextAlignment.LEFT), line3Colour)
    display.display_text_on_line(4, line4String, True, (TextAlignment.LEFT), TextColours.GREEN)
    display.display_text_on_line(5, line5String, True, (TextAlignment.LEFT), TextColours.GREEN)
    
    # check to see if the mtgoxDisplay just toggled, if so, display black text to remove traces of previous icon
    if toggleSinceLast == True:
        display.display_text_anywhere(0, 197, '       ', TextColours.BLACK)
    
    if mtgoxToggleState == True:
        display.display_icon(41, mtgoxDirectionCode) # directionCode should contain the icon number for up or down arrow
        display.display_text_anywhere(95, 200, line6String, TextColours.GREEN)
    else:
        display.display_text_on_line(6, line6String, True, (TextAlignment.LEFT), TextColours.GREEN)
Esempio n. 9
0
  jsondata = jsonp[ jsonp.index("(")+1 : jsonp.rindex(")") ]
  data = json.loads(jsondata)
  totalchecks = data['result']['stats'][0]['checks'] 
  totalerrors = data['result']['stats'][0]['check_errors']
except urllib2.URLError, e:
  print 'no valid data received' 

print json.dumps(data)


bad = " "
line = str("WatchM err " + totalerrors + "/" + totalchecks )
#print line

col = TextColours.GREEN
d.display_text_on_line(6, line, False, TextAlignment.LEFT, col)

f = open('yw', 'r')
c = 1
for line in f:
        if c == 2:
                col = TextColours.PURPLE
        if c == 3:
                col = TextColours.PURPLE
        if c == 4:
                col = TextColours.LIGHT_BLUE
        if c == 5:
                col = TextColours.LIGHT_BLUE
	if c == 6:
		col = TextColours.RED
        d.display_text_on_line(c, line, False, TextAlignment.LEFT, col)
Esempio n. 10
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from pylcdsysinfo import LCDSysInfo, TextAlignment, TextColours
from time import sleep

d = LCDSysInfo()
while True:
    for c in range(0, 8):
        dest = 180 + (c * 38)
        d.display_icon(0, dest)
        d.display_text_on_line(1, "{{{" + str(c), False, TextAlignment.NONE, TextColours.WHITE)
        sleep(1)
Esempio n. 11
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from pylcdsysinfo import BackgroundColours, TextColours, TextAlignment, TextLines, LCDSysInfo
from time import sleep

d = LCDSysInfo()
d.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
d.dim_when_idle(False)
d.set_brightness(255)
d.save_brightness(127, 255)
d.set_text_background_colour(BackgroundColours.BLACK)
d.display_cpu_info(8010, 32, TextColours.RED, TextColours.WHITE)
d.display_ram_gpu_info(1994, 32, TextColours.RED, TextColours.GREEN)
d.display_network_info(1, 2, TextColours.RED, TextColours.GREEN, 0, 1) 
d.display_fan_info(1994, 1994, TextColours.RED, TextColours.GREEN)
for pos in range(0, 48):
    d.display_icon(pos, 1 + pos % 32)
d.clear_lines(63, BackgroundColours.WHITE)
d.set_text_background_colour(BackgroundColours.BLUE)
sleep(1)
for line in range(1, 7):
    d.display_text_on_line(line, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", False, TextAlignment.LEFT, TextColours.WHITE)
Esempio n. 12
0
#Look for it in the result
subStringFindVol = str1.find(str3);
#strip it
substringvolume = str1[subStringFindVol + 15:];
#extract it
volume = substringvolume[0 : 0 +10];

#get the balance from our remote bitcoind and store it.
btcbalance = str(conn.getbalance());
    
# Refresh the background and make it black
display.set_text_background_colour(BackgroundColours.BLACK)

#loop through each line to display, filling in the variables.
for line in range(1, 7):
    if line == 1:
        display.display_text_on_line(line, '1 BTC at MtGox', True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.BLUE)
    elif line == 2:
        display.display_text_on_line(line, '$' + str(price) + " USD", True, (TextAlignment.LEFT, TextAlignment.LEFT), TextColours.GREEN)
    elif line == 3:
        display.display_text_on_line(line, 'Volume: ' + str(volume), True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.RED)
    elif line == 4:
        display.display_text_on_line(line, btcbalance + " btc", True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)
    elif line == 5:
        display.display_text_on_line(line, 'Total local wallet:', False, TextAlignment.LEFT, TextColours.LIGHT_BLUE)
    else:
        #calculate our wallet value with mtgox's price to get a dollar price on our wallet.
        # Shorten the resulting value to two decimals for easier readability
        display.display_text_on_line(line, str("%.2f" % (float(price) * float(btcbalance))) + " usd", True, TextAlignment.RIGHT, TextColours.DARK_BLUE)
#time.sleep(10)
Esempio n. 13
0
subStringFindInt = str1.find(str2)
# strip the string to 'keep' the price
substringprice = str1[subStringFindInt + 4 :]
# extract the price
price = substringprice[0 : 0 + 6]
# get the balance from our remote bitcoind and store it.
btcbalance = str(conn.getbalance())

# Refresh the background and make it black
display.set_text_background_colour(BackgroundColours.BLACK)

# loop through each line to display, filling in the variables.
for line in range(1, 7):
    if line == 1:
        display.display_text_on_line(
            line, "1 btc at MtGox", True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREY
        )
    elif line == 2:
        display.display_text_on_line(
            line, str(price) + " USD", True, (TextAlignment.LEFT, TextAlignment.LEFT), TextColours.GREY
        )
    elif line == 3:
        display.display_text_on_line(
            line, "Local Bitcoind: ", True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.RED
        )
    elif line == 4:
        display.display_text_on_line(
            line, btcbalance + " btc", True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN
        )
    elif line == 5:
        display.display_text_on_line(line, "Total local wallet:", False, TextAlignment.LEFT, TextColours.LIGHT_BLUE)
Esempio n. 14
0
class EventHandler(pyinotify.ProcessEvent):
    last_updated = 0

    def __init__(self, path):
        super(EventHandler, self).__init__()
        self.lcd = LCDSysInfo()
        self.lcd.set_brightness(BRIGHTNESS)
        self.lcd.dim_when_idle(False)
        self.lcd.clear_lines(TextLines.ALL, BGCOLOR)
        self.old_lines = [""] * 6
        self.path = path

    @staticmethod
    def fmt_task(task):
        if task.startswith("+"):
            task = "+ " + task[1:]
        else:
            task = "- " + task
        return "____%s" % task

    @staticmethod
    def _parse_todos(path):
        with open(path, "rU") as fobj:
            yobj = yaml.safe_load_all(fobj)
            yobj.next()  # Skip header text
            return yobj.next() or {}

    def process_IN_MODIFY(self, event):
        # Workaround for race condition when using IN_MODIFY
        # (Because IN_CLOSE_WRITE | IN_MOVED_TO doesn't fire with Leafpad)
        this_stat, waited = os.stat(self.path), 0
        while this_stat.st_size == 0 and waited < 3:
            time.sleep(0.3)
            this_stat = os.stat(self.path)
            waited += 0.3

        # Ensure we fire only once per change
        if self.last_updated == this_stat.st_mtime:
            return

        try:
            data = self._parse_todos(self.path)
        except BaseException:
            log.debug("Couldn't parse data from file: %s", self.path)
            lines = ["Error parsing TODO YAML", "%d bytes" % this_stat.st_size]
        else:
            tasks = data.get("TODO", None)
            if tasks:
                lines = ["TODO:"] + [self.fmt_task(x) for x in tasks]
            else:
                lines = ["No TODOs found"]

        # Waste as little time as possible overwriting lines that haven't
        # changed
        for pos, line in enumerate(lines[:6]):
            if line != self.old_lines[pos]:
                self.lcd.display_text_on_line(pos + 1, line, False, TextAlignment.LEFT, FGCOLOR)
                self.old_lines[pos] = line

        # Only erase lines that used to have something on them
        mask = 0
        for pos in range(len(lines), 6):
            if self.old_lines[pos]:
                mask += 1 << int(pos)
                self.old_lines[pos] = ""
        if mask:
            self.lcd.clear_lines(mask, BGCOLOR)

        # Only update this if we successfuly parsed and applied an update
        self.last_updated = this_stat.st_mtime
Esempio n. 15
0
from pylcdsysinfo import BackgroundColours, TextColours, TextAlignment, TextLines, LCDSysInfo
from time import sleep

d = LCDSysInfo()
d.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
d.dim_when_idle(False)
d.set_brightness(127)
d.save_brightness(127, 255)
d.set_text_background_colour(BackgroundColours.BLACK)

f = open('yw', 'r')
c = 1
col = TextColours.GREEN
for line in f:
        if c == 2:
                col = TextColours.PURPLE
        if c == 3:
                col = TextColours.YELLOW
        if c == 4:
                col = TextColours.LIGHT_BLUE
        if c == 5:
                col = TextColours.ORANGE
        if c == 6:
                col = TextColours.RED

        d.display_text_on_line(c, line, False, TextAlignment.LEFT, col)
        c = c + 1
        if c > 6:
                break
Esempio n. 16
0
d.set_text_background_colour(BackgroundColours.BLACK)
d.display_cpu_info(8010, 32, TextColours.RED, TextColours.WHITE)
d.display_ram_gpu_info(1994, 32, TextColours.RED, TextColours.GREEN)
d.display_network_info(1, 2, TextColours.RED, TextColours.GREEN, False, True)
d.display_fan_info(1994, 1994, TextColours.RED, TextColours.GREEN)

# All icons
for pos in range(0, 48):
    d.display_icon(pos, 1 + pos)
sleep(1)

# Arbitrary text drawing
d.clear_lines(TextLines.ALL, BackgroundColours.WHITE)
d.set_text_background_colour(BackgroundColours.BLUE)
for line in range(1, 7):
    d.display_text_on_line(line, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", False, TextAlignment.LEFT, TextColours.WHITE)
sleep(1)

# Clearing individual lines
for i in range(5,-1,-1):
    d.clear_lines(1 << i, BackgroundColours.BLACK)

# Image Drawing
d.set_text_background_colour(BackgroundColours.BLACK)
d.display_icon(0, 218)

# Multi-color two-column drawing
for line in range(1, 7):
    ipos = (line - 1) * 8
    icon = (line * 2) + 10
    d.display_icon(ipos, icon)
Esempio n. 17
0
d.display_cpu_info(8010, 32, TextColours.RED, TextColours.WHITE)
d.display_ram_gpu_info(1994, 32, TextColours.RED, TextColours.GREEN)
d.display_network_info(1, 2, TextColours.RED, TextColours.GREEN, False, True)
d.display_fan_info(1994, 1994, TextColours.RED, TextColours.GREEN)

# All icons
for pos in range(0, 48):
    d.display_icon(pos, 1 + pos)
sleep(1)

# Arbitrary text drawing
d.clear_lines(TextLines.ALL, BackgroundColours.WHITE)
d.set_text_background_colour(BackgroundColours.BLUE)
for line in range(1, 7):
    d.display_text_on_line(
        line, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        False, TextAlignment.LEFT, TextColours.WHITE)
sleep(1)

# Clearing individual lines
for i in range(5, -1, -1):
    d.clear_lines(1 << i, BackgroundColours.BLACK)

# Image Drawing
d.set_text_background_colour(BackgroundColours.BLACK)
d.display_icon(0, 218)

# Multi-color two-column drawing
for line in range(1, 7):
    ipos = (line - 1) * 8
    icon = (line * 2) + 10
Esempio n. 18
0
def clock_loop(bg=None, fg=None):
    update_display_period = 1  # number of seconds to wait before updating display
    floor = math.floor  # minor optimization

    if bg is None:
        bg = BackgroundColours.BLACK
    if fg is None:
        fg = TextColours.WHITE

    line_num = 1

    d = LCDSysInfo()
    d.clear_lines(TextLines.ALL, bg)
    d.dim_when_idle(False)
    d.set_brightness(127)
    d.save_brightness(127, 255)
    d.set_text_background_colour(bg)

    jsonAfdak = domoticzData(805)
    jsonBuiten = domoticzData(16)
    jsonBinnen = domoticzData(447)
    jsonPower = domoticzData(616)

    d.display_text_on_line(2, 'Buiten:' + jsonBuiten['result'][0]['Data'], False, None, fg)
    d.display_text_on_line(3, 'Afdak:' + jsonAfdak['result'][0]['Data'], False, None, fg)
    d.display_text_on_line(4, 'Binnen:' + jsonBinnen['result'][0]['Data'], False, None, fg)
    d.display_text_on_line(5, 'Verbruik:' + jsonPower['result'][0]['Usage'], False, None, fg)
    d.display_text_on_line(6, 'Vandaag:' + jsonPower['result'][0]['CounterToday'], False, None, fg)

    #print(jsonBuiten['Result']['Name'])
    print(jsonBuiten['result'][0]['Data'])
    timeout = time.time() + 60*2

    while 1:
        clock_str = str(datetime.datetime.now()).split('.')[0]
        d.display_text_on_line(line_num, clock_str, False, None, fg)

        if (time.time() > timeout):
            break
        # Work out when to wake up for the next round/whole (non-fractional) time
        start_time = time.time()
        future_time = floor(start_time) + update_display_period  # pure float math
        sleep_time = future_time - start_time
        time.sleep(sleep_time)

    print('stopped after timeout')
    d.clear_lines(TextLines.ALL, bg)
    d.dim_when_idle(False)
    d.set_brightness(0)
    d.save_brightness(0, 255)
    d.set_text_background_colour(bg)
Esempio n. 19
0
File: mrt.py Progetto: ferrygun/mrt
def getArrivalTime(stationcode, stationname):
    url = 'https://smrtfd18.herokuapp.com/webhook'
    payload = {
        'stationcode': stationcode,
        'key': 'MEtSAm6Tzl5PPT3bmLq1JqkFvcpXmKL2M7EWbq15'
    }

    r = requests.post(url, data=payload)

    output = json.loads(r.content)

    nextTrain = ''
    subTrain = ''
    nextTrainFinalDtn = ''
    j = 0

    d = LCDSysInfo()
    d.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
    d.dim_when_idle(False)
    d.set_brightness(127)
    d.save_brightness(127, 255)
    d.set_text_background_colour(BackgroundColours.BLACK)

    for rows in output['Arrivals']:
        for x in output['Arrivals'][rows]:
            if x > 0:
                for y in output['Arrivals'][rows][x]:
                    print x, ':', y, ':', output['Arrivals'][rows][x][y]

                    if (y == 'nextTrainFinalDtn'):
                        nextTrainFinalDtn = output['Arrivals'][rows][x][
                            y].strip()
                        j += 1

                    if (y == 'nextTrain'):
                        str_ = str(output['Arrivals'][rows][x][y])
                        nextTrain = filter(str.isdigit, str_)
                        j += 1

                    if (y == 'subTrain'):
                        str_ = str(output['Arrivals'][rows][x][y])
                        subTrain = filter(str.isdigit, str_)
                        j += 1

                    if (j == 3):
                        print 'To: ', nextTrainFinalDtn, '> ', nextTrain, ' ', subTrain

                        if (nextTrainFinalDtn != ''):
                            clock_str = str(
                                datetime.datetime.now()).split('.')[0]

                            d.display_text_on_line(1, stationname, False,
                                                   TextAlignment.CENTRE,
                                                   TextColours.PINK)
                            d.display_text_on_line(
                                2, '---------------------------------------',
                                False, TextAlignment.CENTRE, TextColours.PINK)
                            d.display_text_on_line(3,
                                                   'To ' + nextTrainFinalDtn,
                                                   False, TextAlignment.CENTRE,
                                                   TextColours.GREEN)
                            d.display_text_on_line(
                                4, 'Next train: ' + nextTrain + ' min(s)',
                                False, TextAlignment.LEFT, TextColours.YELLOW)
                            d.display_text_on_line(
                                5, 'Sub. train: ' + subTrain + ' min(s)',
                                False, TextAlignment.LEFT, TextColours.CYAN)
                            d.display_text_on_line(6, clock_str, False,
                                                   TextAlignment.CENTRE,
                                                   TextColours.WHITE)

                            time.sleep(5)
                            d.clear_lines(TextLines.ALL,
                                          BackgroundColours.BLACK)

                        j = 0
Esempio n. 20
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from pylcdsysinfo import LCDSysInfo, TextAlignment, TextColours, large_image_indexes
from time import sleep

d = LCDSysInfo()
while True:
    for num, idx in enumerate(large_image_indexes):
        d.display_icon(0, idx)
        d.display_text_on_line(1, "{{{" + str(num), False, TextAlignment.NONE, TextColours.WHITE)
        sleep(1)
Esempio n. 21
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from pylcdsysinfo import BackgroundColours, TextColours, TextAlignment, TextLines, LCDSysInfo
from time import sleep

d = LCDSysInfo()
d.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
d.dim_when_idle(False)
d.set_brightness(255)
d.save_brightness(127, 255)
d.set_text_background_colour(BackgroundColours.BLACK)
d.display_cpu_info(8010, 32, TextColours.RED, TextColours.WHITE)
d.display_ram_gpu_info(1994, 32, TextColours.RED, TextColours.GREEN)
d.display_network_info(1, 2, TextColours.RED, TextColours.GREEN, 0, 1)
d.display_fan_info(1994, 1994, TextColours.RED, TextColours.GREEN)
for pos in range(0, 48):
    d.display_icon(pos, 1 + pos % 32)
d.clear_lines(63, BackgroundColours.WHITE)
d.set_text_background_colour(BackgroundColours.BLUE)
sleep(1)
for line in range(1, 7):
    d.display_text_on_line(
        line, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        False, TextAlignment.LEFT, TextColours.WHITE)
Esempio n. 22
0
import socket
import time

from pylcdsysinfo import BackgroundColours, TextColours, TextAlignment, TextLines, LCDSysInfo
from time import sleep

hostname=socket.gethostname()

#Get IP address and concatenate with "IP: " string
t_ipaddress=socket.gethostbyname(hostname)
ipaddress="IP: " + t_ipaddress
    
d = LCDSysInfo()
d.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
d.dim_when_idle(False)
d.set_brightness(255)
d.save_brightness(127, 255)
d.set_text_background_colour(BackgroundColours.BLACK)

while True:
    d.display_text_on_line(2, "Hostname: ", True, TextAlignment.LEFT, TextColours.GREEN)
    d.display_text_on_line(4, ipaddress, True, TextAlignment.LEFT, TextColours.WHITE)
    time.sleep(5)
    d.display_text_on_line(2, hostname, True, TextAlignment.LEFT, TextColours.GREEN)
    d.display_text_on_line(4, ipaddress, True, TextAlignment.LEFT, TextColours.WHITE)
    time.sleep(5)
    d.clear_lines(TextLines.ALL, BackgroundColours.BLACK)

sys.exit(0)

Esempio n. 23
0
	# generate client name and connect to mqtt
	mypid = os.getpid()
	client_uniq = "pubclient_"+str(mypid)

	# set the screen up
	d = LCDSysInfo()
	d.clear_lines(TextLines.ALL, bg)
	d.dim_when_idle(False)
	d.set_brightness(127)
	d.save_brightness(127, 255)
	d.set_text_background_colour(bg)

	# connect mqtt
	connect()

	#remain connected and publis
	mqttc.loop_forever()

	# bad
	logging.info("Dropped out of the loop, Exiting")
	time.sleep(2)
	sys.exit(1)

except Exception, e:
	# exit with error, supervisord will restart it.
	d.clear_lines(TextLines.ALL, bg)
	d.display_text_on_line(3, "Error", False, TextAlignment.CENTRE, TextColours.CYAN)
	logging.error(e)
	logging.error(traceback.format_exc())
	time.sleep(10)
	sys.exit(1)	
Esempio n. 24
0
#Get IP address and concatenate with "IP: " string
ipaddress=socket.gethostbyname(hostname)
ipstring="IP: " + ipaddress
print(ipstring)

if sys.platform == 'darwin':
    ipaddress=socket.gethostbyname(hostname)
    print("Mac detected")
    

d = LCDSysInfo()
d.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
d.dim_when_idle(False)
d.set_brightness(255)
d.save_brightness(127, 255)
d.set_text_background_colour(BackgroundColours.BLACK)

#d.display_cpu_info(8010, 32, TextColours.RED, TextColours.WHITE)
#d.display_ram_gpu_info(1994, 32, TextColours.RED, TextColours.GREEN)
#d.display_network_info(1, 2, TextColours.RED, TextColours.GREEN, 0, 1) 
#d.display_fan_info(1994, 1994, TextColours.RED, TextColours.GREEN)

d.display_text_on_line(2, "Hostname: ", True, TextAlignment.LEFT, TextColours.GREEN)
d.display_text_on_line(3, hostname, True, TextAlignment.LEFT, TextColours.GREEN)
d.display_text_on_line(4, ipstring, True, TextAlignment.LEFT, TextColours.WHITE)
#d.display_text_on_line(5, ipaddress, True, TextAlignment.LEFT, TextColours.WHITE)

sys.exit(0)

Esempio n. 25
0
class EventHandler(pyinotify.ProcessEvent):
    last_updated = 0

    def __init__(self, path):
        super(EventHandler, self).__init__()
        self.lcd = LCDSysInfo()
        self.lcd.set_brightness(BRIGHTNESS)
        self.lcd.dim_when_idle(False)
        self.lcd.clear_lines(TextLines.ALL, BGCOLOR)
        self.old_lines = [''] * 6
        self.path = path

    @staticmethod
    def fmt_task(task):
        try:
            if task.startswith('+'):
                task = '+ ' + task[1:]
            else:
                task = '- ' + task
            return '____%s' % task
        except AttributeError as err:
            return '- %s' % err

    @staticmethod
    def _parse_todos(path):
        with open(path, 'rU') as fobj:
            yobj = yaml.safe_load_all(fobj)


            # Python 2/3 adapter
            if hasattr(yobj, 'next'):
                yobj_next = yobj.next
            elif hasattr(yobj, '__next__'):
                yobj_next = yobj.__next__
            else:
                raise Exception("Python is broken")

            # Skip header text
            yobj_next()

            return yobj_next() or {}

    def process_IN_MODIFY(self, event):
        # Workaround for race condition when using IN_MODIFY
        # (Because IN_CLOSE_WRITE | IN_MOVED_TO doesn't fire with Leafpad)
        this_stat, waited = os.stat(self.path), 0
        while this_stat.st_size == 0 and waited < 3:
            time.sleep(0.3)
            this_stat = os.stat(self.path)
            waited += 0.3

        # Ensure we fire only once per change
        if self.last_updated == this_stat.st_mtime:
            return

        try:
            data = self._parse_todos(self.path)
        except BaseException as err:
            log.debug("Couldn't parse data from file: %s", self.path)
            lines = ["Error parsing TODO YAML",
                     "%d bytes" % this_stat.st_size,
                     "",
                     str(err)]
            print(err)
        else:
            tasks = data.get('TODO', None)
            if tasks:
                lines = ["TODO:"] + [self.fmt_task(x) for x in tasks]
            else:
                lines = ["No TODOs found"]

        # Waste as little time as possible overwriting lines that haven't
        # changed
        for pos, line in enumerate(lines[:6]):
            if line != self.old_lines[pos]:
                # Work around the ASCII-only-ness of the USBLCD API
                if isinstance(line, bytes):
                    line = line.decode('utf8', 'replace')
                line = unidecode(line)

                self.lcd.display_text_on_line(pos + 1, line, False,
                                         TextAlignment.LEFT, FGCOLOR)
                self.old_lines[pos] = line

        # Only erase lines that used to have something on them
        mask = 0
        for pos in range(len(lines), 6):
            if self.old_lines[pos]:
                mask += 1 << int(pos)
                self.old_lines[pos] = ''
        if mask:
            self.lcd.clear_lines(mask, BGCOLOR)

        # Only update this if we successfuly parsed and applied an update
        self.last_updated = this_stat.st_mtime
Esempio n. 26
0
#strip it
substringvwap = str1[subStringFindVwap + 16:];
#extract it
vwap = substringvwap[0 : 0 +6];
#get the high price
str7 = "high"
#look for it
subStringFindHigh = str1.find(str7);
#strip it
substringhigh = str1[subStringFindHigh + 16:];
#extract it
high = substringhigh[0 : 0 +6];

# Refresh the background and make it black
display.set_text_background_colour(BackgroundColours.BLACK)

#loop through each line to display, filling in the variables.
for line in range(1, 7):
    if line == 1:
        display.display_text_on_line(line, '1 BTC at MtGox', True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)
    elif line == 2:
        display.display_text_on_line(line, 'Last $' + str(price) + " USD", True, (TextAlignment.LEFT, TextAlignment.LEFT), TextColours.GREEN)
    elif line == 3:
        display.display_text_on_line(line, 'Volume: ' + str(volume), True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.RED)
    elif line == 4:
        display.display_text_on_line(line, 'High $' + str(high), True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)
    elif line == 5:
        display.display_text_on_line(line, 'Low $' + str(low), True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)
    elif line == 6:
	    display.display_text_on_line(line, 'Avg $' + str(vwap), True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)
Esempio n. 27
0
substringbtc = str2[subStringFindBTC + 20:];
#extract the price
btc =  substringbtc[0 : 0 +6];
#BTC at BTC-E
str6 ="last"
#look for it in the result
subStringFindBTCE = str3.find(str6);
#strip the string to 'keep' the price
substringbtce = str3[subStringFindBTCE + 6:];
#extract the price
btce =  substringbtce[0 : 0 +6];
# Refresh the background and make it black
display.set_text_background_colour(BackgroundColours.BLACK)

#loop through each line to display, filling in the variables.
for line in range(1, 7):
    if line == 1:
        display.display_text_on_line(line, '1 LTC at BTC-E', True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)
    elif line == 2:
        display.display_text_on_line(line, '$' + str(ltc) + " USD", True, (TextAlignment.LEFT, TextAlignment.LEFT), TextColours.GREEN)
    elif line == 3:
        display.display_text_on_line(line, '1 BTC at Mt. Gox ', True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)
    elif line == 4:
        display.display_text_on_line(line, '$' + str(btc) + " USD", True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)
    elif line == 5:
        display.display_text_on_line(line, '1 BTC at BTC-E ', True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)
    elif line == 6:
        display.display_text_on_line(line, '$' + str(btce) + " USD", True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)


Esempio n. 28
0
    #Look for it in the result
    subStringFindVol = str1.find(str3);
    #strip it
    substringvolume = str1[subStringFindVol + 15:];
    #extract it
    volume = substringvolume[0 : 0 +10];
    
    #get the balance from our remote bitcoind and store it.
    #btcbalance = str(conn.getbalance());
    
    # Refresh the background and make it black
    display.set_text_background_colour(BackgroundColours.BLACK)
    
    #loop through each line to display, filling in the variables.
    for line in range(1, 7):
        if line == 1:
             display.display_text_on_line(line, '1 BTC at MtGox', True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREY)
        elif line == 2:
            display.display_text_on_line(line, '$' + str(price) + " USD", True, (TextAlignment.LEFT, TextAlignment.LEFT), TextColours.GREEN)
        elif line == 3:
            display.display_text_on_line(line, 'Volume: ' + str(volume), True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.RED)
        #elif line == 4:
        #    display.display_text_on_line(line, btcbalance + " btc", True, (TextAlignment.RIGHT, TextAlignment.RIGHT), TextColours.GREEN)
        #elif line == 5:
        #    display.display_text_on_line(line, 'Total local wallet:', False, TextAlignment.LEFT, TextColours.LIGHT_BLUE)
        #else:
        #    #calculate our wallet value with mtgox's price to get a dollar price on our wallet.
        #    # Shorten the resulting value to two decimals for easier readability
        #    display.display_text_on_line(line, str("%.2f" % (float(price) * float(btcbalance))) + " usd", True, TextAlignment.RIGHT, TextColours.DARK_BLUE)
time.sleep(10)
Esempio n. 29
0
def showDefaultScreen(firstTime, summary):

    # extract just the data we want from the API result and
    #  build up display strings for each using the data
        
    avg = float(summary['SUMMARY'][0]['MHS av'])
    avgMhs = convertSize(avg*1000000.0)
    foundBlocks = str(int(summary['SUMMARY'][0]['Found Blocks']))    
    difficultyAccepted = "A:" + str(int(summary['SUMMARY'][0]['Difficulty Accepted']))
    if 'Pool Rejected%' in summary['SUMMARY'][0]:
        rej = str(summary['SUMMARY'][0]['Pool Rejected%'])
        if (rej == '0'):
            rejp = rej + "%"
        else:
            rejp = rej.split('.')[0] + "." + rej.split('.')[1][:2] + "%"
    else:
        rejp = str(int(summary['SUMMARY'][0]['Difficulty Rejected']))
    reject = "R:" + rejp
    if 'Device Hardware%' in summary['SUMMARY'][0]:
        hw = str(summary['SUMMARY'][0]['Device Hardware%'])
        if (hw == '0'):
            hwp = hw + "%"
        else:
            hwp = hw.split('.')[0] + "." + hw.split('.')[1][:2] + "%"
    else:
        hwp = str(int(summary['SUMMARY'][0]['Hardware Errors']))
    hardware = "HW:" + hwp
    bestShare = "S:" + convertSize(int(summary['SUMMARY'][0]['Best Share']))
    workUtility = "WU:" + str(summary['SUMMARY'][0]['Work Utility']) + "/m"
   
    # get current time, and format it per user selection
    theTime = ""   
    time.ctime() # formatted like this: 'Mon Oct 18 13:35:29 2010'
    if timeDisplayFormat == '12':
        theTime = time.strftime("%I:%M%p")  # 12 hour display
    else:    
        theTime = time.strftime("%H:%M:%S")  # default to 24 hour display

    # strip common prefixes and suffixes off of the pool URL (to save display space)
    commonStringPattern = ['stratum+tcp://', 'stratum.', 'www.', '.com', 'mining.', ':3333', ':3334']  
    shortPoolURL = str(poolURL)
    for i in commonStringPattern:
        shortPoolURL = shortPoolURL.replace(i, '', 1).rstrip()   
      
    # build the display strings
    line1String = shortPoolURL + "\t" + theTime
    line2String = "Uptime:  " + upTime
    line3String = "Avg:" + avgMhs + "h/s" + "  B:" + foundBlocks
    #line3String = "Avg:" + avgMhs + "\tB:" + foundBlocks
    line4String = difficultyAccepted + "  " + bestShare
    line5String = reject + "  " + hardware
    line6String = workUtility
        
    # set up to write to the LCD screen
    #
    # Init the LCD screen
    display = LCDSysInfo()
    display.dim_when_idle(False)
    display.set_brightness(255)
    display.save_brightness(100, 255)
    
    if (firstTime == True):
        # clear screen
        display.clear_lines(TextLines.ALL, BackgroundColours.BLACK)

    # write all lines
    display.display_text_on_line(1, line1String, True, (TextAlignment.LEFT, TextAlignment.RIGHT), TextColours.YELLOW)
    display.display_text_on_line(2, line2String, True, (TextAlignment.LEFT, TextAlignment.RIGHT), TextColours.LIGHT_BLUE)    
    display.display_text_on_line(3, line3String, True, (TextAlignment.LEFT), TextColours.GREEN)
    display.display_text_on_line(4, line4String, True, (TextAlignment.LEFT), TextColours.GREEN)
    display.display_text_on_line(5, line5String, True, (TextAlignment.LEFT), TextColours.GREEN)
    display.display_text_on_line(6, line6String, True, (TextAlignment.LEFT), TextColours.GREEN)
def showDefaultScreen(firstTime, summary, mtgoxLastPrice, mtgoxDirectionCode,
                      toggleSinceLast, mtgoxToggleState):

    # extract just the data we want from the API result and
    #  build up display strings for each using the data

    avg = float(summary['SUMMARY'][0]['MHS av'])
    avgMhs = convertSize(avg * 1000000.0)
    foundBlocks = str(int(summary['SUMMARY'][0]['Found Blocks']))
    difficultyAccepted = "A:" + str(
        int(summary['SUMMARY'][0]['Difficulty Accepted']))
    if 'Pool Rejected%' in summary['SUMMARY'][0]:
        rej = str(summary['SUMMARY'][0]['Pool Rejected%'])
        if (rej == '0'):
            rejp = rej + "%"
        else:
            rejp = rej.split('.')[0] + "." + rej.split('.')[1][:2] + "%"
    else:
        rejp = str(int(summary['SUMMARY'][0]['Difficulty Rejected']))
    reject = "R:" + rejp
    if 'Device Hardware%' in summary['SUMMARY'][0]:
        hw = str(summary['SUMMARY'][0]['Device Hardware%'])
        if (hw == '0'):
            hwp = hw + "%"
        else:
            hwp = hw.split('.')[0] + "." + hw.split('.')[1][:2] + "%"
    else:
        hwp = str(int(summary['SUMMARY'][0]['Hardware Errors']))
    hardware = "HW:" + hwp
    bestShare = "S:" + convertSize(int(summary['SUMMARY'][0]['Best Share']))
    workUtility = "WU:" + str(summary['SUMMARY'][0]['Work Utility']) + "/m"

    # get current time, and format it per user selection
    theTime = ""
    time.ctime()  # formatted like this: 'Mon Oct 18 13:35:29 2010'
    if timeDisplayFormat == '12':
        theTime = time.strftime("%I:%M%p")  # 12 hour display
    else:
        theTime = time.strftime("%H:%M:%S")  # 24 hour display

    # strip common prefixes and suffixes off of the pool URL (to save display space)
    # TODO add code to remove all ":dddd" instead of adding port numbers to ignore
    commonStringPattern = [
        'http://', 'stratum+tcp://', 'stratum.', 'www.', '.com', 'mining.',
        ':3333', ':3334', ':8330'
    ]
    shortPoolURL = str(poolURL)
    for i in commonStringPattern:
        shortPoolURL = shortPoolURL.replace(i, '', 1).rstrip()

    # build the display strings
    line1String = shortPoolURL + "\t" + theTime
    line2String = "Uptime:  " + upTime
    line3String = "Avg:" + avgMhs + "h/s" + "  B:" + foundBlocks
    if int(foundBlocks) > 0:
        line3Colour = TextColours.RED
    else:
        line3Colour = TextColours.GREEN

    #line3String = "Avg:" + avgMhs + "\tB:" + foundBlocks
    line4String = difficultyAccepted + "  " + bestShare
    line5String = reject + "  " + hardware

    if mtgoxToggleState:  # if we have MtGox data, get ready to display it
        line6String = "MtGox: " + mtgoxLastPrice
    else:
        line6String = workUtility

    # set up to write to the LCD screen
    #
    # Init the LCD screen
    display = LCDSysInfo()
    display.dim_when_idle(False)
    display.set_brightness(255)
    display.save_brightness(100, 255)

    if (firstTime == True):
        # clear screen
        display.clear_lines(TextLines.ALL, BackgroundColours.BLACK)

    # write all lines
    display.display_text_on_line(1, line1String, True,
                                 (TextAlignment.LEFT, TextAlignment.RIGHT),
                                 TextColours.YELLOW)
    display.display_text_on_line(2, line2String, True,
                                 (TextAlignment.LEFT, TextAlignment.RIGHT),
                                 TextColours.LIGHT_BLUE)
    display.display_text_on_line(3, line3String, True, (TextAlignment.LEFT),
                                 line3Colour)
    display.display_text_on_line(4, line4String, True, (TextAlignment.LEFT),
                                 TextColours.GREEN)
    display.display_text_on_line(5, line5String, True, (TextAlignment.LEFT),
                                 TextColours.GREEN)

    # check to see if the mtgoxDisplay just toggled, if so, display black text to remove traces of previous icon
    if toggleSinceLast == True:
        display.display_text_anywhere(0, 197, '       ', TextColours.BLACK)

    if mtgoxToggleState == True:
        display.display_icon(
            41, mtgoxDirectionCode
        )  # directionCode should contain the icon number for up or down arrow
        display.display_text_anywhere(95, 200, line6String, TextColours.GREEN)
    else:
        display.display_text_on_line(6, line6String, True,
                                     (TextAlignment.LEFT), TextColours.GREEN)