Commit 297a72df6efe6ea340eb6934fc3ae75cdf51938c

Authored by henyxia
1 parent 19082eeb

Added sender

NFC incoming !
UI fixed
Showing 6 changed files with 16 additions and 32 deletions   Show diff stats
@@ -15,12 +15,12 @@ int main(void) @@ -15,12 +15,12 @@ int main(void)
15 printf("Log creation failed\n"); 15 printf("Log creation failed\n");
16 return 1; 16 return 1;
17 } 17 }
18 - printx(INFO, "Tweekd starting\n");  
19 - printx(DEBUG, "Creating processes\n"); 18 + printx(INFO, MAIN, "Tweekd starting\n");
  19 + printx(DEBUG, MAIN, "Creating processes\n");
20 displayUI(); 20 displayUI();
21 ret = pthread_create(&tUI, NULL, drawUI, NULL); 21 ret = pthread_create(&tUI, NULL, drawUI, NULL);
22 - printx(DEBUG, "UI Started ID %08x ret %d\n", tUI, ret);  
23 - printx(INFO, "Initializing NFC"); 22 + printx(DEBUG, MAIN, "UI Started ID %08x ret %d\n", tUI, ret);
  23 + printx(INFO, MAIN, "Initializing NFC");
24 //pthread_create(&tNFC, NULL, 24 //pthread_create(&tNFC, NULL,
25 pthread_join(tUI, NULL); 25 pthread_join(tUI, NULL);
26 closeLog(); 26 closeLog();
nfc.c 0 → 100644
nfc.h 0 → 100644
@@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
13 13
14 FILE* logfile = NULL; 14 FILE* logfile = NULL;
15 char s_color[4][12] = {"\x1b[01;31m", "\x1b[01;33m", "\x1b[01;32m", "\x1b[01;36m"}; 15 char s_color[4][12] = {"\x1b[01;31m", "\x1b[01;33m", "\x1b[01;32m", "\x1b[01;36m"};
  16 +char f_name[5][5] = {"MAIN", "UI ", "NFC ", "HVC ", "BUS "};
16 17
17 void removeCharFromString(char c, char *str) 18 void removeCharFromString(char c, char *str)
18 { 19 {
@@ -48,7 +49,7 @@ void closeLog() @@ -48,7 +49,7 @@ void closeLog()
48 fclose(logfile); 49 fclose(logfile);
49 } 50 }
50 51
51 -void printx(severity s, char* str, ...) 52 +void printx(severity s, msgfrom from, char* str, ...)
52 { 53 {
53 char buffer1[MAX_BUFFER]; 54 char buffer1[MAX_BUFFER];
54 char buffer2[MAX_BUFFER]; 55 char buffer2[MAX_BUFFER];
@@ -56,7 +57,7 @@ void printx(severity s, char* str, ...) @@ -56,7 +57,7 @@ void printx(severity s, char* str, ...)
56 va_start(arglist, str); 57 va_start(arglist, str);
57 vsprintf(buffer1, str, arglist); 58 vsprintf(buffer1, str, arglist);
58 fprintf(logfile, buffer1); 59 fprintf(logfile, buffer1);
59 - sprintf(buffer2, "%s%s%s", s_color[s], buffer1, S_RESET); 60 + sprintf(buffer2, "[%s] : %s%s%s", f_name[from], s_color[s], buffer1, S_RESET);
60 removeCharFromString('\n', buffer2); 61 removeCharFromString('\n', buffer2);
61 addToLog(buffer2); 62 addToLog(buffer2);
62 va_end(arglist); 63 va_end(arglist);
@@ -8,8 +8,13 @@ typedef enum @@ -8,8 +8,13 @@ typedef enum
8 ERROR, WARNING, INFO, DEBUG 8 ERROR, WARNING, INFO, DEBUG
9 }severity; 9 }severity;
10 10
  11 +typedef enum
  12 +{
  13 + MAIN, UI, NFC, HVC, BUS
  14 +}msgfrom;
  15 +
11 bool initLog(); 16 bool initLog();
12 -void printx(severity, char*, ...); 17 +void printx(severity, msgfrom, char*, ...);
13 void closeLog(); 18 void closeLog();
14 19
15 #endif 20 #endif
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 #define TIME_LENGTH 24 8 #define TIME_LENGTH 24
9 #define HEADER_TEXT_LENGTH 24 9 #define HEADER_TEXT_LENGTH 24
10 #define LOG_LINES 25 10 #define LOG_LINES 25
11 -#define LOG_LENGTH 69 11 +#define LOG_LENGTH 82
12 #define IPS 20 12 #define IPS 20
13 #define SCREEN_TIME 1000000/IPS 13 #define SCREEN_TIME 1000000/IPS
14 #define SPACES " " 14 #define SPACES " "
@@ -64,33 +64,11 @@ void addToLog(char* newStr) @@ -64,33 +64,11 @@ void addToLog(char* newStr)
64 64
65 char* fillLogWithSpaces(char* buf, char* text) 65 char* fillLogWithSpaces(char* buf, char* text)
66 { 66 {
67 -/*  
68 - char tmpretlog[LOG_LENGTH];  
69 - strncpy(tmpretlog, text, LOG_LENGTH);  
70 - if(strlen(text) > 0)  
71 - while((strlen(tmpretlog)-12) < LOG_LENGTH)  
72 - strcat(tmpretlog, " ");  
73 - else  
74 - while(strlen(tmpretlog) < LOG_LENGTH)  
75 - strcat(tmpretlog, " ");  
76 -  
77 -// int j;  
78 -// printf("J val\n");  
79 -// printf("%d\n", j);  
80 - for(int j=0; j<strlen(tmpretlog); j++)  
81 - buf[j] = tmpretlog[j];  
82 - buf[strlen(tmpretlog)] = '\0';  
83 -*/  
84 strncpy(buf, text, LOG_LENGTH); 67 strncpy(buf, text, LOG_LENGTH);
85 - /*  
86 if(strlen(buf) > 0) 68 if(strlen(buf) > 0)
87 - while((strlen(buf)-12) < LOG_LENGTH)  
88 - strcat(buf, " "); 69 + strncat(buf, SPACES, LOG_LENGTH-strlen(buf)-1);
89 else 70 else
90 - while(strlen(buf) < LOG_LENGTH)  
91 - strcat(buf, " ");  
92 - */  
93 - //strncat(buf, SPACES, LOG_LENGTH-strlen(buf)); 71 + strncat(buf, SPACES, LOG_LENGTH-strlen(buf)-1-12);
94 72
95 return buf; 73 return buf;
96 } 74 }