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.
Map/Map_test.h@82:3211b31e9421, 2020-05-25 (annotated)
- Committer:
- evanso
- Date:
- Mon May 25 18:39:51 2020 +0000
- Revision:
- 82:3211b31e9421
- Parent:
- 67:a2984682d641
- Child:
- 85:87bc28b151d8
Made commenting and formatting of code more consistent.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| evanso | 12:1c0b6796aaca | 1 | #ifndef MAP_TEST_H |
| evanso | 12:1c0b6796aaca | 2 | #define MAP_TEST_H |
| evanso | 12:1c0b6796aaca | 3 | |
| evanso | 12:1c0b6796aaca | 4 | /** Map Test |
| evanso | 27:8bb2bd97c319 | 5 | * @brief Checks that the map moves to the correct x position depedning on |
| evanso | 27:8bb2bd97c319 | 6 | * joystick input |
| evanso | 27:8bb2bd97c319 | 7 | * @author Benjamin Evans, University of Leeds |
| evanso | 27:8bb2bd97c319 | 8 | * @date April 2020 |
| evanso | 27:8bb2bd97c319 | 9 | * @return true if test are passed |
| evanso | 27:8bb2bd97c319 | 10 | */ |
| evanso | 82:3211b31e9421 | 11 | bool map_move_test(Direction d_, int expected_x_position) { |
| evanso | 21:f7d7834e3af1 | 12 | // Objects reqired for test |
| evanso | 67:a2984682d641 | 13 | Map map; |
| evanso | 67:a2984682d641 | 14 | N5110 lcd; |
| evanso | 14:7419c680656f | 15 | Gamepad pad; |
| evanso | 12:1c0b6796aaca | 16 | |
| evanso | 14:7419c680656f | 17 | // Initialise map in start postion of -84,42 |
| evanso | 14:7419c680656f | 18 | pad.init(); |
| evanso | 14:7419c680656f | 19 | map.init(pad); |
| evanso | 12:1c0b6796aaca | 20 | |
| evanso | 18:11068b98e261 | 21 | printf("Espected map x position = %d, : ",expected_x_position); |
| evanso | 12:1c0b6796aaca | 22 | |
| evanso | 14:7419c680656f | 23 | // Draws map but with move variable set so it starts above 0 |
| evanso | 14:7419c680656f | 24 | // As can't rea pixel of the LCD |
| evanso | 18:11068b98e261 | 25 | map.draw_map(lcd, d_); |
| evanso | 12:1c0b6796aaca | 26 | |
| evanso | 82:3211b31e9421 | 27 | // Reads start postion of map drawn |
| evanso | 14:7419c680656f | 28 | int map_start_draw_postion = map.get_position_x_map(); |
| evanso | 12:1c0b6796aaca | 29 | |
| evanso | 14:7419c680656f | 30 | // Checks final position with espected |
| evanso | 14:7419c680656f | 31 | if (map_start_draw_postion == expected_x_position) { |
| evanso | 14:7419c680656f | 32 | printf ( "Passed!\n"); |
| evanso | 14:7419c680656f | 33 | return true; |
| evanso | 14:7419c680656f | 34 | } else { |
| evanso | 27:8bb2bd97c319 | 35 | printf ( "Failed! value = %d, (expecting %d)\n", |
| evanso | 27:8bb2bd97c319 | 36 | map_start_draw_postion, expected_x_position); |
| evanso | 14:7419c680656f | 37 | return false; |
| evanso | 12:1c0b6796aaca | 38 | } |
| evanso | 14:7419c680656f | 39 | } |
| evanso | 12:1c0b6796aaca | 40 | |
| evanso | 12:1c0b6796aaca | 41 | #endif |