User Tools

Site Tools


lab_1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Previous revision
lab_1 [2018/09/04 11:53]
lab_1 [2019/05/07 12:56] (current)
hutch [Helps: Read display.h to see what display_ functions are available]
Line 27: Line 27:
  
 ===== Requirements ===== ===== Requirements =====
-  * Watch the first four videos on the BYU ECEN 330 channel (V1 - V4) and run helloWorld as instructed. +Watch the first four videos on the BYU ECEN 330 channel (V1 - V4) and run helloWorld as instructed. 
-    * [[https://​www.youtube.com/​watch?​v=OlWu7iRAVd8|V1 Setting Up Directories]] +==== V1Setting Up Directories ​==== 
-    * [[https://​www.youtube.com/watch?v=zxZN-jmNXbc|V2 Import the Extracted Files into the Xilinx SDK]] +{{youtube>​OlWu7iRAVd8?rel=0&​allowfullscreen&​noborder&​560x315}} 
-    * [[https://​www.youtube.com/watch?v=thNfqYz3GiY|V3 Download the Bit-Stream to the ECEN Development Board]] +==== V2Import the Extracted Files into the Xilinx SDK ==== 
-    * [[https://​www.youtube.com/watch?v=OpTXsDc9ptA|V4 Build the Configuration and Execute the Program]]+{{youtube>​zxZN-jmNXbc?rel=0&​allowfullscreen&​noborder&​560x315}} 
 +==== V3Download the Bit-Stream to the ECEN Development Board ==== 
 +{{youtube>​thNfqYz3GiY|?rel=0&​allowfullscreen&​noborder&​560x315}} 
 +==== V4Build the Configuration and Execute the Program ​==== 
 +{{youtube>​OpTXsDc9ptA|?​rel=0&​allowfullscreen&​noborder&​560x315}} 
 + 
 +----
  
 //**Note**: when importing projects (V2), please make sure to navigate through the J Drive as shown below or your project will generate errors during compilation://​ //**Note**: when importing projects (V2), please make sure to navigate through the J Drive as shown below or your project will generate errors during compilation://​
  
 {{::​lab1_import_j_drive.png?​600|}} {{::​lab1_import_j_drive.png?​600|}}
 +
 +----
  
 Also watch the videos below and and do as instructed. Also watch the videos below and and do as instructed.
  
-    * [[https://​youtu.be/​Qu43bwdxNUs|V13 Modify a compiler setting to overcome Xilinx SDK Bug]] +==== V13Modify a compiler setting to overcome Xilinx SDK Bug ==== 
-    * [[https://​www.youtube.com/watch?v=onO-XojGFMM|V11 Setting the Heap and Stack Size]]+{{youtube>​Qu43bwdxNUs?rel=0&​allowfullscreen&​noborder&​560x315}} 
 +==== V11Setting the Heap and Stack Size ==== 
 +{{youtube>​onO-XojGFMM?​rel=0&​allowfullscreen&​noborder&​560x315}}
  
-{{::​lab1helloworldphoto.jpg?​500|The LCD Screen for helloWorld.c}}+---- 
 +----
  
 ===== Exercises ===== ===== Exercises =====
  
-  - Modify the first "hello world" program and remove the \n\r from the string used in the printf function and recompile and execute the program. What happens? Does "hello world!"​ still appear in the console? +1. Modify the first "hello world" program and remove the \n\r from the string used in the printf function and recompile and execute the program. What happens? Does "hello world!"​ still appear in the console? 
-  ​- ​Read the graphics documentation and then modify the "​helloWorld.c"​ program so that it shows the following when executed (both triangles are yellow):+ 
 +{{::​lab1helloworldphoto.jpg?​500|The LCD Screen for helloWorld.c}} 
 + 
 +2. Read the graphics documentation and then modify the "​helloWorld.c"​ program so that it shows the following when executed (both triangles are yellow):
  
 {{::​lab1photo2.jpg?​500|The LCD Screen for the Graphics Program}} {{::​lab1photo2.jpg?​500|The LCD Screen for the Graphics Program}}
 +
 +----
 +
 ===== Notes and Hints ===== ===== Notes and Hints =====
   - Carefully read **every word** of the lab description. These lab descriptions have been refined over the past three years based upon student feedback. In most cases, the answers to your questions are usually present in the lab description. It is good practice to become very skilled at reading documentation as you will find that there are no TAs in industry. In general, students who read the lab description very carefully **before coding anything** complete the lab much more quickly than those who tend to scan the description and jump directly to coding. That said, if something is still unclear after you carefully read the lab description,​ let me know and I will try to fix it. I value student feedback.   - Carefully read **every word** of the lab description. These lab descriptions have been refined over the past three years based upon student feedback. In most cases, the answers to your questions are usually present in the lab description. It is good practice to become very skilled at reading documentation as you will find that there are no TAs in industry. In general, students who read the lab description very carefully **before coding anything** complete the lab much more quickly than those who tend to scan the description and jump directly to coding. That said, if something is still unclear after you carefully read the lab description,​ let me know and I will try to fix it. I value student feedback.
Line 56: Line 73:
   - I strongly advise against a "trial and error" approach when writing the code to draw the lines, circles and triangles. It takes up to a minute each time you build your code and download to the board and this adds up quickly, time-wise. A better approach is to draw a picture of the display and to determine the actual coordinates before writing any code.   - I strongly advise against a "trial and error" approach when writing the code to draw the lines, circles and triangles. It takes up to a minute each time you build your code and download to the board and this adds up quickly, time-wise. A better approach is to draw a picture of the display and to determine the actual coordinates before writing any code.
   - The sizes of the triangles and circles don't need to match my picture exactly but they should be reasonably close.   - The sizes of the triangles and circles don't need to match my picture exactly but they should be reasonably close.
-  - If you are having problems programming the board, ensure that the programming jumper is set correctly. I went through ​413 and I think that I set all of them but double-check this if you are having problems programming the board. The jumper needs to placed over the rightmost two pins as shown in the picture below.+  - If you are having problems programming the board, ensure that the programming jumper is set correctly. I went through ​all of the boards in the shop and I think that I set all of them but double-check this if you are having problems programming the board. The jumper needs to placed over the rightmost two pins as shown in the picture below.
   - The main.c file contains a function called isr_function(). You will not use this function for this lab but it must be defined or you will get a linker error. You will do more with this function in later labs.   - The main.c file contains a function called isr_function(). You will not use this function for this lab but it must be defined or you will get a linker error. You will do more with this function in later labs.
  
 {{::​programmingmodejumpersetting.jpg?​500|Programming Jumper Set to JTAG Mode (programming over the cable}} {{::​programmingmodejumpersetting.jpg?​500|Programming Jumper Set to JTAG Mode (programming over the cable}}
 +
 +----
  
 ===== Questions ====== ===== Questions ======
 Consider the following questions as you work on this lab. Consider the following questions as you work on this lab.
   - What actions occur when you save your program? Do you ever have to manually compile your program?   - What actions occur when you save your program? Do you ever have to manually compile your program?
 +
 +----
 +
  
 ===== Pass Off ===== ===== Pass Off =====
Line 69: Line 91:
  
 **Note to TAs:** Ask the student what happened when they removed the \n\r from the printf() in the exercises. Don't pass the student off unless you are sure that the completed this exercise. **Note to TAs:** Ask the student what happened when they removed the \n\r from the printf() in the exercises. Don't pass the student off unless you are sure that the completed this exercise.
-===== Source Code ===== 
-All of the display functions (display_) can be found in display.h which is contained in the supportFiles directory. I have placed display.h below for convenience. You can learn a lot about the display by reading through the display.h file. 
- 
-<file C display.h>​ 
-/* 
- * display.h 
- * 
- ​* ​ Created on: Jul 18, 2014 
- ​* ​     Author: hutch 
- */ 
- 
-#ifndef DISPLAY_H_ 
-#define DISPLAY_H_ 
- 
-#include <​stdint.h>​ 
-#include <​stdlib.h>​ 
- 
-#define DISPLAY_DEC 10 
-#define DISPLAY_HEX 16 
-#define DISPLAY_OCT 8 
-#define DISPLAY_BIN 2 
- 
-#define DISPLAY_INIT_STATUS_OK 1 
-#define DISPLAY_INIT_STATUS_FAIL 0 
- 
-#define DISPLAY_CHAR_WIDTH 6 
-#define DISPLAY_CHAR_HEIGHT 8 
- 
-#define DISPLAY_WIDTH 320 
-#define DISPLAY_HEIGHT 240 
- 
-#​define DISPLAY_BLACK ​  ​0x0000 
-#​define DISPLAY_BLUE ​   0x001F 
-#​define DISPLAY_RED ​    ​0xF800 
-#​define DISPLAY_GREEN ​  ​0x07E0 
-#define DISPLAY_CYAN ​   0x07FF 
-#define DISPLAY_MAGENTA 0xF81F 
-#define DISPLAY_YELLOW ​ 0xFFE0 
-#define DISPLAY_WHITE ​  ​0xFFFF 
- 
-#define DISPLAY_LANDSCAPE_MODE_ORIGIN_UPPER_LEFT 1 
-#define DISPLAY_LANDSCAPE_MODE_ORIGIN_LOWER_RIGHT 3 
-#define DISPLAY_PORTRAIT_MODE_ORIGIN_LOWER_LEFT 0 
-#define DISPLAY_PORTRAIT_MODE_ORIGIN_UPPER_RIGHT 2 
- 
-typedef uint16_t display_pixel_t;​ // Standard pixel type. 
- 
-// This provides the primary high-level API to the LCD display, including the touch-panel. The interface 
-// will be C-like, with a functional interface that does not require the user to use constructors or objects. 
-// These functions are mostly just wrappers around C++ methods so they can be used for C programming. 
- 
-// Constructs the necessary LCD and touch-controller objects and performs necessary initializations. 
-void display_init();​ 
- 
-// The functionality for these functions comes from Adafruit_GFX.cpp and Adafruit_TFTLCD.cpp. 
-void 
-  display_drawPixel(int16_t x0, int16_t y0, uint16_t color), 
-  display_drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color), 
-  display_drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), 
-  display_drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), 
-  display_drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 
-  display_fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 
-  display_fillScreen(uint16_t color), 
-  display_invertDisplay(bool i), 
-  display_drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 
-  display_fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 
-  display_drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 
-  int16_t x2, int16_t y2, uint16_t color), 
-  display_fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 
-  int16_t x2, int16_t y2, uint16_t color), 
-  display_drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 
-  int16_t radius, uint16_t color), 
-  display_fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 
-  int16_t radius, uint16_t color), 
-  display_drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, 
-  int16_t w, int16_t h, uint16_t color), 
-  display_drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, 
-  uint16_t bg, uint8_t size), 
-  display_setCursor(int16_t x, int16_t y), 
-  display_setTextColor(uint16_t c), 
-  display_setTextColor(uint16_t c, uint16_t bg), 
-  display_setTextSize(uint8_t s), 
-  display_setTextWrap(bool w), 
-  display_setRotation(uint8_t r); 
-  int16_t display_height();​ 
-  int16_t display_width();​ 
-  uint16_t display_color565(uint8_t r, uint8_t g, uint8_t b);  // Packs r,g,b into 16 bits. 
- 
-  // Print routines 
-  size_t display_println(const char str[]); 
-  size_t display_println(char c); 
-  size_t display_println(unsigned char c, int base = DISPLAY_DEC);​ 
-  size_t display_println(int num, int base = DISPLAY_DEC);​ 
-  size_t display_println(unsigned int num, int base = DISPLAY_DEC);​ 
-  size_t display_println(long num, int base = DISPLAY_DEC);​ 
-  size_t display_println(unsigned long num, int base = DISPLAY_DEC);​ 
-  size_t display_println(double num, int fieldWidth = 2); 
-  size_t display_println(void);​ 
  
-  size_t display_print(const char str[]); +----
-  size_t display_print(char c); +
-  size_t display_print(unsigned char c, int base = DISPLAY_DEC);​ +
-  size_t display_print(int num, int base = DISPLAY_DEC);​ +
-  size_t display_print(unsigned int num, int base = DISPLAY_DEC);​ +
-  size_t display_print(long num, int base = DISPLAY_DEC);​ +
-  size_t display_print(unsigned long num, int base = DISPLAY_DEC);​ +
-  size_t display_print(double num, int fieldWidth = 2);+
  
-  // Display test routines. +==== Help: Read display.h to see what display_ functions are available =====
-  unsigned long display_testLines(uint16_t color); +
-  unsigned long display_testFastLines(uint16_t color1, uint16_t color2); +
-  unsigned long display_testRects(uint16_t color); +
-  unsigned long display_testFilledRects(uint16_t color1, uint16_t color2); +
-  unsigned long display_testFilledCircles(uint8_t radius, uint16_t color); +
-  unsigned long display_testCircles(uint8_t radius, uint16_t color); +
-  unsigned long display_testTriangles();​ +
-  unsigned long display_testFilledTriangles();​ +
-  unsigned long display_testRoundRects();​ +
-  unsigned long display_testFilledRoundRects();​ +
-  unsigned long display_testFillScreen();​ +
-  unsigned long display_testText();​ +
-  // Calles all of the test routines. +
-  unsigned long display_test();​+
  
-// The functionality for these routines comes from Adafruit_STMPE610 (touch controller). +You can view the contents of display.h here (found in the supportFiles directory in the Xilinx SDK). This source code is provided so you can easily see what display functions are provided for your use. Don't add this file to your system as it is already installed for you once you have completed Lab 1. This is for convenience only
-// True if the display ​is being touched. +
-bool display_isTouched(void); +
-// Returns ​the x-y coordinate point and the pressure (z). +
-void display_getTouchedPoint(int16_t *x, int16_t *y, uint8_t *z); +
-// Throws away all previous touch data. +
-void display_clearOldTouchData();​+
  
 +[[Lab 1 Display Source Code| Source Code for display_ Functions]]
  
-#endif /* DISPLAY_H_ */ 
  
-</​file>​ 
lab_1.1536083594.txt.gz · Last modified: 2019/04/08 20:12 (external edit)