Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
CrossHairs Class Reference
CrossHairs Class. More...
#include <CrossHairs.h>
Public Member Functions | |
void | init (int speed) |
Initialises the cross hairs at center position. | |
void | draw (N5110 &lcd) |
Draws the cross hairs on the lcd. | |
void | update (float angle, float mag) |
Updates the position of the cross hairs based on user input. | |
Vector2D | get_pos () |
accessors and mutators | |
void | set_pos (Vector2D p) |
sets the position of the cross hairs |
Detailed Description
CrossHairs Class.
- Date:
- April 2019 Revision 1.0
#include "N5110.h" int crossHairsSprite[7][7] = { { 0,0,1,1,1,0,0 }, { 0,1,0,0,0,1,0 }, { 1,0,0,1,0,0,1 }, { 1,0,1,1,1,0,1 }, { 1,0,0,1,0,0,1 }, { 0,1,0,0,0,1,0 }, { 0,0,1,1,1,0,0 }, }; int main() { // first need to initialise display lcd.init(); //make object of cross hairs class CrossHairs _crossHairs; //initialise cross hairs object _crossHairs.init(CrossHairsSpeed); float _angle = 180.0 // degrees float _mag = 1.0 // magnitude 0.0 to 1.0 //update position of cross hairs _crossHairs.update(_angle,_mag); //call to add cross hairs to screen _crossHairs.draw(lcd); //returns Vector2D position Vector2D crossHairsLoc = _crossHairs.get_pos(); Vector2d newPos = = {10,20}; //{x,y}; //set cross hairs position _crossHairs.setPos(newPos); }
Definition at line 64 of file CrossHairs.h.
Member Function Documentation
void draw | ( | N5110 & | lcd ) |
Draws the cross hairs on the lcd.
- Parameters:
-
lcd the N5110 object
Definition at line 37 of file CrossHairs.cpp.
Vector2D get_pos | ( | ) |
accessors and mutators
gets the position of the cross hairs
- Returns:
- a Vector2D value of the coordinates
Definition at line 74 of file CrossHairs.cpp.
void init | ( | int | speed ) |
Initialises the cross hairs at center position.
- Parameters:
-
speed Speed of cross hairs in pixels per frame (integer)
Definition at line 24 of file CrossHairs.cpp.
void set_pos | ( | Vector2D | p ) |
sets the position of the cross hairs
- Parameters:
-
position Vector2D coordinate value
Definition at line 80 of file CrossHairs.cpp.
void update | ( | float | angle, |
float | mag | ||
) |
Updates the position of the cross hairs based on user input.
- Parameters:
-
angle angle in degrees magnitude magnitude from 0.0 to 1.0 to allow user to control speed of motion
Definition at line 44 of file CrossHairs.cpp.
Generated on Mon Nov 11 2024 22:48:00 by
