Skip to content

Commit

Permalink
Merge pull request #3 from RBEGamer/master
Browse files Browse the repository at this point in the history
added power off and gitignore
  • Loading branch information
Edward committed Apr 18, 2019
2 parents 6bdf37a + cb9f5fb commit d7fc166
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 11 deletions.
13 changes: 11 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@

OP_1_Backup_Library/
.DS_Store
*.pyc
.DS_Store
.idea/misc.xml
.idea/modules.xml
.idea/OP1_File_Organizer.iml
.idea/workspace.xml
.idea/misc.xml
.idea/modules.xml
.idea/OP1_File_Organizer.iml
.DS_Store
*.pyc
Binary file added Assets/Img/PowerOff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions Menu_Page_Router.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time
from os.path import basename, isdir
from shutil import rmtree
from subprocess import call

from PIL import Image, ImageDraw
from smbus2 import smbus2
Expand Down Expand Up @@ -157,6 +158,13 @@ def actionRouter(self, event):
except:
print("Error")
self.renderPage(-1, 1)
# ========= POWER OFF ====================
if event == "act_POWER_OFF":
image = Image.new('1', (128, 64))
image.paste(Image.open(workDir + "/Assets/Img/PowerOff.png").convert("1"))
displayImage(image)
time.sleep(1.0)
call("sudo shutdown -h now", shell=True)

if event == "checkStorage":
if check_OP_1_Connection() and config["OP_1_Mounted_Dir"] != "":
Expand Down
5 changes: 2 additions & 3 deletions OP_1_Connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,13 @@ def check_OP_1_Connection():


def unmount_OP_1():
if config["OP_1_Mounted_Dir"] != "":
if is_mounted():
unmountDisplay = Image.new('1', (128, 64))
draw = ImageDraw.Draw(unmountDisplay)
draw.text((30, 25), "Ejecting!", font=getFont(), fill='white')
displayImage(unmountDisplay)

cmd = "sudo umount " + config["OP_1_Mounted_Dir"]
os.system(cmd)
unmountdevice(config["OP_1_Mounted_Dir"])

config["OP_1_Mounted_Dir"] = ""
config["USB_Mount_Path"] = ""
Expand Down
Binary file added documentation/IMG_9550.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/IMG_9551.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions menu_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
["Mount OP1", "act_ESC_Mount_OP_1"],
["Eject OP-1", "act_ESC_Eject_OP_1"]
["MIDI Host", MIDI],
["Remove All User Data", "Remove all Data"]
["Power Off System", "act_POWER_OFF"],
]

# PresetPage = [
Expand Down Expand Up @@ -71,6 +71,5 @@
["Patches", PatchesPage],
["SSH Transfer", SSHPage],
["Utilities", Utilities],
["Eject", "act_ESC_Eject_OP_1"]
]

4 changes: 0 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ def start():
pg.renderPage(0, currentCursor)

while 1:
if not is_connected():
print("Disconnected, try to reconnect")
do_mount()
time.sleep(1)

key = checkKeyInterrupt()

Expand Down

0 comments on commit d7fc166

Please sign in to comment.