mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-22 16:33:17 +00:00
Configurable OLED screen rotation (#359)
* Read rotation from the 1st command line arg * Configure screen rotation during installation * Better argument validation + use human readable arguments * Cleanup
This commit is contained in:
parent
dbaf5dcd30
commit
269b718ec7
@ -139,9 +139,18 @@ function installRaScsiScreen() {
|
||||
echo "IMPORTANT: This configuration requires a OLED screen to be installed onto your RaSCSI board."
|
||||
echo "See wiki for more information: https://github.com/akuker/RASCSI/wiki/OLED-Status-Display-(Optional)"
|
||||
echo ""
|
||||
echo "Press enter to continue or CTRL-C to exit"
|
||||
echo "Do you want to use the recommended screen rotation (180 degrees)?"
|
||||
echo "Press Y/n and Enter, or CTRL-C to exit"
|
||||
read REPLY
|
||||
|
||||
if [ "$REPLY" == "N" ] || [ "$REPLY" == "n" ]; then
|
||||
echo "Proceeding with 0 degrees rotation."
|
||||
ROTATION="0"
|
||||
else
|
||||
echo "Proceeding with 180 degrees rotation."
|
||||
ROTATION="180"
|
||||
fi
|
||||
|
||||
sudo systemctl stop monitor_rascsi || true
|
||||
updateRaScsiGit
|
||||
|
||||
@ -170,6 +179,8 @@ function installRaScsiScreen() {
|
||||
|
||||
echo "Installing the monitor_rascsi.service configuration..."
|
||||
sudo cp -f "$BASE/src/oled_monitor/monitor_rascsi.service" /etc/systemd/system/monitor_rascsi.service
|
||||
sudo sed -i /^ExecStart=/d /etc/systemd/system/monitor_rascsi.service
|
||||
sudo sed -i "8 i ExecStart=$BASE/src/oled_monitor/start.sh --rotation=$ROTATION" /etc/systemd/system/monitor_rascsi.service
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable monitor_rascsi
|
||||
|
@ -29,6 +29,7 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
from time import sleep
|
||||
from sys import argv, exit
|
||||
import logging
|
||||
from board import I2C
|
||||
from adafruit_ssd1306 import SSD1306_I2C
|
||||
@ -60,7 +61,20 @@ print (oled)
|
||||
print ()
|
||||
print ("Will update the OLED display every " + str(delay_time_ms) + "ms (approximately)")
|
||||
|
||||
# Attempt to read the first argument to the script; fall back to 2 (180 degrees)
|
||||
if len(argv) > 1:
|
||||
if str(argv[1]) == "0":
|
||||
rotation = 0
|
||||
elif str(argv[1]) == "180":
|
||||
rotation = 2
|
||||
else:
|
||||
exit("Only 0 and 180 are valid arguments for screen rotation.")
|
||||
else:
|
||||
print("Defaulting to 180 degrees screen rotation.")
|
||||
rotation = 2
|
||||
|
||||
# Clear display.
|
||||
oled.rotation = rotation
|
||||
oled.fill(0)
|
||||
oled.show()
|
||||
|
||||
|
@ -70,5 +70,29 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Starting OLED Screen..."
|
||||
python3 rascsi_oled_monitor.py
|
||||
# parse arguments
|
||||
while [ "$1" != "" ]; do
|
||||
PARAM=$(echo "$1" | awk -F= '{print $1}')
|
||||
VALUE=$(echo "$1" | awk -F= '{print $2}')
|
||||
case $PARAM in
|
||||
-r | --rotation)
|
||||
ROTATION=$VALUE
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: unknown parameter \"$PARAM\""
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
case $VALUE in
|
||||
0 | 180 )
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: invalid option \"$VALUE\""
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
echo "Starting OLED Screen with $ROTATION degrees rotation..."
|
||||
python3 rascsi_oled_monitor.py "${ROTATION}"
|
||||
|
Loading…
Reference in New Issue
Block a user