Encoder task for cooperative multitasking example. More...
Public Member Functions | |
| def | __init__ (self, period, enc_pos, z_flag, enc_delta, enc_obj, my_Q) |
| Constructs an encoder task. More... | |
| def | run (self) |
| Runs one iteration of the FSM. | |
Public Attributes | |
| period | |
| The frequency of the task. More... | |
| enc_pos | |
| The encoder position that counts total movement. 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... | |
| enc_obj | |
| The encoder object that calls encoders 1 or 2. More... | |
| enc_delta | |
| The change in position. More... | |
| state | |
| Sets initial state to State 1. 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... | |
Encoder task for cooperative multitasking example.
Implements a finite state machine that interacts with the encoder driver and task user interface
| def Lab2_task_encoder.Task_Encoder.__init__ | ( | self, | |
| period, | |||
| enc_pos, | |||
| z_flag, | |||
| enc_delta, | |||
| enc_obj, | |||
| my_Q | |||
| ) |
Constructs an encoder task.
The encoder task is implemented as a finite state machine
| 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 |
| enc_obj | The encoder object that calls encoders 1 or 2 |
| my_Q | A shares object that represents the queue for holding list items |
| Lab2_task_encoder.Task_Encoder.enc_delta |
The change in position.
The difference between two recorded positions of the encoder
| Lab2_task_encoder.Task_Encoder.enc_obj |
The encoder object that calls encoders 1 or 2.
Encoders 1 or 2 was defined in the main.py file
| Lab2_task_encoder.Task_Encoder.enc_pos |
The encoder position that counts total movement.
The total position moved is characterized by the total number of timer counts
| Lab2_task_encoder.Task_Encoder.my_Q |
A shares object that represents the queue for holding list items.
The queue holds the time and position list items.
| Lab2_task_encoder.Task_Encoder.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_encoder.Task_Encoder.period |
The frequency of the task.
Defines variable that specifies timer frequency
| Lab2_task_encoder.Task_Encoder.runs |
Sets the number of runs to 0.
Defines a variable to keep track of runs
| Lab2_task_encoder.Task_Encoder.state |
Sets initial state to State 1.
FSM starts at State 1, where the update function is called for encoder object
| Lab2_task_encoder.Task_Encoder.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