Пример #1
0
int extended_charset(struct zint_symbol *symbol, uint8_t *source, int length)
{
	int error_number = 0;

	/* These are the "elite" standards which can support multiple character sets */
	switch(symbol->symbology) {
		case BARCODE_QRCODE: error_number = qr_code(symbol, source, length); break;
		case BARCODE_MICROQR: error_number = microqr(symbol, source, length); break;
	}

	return error_number;
}
Пример #2
0
static uint8_t tick(void) {
    float time = getSysTick() / 10000.0f;
    char text[128];
    snprintf(text, 127, "Device Time: %.1fs", time);

    struct zint_symbol zs;
    memset(&zs, 0, sizeof(zs));
    zs.input_mode = DATA_MODE;
    zs.option_1 = 3;
    /* zs.option_2 = 2; */
    int qr_res = qr_code(&zs, (unsigned char *)text, strlen(text));
    if (qr_res) {
        /* printf("Error: %i\n", qr_res); */
    }

    int zoom = MAX(1, MIN(LED_WIDTH / (zs.width + (BORDER * 2)), LED_HEIGHT / (zs.rows + (BORDER * 2))));
    static int old_width = 0;
    if (old_width != zs.width) {
        old_width = zs.width;
        lcdFillRGB(255, 255, 255);
    }

    int x0 = (LED_WIDTH - zoom * zs.width) / 2;
    int y0 = (LED_HEIGHT - zoom * zs.rows) / 2;
    for(int y = 0; y < zs.width; y++) {
        for(int x = 0; x < zs.rows; x++) {
            for(int y1 = y * zoom; y1 < (y + 1) * zoom; y1++) {
                for(int x1 = x * zoom; x1 < (x + 1) * zoom; x1++) {
                    if (module_is_set(&zs, x, y)) {
                        setLedXY(x0 + x1, y0 + y1, 0, 0, 0);
                    } else {
                        setLedXY(x0 + x1, y0 + y1, 255, 255, 255);
                    }
                }
            }
        }
    }
        
    time++;
    return 0;
}
Пример #3
0
int hibc(struct zint_symbol *symbol, uint8_t source[], int length)
{
	int counter, error_number, i;
	char to_process[40], temp[2], check_digit;

	if(length > 36) {
		strcpy(symbol->errtxt, "Data too long for HIBC LIC");
		return ZERROR_TOO_LONG;
	}
	to_upper(source);
	error_number = is_sane(TECHNETIUM , source, length);
	if(error_number == ZERROR_INVALID_DATA) {
		strcpy(symbol->errtxt, "Invalid characters in data");
		return error_number;
	}

	strcpy(to_process, "+");
	counter = 41;
	for(i = 0; i < length; i++) {
		counter += posn(TECHNETIUM, source[i]);
	}
	counter = counter % 43;

	if(counter < 10) {
		check_digit = itoc(counter);
	} else {
		if(counter < 36) {
			check_digit = (counter - 10) + 'A';
		} else {
			switch(counter) {
				case 36: check_digit = '-'; break;
				case 37: check_digit = '.'; break;
				case 38: check_digit = ' '; break;
				case 39: check_digit = '$'; break;
				case 40: check_digit = '/'; break;
				case 41: check_digit = '+'; break;
				case 42: check_digit = '%'; break;
				default: check_digit = ' '; break; /* Keep compiler happy */
			}
		}
	}

	temp[0] = check_digit;
	temp[1] = '\0';

	concat(to_process, (char *)source);
	concat(to_process, temp);
	length = strlen(to_process);

	switch(symbol->symbology) {
		case BARCODE_HIBC_QR:
			error_number = qr_code(symbol, (uint8_t *)to_process, length);
			break;
		case BARCODE_HIBC_PDF:
			error_number = pdf417enc(symbol, (uint8_t *)to_process, length);
			break;
		case BARCODE_HIBC_MICPDF:
			error_number = micro_pdf417(symbol, (uint8_t *)to_process, length);
			break;
	}

	return error_number;
}