common: move uint16_to_packed_bcd() into common code.

This commit is contained in:
Solomon Peachy 2015-08-25 18:09:24 -04:00
parent 5d3109a05a
commit 82ea661415
2 changed files with 25 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;