Skip to content

Instantly share code, notes, and snippets.

@tirzasrwn
Created April 12, 2024 04:27
Show Gist options
  • Save tirzasrwn/a6f2fb019644f63d42cb6e15d97e5185 to your computer and use it in GitHub Desktop.
Save tirzasrwn/a6f2fb019644f63d42cb6e15d97e5185 to your computer and use it in GitHub Desktop.
ping status lcd 1602 beaglebone black
#!/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()
@tirzasrwn
Copy link
Author

rc.local

#!/bin/bash

sleep 10

echo "run rc.local" >/tmp/rc.local.txt
# /sbin/route add default gw 192.168.7.1
# echo "nameserver 8.8.8.8" >/etc/resolv.conf
# /home/debian/boot/ping-stat.py >/dev/null 2>&1 &

exit 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment