Skip to content

Commit

Permalink
Merge branch 'jjwbruijn:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasniesner authored May 6, 2024
2 parents b627213 + e4351c2 commit 224af3e
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 63 deletions.
122 changes: 87 additions & 35 deletions ESP32_AP-Flasher/src/ble_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "util.h"
#include "web.h"

uint8_t* Mirrorbuffer;

uint8_t gicToOEPLtype(uint8_t gicType) {
switch (gicType) {
case 0xA0:
Expand Down Expand Up @@ -143,14 +145,22 @@ bool BLE_filter_add_device(BLEAdvertisedDevice advertisedDevice) {
bool BLE_is_image_pending(uint8_t address[8]) {
for (int16_t c = 0; c < tagDB.size(); c++) {
tagRecord* taginfo = tagDB.at(c);
if (taginfo->pendingCount > 0 && taginfo->version == 0 && (taginfo->hwType & 0xB0)) {
if (taginfo->pendingCount > 0 && taginfo->version == 0 && ((taginfo->hwType & 0xB0) == 0xB0)) {
memcpy(address, taginfo->mac, 8);
return true;
}
}
return false;
}

uint8_t swapBits(uint8_t num) {
uint8_t result = 0;
for (int i = 0; i < 8; ++i) {
result |= ((num >> i) & 0x01) << (7 - i);
}
return result;
}

uint32_t compress_image(uint8_t address[8], uint8_t* buffer, uint32_t max_len) {
uint32_t t = millis();
PendingItem* queueItem = getQueueItem(address, 0);
Expand Down Expand Up @@ -179,76 +189,77 @@ uint32_t compress_image(uint8_t address[8], uint8_t* buffer, uint32_t max_len) {
uint8_t special_color = ((giciType >> 10) & 12);
uint8_t singleDoubleMirror = giciType & 1;
uint8_t canDoCompression = (giciType & 0x4000) ? 0 : 1;
Serial.printf("BLE Filter options:\r\n");
Serial.printf("screenResolution %d\r\n", screenResolution);
Serial.printf("dispPtype %d\r\n", dispPtype);
Serial.printf("availColors %d\r\n", availColors);
Serial.printf("special_color %d\r\n", special_color);
Serial.printf("singleDoubleMirror %d\r\n", singleDoubleMirror);
Serial.printf("canDoCompression %d\r\n", canDoCompression);

bool extra_color = false;
bool mirror_width = false;
uint16_t width_display = 104;
uint16_t height_display = 212;

switch (screenResolution) {
case 0:
width_display = 104;
height_display = 212;
width_display = 216;
height_display = 104;
break;
case 1:
width_display = 128;
height_display = 296;
width_display = 296;
height_display = 128;
break;
case 2:
width_display = 300;
height_display = 400;
break;
case 3:
width_display = 384;
height_display = 640;
width_display = 640;
height_display = 384;
break;
case 4:
width_display = 640;
height_display = 960;
width_display = 960;
height_display = 640;
break;
case 5:
width_display = 132;
height_display = 256;
width_display = 250;
height_display = 136;
break;
case 6:
width_display = 96;
height_display = 196;
width_display = 196;
height_display = 96;
break;
case 7:
width_display = 480;
height_display = 640;
width_display = 640;
height_display = 480;
break;
case 8:
width_display = 128;
height_display = 256;
width_display = 250;
height_display = 128;
break;
case 9:
width_display = 480;
height_display = 800;
width_display = 800;
height_display = 480;
break;
case 10:
width_display = 480;
height_display = 280;
width_display = 280;
height_display = 480;
break;
}

switch (dispPtype) {
case 0: // TFT
mirror_width = true;
break;
case 1: // EPA
mirror_width = false;
break;
case 2: // EPA1
mirror_width = false;
break;
case 3: // EPA2
mirror_width = false;
break;
}

if (giciType & 0x100) // Some special case, needs to be tested if always correct
mirror_width = true;

switch (availColors) {
case 0: // BW
extra_color = false;
Expand Down Expand Up @@ -278,6 +289,24 @@ uint32_t compress_image(uint8_t address[8], uint8_t* buffer, uint32_t max_len) {
len_compressed = 4;
uint32_t curr_input_posi = 0;
uint32_t byte_per_line = (height_display / 8);
if (height_display % 8 != 0)
byte_per_line++;
Mirrorbuffer = (uint8_t*)malloc(byte_per_line + 1);
if (Mirrorbuffer == nullptr) {
Serial.println("BLE Could not create Mirrorbuffer!");
return 0;
}
Serial.printf("BLE Filter options:\r\n");
Serial.printf("screenResolution %d\r\n", screenResolution);
Serial.printf("dispPtype %d\r\n", dispPtype);
Serial.printf("availColors %d\r\n", availColors);
Serial.printf("special_color %d\r\n", special_color);
Serial.printf("singleDoubleMirror %d\r\n", singleDoubleMirror);
Serial.printf("canDoCompression %d\r\n", canDoCompression);
Serial.printf("byte_per_line %d\r\n", byte_per_line);
Serial.printf("width_display %d\r\n", width_display);
Serial.printf("height_display %d\r\n", height_display);
Serial.printf("mirror_width %d\r\n", mirror_width);
for (int i = 0; i < width_display; i++) {
if (canDoCompression) {
buffer[len_compressed++] = 0x75;
Expand All @@ -288,8 +317,17 @@ uint32_t compress_image(uint8_t address[8], uint8_t* buffer, uint32_t max_len) {
buffer[len_compressed++] = 0x00;
buffer[len_compressed++] = 0x00;
}
for (int b = 0; b < byte_per_line; b++) {
buffer[len_compressed++] = ~queueItem->data[curr_input_posi++];
if (mirror_width) {
for (int b = 0; b < byte_per_line; b++) {
Mirrorbuffer[b] = ~queueItem->data[curr_input_posi++];
}
for (int b = byte_per_line - 1; b >= 0; b--) {
buffer[len_compressed++] = swapBits(Mirrorbuffer[b]);
}
} else {
for (int b = 0; b < byte_per_line; b++) {
buffer[len_compressed++] = ~queueItem->data[curr_input_posi++];
}
}
}
if (extra_color) {
Expand All @@ -303,11 +341,24 @@ uint32_t compress_image(uint8_t address[8], uint8_t* buffer, uint32_t max_len) {
buffer[len_compressed++] = 0x00;
buffer[len_compressed++] = 0x00;
}
for (int b = 0; b < byte_per_line; b++) {
if (queueItem->len <= curr_input_posi)
buffer[len_compressed++] = 0x00;
else
buffer[len_compressed++] = queueItem->data[curr_input_posi++];
if (mirror_width) {
for (int b = 0; b < byte_per_line; b++) {
if (queueItem->len <= curr_input_posi)
Mirrorbuffer[b] = 0x00; // Do not anything outside of the buffer!
else
Mirrorbuffer[b] = queueItem->data[curr_input_posi++];
}
for (int b = byte_per_line - 1; b >= 0; b--) {
buffer[len_compressed++] = swapBits(Mirrorbuffer[b]);
}
} else {
for (int b = 0; b < byte_per_line; b++) {
if (queueItem->len <= curr_input_posi) {
buffer[len_compressed++] = 0x00; // Do not anything outside of the buffer!
} else {
buffer[len_compressed++] = queueItem->data[curr_input_posi++];
}
}
}
}
}
Expand All @@ -317,6 +368,7 @@ uint32_t compress_image(uint8_t address[8], uint8_t* buffer, uint32_t max_len) {
buffer[2] = (len_compressed >> 16) & 0xff;
buffer[3] = (len_compressed >> 24) & 0xff;
}
free(Mirrorbuffer);
return len_compressed;
}

Expand Down
Binary file added Hardware/3D-Printed/chroma74_debug_jig.STL
Binary file not shown.
23 changes: 20 additions & 3 deletions Hardware/3D-Printed/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,29 @@ There are holder and stands for every tag. 1.54", 2.9" and 4.2".



** 4.2 mini stand v2 by Nic.stl
![image](4.2_mini_stand_v2.jpeg)
**4.2 mini stand v2 by Nic.stl**
4.2" mini stand by Nic. Note that these are designed with tight tolerances, to be printed on a resin printer. If you print it using your desktop 3D-printer, it might not fit.

** 4x 1.54" By Pål Hamre
![image](4.2_mini_stand_v2.jpeg)


**4x 1.54" By Pål Hamre**
File: 4x154_holder_by_Pal_Hamre.stl

![image](4_154_Image_1.jpg)

![image](4_154_Image_2.jpg)

![image](4_154_Image_3.jpg)

**Chroma74 Debug JIG**

File: chroma74_debug_jig.STL (fix the pogo pins with a little bit of superglue)

![image](https://github.com/jjwbruijn/OpenEPaperLink/assets/3323812/ef7440f0-40ee-4c0a-a836-0d9541d15922)

![IMG_20240505_183120](https://github.com/jjwbruijn/OpenEPaperLink/assets/3323812/011ad966-8451-467c-8414-8e56c88aa121)

![IMG_20240505_183051](https://github.com/jjwbruijn/OpenEPaperLink/assets/3323812/ad00f712-82e8-4d05-87c2-a5bd54a60eb9)

![IMG_20240505_204601](https://github.com/jjwbruijn/OpenEPaperLink/assets/3323812/2d31e730-5b10-458a-941c-198eab711e1d)
34 changes: 20 additions & 14 deletions resources/tagtypes/05.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@
"shortlut": 1,
"zlib_compression": "27",
"options": [ ],
"contentids": [ 22, 23, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20 ],
"contentids": [ 22, 23, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20, 27 ],
"template": {
"1": {
"weekday": [ 320, -5, "Signika-SB.ttf", 100 ],
"month": [ 320, 265, "Signika-SB.ttf", 100 ],
"day": [ 320, 60, "Signika-SB.ttf", 220 ]
},
"4": {
"location": [ 20, 20, "fonts/calibrib30" ],
"wind": [ 90, 83, "fonts/calibrib30" ],
"temp": [ 20, 170, "fonts/calibrib30" ],
"icon": [ 385, 0, 100, 2 ],
"dir": [ 40, 50, 80 ],
"umbrella": [ 325, 155, 78 ]
"location": [ 40, 20, "fonts/calibrib80" ],
"wind": [ 175, 180, "fonts/calibrib30" ],
"temp": [ 45, 240, "fonts/calibrib100" ],
"icon": [ 520, 80, 150, 2 ],
"dir": [ 120, 60, 180 ],
"umbrella": [ 575, 250, 102 ]
},
"8": {
"location": [ 10, 10, "fonts/calibrib30" ],
"column": [ 6, 66 ],
"day": [ 33, 60, "fonts/bahnschrift20", 104, 230 ],
"rain": [ 34, 260 ],
"icon": [ 32, 145, 30 ],
"wind": [ 17, 90 ],
"line": [ 50, 300 ]
"location": [ 10, 0, "fonts/calibrib80" ],
"column": [ 7, 91 ],
"day": [ 42, 110, "fonts/calibrib30", 150, 285 ],
"rain": [ 48, 340 ],
"icon": [ 45, 180, 60 ],
"wind": [ 17, 120 ],
"line": [ 95, 370 ]
},
"9": {
"title": [ 6, 0, "Signika-SB.ttf", 32 ],
Expand All @@ -52,6 +52,12 @@
"mode": 1,
"days": 7,
"gridparam": [ 3, 17, 30, "calibrib16.vlw", "tahoma9.vlw", 14 ]
},
"27": {
"bars": [ 12, 630, 340, 20 ],
"time": [ "calibrib16.vlw" ],
"yaxis": [ "calibrib16.vlw", 1, 12 ],
"head": [ "calibrib30.vlw" ]
}
}
}
2 changes: 1 addition & 1 deletion resources/tagtypes/26.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"zlib_compression": "27",
"highlight_color": 5,
"options": [ ],
"contentids": [ 22, 23, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20 ],
"contentids": [ 22, 23, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20, 27 ],
"usetemplate" : 5
}
2 changes: 1 addition & 1 deletion resources/tagtypes/80.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
},
"shortlut": 1,
"options": [ ],
"contentids": [ 22, 23, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20 ],
"contentids": [ 22, 23, 1, 4, 5, 7, 8, 9, 10, 11, 17, 18, 19, 20, 27 ],
"usetemplate": 5
}
8 changes: 4 additions & 4 deletions resources/tagtypes/B0.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"version": 3,
"name": "Gicisky BLE EPD BW 2.1\"",
"width": 256,
"version": 4,
"name": "Gicisky BLE EPD BW 2.13\"",
"width": 250,
"height": 128,
"rotatebuffer": 1,
"rotatebuffer": 3,
"bpp": 1,
"colortable": {
"white": [ 255, 255, 255 ],
Expand Down
8 changes: 4 additions & 4 deletions resources/tagtypes/B1.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"version": 3,
"name": "Gicisky BLE EPD BWR 2.1\"",
"width": 256,
"version": 4,
"name": "Gicisky BLE EPD BWR 2.13\"",
"width": 250,
"height": 128,
"rotatebuffer": 1,
"rotatebuffer": 3,
"bpp": 2,
"colortable": {
"white": [ 255, 255, 255 ],
Expand Down
2 changes: 1 addition & 1 deletion resources/tagtypes/BA.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 1,
"version": 3,
"name": "Gicisky BLE TFT 2.13\"",
"width": 250,
"height": 132,
Expand Down

0 comments on commit 224af3e

Please sign in to comment.