indent code with clang-format, add rotation

This commit is contained in:
cuu
2022-03-10 04:02:24 -06:00
parent 3237703ec3
commit 31670a4428
8 changed files with 1250 additions and 1271 deletions

View File

@@ -1,10 +1,10 @@
#ifndef CONFIG_H
#define CONFIG_H
#include <freetype2/ft2build.h>
#include <freetype/freetype.h>
#include <freetype2/ft2build.h>
///raspberry pi CM3
/// raspberry pi CM3
#define BCM_GPIO_28 28
#define BCM_GPIO_29 29
@@ -25,27 +25,28 @@
#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
// 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 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 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 PEM_CTL_PIN BCM_GPIO_32 //3 VPS
#define ENABLE_PEM digitalWrite(PEM_CTL_PIN,HIGH)
#define DISABLE_PEM digitalWrite(PEM_CTL_PIN,LOW)
#define DISABLE_PEM digitalWrite(PEM_CTL_PIN,LOW)
*/
//DevTerm no VPS IO
//#define PEM_CTL_PIN
#define ENABLE_PEM
#define DISABLE_PEM
// 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
// 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`
@@ -53,74 +54,68 @@
#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
*@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 //
/// 0 1 3 2 mine
#define PA_PIN PH1_PIN //
#define PNA_PIN PH2_PIN //
#define PB_PIN PH3_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 THERMISTORPIN BCM_GPIO_35 // ADC,14
#define MOTOR_ENABLE1
#define MOTOR_ENABLE2
#define MOTOR_ENABLE2
#define MOTOR_DISABLE1
#define MOTOR_DISABLE2
#define MOTOR_DISABLE1
#define MOTOR_DISABLE2
#define ENABLE_VH digitalWrite(VH_PIN, HIGH)
#define DISABLE_VH digitalWrite(VH_PIN, LOW)
#define LATCH_ENABLE digitalWrite(LATCH_PIN, LOW)
#define LATCH_DISABLE digitalWrite(LATCH_PIN, HIGH)
#define ASK4PAPER digitalRead(PEM_PIN)
#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 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 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 BCoefficent 3950
#define RthNominal 30000
#define TempNominal 25
#define ADCResolution 1024
#define SeriesResistor 30000
#define NumSamples 1
#define KELVIN 1
#define CELSIUS 0
#define KELVIN 1
#define CELSIUS 0
#define ADC_FILE_PAT "/tmp/devterm_adc"
@@ -129,28 +124,26 @@
#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 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 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
@@ -164,7 +157,6 @@
#define BITS8 8
#define MAX_DOTS 384
#define PRINTER_BITS MAX_DOTS
#define MAXPIXELS 48
@@ -178,81 +170,78 @@
#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)))
// extract bits
#define LAST(k, n) ((k) & ((1 << (n)) - 1))
#define MID(k, m, n) LAST((k) >> (m), ((n) - (m)))
typedef struct _Margin{
typedef struct _Margin {
uint16_t width;
uint8_t esgs;
}Margin;
} Margin;
typedef struct _FONT {
uint8_t width;//in bits
uint8_t width; // in bits
uint8_t height;
uint8_t mode;//0 internal pcf font array,1 external ttf font file
uint8_t mode; // 0 internal pcf font array,1 external ttf font file
const uint8_t *data;
char*file;
}FONT;
char *file;
} FONT;
typedef struct _ImageCache {
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 need_print : 1;
uint8_t revert_bits : 1; // MSB OR LSB
uint8_t cache[IMAGE_MAX]; // 48x192bytes(384x192 pixels) ,max
}ImageCache;
typedef struct _CONFIG
{
} ImageCache;
typedef struct _CONFIG {
uint8_t state;
uint8_t line_space;
uint8_t align;
uint8_t reverse; //reverse print
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
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
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;
FONT *font;
ImageCache *img;
FILE*fp;
FILE *fp;
FT_Face face;
FT_Library ft;
int (*printf)(struct _CONFIG*, char*, ...);
int (*printf)(struct _CONFIG *, char *, ...);
}CONFIG;
} CONFIG;
typedef struct _SerialCache{
typedef struct _SerialCache {
uint8_t idx;
uint8_t utf8idx;//0-4
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;
uint32_t data[MAX_DOTS]; // uint32_t for utf8 characters
} SerialCache;
typedef struct _TimeRec{
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);
} TimeRec;
void PrintDots8bit(uint8_t *Array, uint8_t characters, uint8_t feed_num);
uint8_t invert_bit(uint8_t a);