added v2.0
This commit is contained in:
1
07_Operating_System/09_Screen_Test/Array.jack
Symbolic link
1
07_Operating_System/09_Screen_Test/Array.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../Array.jack
|
1
07_Operating_System/09_Screen_Test/GPIO.jack
Symbolic link
1
07_Operating_System/09_Screen_Test/GPIO.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../GPIO.jack
|
94
07_Operating_System/09_Screen_Test/Main.jack
Normal file
94
07_Operating_System/09_Screen_Test/Main.jack
Normal file
@@ -0,0 +1,94 @@
|
||||
class Main {
|
||||
|
||||
function void main() {
|
||||
var int x;
|
||||
var int vx;
|
||||
var Array map;
|
||||
do Screen.setPenColor(Screen.BLACK());
|
||||
do Screen.drawRectangle(5,5,35,35);
|
||||
do Screen.setPenColor(Screen.NAVY());
|
||||
do Screen.drawRectangle(45,5,75,35);
|
||||
do Screen.setPenColor(Screen.BLUE());
|
||||
do Screen.drawRectangle(85,5,115,35);
|
||||
do Screen.setPenColor(Screen.GREEN());
|
||||
do Screen.drawRectangle(125,5,155,35);
|
||||
do Screen.setPenColor(Screen.CYAN());
|
||||
do Screen.drawRectangle(165,5,195,35);
|
||||
do Screen.setPenColor(Screen.MAROON());
|
||||
do Screen.drawRectangle(205,5,235,35);
|
||||
do Screen.setPenColor(Screen.PURPLE());
|
||||
do Screen.drawRectangle(5,45,35,75);
|
||||
do Screen.setPenColor(Screen.OLIVE());
|
||||
do Screen.drawRectangle(45,45,75,75);
|
||||
do Screen.setPenColor(Screen.MAGENTA());
|
||||
do Screen.drawRectangle(85,45,115,75);
|
||||
do Screen.setPenColor(Screen.DARKGREY());
|
||||
do Screen.drawRectangle(125,45,155,75);
|
||||
do Screen.setPenColor(Screen.LIGHTGREY());
|
||||
do Screen.drawRectangle(165,45,195,75);
|
||||
do Screen.setPenColor(Screen.RED());
|
||||
do Screen.drawRectangle(205,45,235,75);
|
||||
do Screen.setPenColor(Screen.YELLOW());
|
||||
do Screen.drawRectangle(5,85,35,115);
|
||||
do Screen.setPenColor(Screen.ORANGE());
|
||||
do Screen.drawRectangle(45,85,75,115);
|
||||
do Screen.setPenColor(Screen.LIME());
|
||||
do Screen.drawRectangle(85,85,115,115);
|
||||
do Screen.setPenColor(Screen.TEAL());
|
||||
do Screen.drawRectangle(125,85,155,115);
|
||||
|
||||
do Screen.setPenColor(Screen.BLACK());
|
||||
|
||||
let x=0;
|
||||
while (x<240){
|
||||
do Screen.drawPixel(x,150);
|
||||
let x=x+2;
|
||||
}
|
||||
do Screen.drawLine(120,200,170,200);
|
||||
do Screen.drawLine(120,200,170,250);
|
||||
do Screen.drawLine(120,200,120,250);
|
||||
do Screen.drawLine(120,200,70,250);
|
||||
do Screen.drawLine(120,200,70,200);
|
||||
do Screen.drawLine(120,200,70,150);
|
||||
do Screen.drawLine(120,200,120,150);
|
||||
do Screen.drawLine(120,200,170,150);
|
||||
|
||||
let map = Array.new(16);
|
||||
let map[0]=768;
|
||||
let map[1]=768;
|
||||
let map[2]=896;
|
||||
let map[3]=896;
|
||||
let map[4]=960;
|
||||
let map[5]=960;
|
||||
let map[6]=16352;
|
||||
let map[7]=16352;
|
||||
let map[8]=8176;
|
||||
let map[9]=8176;
|
||||
let map[10]=3840;
|
||||
let map[11]=3840;
|
||||
let map[12]=1792;
|
||||
let map[13]=1792;
|
||||
let map[14]=768;
|
||||
let map[15]=768;
|
||||
|
||||
do Screen.setPenColor(Screen.RED());
|
||||
do Screen.drawBitMap(112, 260, 127, 275,map);
|
||||
let x=120;
|
||||
let vx=10;
|
||||
while (true){
|
||||
do Sys.wait(100);
|
||||
do Screen.setPenColor(Screen.WHITE());
|
||||
do Screen.drawCircle(x,300,5);
|
||||
let x=x+vx;
|
||||
do Screen.setPenColor(Screen.RED());
|
||||
do Screen.drawCircle(x,300,5);
|
||||
if (x>220) {
|
||||
let vx=-10;
|
||||
}
|
||||
if (x<20) {
|
||||
let vx=10;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
18
07_Operating_System/09_Screen_Test/Makefile
Normal file
18
07_Operating_System/09_Screen_Test/Makefile
Normal file
@@ -0,0 +1,18 @@
|
||||
all: jack vm asm bin sim
|
||||
|
||||
jack:
|
||||
../../tools/JackCompiler/JackCompiler.pyc ./
|
||||
vm:
|
||||
../../tools/VMTranslator/VMTranslator.pyc ./
|
||||
asm:
|
||||
../../tools/Assembler/assembler.pyc out.asm
|
||||
bin:
|
||||
../../tools/AsciiToBin.py out.hack
|
||||
sim:
|
||||
cp out.hack ../00_HACK/ROM.hack
|
||||
upload:
|
||||
iceprogduino -o 64k -w out.bin
|
||||
clean:
|
||||
rm -f *.vm *.asm *.hack *.bin *~
|
||||
|
||||
.PHONY: all clean
|
1
07_Operating_System/09_Screen_Test/Math.jack
Symbolic link
1
07_Operating_System/09_Screen_Test/Math.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../Math.jack
|
1
07_Operating_System/09_Screen_Test/Memory.jack
Symbolic link
1
07_Operating_System/09_Screen_Test/Memory.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../Memory.jack
|
70
07_Operating_System/09_Screen_Test/Readme.md
Normal file
70
07_Operating_System/09_Screen_Test/Readme.md
Normal file
@@ -0,0 +1,70 @@
|
||||
## Screen.jack
|
||||
|
||||
A library of functions for displaying graphics on the screen.
|
||||
The connected LCD physical screen consists of 320 rows (indexed 0..319, top to bottom) of 240 pixels each (indexed 0..239, left to right). The top left pixel on the screen is indexed (0,0). Every pixel can be set to a 16 bit color code composed of RGB-parts of 5 bit red, 6 bit green and 5 bit blue: `rrrrrggggggbbbbb`.
|
||||
|
||||
### Special function register LCD
|
||||
|
||||
The Screen is controlled by sending commands to special function register LCD, which connects to the ILI9341V controller on MOD-LCD2.8RTP. Every command is 8bit long with DCX=0 pulled low followed by any number (also none) of arguments, which are send with DCX=1 pushed high. All commands are described in the datasheet of [ILI9341V](../../doc/ILI9341V_v1.0.pdf). (h denote hexadecimal and d denote decimal notation).
|
||||
|
||||
1. **Memory access control (36h)**: send 54d (DCX=0) followed by the argument 72d (with DCX=1) to get access to the memory of ILI9341V.
|
||||
2. **COLMOD Pixel Format Set (3Ah)**: send 58d (DCX=0) followed by the argument 85d (DCX=1) to set the pixel format to rgb 16 bit.
|
||||
3. **Sleep Out (11h)**: send 17d (DCX=0) and wait 500 ms to awake ILI9341V from sleep mode.
|
||||
4. **Display ON (29h)**: send 41d (DCX=0) and wait 500 ms to switch the display on.
|
||||
|
||||
After initialisation with commands 1.-4., the screen turns on showing a random pattern of RGB colors. To paint something on the screen, we must send the following three commands to LCD.
|
||||
|
||||
5. **Colum addres set (2Ah)**: To set the x-range of the window into which to paint, send command 42d with DCX=0 followed by x1 (16 bit) and x2 (16 bit) with DCX=1. x1 and x2 must be in the range [0:239] with x2>=x1.
|
||||
6. **Page address set (2Bh):** To set the y-range of the window into which to paint, send 43d with DCX=0 followed by value of y1 (16 bit) and value of y2 (16 bit) with DCX=1. y1 and y2 must be in the range [0:319] with y2>=y1.
|
||||
7. **Memory write (2Ch):** To paint the pixel in the rectangle defined by (x1,y1)-(x2,y2) send 44d with DCX=0 followed by `w*h` 16 bit RGB values (DCX=1) of every individual pixel in the rectangle starting at top left and ending at bottom right.
|
||||
|
||||
For convenience the commands 1.-7. are distributed to three functions of Screen.jack:
|
||||
|
||||
### function void init(int addr)
|
||||
|
||||
Initializes the LCD screen, by sending the commands 1.-4. to LCD. The LCD is memory mapped to the two memory addresses addr and addr+1 according to `06_IO_Devices/08_LCD`.
|
||||
|
||||
### function void setWindow(int x1,int y1, int x2, int y2)
|
||||
|
||||
Sets a rectangle window by sending commands 4.,5. and the command 7. without the arguments. (x1,y1) is the upper left corner and (x2,y2) is the lower right corner of the rectangle window. The next `w*h` calls of writeData16(int value) will paint the pixels in the rectangle according to the rgb values starting in the upper left corner and ending in the lower right corner.
|
||||
|
||||
### function void writeData16(int color)
|
||||
|
||||
Sends a 16 bit RGB value to paint the next pixel in the window defined by `setWindow(int,int,int,int)`. This procedure must be called `w*h` times to paint every pixel in the rectangle defined by `setAddrWindow(int,int,int,int)`.
|
||||
|
||||
***
|
||||
|
||||
### Project
|
||||
|
||||
* implement `Screen.jack`
|
||||
|
||||
* Test in simulation
|
||||
|
||||
```
|
||||
$ cd 09_Screen_Test
|
||||
$ make
|
||||
$ cd ../00_HACK
|
||||
$ apio clean
|
||||
$ apio sim
|
||||
```
|
||||
|
||||

|
||||
|
||||
* Check for the correct init sequence:
|
||||
|
||||
* CSX is low starting from the first command.
|
||||
* DCX is low while sending commands and high while sending data
|
||||
* SDO shows the serial binary representation of the send command/data
|
||||
* SCK shows 8 clocks cycles
|
||||
|
||||
* Run Screen_Test in real hardware on iCE40HX1K-EVB with MOD-LCD2.8RTP connected as described in `06_IO_Devices/LCD`.
|
||||
|
||||
```
|
||||
$ cd 09_Screen_Test
|
||||
$ make
|
||||
$ make upload
|
||||
```
|
||||
|
||||
* Compare the pattern on the LCD with the following picture:
|
||||
|
||||

|
57
07_Operating_System/09_Screen_Test/Readme.md.backup
Normal file
57
07_Operating_System/09_Screen_Test/Readme.md.backup
Normal file
@@ -0,0 +1,57 @@
|
||||
## Screen.jack
|
||||
A library of functions for displaying graphics on the screen.
|
||||
The connected LCD physical screen consists of 320 rows (indexed 0..319, top to bottom) of 240 pixels each (indexed 0..239, left to right). The top left pixel on the screen is indexed (0,0). Every pixel can be set to a 16 bit color code divided into RGB-parts of 5 bit red, 6 bit green and 5 bit blue: `rrrrrggggggbbbbb`.
|
||||
|
||||
### LCD
|
||||
LCD is controlled by sending commands to LCD. Every command is 8bit long with CDX high followed by any number (also none) of arguments, which are send with CDX low. The needed commands are described in the datasheet of [ILI9341V](../../doc/ILI9341V_v1.0.pdf). (h denote hexadecimal and d denote decimal notation).
|
||||
|
||||
1. **Memory access control (36h)**: send 54d (CDX high) followed by the argument 72d (with CDX low) to get access to the memory of ILI9341V.
|
||||
2. **COLMOD Pixel Format Set (3Ah)**: send 58d (CDX high) followed by the argument 85d (CDX low) to set the pixel format to rgb 16 bit.
|
||||
3. **Sleep Out (11h)**: send 17d (CDX high) and wait 500 ms to awake ILI9341V from sleep mode.
|
||||
4. **Display ON (29h)**: send 41d (CDX high) and wait 500 ms to switch the display on.
|
||||
|
||||
After initialisation with commands 1-4, the screen turns on showing a random pattern of RGB colors. To paint something on the screen, we must send the following three commands to LCD.
|
||||
|
||||
5. **Colum addres set (2Ah)**: To set the x-range of the window into which to paint, send command 42d with CDX high followed by x1 (16 bit) and x2 (16 bit) with CDX low. x1 and x2 must be in the range [0:239] with x2>=x1.
|
||||
6. **Page address set (2Bh):** To set the y-range of the window into which to paint, send 43d with CDX high followed by value of y1 (16 bit) and value of y2 (16 bit) with CDX low. y1 and y2 must be in the range [0:319] with y2>=y1.
|
||||
7. **Memory write (2Ch):** To paint the pixel in the rectangle defined by (x1,y1)-(x2,y2) send 44d with CDX high followed by `w*h` 16 bit RGB values of every individual pixel in the rectangle starting at top left and ending at bottom right.
|
||||
|
||||
For convenience the commands 1.-7. are distributed to three functions of Screen.jack:
|
||||
### function void init(int addr)
|
||||
Initializes the LCD screen, by sending the commands 1.-4. to LCD. The LCD is memory mapped to the two memory addresses addr and addr+1 according to `06_IO_Devices/08_LCD`.
|
||||
|
||||
### function void setWindow(int x1,int y1, int x2, int y2)
|
||||
Sets a rectangle window by sending commands 4.,5. and the command 7. without the arguments. (x1,y1) is the upper left corner and (x2,y2) is the lower right corof the rectangle with width and height. The next `w*h` calls of writeData16(int value) will paint the pixels in the rectangle according to the rgb values.
|
||||
|
||||
### function void writeData16(int color)
|
||||
Sends a 16 bit RGB value to paint the next pixel in the window defined by `setWindow(int,int,int,int)`. This procedure must be called `w*h` times to paint every pixel in the rectangle defined by `setAddrWindow(int,int,int,int)`.
|
||||
|
||||
***
|
||||
### Project
|
||||
* implement `Screen.jack`
|
||||
* Test in simulation
|
||||
```
|
||||
$ cd 09_Screen_Test
|
||||
$ make
|
||||
$ cd ../00_HACK
|
||||
$ apio clean
|
||||
$ apio sim
|
||||
```
|
||||
|
||||

|
||||
|
||||
* Check for the correct init sequence:
|
||||
* CSX is low starting from the first command.
|
||||
* DCX is low while sending commands and high while sending data
|
||||
* SDO shows the serial binary representation of the send command/data
|
||||
* SCK shows 8 clocks cycles
|
||||
|
||||
* Run Screen_Test in real hardware on iCE40HX1K-EVB with MOD-LCD2.8RTP connected as described in `06_IO_Devices/LCD`.
|
||||
```
|
||||
$ cd 09_Screen_Test
|
||||
$ make
|
||||
$ make upload
|
||||
```
|
||||
* Compare the pattern on the LCD with the following picture:
|
||||
|
||||

|
1
07_Operating_System/09_Screen_Test/Screen.jack
Symbolic link
1
07_Operating_System/09_Screen_Test/Screen.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../Screen.jack
|
1
07_Operating_System/09_Screen_Test/StdIO.jack
Symbolic link
1
07_Operating_System/09_Screen_Test/StdIO.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../StdIO.jack
|
1
07_Operating_System/09_Screen_Test/String.jack
Symbolic link
1
07_Operating_System/09_Screen_Test/String.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../String.jack
|
1
07_Operating_System/09_Screen_Test/Sys.jack
Symbolic link
1
07_Operating_System/09_Screen_Test/Sys.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../Sys.jack
|
1
07_Operating_System/09_Screen_Test/UART.jack
Symbolic link
1
07_Operating_System/09_Screen_Test/UART.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../UART.jack
|
BIN
07_Operating_System/09_Screen_Test/lcd.png
Normal file
BIN
07_Operating_System/09_Screen_Test/lcd.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 111 KiB |
BIN
07_Operating_System/09_Screen_Test/screen.png
Normal file
BIN
07_Operating_System/09_Screen_Test/screen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 136 KiB |
Reference in New Issue
Block a user