Luisa Chiu Portfolio
Lab2_task_userinterface.Task_User Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

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.

Parameters
periodThe period, in microseconds, between runs of the task
enc_posThe encoder position that counts total movement
z_flagA boolean flag used to reset encoder position to 0
enc_deltaThe change in time increments in timer count
my_QA shares object that represents the queue for holding list items

Member Function Documentation

◆ run()

def Lab2_task_userinterface.Task_User.run (   self)

Runs one iteration of the FSM.

Implements a finite state machine

◆ transition_to()

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

Parameters
new_stateThe state to transition to

Member Data Documentation

◆ collect_time

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

◆ enc_delta

Lab2_task_userinterface.Task_User.enc_delta

The change in position.

The difference between two recorded positions of the encoder

◆ enc_pos

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

◆ my_Q

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.

◆ my_tuple

Lab2_task_userinterface.Task_User.my_tuple

Creates a tuple that holds time and position data.

Used to store all data collected into queue

◆ next_time

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

◆ period

Lab2_task_userinterface.Task_User.period

The frequency of the task.

Defines variable that specifies timer frequency

◆ runs

Lab2_task_userinterface.Task_User.runs

Sets the number of runs to 0.

Defines a variable to keep track of runs

◆ ser

Lab2_task_userinterface.Task_User.ser

A serial port to use for user I/O.

Create a new USB_VCP object

◆ state

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

◆ time_diff

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

◆ z_flag

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


The documentation for this class was generated from the following file: