ME 305
|
Handles the user UI of our encoder system. More...
Functions | |
def | task_user.taskUser (taskname, period, zFlag, pFlag, dFlag, gFlag, position, delta, P, T) |
A generator to implement the UI task as an Finite State Machine. More... | |
Variables | |
task_user.S0_INIT = micropython.const(0) | |
State 0 - Initialize. More... | |
task_user.S1_CMD = micropython.const(1) | |
State 1 - Command. More... | |
task_user.S2_ZERO = micropython.const(2) | |
State 2 - Zero Encoder. More... | |
task_user.S3_POS = micropython.const(3) | |
State 3 - Position. More... | |
task_user.S4_DEL = micropython.const(4) | |
State 4 - Delta. More... | |
task_user.S5_DATA = micropython.const(5) | |
State 5 - Data Collection. More... | |
task_user.S6_HELP = micropython.const(6) | |
State 6 - Help. More... | |
Handles the user UI of our encoder system.
This file interacts directly with user keyboard inputs to then send the request to the task_encoder.py file. It uses six states that correspond to different key in puts to send the program into its appropriate settings based on the user input. These states are highlighted below:
S0-Initialization S1-Command S2-Zero S3-Position S4-Delta S5-Data S6-Help
The below image shows the state transition diagram employed for this task file:
def task_user.taskUser | ( | taskname, | |
period, | |||
zFlag, | |||
pFlag, | |||
dFlag, | |||
gFlag, | |||
position, | |||
delta, | |||
P, | |||
T | |||
) |
A generator to implement the UI task as an Finite State Machine.
The task runs as a generator function and requires a task name and interval to be specified. This task file receives flag values altered by the user. These flags are then shared with task_encoder.py where that task file can execute actions defined in encoder.py. Once the desired task is completed, the state is reset back to idle state (State 1).
taskName | The name of the task as a string. |
period | Specifies how long the task has to perform its function in microseconds. Specified as an integer. |
zFlag | Holds True or False value to know when zeroing command was called by the user to zero the current position of the encoder. |
pFlag | Holds True or False value to know when position command was called by the user to know the current position of the encoder. |
dFlag | Holds True or False value to know when delta command was called by the user to know the current delta (speed) of the encoder. |
gFlag | Holds True or False value to know when data collection command was called by the user to collect current time and position data. |
position | Stores current position of encoder to be read in task_user.py |
delta | Stores the delta (speed) of the encoder to be read in to task_user.py |
P | Stores current position of encoder for data collection |
T | Stores current time of encoder for data collection |
task_user.S0_INIT = micropython.const(0) |
State 0 - Initialize.
State that corresponds to initializing encoder 1 and printing out the initial help menu.
task_user.S1_CMD = micropython.const(1) |
State 1 - Command.
State that waits for a user input and transfers the user to the correct state based on that input.
task_user.S2_ZERO = micropython.const(2) |
State 2 - Zero Encoder.
State that zeros out the encoder
task_user.S3_POS = micropython.const(3) |
State 3 - Position.
State that returns position to the user
task_user.S4_DEL = micropython.const(4) |
State 4 - Delta.
State that returns the delta(speed) of the encoder to the user
task_user.S5_DATA = micropython.const(5) |
State 5 - Data Collection.
State that collects 30 seconds of data and outputs it to the user
task_user.S6_HELP = micropython.const(6) |
State 6 - Help.
State that returns a help window to the user