ELEC2645 (2018/19) / Mbed 2 deprecated el17lw

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Tests Class Reference

Tests Class Reference

Tests Class. More...

#include <Tests.h>

Public Member Functions

 Tests ()
 Constructor.
 ~Tests ()
 Destructor.
void init (int platforms_y)
 Initalises the Tests.
void run_tests (float joy_x, float joy_y, Sprite_value sprite, int coin_x, int coin_y, int fire_y, int line_1_start, int line_2_start, int line_3_start, int line_length, N5110 &lcd)
 Runs all the Tests with input stimulus.

Detailed Description

Tests Class.

Allows the user to input a set stimulus to test sprites by printing to LCD and terminal.

Author:
Lewis Wooltorton
Date:
May 2019
#include "N5110.h"
#include "Gamepad.h"
#include "mbed.h"
#include "Tests.h"

N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad gamepad;
Tests test;  // Create a test object if tests are to be done.

void init_game();

int main() {
  init_game();
  while(1) {
    lcd.setContrast(gamepad.read_pot());  // Contrast is controlled by pot.
    lcd.clear();  
    // Blelow line is an example of testing sprites. See documentation for 
    // parameters and details.
    test.run_tests(1,1,Left,Skate_right,20,20,20,10,30,50,5,lcd);     
    lcd.refresh();
    wait(0.01);  
  }     
}  
 
void init_game() {
  test.init(20);  // Argument is the vertical position of test platforms.
  gamepad.init();
  lcd.init(); 
  lcd.normalMode();      
  lcd.setBrightness(0.5); 
}

Definition at line 54 of file Tests.h.


Constructor & Destructor Documentation

Tests (  )

Constructor.

Non user specified.

Definition at line 3 of file Test.cpp.

~Tests (  )

Destructor.

Non user specified.

Definition at line 5 of file Test.cpp.


Member Function Documentation

void init ( int  platforms_y )

Initalises the Tests.

Parameters:
platforms_yThe vertical position of the platforms

Definition at line 7 of file Test.cpp.

void run_tests ( float  joy_x,
float  joy_y,
Sprite_value  sprite,
int  coin_x,
int  coin_y,
int  fire_y,
int  line_1_start,
int  line_2_start,
int  line_3_start,
int  line_length,
N5110 lcd 
)

Runs all the Tests with input stimulus.

Parameters:
joy_xThe x coordinate of the joystick
joy_yThe y coordinate of the joystick
spritethe skateboarder sprite to be printed (from the enum class Sprite_value)
coin_xThe x coordinate of the coin
coin_yThe y coordinate of the coin
fire_yThe y coordinate of the fire
line_1_startThe starting x coordinate of line 1
line_2_startThe starting x coordinate of line 2
line_3_startThe starting x coordinate of line 3
line_lengthThe length of each line in the platform object
&lcdThe lcd object from the N5110 class

Definition at line 15 of file Test.cpp.