#!/bin/bash

clear
function clear_stdin()
(
    old_tty_settings=`stty -g`
    stty -icanon min 0 time 0

    while read none; do :; done

    stty "$old_tty_settings"
)
if [ $# -ne 1 ];
then
	echo Kindly specify the i2c bus number. The default i2c bus number is 3.
	echo Command as following:
	echo $0 i2c-bus-number
	i2c_bus=3
else
	i2c_bus=$1
fi

i2c_addr=(0x3f 0x38)

for value in ${i2c_addr[@]};
do
i2cset -f -y $i2c_bus $value 0x00 0x00
i2cset -f -y $i2c_bus $value 0x7f 0x00
i2cdump -f -y $i2c_bus $value
clear_stdin
read -n1 -p "Press any key to continue..."
done;