Nikita Ivanykov
/
LAB_DISPLAY
7
main.cpp
- Committer:
- troshha
- Date:
- 2019-11-13
- Revision:
- 3:9909607749dd
- Parent:
- 2:82f5f57eac91
File content as of revision 3:9909607749dd:
#include "mbed.h" #include "ILI9341_Defines.h" SPI spi_dev(PB_15, PB_14, PB_13, PB_12); DigitalOut cs(PC_4); DigitalOut ao(PB_3); uint8_t tarr[1024]; uint8_t rarr[1024]; void writecommand(uint8_t command) { cs = 0; ao = 0; spi_dev.write(command); cs = 1; } void writedata(uint8_t data) { cs = 0; ao = 1; spi_dev.write(data); cs = 1; } void setAddress(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) { writecommand(0x2a); writedata(0x00); writedata(x1); writedata(0x00); writedata(x2); writecommand(0x2b); writedata(0x00); writedata(y1); writedata(0x00); writedata(y2); writecommand(0x2c); } void writeColorData(uint8_t * arr, int length) { cs = 0; ao = 1; spi_dev.write((char*)arr, length, NULL, length); cs = 1; } int main() { HAL_Init(); #include "ILI9341_Init.h" setAddress(0, 0, 127, 127); for (int i = 0; i < 1024; i++) { tarr[i] = 0; } for (int i = 0; i < 32; i++) { writeColorData(tarr, 1024); } while(1) { setAddress(64, 64, 127, 127); for (int i = 0; i < 1024; i++) { tarr[i] = 10; } for (int i = 0; i < 32; i++) { writeColorData(tarr, 1024); } setAddress(0, 0, 64, 64); for (int i = 0; i < 1024; i++) { tarr[i*2] = 0xF8; tarr[i*2+1] = 0x00; } for (int i = 0; i < 32; i++) { writeColorData(tarr, 1024); } setAddress(0, 64, 64, 127); for (int i = 0; i < 1024; i++) { tarr[i] = 07E0; } for (int i = 0; i < 32; i++) { writeColorData(tarr, 1024); } setAddress(64, 0, 127, 64); for (int i = 0; i < 1024; i++) { tarr[i] = 40; } for (int i = 0; i < 32; i++) { writeColorData(tarr, 1024); } wait(0.5); setAddress(64, 64, 127, 127); for (int i = 0; i < 1024; i++) { tarr[i] = 0; } for (int i = 0; i < 32; i++) { writeColorData(tarr, 1024); } wait(0.5); setAddress(0, 0, 64, 64); for (int i = 0; i < 1024; i++) { tarr[i] = 0; } for (int i = 0; i < 32; i++) { writeColorData(tarr, 1024); } wait(0.5); setAddress(0, 64, 64, 127); for (int i = 0; i < 1024; i++) { tarr[i] = 0; } for (int i = 0; i < 32; i++) { writeColorData(tarr, 1024); } wait(0.5); setAddress(64, 0, 127, 64); for (int i = 0; i < 1024; i++) { tarr[i] = 0; } for (int i = 0; i < 32; i++) { writeColorData(tarr, 1024); } } }