User interface task for data collection and interaction with encoder object. More...
Public Member Functions | |
| def | __init__ (self, period, enc_pos, z_flag, enc_delta, my_Q) |
| Constructs the user interface task. More... | |
| def | run (self) |
| Runs one iteration of the FSM. More... | |
| def | transition_to (self, new_state) |
| Transitions the FSM to a new state. More... | |
Public Attributes | |
| period | |
| The frequency of the task. More... | |
| enc_pos | |
| The encoder position that counts total movement. More... | |
| enc_delta | |
| The change in position. More... | |
| z_flag | |
| A boolean flag used to reset encoder position to 0. More... | |
| my_Q | |
| A shares object that represents the queue for holding list items. More... | |
| state | |
| Sets initial state to State 0. More... | |
| runs | |
| Sets the number of runs to 0. More... | |
| next_time | |
| The utime.ticks_us() value associated with the next run of the FSM. More... | |
| ser | |
| A serial port to use for user I/O. More... | |
| collect_time | |
| Variable that defines encoder position shared item. More... | |
| time_diff | |
| Creates a variable that calculates difference between time reference points. More... | |
| my_tuple | |
| Creates a tuple that holds time and position data. More... | |
User interface task for data collection and interaction with encoder object.
Implements a finite state machine that runs a data collection interface to interact with the encoder object.
| def Lab2_task_userinterface.Task_User.__init__ | ( | self, | |
| period, | |||
| enc_pos, | |||
| z_flag, | |||
| enc_delta, | |||
| my_Q | |||
| ) |
Constructs the user interface task.
The user task is implemented as a finite state machine that takes in character input from the user and obtains information from the encoder task to present to user.
| period | The period, in microseconds, between runs of the task |
| enc_pos | The encoder position that counts total movement |
| z_flag | A boolean flag used to reset encoder position to 0 |
| enc_delta | The change in time increments in timer count |
| my_Q | A shares object that represents the queue for holding list items |
| def Lab2_task_userinterface.Task_User.run | ( | self | ) |
Runs one iteration of the FSM.
Implements a finite state machine
| def Lab2_task_userinterface.Task_User.transition_to | ( | self, | |
| new_state | |||
| ) |
Transitions the FSM to a new state.
A function that transitions the FSM to a new state
| new_state | The state to transition to |
| Lab2_task_userinterface.Task_User.collect_time |
Variable that defines encoder position shared item.
Allows encoder position data to be accessed
Assigns an arbitrary reference point that begins when 'g' is pressed
Used to implement the timed data collection period
| Lab2_task_userinterface.Task_User.enc_delta |
The change in position.
The difference between two recorded positions of the encoder
| Lab2_task_userinterface.Task_User.enc_pos |
The encoder position that counts total movement.
The total position moved is characterized by the total number of timer counts
| Lab2_task_userinterface.Task_User.my_Q |
A shares object that represents the queue for holding list items.
The queue holds the time and position list items.
| Lab2_task_userinterface.Task_User.my_tuple |
Creates a tuple that holds time and position data.
Used to store all data collected into queue
| Lab2_task_userinterface.Task_User.next_time |
The utime.ticks_us() value associated with the next run of the FSM.
Defines a variable that adds the period to the ongoing timer
| Lab2_task_userinterface.Task_User.period |
The frequency of the task.
Defines variable that specifies timer frequency
| Lab2_task_userinterface.Task_User.runs |
Sets the number of runs to 0.
Defines a variable to keep track of runs
| Lab2_task_userinterface.Task_User.ser |
A serial port to use for user I/O.
Create a new USB_VCP object
| Lab2_task_userinterface.Task_User.state |
Sets initial state to State 0.
Starts timer.
FSM starts at State 0, where user input is prompted for further action
An increasing microsecond counter with an arbitrary reference point
| Lab2_task_userinterface.Task_User.time_diff |
Creates a variable that calculates difference between time reference points.
Used to collect data for a maximum time of 30 seconds self.time_diff = (current_time - self.collect_time)/1000000
| Lab2_task_userinterface.Task_User.z_flag |
A boolean flag used to reset encoder position to 0.
When character "z" is pressed on the keyboard, z-flag will be 'True' and reset encoder position