Get input from OLED Joystick, Runs command, Displays output on OLED Screen (Great for P4wnP1)

Overview

p4wnsolo-joyterm

  • Gets text input from OLED Joystick
  • Runs the command you typed
  • Displays output on OLED Screen (Great for P4wnP1 - even better on Raspberry Pi Zero 2)

This is a small collection of a few scripts I put together to enable Terminal functionality on Raspberry Pi with OLED screen (especially P4wnP1).

It is assumed that you already got your OLED screen working before trying p4wnsolo-joyterm (see SH1106 on Github).

Performance Note (Pi0W vs Pi02)

Everything about this project runs way faster and more smoothly on Raspberry Pi Zero 2.

But until nexmon is released for RPi02W, we're stuck with slower performance (if you're dead set on using P4wnP1 as your OS - and if so, I don't blame you one bit).

It's entirely possible that the code in this repo is so sloppy that it's causing the joystick-press performance to suffer on RPiZeroW. But like I said - it runs perfectly (and FAST) on Raspberry Pi Zero 2 (see Demo video clip on Twitter 0m19s)

So for now, here's a Demo / pre-release to get you entering commands using that little Joystick on your P4wnP1.

Requirements:

Hardware:

  • Raspberry Pi (any model should work - tested successfully on RPi0W [OS: P4wnP1_ALOA] and RPi02W [OS: RaspberryPi OS]
  • SH1106 OLED Screen (1.3" by Waveshare)

Software:

  • Linux (so far tested on P4wnP1 ALOA [Kali] and Raspberry Pi OS [Debian])
  • You need luma and luma.oled.
How to Install Luma, Luma.OLED

sudo pip3 install luma luma.oled

Install:

cd ~
git clone https://github.com/p4wnsolo/p4wnsolo-joyterm.git
cd p4wnsolo-joyterm
sudo python3 go.py

Usage:

  1. Use the LEFT and RIGHT buttons on the OLED Joystick to switch characters
  2. Press the CENTER Joystick button to add the current character to the Command Line
  3. If you made a mistake, press KEY2 ("X") for Backspace
  4. To switch KEYBOARD Layout, press KEY1. For example, the default keyboard layout is "a-z" (lowercase).
  5. Launch the command: press KEY3 (">")
  6. View the command output on the OLED screen

Tips:

  • The SPACE character (" ") exists in at least two character sets: "a-z" and "A-Z" (both uppercase and lowercase alphabet character sets have the SPACE character after the "Z" character or before the "A" character).
  • The character set repeats (or "cycles") when the last character in the set is reached. So you can just keep scrolling through characters (ex: If you're on the A character, press Left to go to Z from A, or press Right to go from A to B).

There are four (4) character sets:

  • a-z (lowercase) (default)
  • 0-9
  • special characters
  • A-Z (uppercase)

Compatibility & Platforms

For developing the script, I actually used a RaspberryPi Zero 2.
To finish developing the script (make it cross-compatible), I ran it several times on Raspberry Pi Zero W running P4wnP1 ALOA latest.

Testing DONE on Pi Zero W (I ran the scripts on my RPi0W P4wnP1 and changed the code to be cross-platform).

Files included:

go.py – Adapted from a code snippet found somewhere
  • Launches the scripts that do the actual work:
p4wnsolo-joytext.py – Adapted from key_demo.py in SH1106 demo files (but by now it’s its own beast, pretty much)
  • Displays the “Enter Command” screen and takes text input using Joystick & buttons on OLED screen
p4wnsolo-terminal.py – Adapted from terminal.py in luma.examples
  • Runs the command Prints the output onto the OLED screen

Explanation of Scripts in p4wnsolo-joyterm

What is go.py?

  • Launches the “wifi-pw-skiptest.py” script to get text input from joystick and buttons on OLED screen
  • Then runs the “terminal.py” script to execute the text input (command)

What is p4wnsolo-joytext.py?

This script displays an “Enter command” screen on the SH1106 OLED display.

Then it waits for the user to press the joystick to change characters (using the Left and Right joystick buttons).

Pressing the “Center” joystick button adds the current character to the line.

KEY1 (font-awesome keyboard icon) switches keyboard layouts:

[0] The default layout is uppercase alphabet (A-Z) [1] Next is 0-9 [2] Then the special characters (./!@#$%^&* etc) The SPACE character is currently located in this character set [3] Finally, we have lowercase alphabet (a-z) KEY2 (“X”) is the backspace key.

KEY3 (“>”) is the GO button.

What is p4wnsolo-terminal.py?

The terminal.py script is an adaptation of the terminal.py script found in luma.examples repo. The terminal.py from luma.examples utilizes a LOOP to display “lines” of text on the OLED screen. But the text it displays is static – it’s generated by simple code (resulting in “Line 1, Line 2, Line 3..”). So I simply replaced that part of the code to display lines of text from a TEXT FILE. This was way more interesting than just displaying lines being generated by code. Now that we got the (excellent) terminal.py (from luma.examples) script to display dynamic content, we’re ready to take the command input from the user and send it to terminal.py.

Entering text using joystick on OLED screen

Just enter any command you normally would on the Linux command line. Here are some nice, short, sweet commands if you're out of ideas:

  • ls
  • iwconfig
  • who
  • whoami

Or be bold, install Wifite, and try "sudo wifite".

The Docket

To Do

Eventually I'll add these features:

  • Run previous command(s) (like pressing the "Up" arrow key in Linux CLI)
  • Make some aliases to speed up entry of common commands
  • Move command-entry area to very bottom of screen
  • (Priority #1) Have the script continue to read lines of text even after the last line was read (until the “X” key is pressed)
  • (Priority #2) Have the command-entry area re-appear after no new lines in text file have been read for 2 or 3 seconds The purpose of this is to enable the user to input more text when a program pauses and asks for user input (such as Wifite and many other hacking programs for Linux)
  • Optional cool add-on: Show a countdown / progress bar/line that fills from top of screen to bottom, to meet the command-entry area when it appears after X seconds of no more text output
  • Add a few useful aliases

Done

Add space character (” “) between A and Z in A-Z uppercase AND lowercase charsets Add space character to 0-9 charset

Local file locations:

The following list of files are required to run P4wn-Term. go.py p4wnsolo-joytext.py p4wnsolo-terminal.py

Run on Boot

To run this script on boot, just follow the steps below to add p4wnsolo-joyterm to Crontab as a new entry.

How to Add p4wnsolo-joyterm to Crontab

  • Enter "crontab -e" on command line
  • Paste the code below in the first empty line: @reboot cd /home/pi/BeBoXGui/ && /usr/bin/python3 /home/pi/BeBoXGui/termwrap.py
P4wnP1 / Kali Linux:

@reboot cd /root/p4wnsolo-joyterm/ && /usr/bin/python3 /root/p4wnsolo-joyterm/go.py

Raspberry Pi OS:

@reboot cd /home/pi/p4wnsolo-joyterm/ && /usr/bin/python3 /home/pi/p4wnsolo-joyterm/go.py

The crontab entry above does the following:

  • Changes folders into the main working folder using crontab
  • Then runs the P4wnP1 OLED Terminal wrapper

Aliases to Add

Side project idea – PiPod Shuffle:

Use a quick alias to play MP3 files randomly to mimic and iPod shuffle.

Command:

mplayer -loop 0 -shuffle $(cat your_playlist.m3u)

alias music='mplayer --shuffle *

Mplayer

or Mimic an iPod shuffle using this command:

https://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html Find a File I can never remember the syntax for this command. So why not make an alias for it.

Command:

find /home -name *.jpg

Modify ping Behavior

I don’t know why I’d do this, but I might:

Command:

Stop after sending count ECHO_REQUEST packets: alias ping=’ping -c 5′ Do not wait interval 1 second, go fast # alias fastping=’ping -c 100 -s.2′

Wrap-Up:

To make this script, I basically just modified the terminal.py file from Luma.examples

  1. Take terminal.py from luma.examples
  2. Find the loop that displays “Line 1, Line 2, Line 3”
  3. Replace it with a loop to read lines from a text file

The result from changing this code was significant:

The terminal.py script now shows output from any program – as long as that program is outputting to a text file. Since getting programs to output to text in Linux is pretty easy, we can now display pretty much any program’s output on our OLED screen.

You might also like...
A LiteX project which builds a SoC with DRAM / HDIM output via the GPDI SYZYGY addon.

ButterStick GPDI LiteX demo A LiteX project which builds a SoC with DRAM / HDIM output via the GPDI SYZYGY addon. Getting started Connect GPDI board t

This allows you to record keyboard and mouse input, and play it back using pynput.

Record and Play with Python! This allows you to record keyboard and mouse input, and play it back (with looping) using pynput. It allows for automatio

PyLog - Simple keylogger that uses pynput to listen to keyboard input.

Simple keylogger that uses pynput to listen to keyboard input. Outputs to a text file and the terminal. Press the escape key to stop.

The project is an open-source and low-cost kit to get started with underactuated robotics.
The project is an open-source and low-cost kit to get started with underactuated robotics.

Torque Limited Simple Pendulum Introduction The project is an open-source and low-cost kit to get started with underactuated robotics. The kit targets

Doughskript interpreter for converting simple command sequences into executable Arduino C++ code.

Doughskript interpreter for converting simple command sequences into executable Arduino C++ code.

Runs a command in P4wnP1 and displays the output on OLED screen (SH1106)

p4wnp1-oled-terminal Runs a command in P4wnP1 and displays the output on OLED screen (SH1106) Works on Raspberry Pi Zero 2 W Tested successfully on RP

Get the AltAz coordinates for a given object using astropy and output on a OLED screen.
Get the AltAz coordinates for a given object using astropy and output on a OLED screen.

Star Coordinates Get the AltAz coordinates for a given object using astropy and output on a OLED screen. As a very very newcomer to the astronomy scen

PathPicker accepts a wide range of input -- output from git commands, grep results, searches -- pretty much anything.After parsing the input, PathPicker presents you with a nice UI to select which files you're interested in. After that you can open them in your favorite editor or execute arbitrary commands. A Fear and Greed index visualiser for Bitcoin on a SSD1351 OLED Screen
A Fear and Greed index visualiser for Bitcoin on a SSD1351 OLED Screen

We're Doomed - A Bitcoin Fear and Greed index OLED visualiser Doom is a first-person-shooter from the 1990s. The health status monitor was one of the

Uses diff command to compare expected output with student's submission output

AUTOGRADER for GRADESCOPE using diff with partial grading Description: Uses diff command to compare expected output with student's submission output U

Fly DCS without a joystick
Fly DCS without a joystick

Intro Usage Delete all mouse view axis Install DCSEasyControlExports to your "Saved Games/DCS/" Path python DCSEasyControl/main.py Set DCS to F12 view

A program that lets you use your tablet's tilting to emulate an actual joystick on a Linux computer.

Tablet Tilt Joystick A program that lets you use your tablet's tilting to emulate an actual joystick on a Linux computer. It's called tablet tilt joys

A cross-platform Python module that displays **** for password input. Works on Windows, unlike getpass. Formerly called stdiomask.

PWInput A cross-platform Python module that displays **** for password input. Works on Windows, unlike getpass. Formerly called stdiomask. Installatio

Key Cast - Cast your key presses and mouse clicks on the screen, while casting your favorite application on the screen. Better than the rest.
Key Cast - Cast your key presses and mouse clicks on the screen, while casting your favorite application on the screen. Better than the rest.

Key Cast Screen cast your keyboard and mouse clicks in style Project Homepage » View Demo · Report Bug · Request Feature Table of Contents Introductio

♟️ QR Code display for P4wnP1 (SSH, VNC, any text / URL)
♟️ QR Code display for P4wnP1 (SSH, VNC, any text / URL)

♟️ Display QR Codes on P4wnP1 (p4wnsolo-qr) 🟢 QR Code display for P4wnP1 w/OLED (SSH, VNC, P4wnP1 WebGUI, any text / URL / exfiltrated data) Note: Th

LCD GUI for P4wnP1 ALOA
LCD GUI for P4wnP1 ALOA

GUI for P4wnP1 Colorful UI interface for P4wnP1 ALOA Don't pwn just as a USB client. Use also the USB host capabilities! UPS Lite support Scalability

A python screen recorder for low-end computers, provides high quality video output.

RecorderX - v1.0 A screen recorder made in Python with the help of OpenCv, it has ability to record your screen in high quality. No matter what your P

Comments
  • Input doesn't display text input longer than X characters long

    Input doesn't display text input longer than X characters long

    Since the screen is only 128px wide, we can only display about 12 characters in this script before the text goes off the screen.

    So there needs to be code to allow long commands (by scrolling the text input as it's entered, once it reaches X number of characters).

    opened by p4wnsolo 1
  • go.py has wrong file paths

    go.py has wrong file paths

    Error:

    /usr/bin/python3: can't open file '/home/pi/p4wnsolo/p4wnsolo-joyterm/p4wnsolo-joytext.py': [Errno 2] No such file or directory /usr/bin/python3: can't open file '/home/pi/p4wnsolo/p4wnsolo-joyterm/p4wnsolo-terminal.py': [Errno 2] No such file or directory

    opened by p4wnsolo 1
Releases(alpha3)
  • alpha3(Dec 23, 2021)

    Updated Dec 23, 2021

    • Fixed "wrong file path" issue with go.py
    • Added feature to allow input of Commands of any length (the input now scrolls as new characters are added)
    Source code(tar.gz)
    Source code(zip)
  • alpha2(Dec 15, 2021)

  • alpha(Dec 15, 2021)

    This is first (pre)release of p4wnsolo-joyterm.

    Known issues with this release:

    1. This was developed on RPi Zero 2 running Raspberry Pi OS. And the HOME folder is hard-coded into the code. So if using on P4wnP1, you'll need to edit the .py files to reflect your HOME folder.

    But instead of doing that, I'll just add the proper code now to make the scripts cross-platform. Then I'll make a new release. Here's the code to get the HOME folder on any platform:

    from pathlib import Path home = str(Path.home())

    Source code(tar.gz)
    Source code(zip)
Owner
PawnSolo
I was born in a factory and designed to p4wn
PawnSolo
A iot Bike sytem based on RaspberryPi, Ardiuino

Cyclic 's Kernel ---- A iot Bike sytem based on RaspberryPi, Ardiuino, etc 0x1 What is This? Cyclic 's Kernel is an independent System With self-produ

Retr0mous 2 Oct 09, 2022
Lenovo Legion 5 Pro 2021 Linux RGB Keyboard Light Controller

Lenovo Legion 5 Pro 2021 Linux RGB Keyboard Light Controller This util allows to drive RGB keyboard light on Lenovo Legion 5 Pro 2021 Laptop Requireme

36 Dec 16, 2022
Example code to sending USB Gadget multimedia keys via Python

Send Multimedia USB HID Keys via Python As an USB Gadget in Linux This gives a simple script with zero dependencies that can easily run on any Linux d

DevOps Nirvana 2 Jan 02, 2023
Raspberry Pi Spectrometer

PySpectrometer 2021-03-05 Raspberry Pi Spectrometer The PySpectrometer is a Python (OpenCV and Tkinter) implementation of an optical spectrometer. The

Les Wright 538 Jan 05, 2023
PBA: Pleco Breeding Assistant

A small monitor that reports the external, fishroom and water change parameters to have suitable water parameters and induce breeding. These two features already represent 50% of the "reproductive su

Mirko Mancin 1 Jan 19, 2022
The software that powers the sPot: a 4th generation

This code is meant to accompany this project in which a Spotify client is built into an iPod "Classic" from 2004. Everything is meant to run on a Raspberry Pi Zero W.

Guy Dupont 683 Dec 28, 2022
Zev es un Bot/Juego RPG de Discord creado en y para aprender Python.

Zev es un Bot/Juego RPG de Discord creado en y para aprender Python.

Julen Smith 3 Jan 12, 2022
Automatically draw a KiCad schematic for a circuit prototyped on a breadboard.

Schematic-o-matic Schematic-o-matic automatically draws a KiCad schematic for a circuit prototyped on a breadboard. How It Works The first step in the

Nick Bild 22 Oct 11, 2022
A DUCO (Duino-Coin) miner for GigaDevice ARM boards.

GD32 Duino-Coin Miner Description Contains the firmware and miner software for mining DUCO (Duino-Coin) on GigaDevice GD32 chips. Supported boards GD3

Maximilian Gerhardt 2 Feb 20, 2022
Classes and functions for animated text and graphics on an LED display

LEDarcade A collection of classes and functions for animated text and graphics on an Adafruit LED Matrix.

datagod 31 Jan 04, 2023
A install script for installing qtile and my configs on Raspberry Pi OS

QPI OS - Qtile + Raspberry PI OS Qtile + Raspberry Pi OS :) Installation Run this command in the terminal

RPICoder 3 Dec 19, 2021
A Fast, Easy, and User Friendly way to control Robotics Actuators.

T-Motor Controller A Fast, Easy, and User Friendly way to control Robotics Actuators. View Demo · Report Bug · Request Feature Table of Contents About

26 Aug 23, 2022
A simple non-official manager interface I'm using for my Raspberry Pis.

My Raspberry Pi Manager Overview I have two Raspberry Pi 4 Model B devices that I hooked up to my two TVs (one in my bedroom and the other in my new g

Christian Deacon 21 Jan 04, 2023
This OctoPrint plugin will make the initial connection to 3D Hub a breeze

3D Hub Connector This OctoPrint plugin will make the initial connection to 3D Hub a breeze. In future it will help in setting up a tunnel connection a

3D Hub 2 Aug 03, 2022
Add filters (background blur, etc) to your webcam on Linux.

webcam-filters Add filters (background blur, etc) to your webcam on Linux. Video conferencing applications tend to either lack video effects altogethe

Jashandeep Sohi 480 Dec 14, 2022
HA-Edge-Connector - HA Edge Connector For Python

HA-Edge-Connector 1. Required a. Smartthings Hub & Homeassistant must be in same

chals 21 Dec 29, 2022
A flexible data historian based on InfluxDB, Grafana, MQTT and more. Free, open, simple.

Kotori Telemetry data acquisition and sensor networks for humans. Documentation: https://getkotori.org/ Source Code: https://github.com/daq-tools/koto

83 Nov 26, 2022
A ESP32 project template with a web interface built in React

ESP AP Webserver demo.mp4 This is my experiment with "mobile app development" for the ESP32. The project consists of two parts, the ESP32 code and the

8 Dec 15, 2022
智能无人机路径规划仿真系统是一个具有操作控制精细、平台整合性强、全方向模型建立与应用自动化特点的软件

Drone智能无人机路径规划仿真系统是一个具有操作控制精细、平台整合性强、全方向模型建立与应用自动化特点的软件。它以A、B两国在C区开展无人机战争为背景,该系统的核心功能是通过仿真平台规划无人机航线,并进行验证输出,数据可导入真实无人机,使其按照规定路线精准抵达战场任一位置,支持多人多设备编队联合行动。

wwy 349 Jan 03, 2023
An emulated LED scoreboard for Major League Baseball ⚾

An LED scoreboard for Major League Baseball. Displays a live scoreboard for your team's game on that day.

Tyler Porter 8 Apr 08, 2022