forked from charlesweir/BrickPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandLineApplication.py
More file actions
24 lines (18 loc) · 867 Bytes
/
CommandLineApplication.py
File metadata and controls
24 lines (18 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# CommandLineApplication class. Provides a dummy scheduler for BrickPiWrapper.
# Applications using the BrickPi derive from this, implementing appropriate functionality.
#
# Copyright (c) 2014 Charles Weir. Shared under the MIT Licence.
from BrickPiWrapper import BrickPiWrapper
import time
class CommandLineApplication(BrickPiWrapper):
'''
Main application class for command-line only apps. Doesn't support user input.
'''
def __init__(self, sensorConfiguration={}):
'''Initialization: *sensorConfiguration* is a map as passed to BrickPiWrapper'''
BrickPiWrapper.__init__(self, sensorConfiguration )
def mainloop(self):
'The main loop for the application - call this after initialization. Never returns.'
while True:
self.doWork()
time.sleep(self.timeMillisToNextCall() / 1000.0)