aboutsummaryrefslogtreecommitdiff
path: root/Raspberry Pi/python.py
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2016-10-18 12:46:55 +0200
committerJakob Stendahl <jakob.stendahl@outlook.com>2016-10-18 12:46:55 +0200
commitaf2d66f9e7a604cfec51d6e7b66d5f90827fe7bb (patch)
treeb4dc8c28b57db4c48d7d59c261fa046f44852b96 /Raspberry Pi/python.py
parent44c8940211225e772851b36dc4088f3b6989f5f4 (diff)
downloadi2c-Neopixel-af2d66f9e7a604cfec51d6e7b66d5f90827fe7bb.tar.gz
i2c-Neopixel-af2d66f9e7a604cfec51d6e7b66d5f90827fe7bb.zip
Added functions, error-handling
Added errorhandeler Added try-catch
Diffstat (limited to 'Raspberry Pi/python.py')
-rw-r--r--Raspberry Pi/python.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/Raspberry Pi/python.py b/Raspberry Pi/python.py
index 57cf380..6ebb805 100644
--- a/Raspberry Pi/python.py
+++ b/Raspberry Pi/python.py
@@ -1,6 +1,7 @@
""" Imports """
import logging
import smbus
+import sys
import time
import json
import i2cPixel
@@ -28,13 +29,38 @@ def lightStaircase(direction):
return true
+def errorHandler(type, errorMsg):
+ if type = 1: # Debug
+ logging.debug(errorMsg)
+ print("Debug Message: See logfile")
+ else if type = 2: # info
+ logging.info(errorMsg)
+ else if type = 3: # Warning
+ logging.warning(errorMsg)
+ else if type = 4: # Error
+ logging.error(errorMsg)
+ print("Error: See logfile")
+ else if type = 5: # Error
+ logging.critical(errorMsg)
+ print("Critical Error: See logfile")
+ else:
+ logging.critical(errorMsg)
+ print("Something went terribly wrong! Not even the errorhandler was able to find out what. Which basically means 'You are doomed'")
+
def setup():
-
+
+ """ Setup Log File """
+ logging.basicConfig(filename='error.log',level=logging.DEBUG)
+
+ """ Print first line of log file """
+ logging.info('Starting App')
+
""" Setup i2c communication """
i2cPixel.version()
i2cPixel.setBus(1)
i2cPixel.setAddress(0x04)
+
def main():
""" Wait for heartbeat from Arduino """