def oledDisplay(msgType, message): # Displays to th oled, doesn't bother if the message hasnt changed. global lastDisplay #print "Message is %s and lastDisplay is %s" % (message,lastDisplay) if msgType == 'p': header = 'Pwned!:' elif msgType == 'h': header = 'Recent host:' if message != lastDisplay: #print "Upating display" # lcd.home() # lcd.clear() # #lcd.autoscroll() # #lcd.setCursor(2,1) # lcd.message('%s' % (message)) if lastDisplay: oled.chompit() else: oled.clear_display() oled.shift_display(right=True, count=16) oled.set_pos(0, 0) oled.write_string(header) oled.shift_display(right=False, count=16) oled.set_pos(1, 0) tdelay = 0.1 oled.write_string(message.center(16), typeomatic_delay=tdelay) lastDisplay = message
def oledDisplay(msgType, message): # Displays to th oled, doesn't bother if the message hasnt changed. global lastDisplay # print "Message is %s and lastDisplay is %s" % (message,lastDisplay) if msgType == "p": header = "Pwned!:" elif msgType == "h": header = "Recent host:" if message != lastDisplay: # print "Upating display" # lcd.home() # lcd.clear() # #lcd.autoscroll() # #lcd.setCursor(2,1) # lcd.message('%s' % (message)) if lastDisplay: oled.chompit() else: oled.clear_display() oled.shift_display(right=True, count=16) oled.set_pos(0, 0) oled.write_string(header) oled.shift_display(right=False, count=16) oled.set_pos(1, 0) tdelay = 0.1 oled.write_string(message.center(16), typeomatic_delay=tdelay) lastDisplay = message
def partyMode(): sch = 2 oled.clear_display() for col in range(16): oled.set_pos(1, col) if sch == 2 or sch == 3: oled.write_raw_data(sch) else: oled.write_string(sch) if sch == 2: sch = 3 elif sch == 3: sch = " " else: sch = 2 for count in range(20): oled.set_pos(0, 0) oled.write_raw_data(5) oled.set_pos(0, 3) oled.write_raw_data(4) oled.set_pos(0, 6) oled.write_raw_data(5) oled.set_pos(0, 10) oled.write_raw_data(4) oled.set_pos(0, 14) oled.write_raw_data(5) sleep(0.5) oled.set_pos(0, 0) oled.write_raw_data(4) oled.set_pos(0, 3) oled.write_raw_data(5) oled.set_pos(0, 6) oled.write_raw_data(4) oled.set_pos(0, 10) oled.write_raw_data(5) oled.set_pos(0, 14) oled.write_raw_data(4) sleep(0.5) for col in range(16): oled.set_pos(0, col) oled.write_string(" ") for col in [10, 3, 6, 4, 8, 9, 12, 4, 13, 3, 15, 8]: oled.set_pos(0, col) oled.write_raw_data(5) sleep(0.5) oled.set_pos(0, col) oled.write_raw_data(4) sleep(0.5) oled.set_pos(0, col) oled.write_string(" ") for col in range(16): oled.set_pos(0, col) oled.write_string(" ") oled.set_pos(0, 0) display = "D E R B Y C O N" oled.write_string(display.center(16), typeomatic_delay=0.5)
def advertise(): # Retruns a random advertisement. global lastDisplay global adLoopCount global ownerTwitter currentHour = datetime.now().hour if currentHour >= 20 or currentHour <= 2: partyMode() else: ads = [ twitter, "Free Hugs!", "___ all the ___!", "Hack the Planet!", "We like beer.", "Ice? Not so much", "Hack 4 Charities", "Chess?", "Ironliver comp.", "@starkdong", "LiverStrong!", "CTF fun for all!", ] if adLoopCount >= 5: message = "Join my SSID:" ssid = getSSID() adLoopCount = 0 oled.chompit() oled.set_pos(0, 0) oled.write_string("There are many") oled.set_pos(1, 0) oled.write_string("derbies but") sleep(5) oled.clear_display() oled.set_pos(0, 0) oled.write_string("This one is") oled.set_pos(1, 0) owner = ownerTwitter + "'s" oled.write_string(owner.center(16)) sleep(10) oled.chompit() oled.set_pos(0, 0) oled.shift_display(right=True, count=16) oled.write_string(message) oled.shift_display(right=False, count=16) sleep(1) oled.set_pos(1, 0) oled.write_string(ssid.center(16)) sleep(10) oled.chompit() oled.set_pos(0, 0) oled.write_string("Information at:") oled.set_pos(1, 0) oled.write_string("http://hmd.lafayette.edu") for shift in range(8): oled.shift_display(right=False, count=1) sleep(1) for shift in range(8): oled.shift_display(right=True, count=1) sleep(1) for shift in range(8): oled.shift_display(right=False, count=1) sleep(1) for shift in range(8): oled.shift_display(right=True, count=1) sleep(1) else: ad = random.choice(ads) if ad != lastDisplay: footer = "Hack My Derby!" if lastDisplay: oled.chompit() else: oled.clear_display() oled.set_pos(0, 0) oled.shift_display(right=True, count=16) oled.write_string(ad.center(16)) oled.shift_display(right=False, count=16) sleep(1) oled.set_pos(1, 0) oled.write_string(footer.center(16)) lastDisplay = ad adLoopCount = adLoopCount + 1
def advertise(): # Retruns a random advertisement. global lastDisplay global adLoopCount global ownerTwitter currentHour = datetime.now().hour if currentHour >= 20 or currentHour <= 2: partyMode() else: ads = [ twitter, 'Free Hugs!', '___ all the ___!', 'Hack the Planet!', 'We like beer.', 'Ice? Not so much', 'Hack 4 Charities', 'Chess?', 'Ironliver comp.', '@starkdong', 'LiverStrong!', 'CTF fun for all!' ] if adLoopCount >= 5: message = 'Join my SSID:' ssid = getSSID() adLoopCount = 0 oled.chompit() oled.set_pos(0, 0) oled.write_string('There are many') oled.set_pos(1, 0) oled.write_string('derbies but') sleep(5) oled.clear_display() oled.set_pos(0, 0) oled.write_string('This one is') oled.set_pos(1, 0) owner = ownerTwitter + '\'s' oled.write_string(owner.center(16)) sleep(10) oled.chompit() oled.set_pos(0, 0) oled.shift_display(right=True, count=16) oled.write_string(message) oled.shift_display(right=False, count=16) sleep(1) oled.set_pos(1, 0) oled.write_string(ssid.center(16)) sleep(10) oled.chompit() oled.set_pos(0, 0) oled.write_string('Information at:') oled.set_pos(1, 0) oled.write_string('http://hmd.lafayette.edu') for shift in range(8): oled.shift_display(right=False, count=1) sleep(1) for shift in range(8): oled.shift_display(right=True, count=1) sleep(1) for shift in range(8): oled.shift_display(right=False, count=1) sleep(1) for shift in range(8): oled.shift_display(right=True, count=1) sleep(1) else: ad = random.choice(ads) if ad != lastDisplay: footer = 'Hack My Derby!' if lastDisplay: oled.chompit() else: oled.clear_display() oled.set_pos(0, 0) oled.shift_display(right=True, count=16) oled.write_string(ad.center(16)) oled.shift_display(right=False, count=16) sleep(1) oled.set_pos(1, 0) oled.write_string(footer.center(16)) lastDisplay = ad adLoopCount = adLoopCount + 1
def get(self): result = oled.clear_display() return jsonify(result)