Commit 31093b73b1f56db3382d3a58fdd6e8c0e49781e6

Authored by henyxia
1 parent 9c066355

Home screen finally displayed

.gitignore
... ... @@ -3,3 +3,7 @@
3 3 tweekd
4 4 *.log
5 5 *.csv
  6 +*.rgb
  7 +*.bmpr
  8 +*.map
  9 +*.boz
... ...
img/home.bmp
No preview for this file type
img/home.xcf
No preview for this file type
... ... @@ -12,9 +12,9 @@ int main(void)
12 12 {
13 13 int ret;
14 14 pthread_t tUI;
15   - pthread_t tNFC;
  15 + //pthread_t tNFC;
16 16 pthread_t tBUS;
17   - pthread_t tHVC;
  17 + //pthread_t tHVC;
18 18 initUILog();
19 19 if(!initLog())
20 20 {
... ... @@ -25,25 +25,25 @@ int main(void)
25 25 printx(DEBUG, MAIN, "Creating processes\n");
26 26 ret = pthread_create(&tUI, NULL, drawUI, NULL);
27 27 printx(DEBUG, MAIN, "UI Started ID %08x ret %d\n", tUI, ret);
28   - printx(INFO, MAIN, "Initializing NFC\n");
  28 + printx(INFO, MAIN, "Initializing NFC\n");/*
29 29 if(!initNFC())
30 30 {
31 31 printx(ERROR, MAIN, "Unable to start the NFC interface\n");
32 32 return 2;
33 33 }
34   - pthread_create(&tNFC, NULL, processNFC, NULL);
  34 + pthread_create(&tNFC, NULL, processNFC, NULL);*/
35 35 if(!initBus())
36 36 {
37 37 printx(ERROR, MAIN, "Unable to start the BUS interface\n");
38 38 return 3;
39 39 }
40   - pthread_create(&tBUS, NULL, processBus, NULL);
  40 + pthread_create(&tBUS, NULL, processBus, NULL);/*
41 41 if(!initHVC())
42 42 {
43 43 printx(ERROR, MAIN, "Unable to start the HVC interface\n");
44 44 return 4;
45 45 }
46   - pthread_create(&tHVC, NULL, processHVC, NULL);
  46 + pthread_create(&tHVC, NULL, processHVC, NULL);*/
47 47 //initProcessHeat();
48 48  
49 49 pthread_join(tUI, NULL);
... ...
... ... @@ -8,8 +8,79 @@
8 8 #define PRODUCT_ID 0xa001
9 9 #define ENDPOINT_OUT 0x01
10 10 #define MAX_SIZE_OUT 64
  11 +#define HEIGHT 240
  12 +#define WIDTH 320
11 13  
12   -libusb_device_handle* screenHandle;
  14 +libusb_device_handle* screenHandle;
  15 +unsigned char data[MAX_SIZE_OUT];
  16 +unsigned short dataPointer = 0;
  17 +
  18 +void fillDataWithHeader(void)
  19 +{
  20 + data[dataPointer] = 0x82; // HEADER
  21 + dataPointer++;
  22 + data[dataPointer] = 0x00; // XPOS
  23 + dataPointer++;
  24 + data[dataPointer] = 0x00; // XPOS
  25 + dataPointer++;
  26 + data[dataPointer] = 0x00; // YPOS
  27 + dataPointer++;
  28 + data[dataPointer] = 0x00; // YPOS
  29 + dataPointer++;
  30 + data[dataPointer] = 0x40; // Width 0x40
  31 + dataPointer++;
  32 + data[dataPointer] = 0x01; // Width 0x01
  33 + dataPointer++;
  34 + data[dataPointer] = 0xF0; // Height
  35 + dataPointer++;
  36 + data[dataPointer] = 0x00; // Height
  37 + dataPointer++;
  38 + data[dataPointer] = 0x00; // Copy
  39 + dataPointer++;
  40 +}
  41 +
  42 +void fillDataWithSubHeader(void)
  43 +{
  44 + data[dataPointer] = 0x02; // HEADER
  45 + dataPointer++;
  46 +}
  47 +
  48 +void sendUSBData(int i)
  49 +{
  50 + printf("Sending data %d\n", i);
  51 + int transfered;
  52 + libusb_bulk_transfer(screenHandle, ENDPOINT_OUT, data, dataPointer, &transfered, 0);
  53 + dataPointer = 0;
  54 + fillDataWithSubHeader();
  55 +}
  56 +
  57 +void displayPicture(char* filename)
  58 +{
  59 + FILE* file = NULL;
  60 + file = fopen(filename, "r");
  61 +
  62 + if(file == NULL)
  63 + {
  64 + printf("Unable to open the picture\n");
  65 + return;
  66 + }
  67 + else
  68 + printf("Picture successfully opened\n");
  69 +
  70 + fillDataWithHeader();
  71 + for(int i=0; i<HEIGHT*WIDTH*2; i++)
  72 + {
  73 + if(feof(file))
  74 + {
  75 + printf("File corrupted\n");
  76 + return;
  77 + }
  78 + data[dataPointer] = getc(file);
  79 + dataPointer++;
  80 + if(dataPointer == MAX_SIZE_OUT)
  81 + sendUSBData(i);
  82 + }
  83 +}
13 84  
14 85 bool initUSB(void)
15 86 {
... ... @@ -95,6 +166,8 @@ bool initUSB(void)
95 166  
96 167 libusb_free_config_descriptor(dConfig);
97 168  
  169 + displayPicture("home.rgb");
  170 +
98 171 return true;
99 172 }
100 173  
... ...
... ... @@ -2,5 +2,6 @@
2 2 #define __USB_H__
3 3  
4 4 bool initUSB();
  5 +void displayPicture(char*);
5 6  
6 7 #endif
... ...