From 31093b73b1f56db3382d3a58fdd6e8c0e49781e6 Mon Sep 17 00:00:00 2001 From: henyxia Date: Thu, 23 Apr 2015 14:28:24 +0200 Subject: [PATCH] Home screen finally displayed --- .gitignore | 4 ++++ img/home.bmp | Bin 230522 -> 0 bytes img/home.xcf | Bin 144875 -> 0 bytes main.c | 12 ++++++------ usb.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- usb.h | 1 + 6 files changed, 85 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 9fc43b0..822cbe7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ tweekd *.log *.csv +*.rgb +*.bmpr +*.map +*.boz diff --git a/img/home.bmp b/img/home.bmp index 256f477..0c1bf54 100644 Binary files a/img/home.bmp and b/img/home.bmp differ diff --git a/img/home.xcf b/img/home.xcf index 94dcd1f..97c6edc 100644 Binary files a/img/home.xcf and b/img/home.xcf differ diff --git a/main.c b/main.c index ca77e3b..a80ed68 100644 --- a/main.c +++ b/main.c @@ -12,9 +12,9 @@ int main(void) { int ret; pthread_t tUI; - pthread_t tNFC; + //pthread_t tNFC; pthread_t tBUS; - pthread_t tHVC; + //pthread_t tHVC; initUILog(); if(!initLog()) { @@ -25,25 +25,25 @@ int main(void) printx(DEBUG, MAIN, "Creating processes\n"); ret = pthread_create(&tUI, NULL, drawUI, NULL); printx(DEBUG, MAIN, "UI Started ID %08x ret %d\n", tUI, ret); - printx(INFO, MAIN, "Initializing NFC\n"); + printx(INFO, MAIN, "Initializing NFC\n");/* if(!initNFC()) { printx(ERROR, MAIN, "Unable to start the NFC interface\n"); return 2; } - pthread_create(&tNFC, NULL, processNFC, NULL); + pthread_create(&tNFC, NULL, processNFC, NULL);*/ if(!initBus()) { printx(ERROR, MAIN, "Unable to start the BUS interface\n"); return 3; } - pthread_create(&tBUS, NULL, processBus, NULL); + pthread_create(&tBUS, NULL, processBus, NULL);/* if(!initHVC()) { printx(ERROR, MAIN, "Unable to start the HVC interface\n"); return 4; } - pthread_create(&tHVC, NULL, processHVC, NULL); + pthread_create(&tHVC, NULL, processHVC, NULL);*/ //initProcessHeat(); pthread_join(tUI, NULL); diff --git a/usb.c b/usb.c index 2a98871..aeff742 100644 --- a/usb.c +++ b/usb.c @@ -8,8 +8,79 @@ #define PRODUCT_ID 0xa001 #define ENDPOINT_OUT 0x01 #define MAX_SIZE_OUT 64 +#define HEIGHT 240 +#define WIDTH 320 -libusb_device_handle* screenHandle; +libusb_device_handle* screenHandle; +unsigned char data[MAX_SIZE_OUT]; +unsigned short dataPointer = 0; + +void fillDataWithHeader(void) +{ + data[dataPointer] = 0x82; // HEADER + dataPointer++; + data[dataPointer] = 0x00; // XPOS + dataPointer++; + data[dataPointer] = 0x00; // XPOS + dataPointer++; + data[dataPointer] = 0x00; // YPOS + dataPointer++; + data[dataPointer] = 0x00; // YPOS + dataPointer++; + data[dataPointer] = 0x40; // Width 0x40 + dataPointer++; + data[dataPointer] = 0x01; // Width 0x01 + dataPointer++; + data[dataPointer] = 0xF0; // Height + dataPointer++; + data[dataPointer] = 0x00; // Height + dataPointer++; + data[dataPointer] = 0x00; // Copy + dataPointer++; +} + +void fillDataWithSubHeader(void) +{ + data[dataPointer] = 0x02; // HEADER + dataPointer++; +} + +void sendUSBData(int i) +{ + printf("Sending data %d\n", i); + int transfered; + libusb_bulk_transfer(screenHandle, ENDPOINT_OUT, data, dataPointer, &transfered, 0); + dataPointer = 0; + fillDataWithSubHeader(); +} + +void displayPicture(char* filename) +{ + FILE* file = NULL; + file = fopen(filename, "r"); + + if(file == NULL) + { + printf("Unable to open the picture\n"); + return; + } + else + printf("Picture successfully opened\n"); + + fillDataWithHeader(); + for(int i=0; i