s2145: More accurate "new media" number based on our guess of media type.

This commit is contained in:
Solomon Peachy 2016-08-19 18:00:23 -04:00
parent b210c5a5c0
commit e83b30df96
1 changed files with 25 additions and 2 deletions

View File

@ -106,6 +106,7 @@ struct shinkos2145_ctx {
uint16_t last_donor; uint16_t last_donor;
uint16_t last_remain; uint16_t last_remain;
uint16_t media_prints;
}; };
/* Structs for printer */ /* Structs for printer */
@ -201,6 +202,23 @@ static char *print_sizes (uint8_t v) {
} }
} }
static int print_counts (uint8_t v) {
switch (v) {
case PRINT_MEDIA_4x6:
return 700;
case PRINT_MEDIA_5x3_5:
return 800;
case PRINT_MEDIA_5x7:
return 400;
case PRINT_MEDIA_6x9:
return 310;
case PRINT_MEDIA_6x8:
return 350;
default:
return 700;
}
}
#define PRINT_MODE_DEFAULT 0x01 #define PRINT_MODE_DEFAULT 0x01
#define PRINT_MODE_STD_GLOSSY 0x02 #define PRINT_MODE_STD_GLOSSY 0x02
#define PRINT_MODE_FINE_GLOSSY 0x03 #define PRINT_MODE_FINE_GLOSSY 0x03
@ -1399,7 +1417,7 @@ static void shinkos2145_attach(void *vctx, struct libusb_device_handle *dev,
ctx->jobid++; ctx->jobid++;
/* Initialize donor */ /* Initialize donor */
ctx->last_donor = ctx->last_remain = 65535; ctx->last_donor = ctx->last_remain = ctx->media_prints = 65535;
} }
static void shinkos2145_teardown(void *vctx) { static void shinkos2145_teardown(void *vctx) {
@ -1525,6 +1543,11 @@ static int shinkos2145_main_loop(void *vctx, int copies) {
/* Validate print sizes */ /* Validate print sizes */
for (i = 0; i < media->count ; i++) { for (i = 0; i < media->count ; i++) {
/* Figure out the media type... */
int media_prints = print_counts(media->items[i].code);
if (media_prints < ctx->media_prints)
ctx->media_prints = media_prints;
/* Look for matching media */ /* Look for matching media */
if (le16_to_cpu(media->items[i].columns) == cpu_to_le16(le32_to_cpu(ctx->hdr.columns)) && if (le16_to_cpu(media->items[i].columns) == cpu_to_le16(le32_to_cpu(ctx->hdr.columns)) &&
le16_to_cpu(media->items[i].rows) == cpu_to_le16(le32_to_cpu(ctx->hdr.rows)) && le16_to_cpu(media->items[i].rows) == cpu_to_le16(le32_to_cpu(ctx->hdr.rows)) &&
@ -1573,7 +1596,7 @@ top:
sts->hdr.status, status_str(sts->hdr.status)); sts->hdr.status, status_str(sts->hdr.status));
/* Guessimate a percentage for the remaining media */ /* Guessimate a percentage for the remaining media */
donor = le32_to_cpu(sts->count_ribbon_left) * 100 / (le32_to_cpu(sts->count_ribbon_left)+le32_to_cpu(sts->count_paper)); donor = le32_to_cpu(sts->count_ribbon_left) * 100 / ctx->media_prints;
if (donor != ctx->last_donor) { if (donor != ctx->last_donor) {
ctx->last_donor = donor; ctx->last_donor = donor;
ATTR("marker-levels=%d\n", donor); ATTR("marker-levels=%d\n", donor);