Created
April 12, 2024 04:27
-
-
Save tirzasrwn/a6f2fb019644f63d42cb6e15d97e5185 to your computer and use it in GitHub Desktop.
ping status lcd 1602 beaglebone black
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import time | |
import os | |
import Adafruit_CharLCD as LCD | |
# BeagleBone Black configuration: | |
lcd_rs = 'P8_8' | |
lcd_en = 'P8_10' | |
lcd_d4 = 'P8_18' | |
lcd_d5 = 'P8_16' | |
lcd_d6 = 'P8_14' | |
lcd_d7 = 'P8_12' | |
lcd_backlight = 'P8_7' | |
# Define LCD column and row size for 16x2 LCD. | |
lcd_columns = 16 | |
lcd_rows = 2 | |
# Initialize the LCD using the pins above. | |
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, | |
lcd_columns, lcd_rows, lcd_backlight) | |
while(True): | |
ping = os.popen("ping -i 0.2 -c 1 8.8.8.8 | grep ttl | awk '{ print $7 }'").read().replace("\n", "").replace("time=", "") | |
dc = os.popen("date -d '+7 hours' '+%a %T'").read().replace("\n", "") | |
date = os.popen("date -d '+7 hours' '+%d/%m'").read().replace("\n", "") | |
lcd.message(str(dc) + "\n" + str(date) + " " + str(ping) + " ms") | |
time.sleep(1) | |
lcd.clear() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rc.local