From 82ea661415cd7727306519fce72a6ca1cda39988 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Tue, 25 Aug 2015 18:09:24 -0400 Subject: [PATCH] common: move uint16_to_packed_bcd() into common code. --- backend_common.c | 25 +++++++++++++++++++++++-- backend_common.h | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/backend_common.c b/backend_common.c index b2e6bda..2b8dd39 100644 --- a/backend_common.c +++ b/backend_common.c @@ -27,7 +27,7 @@ #include "backend_common.h" -#define BACKEND_VERSION "0.60" +#define BACKEND_VERSION "0.61" #ifndef URI_PREFIX #error "Must Define URI_PREFIX" #endif @@ -1037,7 +1037,7 @@ int lookup_printer_type(struct dyesub_backend *backend, uint16_t idVendor, uint1 { int i; int type = -1; - + for (i = 0 ; backend->devices[i].vid ; i++) { if (extra_pid != -1 && extra_vid != -1 && @@ -1056,3 +1056,24 @@ int lookup_printer_type(struct dyesub_backend *backend, uint16_t idVendor, uint1 return type; } + +uint16_t uint16_to_packed_bcd(uint16_t val) +{ + uint16_t bcd; + uint16_t i; + + /* Handle from 0-9999 */ + i = val % 10; + bcd = i; + val /= 10; + i = val % 10; + bcd |= (i << 4); + val /= 10; + i = val % 10; + bcd |= (i << 8); + val /= 10; + i = val % 10; + bcd |= (i << 12); + + return bcd; +} diff --git a/backend_common.h b/backend_common.h index 14ddf23..881c426 100644 --- a/backend_common.h +++ b/backend_common.h @@ -151,6 +151,8 @@ int lookup_printer_type(struct dyesub_backend *backend, uint16_t idVendor, uint1 void print_license_blurb(void); void print_help(char *argv0, struct dyesub_backend *backend); +uint16_t uint16_to_packed_bcd(uint16_t val); + /* Global data */ extern int terminate; extern int dyesub_debug;