Commit 5a135e772dfbd04f94bf444d57ecce813ea18636

Authored by henyxia
1 parent 8b194ee7

MAP Files generated

Fixed exchange between main and main_map
MAP almost done
@@ -5,30 +5,36 @@ INCLUDES= @@ -5,30 +5,36 @@ INCLUDES=
5 5
6 SOURCES=main.c printx.c ui.c serial.c nfc.c bus.c hvc.c heat.c pump.c usb.c 6 SOURCES=main.c printx.c ui.c serial.c nfc.c bus.c hvc.c heat.c pump.c usb.c
7 BMP=img/home.bmp img/main.bmp 7 BMP=img/home.bmp img/main.bmp
8 -MAP_SRC= 8 +MAP_SRC=map/main.bmp
9 OBJECTS=$(SOURCES:.c=.o) 9 OBJECTS=$(SOURCES:.c=.o)
  10 +BOZ=$(MAP_SRC:.bmp=.boz)
  11 +#BOZ=$(patsubst %_map.bmp,%.boz,$(MAP_SRC))
  12 +MAP=$(BOZ:.boz=.map)
10 BMPR=$(BMP:.bmp=.bmpr) 13 BMPR=$(BMP:.bmp=.bmpr)
11 RGB=$(BMPR:.bmpr=.rgb) 14 RGB=$(BMPR:.bmpr=.rgb)
12 -MAP=$(MAP_SRC:.bmp=.map)  
13 -BOZ=$(RGB:.rgb=.boz)  
14 OUTPUT=tweekd 15 OUTPUT=tweekd
15 16
16 -all: $(SOURCES) $(BMP) $(OUTPUT) 17 +all: $(SOURCES) pictures $(OUTPUT)
17 18
18 -$(OUTPUT): $(BOZ) $(OBJECTS) 19 +pictures: $(MAP_SRC) $(BMP) $(MAP) $(RGB)
  20 +
  21 +$(OUTPUT): $(OBJECTS) $(MAP)
19 $(CC) $(OBJECTS) $(CC_LIBS) -o $@ 22 $(CC) $(OBJECTS) $(CC_LIBS) -o $@
20 23
21 %.o: %.c 24 %.o: %.c
22 $(CC) $(INCLUDES) $(CC_FLAGS) $< -o $@ 25 $(CC) $(INCLUDES) $(CC_FLAGS) $< -o $@
23 26
24 -%.bmpr: %.bmp  
25 - convert -flip $< $@  
26 -  
27 %.rgb: %.bmpr 27 %.rgb: %.bmpr
28 bmp2rgb565 $< $@ 28 bmp2rgb565 $< $@
29 29
30 -%.boz: %.rgb  
31 - cat $< > $@ 30 +%.boz: %.bmp
  31 + convert -flip $< $@
  32 +
  33 +%.bmpr: %.bmp
  34 + convert -flip $< $@
  35 +
  36 +%.map: %.boz
  37 + bmp2map $< $@
32 38
33 clear: 39 clear:
34 rm -f $(OUTPUT) $(OBJECTS) $(BOZ) $(BMPR) $(MAP) $(RGB) 40 rm -f $(OUTPUT) $(OBJECTS) $(BOZ) $(BMPR) $(MAP) $(RGB)
img/main.xcf
No preview for this file type
img/main_map.xcf deleted
No preview for this file type
map/main.bmp 0 → 100644
No preview for this file type
map/main.xcf 0 → 100644
No preview for this file type
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 #include <time.h> 5 #include <time.h>
6 #include <stdbool.h> 6 #include <stdbool.h>
7 #include <termios.h> 7 #include <termios.h>
  8 +#include "printx.h"
8 #include "ui.h" 9 #include "ui.h"
9 #include "bus.h" 10 #include "bus.h"
10 #include "usb.h" 11 #include "usb.h"
@@ -15,9 +16,11 @@ @@ -15,9 +16,11 @@
15 #define LOG_LENGTH 82 16 #define LOG_LENGTH 82
16 #define IPS 2 17 #define IPS 2
17 #define SCREEN_TIME 1000000/IPS 18 #define SCREEN_TIME 1000000/IPS
  19 +#define MAX_FILENAME_LENGTH 30
18 #define SC_HOME 0 20 #define SC_HOME 0
19 #define SC_MAIN 1 21 #define SC_MAIN 1
20 -#define SPACES " " 22 +
  23 +
21 char started[TIME_LENGTH]; 24 char started[TIME_LENGTH];
22 char uid[HEADER_TEXT_LENGTH]; 25 char uid[HEADER_TEXT_LENGTH];
23 char cmd[LOG_LENGTH]; 26 char cmd[LOG_LENGTH];
@@ -55,6 +58,31 @@ void setDebit(unsigned int d) @@ -55,6 +58,31 @@ void setDebit(unsigned int d)
55 debit = d; 58 debit = d;
56 } 59 }
57 60
  61 +int calculateInteraction(int act, int x, int y)
  62 +{
  63 + char filename[MAX_FILENAME_LENGTH];
  64 + FILE* f = NULL;
  65 + switch(act)
  66 + {
  67 + case SC_HOME:
  68 + return act;
  69 + case SC_MAIN:
  70 + strcat(filename, "map/main.map");
  71 + break;
  72 + default:
  73 + return act;
  74 + }
  75 +
  76 + f = fopen(filename, "r");
  77 + if(f == NULL)
  78 + {
  79 + printx(ERROR, UI, "The selected map is unopenable\n");
  80 + return act;
  81 + }
  82 +
  83 + return act;
  84 +}
  85 +
58 void processScreen() 86 void processScreen()
59 { 87 {
60 int x = -1; 88 int x = -1;
@@ -66,14 +94,13 @@ void processScreen() @@ -66,14 +94,13 @@ void processScreen()
66 else 94 else
67 { 95 {
68 actScreen = SC_MAIN; 96 actScreen = SC_MAIN;
69 - displayPicture("img/main.boz"); 97 + displayPicture("img/main.rgb");
70 } 98 }
71 } 99 }
72 else if(actScreen == SC_MAIN) 100 else if(actScreen == SC_MAIN)
73 { 101 {
74 if(screenTouched(&x, &y)) 102 if(screenTouched(&x, &y))
75 - displayPicture("img/home.boz");  
76 - //displayPicture = calculateInteraction(displayPicture, x, y); 103 + actScreen = calculateInteraction(actScreen, x, y);
77 } 104 }
78 } 105 }
79 106
@@ -182,7 +182,7 @@ bool initUSB(void) @@ -182,7 +182,7 @@ bool initUSB(void)
182 182
183 libusb_free_config_descriptor(dConfig); 183 libusb_free_config_descriptor(dConfig);
184 184
185 - displayPicture("img/home.boz"); 185 + displayPicture("img/home.rgb");
186 186
187 return true; 187 return true;
188 } 188 }
@@ -198,12 +198,7 @@ bool screenTouched(int* x, int* y) @@ -198,12 +198,7 @@ bool screenTouched(int* x, int* y)
198 return false; 198 return false;
199 } 199 }
200 200
201 - //printx(DEBUG, UI, "%02X %02X %02X %02X", data[0], data[1], data[2], data[3]);  
202 - //printx(DEBUG, UI, "%02X %02X %02X %02X", data[4], data[5], data[6], data[7]);  
203 - //printx(DEBUG, UI, "%02X %02X %02X\n", data[8], data[9], data[10]);  
204 -  
205 *x = data[3] + (256 * (int)data[4]); 201 *x = data[3] + (256 * (int)data[4]);
206 -  
207 *y = data[7]; 202 *y = data[7];
208 203
209 printx(DEBUG, UI, "Screen %s at X %d Y %d\n", data[2] == 1 ? "touched" : "untouched", *x, *y); 204 printx(DEBUG, UI, "Screen %s at X %d Y %d\n", data[2] == 1 ? "touched" : "untouched", *x, *y);