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.
Diff: HUD/HUD_test.h
- Revision:
- 66:33f479036a5d
- Child:
- 67:a2984682d641
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/HUD/HUD_test.h Thu May 21 17:37:15 2020 +0000
@@ -0,0 +1,40 @@
+#ifndef HUD_TEST_H
+#define HUD_TEST_H
+
+/** HUD Test
+ * @brief Checks that the differnt parts of the hud draw
+ * of map when being drawn
+ * @author Benjamin Evans, University of Leeds
+ * @date May 2020
+ * @return true if test are passed
+ */
+bool HUD_draw_test(int spaceship_lives, int points, int smart_bomb_counter,
+int expected_pixel_status, int expected_postion_x, int expected_postion_y){
+
+ // Objects reqired for test
+ HUD hud;
+ N5110 lcd;
+
+ // Initialise lcd
+ lcd.init();
+
+ // Reads start spaceship postion
+ printf("HUD_draw x,y = %d,%d : ",expected_postion_x,expected_postion_y );
+
+ hud.draw_HUD(lcd,spaceship_lives, points, smart_bomb_counter);
+
+ // Reads pixel where hud is expected to be drawn
+ int actual_pixel_status = lcd.getPixel(expected_postion_x,
+ expected_postion_y);
+
+ // Checks if pixel is drawn and therefor testing it hasnt gone of screen
+ if (actual_pixel_status == expected_pixel_status) {
+ printf ( "Passed!\n");
+ return true;
+ } else {
+ printf ( "Failed! value = %d (expecting %d)\n", actual_pixel_status,
+ expected_pixel_status);
+ return false;
+ }
+}
+#endif
\ No newline at end of file