Skip to content

Commit

Permalink
Removed warnings, added config file for audio, and made logs and conf…
Browse files Browse the repository at this point in the history
…igure directories generate automatic
  • Loading branch information
tyspa1 committed May 31, 2015
1 parent 165a8ad commit 77f8704
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 16 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# TYOS
0.3.7 Beta
0.4.9 Beta</br>
A mobile operating system for the tyfone.

copyright (c) 2015 Tyler Spadgenske
copyright :copyright: 2015 Tyler Spadgenske

##Installation and Setup
Follow the guide at:</br>
http://instructables.com/id/Build-Your-Own-Smartphone/</br>

##Developers
TYOS is now in Beta! Developing your own apps is as easy as pi. Check out the
docs at https://github.com/spadgenske/tyos/wiki
##Docs
Check out the docs at https://github.com/spadgenske/tyos/wiki

##Update
To update your version of TYOS do so here: </br>
https://github.com/spadgenske/TYOS/releases
22 changes: 19 additions & 3 deletions apps/message/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#To be packaged with stock TYOS#
################################

import pygame, time
import pygame, time, os
from pygame.locals import *

class Run():
Expand Down Expand Up @@ -142,13 +142,29 @@ def load_contacts(self):
try:
contact_file = open('/home/pi/tyos/configure/contacts.conf', 'r')
except:
print '***********************************************************'
print 'NO CONTACTS FOUND'
print 'PLEASE CREATE /home/pi/tyos/configure/contacts.conf FILE'
print 'PLEASE EDIT /home/pi/tyos/configure/contacts.conf FILE'
print '***********************************************************'
if not os.path.exists('/home/pi/tyos/configure'):
os.mkdir('/home/pi/tyos/configure')
if not os.path.exists('/home/pi/tyos/logs'):
os.mkdir('/home/pi/tyos/logs') #May be in wrong spot, but it works
contact_file = open('/home/pi/tyos/configure/contacts.conf', 'w+')
contact_file.write('#Contacts\n')
contact_file.write('#Use format name=number i.e. Joe=1555666777 # are comments\n')
contact_file.close()
contact_file = open('/home/pi/tyos/configure/contacts.conf', 'r')

self.contact_list = contact_file.readlines()
contact_file.close()

for i in range(0, len(self.contact_list)):
self.contact_list[i] = self.contact_list[i].rstrip().split('=')
if self.contact_list[i][0] == '#':
pass
#Do Nothing. Line is comment
else:
self.contact_list[i] = self.contact_list[i].rstrip().split('=')

def on_first_run(self):
self.first = False
Expand Down
30 changes: 30 additions & 0 deletions apps/settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Run():
def __init__(self, fona):
self.fona = fona
self.headset = False
self.get_audio_mode()
#Setup colors
self.RED = (255,0,0)
self.GREEN = (0,255,0)
Expand All @@ -38,8 +39,37 @@ def __init__(self, fona):
self.exit = False
self.blit_one_surface = {'surface':[], 'rects':[]}
self.blit = {'surfaces':[self.menu, self.fona_power, self.off], 'rects':[self.menu_rect, self.fona_power_rect, self.rect]}

#Set audio mode text
if self.headset:
self.blit['surfaces'][2] = self.on
else:
self.blit['surfaces'][2] = self.off

self.next_app = None

def get_audio_mode(self):
audio_config = open('/home/pi/tyos/configure/audio.conf', 'r')
file = audio_config.readlines()

for i in range(0, len(file)):#Parse file
if file[i][0] == '#':
pass
#Do Nothing. Line is comment
else:
file[i] = file[i].rstrip()
if 'mode' in file[i]: #Extract audio mode: 1=Built in, 0=External
mode = file[i]

mode = mode.split('=')
self.mode = int(mode[1])

if self.mode == 1:
self.headset = False
else:
self.headset = True


def run_app(self):
pass

Expand Down
10 changes: 7 additions & 3 deletions src/framebuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time
import random

DEBUG = False
class pyscope :
screen = None;

Expand All @@ -16,7 +17,8 @@ def __init__(self):
# http://www.karoltomala.com/blog/?p=679
disp_no = os.getenv("DISPLAY")
if disp_no:
print "I'm running under X display = {0}".format(disp_no)
if DEBUG:
print "I'm running under X display = {0}".format(disp_no)

# Check which frame buffer drivers are available
# Start with fbcon since directfb hangs with composite output
Expand All @@ -29,7 +31,8 @@ def __init__(self):
try:
pygame.display.init()
except pygame.error:
print 'Driver: {0} failed.'.format(driver)
if DEBUG:
print 'Driver: {0} failed.'.format(driver)
continue
found = True
break
Expand All @@ -38,7 +41,8 @@ def __init__(self):
raise Exception('No suitable video driver found!')

size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
print "Framebuffer size: %d x %d" % (size[0], size[1])
if DEBUG:
print "Framebuffer size: %d x %d" % (size[0], size[1])
self.screen = pygame.display.set_mode(size, pygame.FULLSCREEN)
# Clear the screen to start
self.screen.fill((0, 0, 0))
Expand Down
41 changes: 36 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@
If FONA is already on, just run sudo python /home/pi/tyos/src/main.py
Upgrade:
To check for updates go to https://github.com/spadgenske/TYOS/releases/latest and compare the version number with your
current version of TYOS. If higher, you can update. To your version of TYOS run the command
current version of TYOS. If higher, you can update. To get your version of TYOS run the command
sudo python /home/pi/tyos/src/main.py --version
'''

VERSION = '0.3.7'
VERSION = '0.4.9'

import pygame, sys, os, time, datetime, traceback
import pygame, sys, os, time, datetime, traceback, warnings
from pygame.locals import *
import framebuffer, toolbar, apps, serialport, receive

class tyos():
def __init__(self):
warnings.filterwarnings("ignore")
for arg in sys.argv:
if arg == '--power':
self.POWER_FONA = True
Expand All @@ -39,8 +40,8 @@ def __init__(self):
#Setup fona
self.fona = serialport.SerialPort()
self.fona.connect()
#Set audio in/out to speaker and microphone
self.fona.transmit('AT+CHFA=1')

self.set_audio()

#Setup some important objects
self.scope = framebuffer.pyscope()
Expand Down Expand Up @@ -109,6 +110,36 @@ def __init__(self):

self.blit_logo = True
self.dead_bat = False

def set_audio(self):
#Set audio in/out to selected from config file
try: #See if config file exists
self.audio_file = open('/home/pi/tyos/configure/audio.conf', 'r')
except:
if not os.path.exists('/home/pi/tyos/configure'):#If configure directory doesn't exist, create one
os.mkdir('/home/pi/tyos/configure')

self.audio_file = open('/home/pi/tyos/configure/audio.conf', 'w+')#Create config file and add some lines
self.audio_file.write('#Audio config file\n')
self.audio_file.write('mode=1\n')
self.audio_file.close()
self.audio_file = open('/home/pi/tyos/configure/audio.conf', 'r')

file = self.audio_file.readlines()

for i in range(0, len(file)):#Parse file
if file[i][0] == '#':
pass
#Do Nothing. Line is comment
else:
file[i] = file[i].rstrip()
if 'mode' in file[i]: #Extract audio mode: 1=Built in, 0=External
mode = file[i]

mode = mode.split('=')
mode = mode[1]

self.fona.transmit('AT+CHFA=' + mode)

def blit_time(self):
#Convert to 12 hour time then blit it to surface
Expand Down

0 comments on commit 77f8704

Please sign in to comment.