John von Neumann Faculty of Informatics

Slides:



Advertisements
Similar presentations
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren.
Advertisements

Mrs. Navickas Algebraically: 1 Solve for y, if necessary. If equation is given equal to zero or a y is not present, rewrite in descending powers of x.
TOPIC 12 CREATING CLASSES PART 1 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson,
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
 A quantum is the amount of time a thread gets to run before Windows checks.  Length: Windows 2000 / XP: 2 clock intervals Windows Server systems: 12.
An Introduction to Programming with C++ Fifth Edition
CENTER OF GRAVITY, CENTER OF MASS AND CENTROID FOR A BODY
Texas Instruments TI-83 Plus Graphing Calculator Basic Operations.
User Interface Programming in C#: Direct Manipulation Chris North CS 3724: HCI.
Chapter 3 Introduction to Event Handling and Windows Forms Applications.
 The graph of a function f is shown. Graph the inverse and describe the relationship between the function & its inverse. xy
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Tutorial 1: An Introduction to Visual Basic.NET1 Tutorial 1 An Introduction to Visual Basic.NET.
Visual Basic .NET BASICS
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
1 Getting Started Exercise Part 1. 2 Profiles related to the exercise When starting use archive profile: GettingStarted_Start.zip The fully completed.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 6B Methods (Tutorial)
CSCI-383 Object-Oriented Programming & Design Lecture 12.
Graphing Linear Equations From the beginning. What is a Linear Equation? A linear equation is an equation whose graph is a LINE. Linear Not Linear.
The Number Line Lesson After completing this lesson, you will be able to say: I can locate a number and its opposite on a number line. I can determine.
COM148X1 Interactive Programming Lecture 8. Topics Today Review.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Chapter 6 Continuous Random Variables Copyright © 2014 by The McGraw-Hill Companies, Inc. All rights reserved.McGraw-Hill/Irwin.
Chapter 1: An Introduction to Visual Basic .NET
VISUAL BASIC 6.0 Designed by Mrinal Kanti Nath.
HMI - Web Visualization
Introduction to Programming Lecture 2
Java FX: Scene Builder.
A variable is a name for a value stored in memory.
What is a Function Expression?
INF230 Basics in C# Programming
Neumann János Informatikai Kar
Static data members Constructors and Destructors
Creating LOVs and Editors
Graphing Linear Equations
Lesson 16 Sub Procedures Lesson 17 Functions
WARM UP By composite argument properties cos (x – y) =
“Teach A Level Maths” Vol. 1: AS Core Modules
The Selection Structure
Java Programming: Guided Learning with Early Objects
Miscellaneous Topics #6: Polygons GUI Components and Event Handlers
Windows Desktop Applications
Control Statement Examples
Variables and Arithmetic Operations
Java Programming with BlueJ
Debugging with Eclipse
Click the mouse or press the spacebar to continue.
Chapter 3 Introduction to Classes, Objects Methods and Strings
Statistical Tables and Graphs
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
Precalculus Essentials
Iteration: Beyond the Basic PERFORM
File I/O in C Lecture 7 Narrator: Lecture 7: File I/O in C.
In this chapter, you will learn the following:
CIS 16 Application Development Programming with Visual Basic
More programming with "Processing"
CS285 Introduction - Visual Basic
Multi-Form Applications Things You Need to Know
Chapter 5: Control Structure
Lecture 13: Two-Dimensional Arrays
C++ programming in Windows environment
Y-axis A Quadrant 2 Quadrant I (4,2) 2 up
ICT Gaming Lesson 3.
Real Numbers and Their Properties Section 1.1 – The Real Numbers
Y-axis A Quadrant 2 Quadrant I (4,2) 2 up
“Teach A Level Maths” Vol. 1: AS Core Modules
Debugging with Eclipse
Introduction to Excel 2007 Part 1: Basics and Descriptive Statistics Psych 209.
Creating and Using Classes
Presentation transcript:

John von Neumann Faculty of Informatics ÓBUDA UNIVERSITY John von Neumann Faculty of Informatics .NET Gadgeteer – Joystick module

Introduction Using the Joystick module Event handling Reading the status and position Creation of an example application Questions for preparation

1. Using the Joystick module Parameters of the Joystick Position of the Joystick (along the X and Y axis) Values may be taken in the interval of [-1,1] on both axis. Zero (0,0) means default position. Hint: GetPostion(); Button state of Joystick: pressed/released Hint: IsPressed property

1. Using the Joystick module Event Handling The Press Event of the button of the Joystick is listened to by two Event handlers: JoystickPressed: Triggered if button is pressed JoystickReleased: Triggered if button is released The JoystickEventHandler delegate: sender: Joystick object that triggers the event state: the state of the button when the event is triggered

1. Using the Joystick module Accessing status and position(1) IsPressed property is used to read the state of the Joystick at any arbitrary moment. (True = Pressed; False = Released) GetPosition() method is used to return the position of the Joystick (x;y coordinates) at any arbitrary moment.

1. Using the Joystick module Accessing status and position(2) Accessing the current position of the Joystick we get an instance of the Position struct which has got two double fields corresponding to X and Y axis. Reading the values minor noises may appear so one must never compare values using many decimal numbers or the equals sign (‘=‘). Bear in mind that even if the Joystick is in its default positon the GetPosition() will NOT return (0,0).

2. Creation of an example application Exercise Create an application that constantly displays the current state of the Joystick. Represent the shift along the X and Y axis textually. Display whether the Joystick is pressed or not. Display a marker (line) which corresponds to direction of the shift.

2. Creation of an example application Configuration You need the configuration shown below:

2. Creation of an example application Plan of the application You need to get the state of the Joystick continuously. For that, use a timer which operates in periodic mode. In order to avoid the Screen from flashing all the time, declare a Bitmap and do all the necessary drawings on it, then display it on the Screen (double buffering) Watch out, the values of the Joystick are not always precise. Hence, the default position is not the (0,0) coordinate either.

2. Creation of an example application Steps to take Declare the fields Initialize Bitmap Timer Calculate with the auxiliary variables Start Timer Get the state and display it Check the Position of the Joystick Check the state of the Joystick Draw the state (parameters, direction) on the Bitmap Display the Bitmap

2. Creation of an example application Declare the fields Explanation: Instance of the Timer Bitmap object for drawing Length of the marker (line) representing the direction of the shift Width of the marker (line) representing the direction of the shift Horizontal coordinate of the center of the Screen Vertical coordinate of the center of the Screen Threshold for the minimal shift of the Joystick

2. Creation of an example application Initialization Explanation: The Bitmap object is instantiated such that it fits to the measures of the Screen. The Timer object is instantiated with 100ms of periodic time. (i.e. the Tick event will be invoked 10 times in every second.) centerX and center are auxiliary variables to store the coordinates of the center of the Screen. The fixed end of the marker line is on this coordinate.

2. Creation of an example application Starting the timer After the initialization the timer is started When the timer starts the timer_Tick method is invoked 10 times a second. Multiple tasks are to be implemented there.

2. Creation of an example application Getting and displaying the state(1) Must be repeated continuously so that we can display the state in real-time. Explanation: The shift and state of the Joystick is returned by the GetPosition() method and the IsPressed property. After erasing the Bitmap, the previously acquired values are drawn using the PrintParameters() and DrawDirection() methods. The Bitmap is displayed through the DisplayImage() method.

2. Creation of an example application Getting and displaying the state(2) Printing parameters: Explanation: Represent the shift along the X and Y axis textually on the Bitmap Represent the state of Joystick the textually with the help the pressed variable.

2. Joystick példaprogram készítése Getting and displaying the state(3) Drawing the direction: Explanation The shift along the axis is compared to threshold number. Ha az elmozdulás mértéke valamely tengely mentén meghaladja a küszöbszámot, akkor kirajzolásra kerül az irány, egyébként egy pont jelenik meg a képernyő közepén If the value of the shift exceeds the threshold on any axis, the direction marker is drawn. Otherwise, only a point is drawn.

2. Joystick példaprogram készítése Application in use

3. Questions for preparation What techniques do know to acquire the state of the button of the Joystick? How can you get the current shift along the x and y axis? How would you work with this value? What is that you should always pay attention to while working with the shift values?