1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Furkat [3]
3 years ago
5

2. From the listing code, please give the block of line numbers for code which are concerned with the following: A) Main functio

n initialization of values B) Main function idle loop C) Main function schedule loop has already been moved to the ISR, but give those numbers too.
Computers and Technology
1 answer:
arsen [322]3 years ago
7 0

Answer:

Complete question is:

When the C-language code is generated, -1 is used to create the initialization state for each of the Tick

functions.

The challenge is if this code is used with C++ compiler, there is an incorrect mix between integer and

the enum data types.

1. Take the generated C code, edit it, and

replace the -1 state with an enum data type state

so it will

compile properly.

2. Replace the integer notation for the call and return arguments for Tick functions where they should

also be the enum data types.

2. From the listing lines of code, please give the line numbers for code which are concerned with the

following:

A)

Main function initialization of values

B)

Main function idle loop

C)

Main function schedule loop has already been moved to the ISR, but give those numbers too.

This action is required when moving this state machine model to a C++ GUI system.

Submit the C code with the corrections made

and this is my code

/*

This code was automatically generated using the Riverside-Irvine State machine Builder tool

Version 2.8 --- 6/23/2015 16:19:15 PST

*/

#include "rims.h"

/*This code will be shared between state machines.*/

unsigned char TimerFlag = 0;

void TimerISR() {

TimerFlag = 1;

}

enum BL_States { BL_LedOff, BL_LedOn } BL_State;

TickFct_BlinkLeds() {

/*VARIABLES MUST BE DECLARED STATIC*/

/*e.g., static int x = 0;*/

/*Define user variables for this state machine here. No functions; make them global.*/

switch(BL_State) { // Transitions

case -1:

BL_State = BL_LedOff;

break;

case BL_LedOff:

if (1) {

BL_State = BL_LedOn;

}

break;

case BL_LedOn:

if (1) {

BL_State = BL_LedOff;

}

break;

default:

BL_State = BL_LedOff;

} // Transitions

switch(BL_State) { // State actions

case BL_LedOff:

B0= 0;

break;

case BL_LedOn:

B0 = 1;

break;

default: // ADD default behaviour below

break;

} // State actions

}

enum TL_States { TL_T0, TL_T1, TL_T2 } TL_State;

TickFct_ThreeLeds() {

/*VARIABLES MUST BE DECLARED STATIC*/

/*e.g., static int x = 0;*/

/*Define user variables for this state machine here. No functions; make them global.*/

switch(TL_State) { // Transitions

case -1:

TL_State = TL_T0;

break;

case TL_T0:

if (1) {

TL_State = TL_T1;

}

break;

case TL_T1:

if (1) {

TL_State = TL_T2;

}

break;

case TL_T2:

if (1) {

TL_State = TL_T0;

}

break;

default:

TL_State = TL_T0;

} // Transitions

switch(TL_State) { // State actions

case TL_T0:

B5 = 1;

B6 = 0;

B7 = 0;

break;

case TL_T1:

B5 = 0;

B6 = 1;

B7 = 0;

break;

case TL_T2:

B5 = 0;

B5 = 0;

B5 = 1;

break;

default: // ADD default behaviour below

break;

} // State actions

}

int main() {

B = 0; //Init outputs

TimerSet(1000);

TimerOn();

BL_State = -1;

TL_State = -1;

while(1) {

TickFct_BlinkLeds();

TickFct_ThreeLeds();

while (!TimerFlag);

TimerFlag = 0;

}

}

Answer is:

#include "rims.h"

/*This code will be shared between state machines.*/

unsigned char TimerFlag = 0;

void TimerISR() {

TimerFlag = 1;

}

enum BL_States { BL_LedOff, BL_LedOn, BL_LedOnOff } BL_State;

TickFct_BlinkLeds() {

/*VARIABLES MUST BE DECLARED STATIC*/

/*e.g., static int x = 0;*/

/*Define user variables for this state machine here. No functions; make them global.*/

switch(BL_State) { // Transitions

case BL_LedOnOff:

BL_State = BL_LedOff;

break;

case BL_LedOff:

if (BL_LedOn) {

BL_State = BL_LedOn;

}

break;

case BL_LedOn:

if (true) {

BL_State = BL_LedOff;

}

break;

default:

BL_State = BL_LedOff;

} // Transitions

switch(BL_State) { // State actions

case BL_LedOff:

B0= 0;

break;

case BL_LedOn:

B0 = 1;

break;

default: // ADD default behaviour below

break;

} // State actions

}

enum TL_States { TL_T0, TL_T1, TL_T2 } TL_State;

TickFct_ThreeLeds() {

/*VARIABLES MUST BE DECLARED STATIC*/

/*e.g., static int x = 0;*/

/*Define user variables for this state machine here. No functions; make them global.*/

switch(TL_State) { // Transitions

case BL_LedOnOff:

TL_State = TL_T0;

break;

case TL_T0:

if (1) {

TL_State = TL_T1;

}

break;

case TL_T1:

if (true) {

TL_State = TL_T2;

}

break;

case TL_T2:

if (true) {

TL_State = TL_T0;

}

break;

default:

TL_State = TL_T0;

} // Transitions

switch(TL_State) { // State actions

case TL_T0:

B5 = 1;

B6 = 0;

B7 = 0;

break;

case TL_T1:

B5 = 0;

B6 = 1;

B7 = 0;

break;

case TL_T2:

B5 = 0;

B5 = 0;

B5 = 1;

break;

default: // ADD default behaviour below

break;

} // State actions

}

int main() {

B = 0; //Init outputs

TimerSet(1000);

TimerOn();

BL_State = -1;

TL_State = -1;

while(1) {

TickFct_BlinkLeds();

TickFct_ThreeLeds();

while (!TimerFlag);

TimerFlag = 0;

}

}

Explanation:

You might be interested in
How are XY coordinates utilized in construct ?
marshall27 [118]

Answer:

In 2d space we can describe an object's position using 2 values that represent an object's placement on a grid, invisible or not. Typically this is referred to as a 2d coordinate; X and Y. X describes which column the object is in and Y tells what row the object is in. It is pretty much like bingo. A 2d coordinate should look something like these examples: (56,2) or (-1,3). The first number is the X position and tells us how far left or right the position is. The second number is Y and tells us an objects position up and down.

The pixel at the very top left of your screen is always pixel (0,0) - not (1,1). This is because computers always start counting at 0. They think of 0 as being the first position a number can be. This means if your screen is 640 pixels wide, your screen X position will go from 0-639. Any object on screen will have an (x,y) position. and this position can be manipulated by changing these values.

If you subtract from an objects X position it will appear to move left. If you add to it, it will seem as the object is going to the right. Adding to the Y value makes the object go down and subtracting from Y makes it go up.

Just remember: Add to X = right, Subtract from X = left, Add to Y = down, and subtract from Y = Up.

The more you handle (X,Y) coordinates the more second nature this becomes, so don't worry if it seems odd at first.

MOVING AN OBJECT USING VELOCITY

If you simply change an objects position to where you want it to be it will seem as if it is teleporting. Going from (10,10) to (100,100) is a big jump. If you want an object to seem as if it is moving from one place to another then you need to gradually change its position over time. This is an easy process.

In construct 2, a sprite object already has an X and Y position, so all you need to do is create 2 variables, each representing velocity along either the X or Y axis. I normally call them velocityX and velocityY.

Every frame of the game you then add velocity to position. It looks like this below:

notice that I am multiplying velocity by dt. dt stands for Delta Time and tells us how much time has passed since our last frame. Most games will run 60 frames per second, meaning the computer will run the code you made 60 times a second. In this case dt = 0.0166666- or 1/60. Since we want our velocity to be in pixels per second (and not per frame) we multiply velocity by dt. If our velocity was 100 then per frame it would only add 1.6666 to the position of an object. Over the course of a full second the total of the changes will equal 100.

velocity dt frames per second = velocity.

Here is a quick velocity cheat sheet; The velocity of the object is on the left, described using X and Y. The direction the object would be moving as a result is written next to it.

(0,0) - not moving.

(1,0) - moving right.

(-1,0) - moving left.

(0,1) - moving down.

(0,-1) - moving up.

(-1,-1) - moving diagonally up left.

(1,-1) - moving diagonally up right.

(-1,1) - moving diagonally down left.

(1,1) - moving diagonally down right.

Hopefully that wraps it up. Let me know if you have questions.

Introduction to rotation and angles!

6 0
4 years ago
)what item is at the front of the list after these statements are executed?
White raven [17]

Answer:

Option (a) : sam

Explanation:

  • In the given program, the queue is defined in the first step.
  • The method addToFront() adds the given element to the front of the queue. After this step is executed the front element in the queue is that element.
  • The method addToBack() adds the given element to the back of the queue. After this step is executed the back element in the queue is that element.
  • After step 1, Jack is added to the front of the queue.
  • After step 2, Rudy is added to the back of the queue.
  • After step 3, Larry is added to the back of the queue.
  • After step 4, sam is added to the front of the queue.
  • After step 5, name contains Larry as the getBack() returns the element present at the back of the queue.
  • After step 6, Adam is added to the back of the queue.
  • After executing all of the steps now the queue contains "sam" as the front element of the queue.
  • So, the correct option is "sam".
3 0
3 years ago
How can one create an online professional network using Face book?
Paha777 [63]

Answer:

by posting intelligent status updates

6 0
3 years ago
. An access specifier is one of three keywords:
Zolol [24]

Answer:

Access specifiers are used to control the visibility of members like classes, variables and methods. There are three access specifiers: public, private and protected. We shall see only about the public and private access specifiers for now. Protected access specifier comes into picture when inheritance is implemented. plz brainly me

Explanation:

8 0
3 years ago
Which of the following statements is false?
GrogVix [38]

Answer:

bnnnnn A1

Explanation:

bnnnnnjm

8 0
3 years ago
Other questions:
  • The ________ occurs when the user presses the enter key without typing a value for an input operation.
    5·1 answer
  • Can somebody help me with this problem
    10·1 answer
  • 3. By eliminating data redundancy, you're enforcing data A. validation. B. integrity. C. consistency. D. accuracy.
    14·2 answers
  • Consumers’ ability to ""time shift"" programs using DVRs and Internet video and other situations that lack simultaneity is an ex
    6·1 answer
  • When using a file name you have to use only lower case letters<br>true or false
    11·1 answer
  • Program: ASCII art (Python 3)1) Output this tree. 2) Below the tree (with two blank lines), output this cat. (3 pts) /\ /\ o o =
    8·1 answer
  • Wendy had been searching the internet for a great deal on jewelry. While looking at one site, a pop-up was displayed that told h
    11·1 answer
  • Match the following internet related terms to their definition
    13·1 answer
  • 11. a) What is character size measured in?
    5·1 answer
  • How to make classs constructer java.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!