git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/examples/megaduck/laptop_printer/src/megaduck_printer.h

      1 #include <gbdk/platform.h>
      2 #include <stdint.h>
      3 #include <stdbool.h>
      4 
      5 #ifndef _MEGADUCK_PRINTER_H
      6 #define _MEGADUCK_PRINTER_H
      7 
      8 // // Thermal Printer related 
      9 #define PRINTER_CARRIAGE_RETURN       0x0D  // Return print head to start of 8 pixel high row
     10 #define PRINTER_LINE_FEED             0x0A  // Feed printer paper to next 8 pixel high row (there are two print passes per-row [to print different greys], so LF only happens every other row of printing)
     11 #define PRINTER_LEN_END_ROW_DATA_SZ   4     // 4 data bytes
     12 #define PRINTER_LEN_5_END_ROW_CR      5     // 5 bytes (4 data bytes + CR + LF)
     13 #define PRINTER_LEN_6_END_ROW_CRLF    6     // 6 bytes (4 data bytes + CR + LF)
     14 #define PRINTER_LEN_12_ROW_DATA       12    // 12 data bytes
     15 #define PRINTER_CR_IDX                (PRINTER_LEN_5_END_ROW_CR - 1)   // Byte number 5
     16 #define PRINTER_LF_IDX                (PRINTER_LEN_6_END_ROW_CRLF - 1) // Byte number 6
     17 
     18 #define PRINTER_2_PASS_ROW_NUM_PACKETS  14u
     19 #define PRINTER_2_PASS_ROW_LAST_PACKET  (PRINTER_2_PASS_ROW_NUM_PACKETS - 1u)
     20 
     21 #define PRINTER_1_PASS_ROW_NUM_PACKETS             4u
     22 #define PRINTER_1_PASS_ROW_NUM_BULK_BYTES          118u
     23 #define PRINTER_1_PASS_ROW_NUM_BULK_DATA_BYTES     112u
     24 #define PRINTER_1_PASS_ROW_NUM_BULK_UNKNOWN_BYTES  (PRINTER_1_PASS_ROW_NUM_BULK_BYTES - PRINTER_1_PASS_ROW_NUM_BULK_DATA_BYTES)
     25 #define PRINTER_1_PASS_BULK_ACK_TIMEOUT_100MSEC    100u
     26 
     27 #define PRINT_ROW_END_ACK_WAIT_TIMEOUT_200MSEC     200u // Presumably waiting for a carriage return confirmation ACK from the printer
     28 #define PRINT_DELAY_BETWEEN_ROWS_1000MSEC         1000u // Waiting for the print head to return to the start of the line and buffer to be cleared
     29 
     30 
     31 #define BYTES_PER_PRINTER_TILE  8u
     32 #define BYTES_PER_VRAM_TILE     16u
     33 #define TILE_HEIGHT             8u
     34 #define TILE_WIDTH              8u
     35 
     36 // Buffer to store an entire queued tile row for printing
     37 extern uint8_t tile_row_buffer[DEVICE_SCREEN_WIDTH * BYTES_PER_PRINTER_TILE];
     38 
     39 
     40 bool duck_printer_send_tile_row_1pass(void);
     41 void duck_printer_convert_tile(uint8_t * p_out_buf, uint8_t * p_tile_buf);
     42 void duck_printer_convert_tile_dithered(uint8_t * p_out_buf, uint8_t * p_tile_buf);
     43 bool duck_printer_send_tile_row_1pass(void);
     44 
     45 
     46 #endif // _MEGADUCK_PRINTER_H

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.