123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- #ifndef CONFIG_H
- #define CONFIG_H
- // clang-format off
- #include <freetype2/ft2build.h>
- #include <freetype/freetype.h>
- // clang-format on
- /// raspberry pi CM3
- #define BCM_GPIO_28 28
- #define BCM_GPIO_29 29
- #define BCM_GPIO_30 30
- #define BCM_GPIO_31 31
- #define BCM_GPIO_32 32
- #define BCM_GPIO_33 33
- #define BCM_GPIO_34 34
- #define BCM_GPIO_35 35
- #define BCM_GPIO_36 36
- #define BCM_GPIO_37 37
- #define BCM_GPIO_38 38
- #define BCM_GPIO_39 39
- #define BCM_GPIO_40 40
- #define BCM_GPIO_41 41
- #define BCM_GPIO_42 42
- #define BCM_GPIO_43 43
- #define BCM_GPIO_44 44
- #define BCM_GPIO_45 45
- // PA8-12 UART1
- //#define SPI1_NSS_PIN PA4 //SPI_1 Chip Select pin is PA4. //no use in
- //DevTerm
- #define VH_PIN BCM_GPIO_40 // ENABLE_VH required,PRT_EN
- #define LATCH_PIN BCM_GPIO_36 // 18
- #define PEM_PIN BCM_GPIO_34 // 1 [PS,PAPER]
- /*
- #define PEM_CTL_PIN BCM_GPIO_32 //3 VPS
- #define ENABLE_PEM digitalWrite(PEM_CTL_PIN,HIGH)
- #define DISABLE_PEM digitalWrite(PEM_CTL_PIN,LOW)
- */
- // DevTerm no VPS IO
- //#define PEM_CTL_PIN
- #define ENABLE_PEM
- #define DISABLE_PEM
- // https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
- // enable SPI0 ALT0 in CM3 first
- // in /boot/config.txt
- // dtparam=spi=on
- // dtoverlay=spi-gpio35-39
- // then we can see GPIO38 GPIO39 in ALT0 Mode by `gpio readall`
- #define MOSI_PIN BCM_GPIO_38
- #define CLK_PIN BCM_GPIO_39
- /**
- *@brief STB_NUMBER stand for STROBE NUMBER of lines, which means how many lines
- * are going to be activated
- **/
- #define STB_NUMBER 1
- #define STB1_PIN BCM_GPIO_37 // 13
- #define STB2_PIN STB1_PIN
- #define STB3_PIN STB1_PIN
- #define STB4_PIN STB1_PIN
- #define STB5_PIN STB1_PIN
- #define STB6_PIN STB1_PIN
- #define PH1_PIN BCM_GPIO_28
- #define PH2_PIN BCM_GPIO_29
- #define PH3_PIN BCM_GPIO_30
- #define PH4_PIN BCM_GPIO_31
- /// 0 1 3 2 mine
- #define PA_PIN PH1_PIN //
- #define PNA_PIN PH2_PIN //
- #define PB_PIN PH3_PIN //
- #define PNB_PIN PH4_PIN //
- //#define ENABLE1_PIN PA13
- //#define ENABLE2_PIN PA14
- #define THERMISTORPIN BCM_GPIO_35 // ADC,14
- #define MOTOR_ENABLE1
- #define MOTOR_ENABLE2
- #define MOTOR_DISABLE1
- #define MOTOR_DISABLE2
- #define ENABLE_VH digitalWrite(VH_PIN, HIGH)
- #define DISABLE_VH digitalWrite(VH_PIN, LOW)
- #define READ_VH digitalRead(VH_PIN)
- #define LATCH_ENABLE digitalWrite(LATCH_PIN, LOW)
- #define LATCH_DISABLE digitalWrite(LATCH_PIN, HIGH)
- #define ASK4PAPER digitalRead(PEM_PIN)
- #define ERROR_FEED_PITCH ((uint8_t)0x01)
- #define IS_PAPER 0x00
- #define NO_PAPER 0x01
- #define HOT_PRINTER 0x02
- #define FORWARD 0x01
- #define BACKWARD 0x00
- #define HOT 64
- #define BCoefficent 3950
- #define RthNominal 30000
- #define TempNominal 25
- #define ADCResolution 1024
- #define SeriesResistor 30000
- #define NumSamples 1
- #define KELVIN 1
- #define CELSIUS 0
- #define ADC_FILE_PAT "/tmp/devterm_adc"
- #define HEAT_TIME 100 // heat time + (0-f)*46
- #define BAT_CAP "/sys/class/power_supply/axp20x-battery/capacity"
- #define BAT_THRESHOLD 14 // %14 battery = low power
- #define int16 uint16_t
- #define int8 uint8_t
- #define asciistart ((uint8_t)'A')
- #define netxcharacter ((uint8_t)24)
- #define Fontrows ((uint8_t)24)
- #define FontColums ((uint8_t)16)
- #define nextcharactercolum ((uint8_t)Fontrows / 8) // = 3
- #define ASCII_TAB '\t' // Horizontal tab
- #define ASCII_LF '\n' // Line feed,10
- #define ASCII_FF '\f' // Form feed
- #define ASCII_CR '\r' // Carriage return
- #define ASCII_EOT 4 // End of Transmission
- #define ASCII_DLE 16 // Data Link Escape
- #define ASCII_DC2 18 // Device control 2 //0x12
- #define ASCII_ESC 27 // Escape //0x1b
- #define ASCII_FS 28 // Field separator//0x1c
- #define ASCII_GS 29 // Group separator //0x1d
- #define PRINT_STATE 0
- #define ESC_STATE 1
- #define GET_IMAGE 2
- #define ALIGN_LEFT 0
- #define ALIGN_CENTER 1
- #define ALIGN_RIGHT 2
- #define IMAGE_MAX 9224
- #define BITS8 8
- #define MAX_DOTS 384
- #define PRINTER_BITS MAX_DOTS
- #define MAXPIXELS 48
- #ifdef MTP03
- #define MAX_DOTS 576
- #define PRINTER_BITS MAX_DOTS
- #define MAXPIXELS 72
- #endif
- #define FONT_MODE_0 0 // Internal
- #define FONT_MODE_1 1 // External
- // extract bits
- #define LAST(k, n) ((k) & ((1 << (n)) - 1))
- #define MID(k, m, n) LAST((k) >> (m), ((n) - (m)))
- typedef struct _Margin {
- uint16_t width;
- uint8_t esgs;
- } Margin;
- typedef struct _FONT {
- uint8_t width; // in bits
- uint8_t height;
- uint8_t mode; // 0 internal pcf font array,1 external ttf font file
- const uint8_t *data;
- char *file;
- } FONT;
- typedef struct _ImageCache {
- uint16_t idx;
- uint16_t num;
- uint16_t width;
- uint16_t height;
- uint8_t need_print : 1;
- uint8_t revert_bits : 1; // MSB OR LSB
- uint8_t cache[IMAGE_MAX]; // 48x192bytes(384x192 pixels) ,max
- } ImageCache;
- typedef struct _CONFIG {
- uint8_t state;
- uint8_t line_space;
- uint8_t align;
- uint8_t reverse; // reverse print
- uint8_t orient;
- uint8_t under_line;
- uint8_t feed_pitch;
- uint8_t density : 4; // 0-f,300+density*46 HEAT_TIME
- uint16_t wordgap : 10; // 1023 max
- uint8_t max_pts; // max pts in print_dots_8bit_split
- uint8_t lock;
- int16_t degree; // char rotate 0,90,180,270, -90,-180,-270
- Margin margin;
- FONT *font;
- ImageCache *img;
- FILE *fp;
- FT_Face face;
- FT_Library ft;
- int (*printf)(struct _CONFIG *, char *, ...);
- } CONFIG;
- typedef struct _SerialCache {
- uint8_t idx;
- uint8_t utf8idx; // 0-4
- // uint8_t data[77];//384/5, minium size font 5 pixel
- uint32_t data[MAX_DOTS]; // uint32_t for utf8 characters
- } SerialCache;
- typedef struct _TimeRec {
- unsigned int time;
- uint8_t last_status;
- uint8_t check;
- } TimeRec;
- void PrintDots8bit(uint8_t *Array, uint8_t characters, uint8_t feed_num);
- uint8_t invert_bit(uint8_t a);
- #endif
|