diff --git a/Makefile b/Makefile index 39f83ae..6aff8ed 100644 --- a/Makefile +++ b/Makefile @@ -5,30 +5,36 @@ INCLUDES= SOURCES=main.c printx.c ui.c serial.c nfc.c bus.c hvc.c heat.c pump.c usb.c BMP=img/home.bmp img/main.bmp -MAP_SRC= +MAP_SRC=map/main.bmp OBJECTS=$(SOURCES:.c=.o) +BOZ=$(MAP_SRC:.bmp=.boz) +#BOZ=$(patsubst %_map.bmp,%.boz,$(MAP_SRC)) +MAP=$(BOZ:.boz=.map) BMPR=$(BMP:.bmp=.bmpr) RGB=$(BMPR:.bmpr=.rgb) -MAP=$(MAP_SRC:.bmp=.map) -BOZ=$(RGB:.rgb=.boz) OUTPUT=tweekd -all: $(SOURCES) $(BMP) $(OUTPUT) +all: $(SOURCES) pictures $(OUTPUT) -$(OUTPUT): $(BOZ) $(OBJECTS) +pictures: $(MAP_SRC) $(BMP) $(MAP) $(RGB) + +$(OUTPUT): $(OBJECTS) $(MAP) $(CC) $(OBJECTS) $(CC_LIBS) -o $@ %.o: %.c $(CC) $(INCLUDES) $(CC_FLAGS) $< -o $@ -%.bmpr: %.bmp - convert -flip $< $@ - %.rgb: %.bmpr bmp2rgb565 $< $@ -%.boz: %.rgb - cat $< > $@ +%.boz: %.bmp + convert -flip $< $@ + +%.bmpr: %.bmp + convert -flip $< $@ + +%.map: %.boz + bmp2map $< $@ clear: rm -f $(OUTPUT) $(OBJECTS) $(BOZ) $(BMPR) $(MAP) $(RGB) diff --git a/img/main.xcf b/img/main.xcf index cb0d12e..7180e3f 100644 Binary files a/img/main.xcf and b/img/main.xcf differ diff --git a/img/main_map.xcf b/img/main_map.xcf deleted file mode 100644 index 7180e3f..0000000 Binary files a/img/main_map.xcf and /dev/null differ diff --git a/map/main.bmp b/map/main.bmp new file mode 100644 index 0000000..d54a87f Binary files /dev/null and b/map/main.bmp differ diff --git a/map/main.xcf b/map/main.xcf new file mode 100644 index 0000000..cb0d12e Binary files /dev/null and b/map/main.xcf differ diff --git a/ui.c b/ui.c index 8f4daaf..cdbb43b 100644 --- a/ui.c +++ b/ui.c @@ -5,6 +5,7 @@ #include #include #include +#include "printx.h" #include "ui.h" #include "bus.h" #include "usb.h" @@ -15,9 +16,11 @@ #define LOG_LENGTH 82 #define IPS 2 #define SCREEN_TIME 1000000/IPS +#define MAX_FILENAME_LENGTH 30 #define SC_HOME 0 #define SC_MAIN 1 -#define SPACES " " + + char started[TIME_LENGTH]; char uid[HEADER_TEXT_LENGTH]; char cmd[LOG_LENGTH]; @@ -55,6 +58,31 @@ void setDebit(unsigned int d) debit = d; } +int calculateInteraction(int act, int x, int y) +{ + char filename[MAX_FILENAME_LENGTH]; + FILE* f = NULL; + switch(act) + { + case SC_HOME: + return act; + case SC_MAIN: + strcat(filename, "map/main.map"); + break; + default: + return act; + } + + f = fopen(filename, "r"); + if(f == NULL) + { + printx(ERROR, UI, "The selected map is unopenable\n"); + return act; + } + + return act; +} + void processScreen() { int x = -1; @@ -66,14 +94,13 @@ void processScreen() else { actScreen = SC_MAIN; - displayPicture("img/main.boz"); + displayPicture("img/main.rgb"); } } else if(actScreen == SC_MAIN) { if(screenTouched(&x, &y)) - displayPicture("img/home.boz"); - //displayPicture = calculateInteraction(displayPicture, x, y); + actScreen = calculateInteraction(actScreen, x, y); } } diff --git a/usb.c b/usb.c index 225f370..8db9299 100644 --- a/usb.c +++ b/usb.c @@ -182,7 +182,7 @@ bool initUSB(void) libusb_free_config_descriptor(dConfig); - displayPicture("img/home.boz"); + displayPicture("img/home.rgb"); return true; } @@ -198,12 +198,7 @@ bool screenTouched(int* x, int* y) return false; } - //printx(DEBUG, UI, "%02X %02X %02X %02X", data[0], data[1], data[2], data[3]); - //printx(DEBUG, UI, "%02X %02X %02X %02X", data[4], data[5], data[6], data[7]); - //printx(DEBUG, UI, "%02X %02X %02X\n", data[8], data[9], data[10]); - *x = data[3] + (256 * (int)data[4]); - *y = data[7]; printx(DEBUG, UI, "Screen %s at X %d Y %d\n", data[2] == 1 ? "touched" : "untouched", *x, *y); -- libgit2 0.21.2