Skip to content

Fixed Issue with MCP3xxx Sensors #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions mudpi.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import time
import json
import sys
import traceback
sys.path.append('..')
from action import Action
from config_load import loadConfigJson
Expand Down Expand Up @@ -63,7 +64,7 @@
print('_________________________________________________')
print('')
print('Eric Davisson @theDavisson')
print('Version: ', CONFIGS.get('version', '0.8.6'))
print('Version: ', CONFIGS.get('version', '0.8.7'))
print('\033[0;0m')

if CONFIGS['debug'] is True:
Expand Down Expand Up @@ -135,6 +136,7 @@
threads.append(pw)
except KeyError:
print('No Pi Workers Found to Load or Invalid Type')
traceback.print_exc()


# Worker for relays attached to pi
Expand All @@ -157,6 +159,7 @@
threads.append(r)
except KeyError:
print('No Relays Found to Load')
traceback.print_exc()

# Worker for nodes attached to pi via serial or wifi[esp8266]
# Supported nodes: arduinos, esp8266, ADC-MCP3xxx, probably others
Expand All @@ -178,8 +181,9 @@
t = t.run()
if t is not None:
threads.append(t)
except KeyError:
except KeyError as e:
print('Invalid or no Nodes found to Load')
traceback.print_exc()


# Load in Actions
Expand All @@ -190,6 +194,7 @@
actions[a.key] = a
except KeyError:
print('No Actions Found to Load')
traceback.print_exc()

# Worker for Triggers
try:
Expand All @@ -199,6 +204,7 @@
threads.append(t)
except KeyError:
print('No Triggers Found to Load')
traceback.print_exc()


#Decided not to build server worker (this is replaced with nodejs, expressjs)
Expand Down Expand Up @@ -254,4 +260,4 @@ def server_worker():

print("MudPi Shutting Down...\t\t\t\033[1;32m Complete\033[0;0m")
print("Mudpi is Now...\t\t\t\t\033[1;31m Offline\033[0;0m")


16 changes: 8 additions & 8 deletions sensors/MCP3xxx/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
class Sensor:

PINS = {
'0': MCP.P0,
'1': MCP.P1,
'2': MCP.P2,
'3': MCP.P3,
'4': MCP.P4,
'5': MCP.P5,
'6': MCP.P6,
'7': MCP.P7,
0: MCP.P0,
1: MCP.P1,
2: MCP.P2,
3: MCP.P3,
4: MCP.P4,
5: MCP.P5,
6: MCP.P6,
7: MCP.P7,
}

def __init__(self, pin: int, mcp, name='Sensor', key=None):
Expand Down