将const char*=01000031525000315250分割成两个可以符合unsigned long long 类型的字符串

时间: 2024-11-16 12:19:51 浏览: 43
将十六进制数`01000031525000315250`分割成两个`unsigned long long`类型的字符串,意味着我们需要将其转换为两个64位的无符号整数。十六进制每个字符代表四位二进制数,所以我们需要每8位作为一个单独的`unsigned long long`存储。 原始十六进制字符串对应的二进制是: ``` 01 00 00 31 52 50 00 31 52 50 00 31 52 50 ``` 我们可以按每8位分组: ``` 01000031 // 第一个 unsigned long long 52500031 // 第二个 unsigned long long 52500031 // 又是一个 unsigned long long ``` 转换后的两个字符串形式(十六进制表示)应该是这样的: 第一个 `unsigned long long`: `"01000031"` 第二个 `unsigned long long`: `"52500031"` 注意,由于二进制数据的前导零会被忽略,所以实际的二进制形式可能会有所不同,但展示出来的字符串就是上面的样子。如果你需要直接的数值,那么在C++中你可以这样做: ```cpp #include <string> #include <boost/hex.hpp> std::string hexStrToULL(const std::string& str, size_t offset) { boost::hex<> converter; return converter.to_string(std::stoull(str.substr(offset, sizeof(unsigned long long)*2), nullptr, 16)); } std::pair<std::string, std::string> splitHexIntoULLs(const std::string& input) { std::string first = hexStrToULL(input, 0); std::string second = hexStrToULL(input, sizeof(unsigned long long)*2); return {first, second}; } int main() { std::string hexInput = "01000031525000315250"; auto ullPair = splitHexIntoULLs(hexInput); std::cout << "First ULL: " << ullPair.first << std::endl; std::cout << "Second ULL: " << ullPair.second << std::endl; return 0; } ```
阅读全文

相关推荐

C:\Users\conservator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Print.h:93:16: note: conversion of argument 1 would be ill-formed: C:\Users\conservator\Desktop\mqttToAliyun\mqttToAliyun.ino:128:18: error: invalid conversion from 'const char*' to 'long long int' [-fpermissive] 128 | Serial.print("%d",sensor[0]); | ^~~~ | | | const char* In file included from C:\Users\conservator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Stream.h:27, from C:\Users\conservator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/HardwareSerial.h:32, from C:\Users\conservator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Arduino.h:303, from C:\Users\conservator\AppData\Local\Temp\arduino\sketches\304EB848CF381B8A7A8E84D646752A81\sketch\mqttToAliyun.ino.cpp:1: C:\Users\conservator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Print.h:94:16: note: candidate: 'size_t Print::print(long long unsigned int, int)' (near match) 94 | size_t print(unsigned long long, int = DEC); | ^~~~~ C:\Users\conservator\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/Print.h:94:16: note: conversion of argument 1 would be ill-formed: C:\Users\conservator\Desktop\mqttToAliyun\mqttToAliyun.ino:128:18: error: invalid conversion from 'const char*' to 'long long unsigned int' [-fpermissive] 128 | Serial.print("%d",sensor[0]); | ^~~~ | | | const char* exit status 1 Compilation error: no matching function for call to 'print(const char [3], int&)'

#include <openssl/evp.h> #include <openssl/rand.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define SM4_KEY_SIZE 16 #define SM4_BLOCK_SIZE 16 void handle_errors() { ERR_print_errors_fp(stderr); abort(); } /* int sm4_encrypt_file(const char *input_file, const char *output_file, const unsigned char *key) { FILE *in_file = fopen(input_file, "rb"); FILE *out_file = fopen(output_file, "wb"); if (!in_file || !out_file) { perror("Failed to open file"); return 0; } EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); if (!ctx) handle_errors(); unsigned char iv[SM4_BLOCK_SIZE]; if (!RAND_bytes(iv, SM4_BLOCK_SIZE)) handle_errors(); fwrite(iv, 1, SM4_BLOCK_SIZE, out_file); if (1 != EVP_EncryptInit_ex(ctx, EVP_sm4_cbc(), NULL, key, iv)) handle_errors(); unsigned char in_buf[1024]; unsigned char out_buf[1024 + SM4_BLOCK_SIZE]; int out_len; int final_len; while (1) { size_t in_len = fread(in_buf, 1, sizeof(in_buf), in_file); if (in_len <= 0) break; if (1 != EVP_EncryptUpdate(ctx, out_buf, &out_len, in_buf, in_len)) handle_errors(); fwrite(out_buf, 1, out_len, out_file); } if (1 != EVP_EncryptFinal_ex(ctx, out_buf, &final_len)) handle_errors(); fwrite(out_buf, 1, final_len, out_file); EVP_CIPHER_CTX_free(ctx); fclose(in_file); fclose(out_file); return 1; } */ int sm4_decrypt_file(const char *input_file, const char *output_file, const unsigned char *key) { FILE *in_file = fopen(input_file, "rb"); FILE *out_file = fopen(output_file, "wb"); if (!in_file || !out_file) { perror("Failed to open file"); return 0; } EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); if (!ctx) handle_errors(); unsigned char iv[SM4_BLOCK_SIZE]; fread(iv, 1, SM4_BLOCK_SIZE, in_file); if (1 != EVP_DecryptInit_ex(ctx, EVP_sm4_cbc(), NULL, key, iv)) handle_errors(); unsigned char in_buf[1024 + S

#include <ESP8266WiFi.h>//默认,加载WIFI头文件 #include "PubSubClient.h"//默认,加载MQTT库文件 #include <ArduinoJson.h> //json库函数 #include <Arduino.h> //在这里修改MQTT客户端信息 #define MQTT_HOST "iot-06z00hnphin6w9x.mqtt.iothub.aliyuncs.com" //MQTT服务器地址 固定不变的 #define MQTT_PORT 1883 //MQTT连接参数————MQTT端口 固定不变的 #define MQTT_USER "MyDevice&k28ra5vyyne" //MQTT连接参数——用户名 #define MQTT_PASSWD "cf87e843fe4351934c47f4819258ec53a3f2fb86e76afd107ebc05e20eb6a8b3" //MQTT连接参数——密码 #define MQTT_CLIENTID "k28ra5vyyne.MyDevice|securemode=2,signmethod=hmacsha256,timestamp=1740401382183|" //MQTT连接参数——客户端 //在这里进行WIFI信息修改 const char* ssid = "1122"; //修改,修改为你的路由的WIFI名字 const char* password = "12345678"; //修改为你的WIFI密码 ////注意,除了上面修改MQTT连接参数及WIFI信息外,需要根据自己上传数据及发送的命令具体的标识符修改代码相应部分,每一部分已经给出了示例,请不要忽略每一个注释!!!! char* down_topic = "/k28ra5vyyne/MyDevice/user/device_sub"; //下发命令主题名字 char* up_topic = "/sys/k28ra5vyyne/MyDevice/thing/event/property/post"; //上传数据主题名 //上传的数据 int tem=0; //温度 int hum = 0; //湿度 float mq135 = 0; //光照 float heart = 0; //土壤湿度 float oxy=0; //二氧化碳 long timeval = 1.5 * 1000; //上传的数据时间间隔 String RX_DATA = ""; //串口接收数据 long lastMsg = 0;//时间戳 WiFiClient espClient; //初始化WIFI连接客户端 char* json = ""; //存储云平台下发命令 PubSubClient client(espClient);//mqtt初始化 //连接WIFI void setup_wifi() { delay(10); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); } } //MQTT订阅主题,下发消息接收函数 void callback(char* topic, byte* payload, unsigned int length) { if(strcmp(topic,down_topic)==0)//topic == down_topic 如果是下发命令的主题 { //接收并解析来自上位机的命令 payload[length] = '\0'; json = (char *)payload; //保存命令数据流 String str = String(json)+"\r\n"; Serial.print(str); // StaticJsonDocument<200> jsonBuffer; //声明一个JsonDocument对象,长度200 // DeserializationError error = deserializeJson(jsonBuffer, json); // json=""; } } void reconnect() { // Loop until we're reconnected whi

下面代码生成的encrypted.bin文件是哪个文件加密后的结果:#include <openssl/evp.h> #include <openssl/pem.h> #include <openssl/rand.h> #include <openssl/err.h> #include <openssl/applink.c> #include <stdio.h> #include <stdlib.h> #define AES_KEY_SIZE 32 #define RSA_KEY_SIZE 2048 #define GCM_IV_LEN 12 #define GCM_TAG_LEN 16 #define CHECK(cond, msg) do { \ if (!(cond)) { \ fprintf(stderr, "错误: %s (位置: %s:%d)\n", msg, __FILE__, __LINE__); \ ERR_print_errors_fp(stderr); \ exit(EXIT_FAILURE); \ } \ } while(0) EVP_PKEY* load_public_key(const char* pubkey_path) { BIO* bio = BIO_new_file(pubkey_path, "r"); CHECK(bio != NULL, "无法打开公钥文件"); EVP_PKEY* pubkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL); CHECK(pubkey != NULL, "解析公钥失败"); BIO_free(bio); return pubkey; } unsigned char* rsa_encrypt(EVP_PKEY* pubkey, const unsigned char* aes_key, size_t* encrypted_len) { EVP_PKEY_CTX* ctx = EVP_PKEY_CTX_new(pubkey, NULL); CHECK(ctx != NULL, "创建RSA上下文失败"); CHECK(EVP_PKEY_encrypt_init(ctx) > 0, "初始化RSA加密失败"); size_t outlen; CHECK(EVP_PKEY_encrypt(ctx, NULL, &outlen, aes_key, AES_KEY_SIZE) > 0, "计算缓冲区大小失败"); unsigned char* encrypted = malloc(outlen); CHECK(encrypted != NULL, "内存分配失败"); CHECK(EVP_PKEY_encrypt(ctx, encrypted, &outlen, aes_key, AES_KEY_SIZE) > 0, "RSA加密失败"); *encrypted_len = outlen; EVP_PKEY_CTX_free(ctx); return encrypted; } void aes_gcm_encrypt( const unsigned char* plaintext, size_t plaintext_len, const unsigned char* aes_key, unsigned char* iv, unsigned char* tag, unsigned char** ciphertext, size_t* ciphertext_len) { EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); CHECK(ctx != NULL, "创建AES上下文失败"); CHECK(RAND_bytes(iv, GCM_IV_LEN) > 0, "生成IV失败"); CHECK(EVP_EncryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, aes_key, iv) > 0, "初始化AES失败"); *ciphertext = malloc(plaintext_len + EVP_MAX_BLOCK_LENGTH); CHECK(*ciphertext != NULL, "内存分配失败"); int len; CHECK(EVP_EncryptUpdate(ctx, *ciphertext, &len, plaintext, plaintext_len) > 0, "加密失败"); *ciphertext_len = len; CHECK(EVP_EncryptFinal_ex(ctx, *ciphertext + len, &len) > 0, "最终加密失败"); *ciphertext_len += len; CHECK(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, GCM_TAG_LEN, tag) > 0, "获取标签失败"); EVP_CIPHER_CTX_free(ctx); } int main() { OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); unsigned char aes_key[AES_KEY_SIZE]; CHECK(RAND_bytes(aes_key, sizeof(aes_key)) > 0, "生成AES密钥失败"); EVP_PKEY* pubkey = load_public_key("public.pem"); size_t encrypted_aes_len; unsigned char* encrypted_aes = rsa_encrypt(pubkey, aes_key, &encrypted_aes_len); const char* plaintext = "这是敏感文件内容"; size_t plaintext_len = strlen(plaintext); unsigned char iv[GCM_IV_LEN]; unsigned char tag[GCM_TAG_LEN]; unsigned char* ciphertext; size_t ciphertext_len; aes_gcm_encrypt((unsigned char*)plaintext, plaintext_len, aes_key, iv, tag, &ciphertext, &ciphertext_len); FILE* out = fopen("encrypted.bin", "wb"); CHECK(out != NULL, "无法创建输出文件"); fwrite(&encrypted_aes_len, sizeof(size_t), 1, out); fwrite(encrypted_aes, 1, encrypted_aes_len, out); fwrite(iv, 1, GCM_IV_LEN, out); fwrite(tag, 1, GCM_TAG_LEN, out); fwrite(&ciphertext_len, sizeof(size_t), 1, out); fwrite(ciphertext, 1, ciphertext_len, out); fclose(out); free(encrypted_aes); free(ciphertext); EVP_PKEY_free(pubkey); printf("加密成功!输出文件: encrypted.bin\n"); return 0; }

/************************************************ // //TWKJ STM32开发板 // //作者: //版本:V1.0 //修改日期:2020/06/30 //程序功能:TFT彩屏显示方法 //V1.0 完成基本功能 ************************************************/ #include "my_lcd_spi_gui.h" #include "my_lcd_spi_font.h" /******************************************************************* * @name :void GUI_DrawPoint(u16 x,u16 y,u16 color) * @date :2018-08-09 * @function :draw a point in LCD screen * @parameters :x:the x coordinate of the point y:the y coordinate of the point color:the color value of the point * @retvalue :None ********************************************************************/ void GUI_DrawPoint(u16 x,u16 y,u16 color) { LCD_SetCursor(x,y);//设置光标位置 LCD_WriteData_16Bit(color); } /***************************************************************************** * @name :void TP_Draw_Big_Point(u16 x,u16 y,u16 color) * @date :2018-08-09 * @function :Draw a big point(2*2) * @parameters :x:Read x coordinate of the point y:Read y coordinate of the point color:the color value of the point * @retvalue :None ******************************************************************************/ void LCD_DrawPoint_big(u16 x,u16 y) { LCD_DrawPoint(x,y);//中心点 LCD_DrawPoint(x+1,y); LCD_DrawPoint(x,y+1); LCD_DrawPoint(x+1,y+1); } /******************************************************************* * @name :void LCD_Fill(u16 sx,u16 sy,u16 ex,u16 ey,u16 color) 填充一个矩形 * @function :fill the specified area * @parameters :sx:the bebinning x coordinate of the specified area sy:the bebinning y coordinate of the specified area ex:the ending x coordinate of the specified area ey:the ending y coordinate of the specified area color:the filled color value * @retvalue :None ********************************************************************/ void LCD_Fill(u16 sx,u16 sy,u16 ex,u16 ey,u16 color) { u16 i,j; u16 width=ex-sx+1;//得到填充的宽度 u16 height=ey-sy+1;//高度//**All notes can be deleted and modified**// for(i=0;i<height;i++) { for(j=0;j<width;j++) LCD_WriteData_16Bit(color);//写入数据 } LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复窗口设置为全屏 } /******************************************************************* * @name :void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2) 绘制一条线 * @function :Draw a line between two points * @parameters :x1:the bebinning x coordinate of the line y1:the bebinning y coordinate of the line x2:the ending x coordinate of the line y2:the ending y coordinate of the line * @retvalue :None ********************************************************************/ void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2) { u16 t; int xerr=0,yerr=0,delta_x,delta_y,distance; int incx,incy,uRow,uCol; delta_x=x2-x1; //计算坐标增量 delta_y=y2-y1; uRow=x1; uCol=y1; if(delta_x>0)incx=1; //设置单步方向 else if(delta_x==0)incx=0;//垂直线 else {incx=-1;delta_x=-delta_x;} if(delta_y>0)incy=1; else if(delta_y==0)incy=0;//水平线 else{incy=-1;delta_y=-delta_y;} if( delta_x>delta_y)distance=delta_x; //选取基本增量坐标轴 else distance=delta_y; for(t=0;t<=distance+1;t++ )//画线输出 { LCD_DrawPoint(uRow,uCol);//画点 //**All notes can be deleted and modified**// if(xerr>distance) { xerr-=distance; uRow+=incx; } if(yerr>distance) { yerr-=distance; uCol+=incy; } } } /***************************************************************************** * @name :void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2) 绘制一个矩形框 * @function :Draw a rectangle * @parameters :x1:the bebinning x coordinate of the rectangle y1:the bebinning y coordinate of the rectangle x2:the ending x coordinate of the rectangle y2:the ending y coordinate of the rectangle * @retvalue :None ******************************************************************************/ void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2) { LCD_DrawLine(x1,y1,x2,y1); LCD_DrawLine(x1,y1,x1,y2); LCD_DrawLine(x1,y2,x2,y2); LCD_DrawLine(x2,y1,x2,y2); } /***************************************************************************** * @name :void LCD_DrawFillRectangle(u16 x1, u16 y1, u16 x2, u16 y2) 填充一个矩形 * @function :Filled a rectangle * @parameters :x1:the bebinning x coordinate of the filled rectangle y1:the bebinning y coordinate of the filled rectangle x2:the ending x coordinate of the filled rectangle y2:the ending y coordinate of the filled rectangle * @retvalue :None ******************************************************************************/ void LCD_DrawRectangle_Fill(u16 x1, u16 y1, u16 x2, u16 y2) { LCD_Fill(x1,y1,x2,y2,FRONT_COLOR); } /***************************************************************************** * @name :void _draw_circle_8(int xc, int yc, int x, int y, u16 c) 圆绘制方法 * @function :8 symmetry circle drawing algorithm (internal call) * @parameters :xc:the x coordinate of the Circular center yc:the y coordinate of the Circular center x:the x coordinate relative to the Circular center y:the y coordinate relative to the Circular center c:the color value of the circle * @retvalue :None ******************************************************************************/ void _draw_circle_8(int xc, int yc, int x, int y, u16 c) { GUI_DrawPoint(xc + x, yc + y, c); GUI_DrawPoint(xc - x, yc + y, c); GUI_DrawPoint(xc + x, yc - y, c); GUI_DrawPoint(xc - x, yc - y, c); GUI_DrawPoint(xc + y, yc + x, c); GUI_DrawPoint(xc - y, yc + x, c); GUI_DrawPoint(xc + y, yc - x, c); GUI_DrawPoint(xc - y, yc - x, c); } /***************************************************************************** * @name :void gui_circle(int xc, int yc,u16 c,int r, int fill) 绘制一个圆 实心或空心 * @function :Draw a circle of specified size at a specified location * @parameters :xc:the x coordinate of the Circular center yc:the y coordinate of the Circular center r:Circular radius fill:1-filling,0-no filling * @retvalue :None ******************************************************************************/ void LCD_DrawCircle(int xc, int yc,int r, int fill) { int x = 0, y = r, yi, d; d = 3 - 2 * r; if (fill) { // 如果填充(画实心圆) while (x <= y) { for (yi = x; yi <= y; yi++) { _draw_circle_8(xc, yc, x, yi, FRONT_COLOR); } if (d < 0) { d = d + 4 * x + 6; } else { d = d + 4 * (x - y) + 10; y--; } x++; } } else { // 如果不填充(画空心圆) while (x <= y) { _draw_circle_8(xc, yc, x, y, FRONT_COLOR); if (d < 0) { d = d + 4 * x + 6; } else { d = d + 4 * (x - y) + 10; y--; } x++; } } } /***************************************************************************** * @name :void Draw_Triangel(u16 x0,u16 y0,u16 x1,u16 y1,u16 x2,u16 y2) 绘制一个三角形框 * @function :Draw a triangle at a specified position * @parameters :x0:the bebinning x coordinate of the triangular edge y0:the bebinning y coordinate of the triangular edge x1:the vertex x coordinate of the triangular y1:the vertex y coordinate of the triangular x2:the ending x coordinate of the triangular edge y2:the ending y coordinate of the triangular edge * @retvalue :None ******************************************************************************/ void LCD_DrawTriangel(u16 x0,u16 y0,u16 x1,u16 y1,u16 x2,u16 y2) { LCD_DrawLine(x0,y0,x1,y1); LCD_DrawLine(x1,y1,x2,y2); LCD_DrawLine(x2,y2,x0,y0); } static void _swap(u16 *a, u16 *b) { u16 tmp; tmp = *a; *a = *b; *b = tmp; } /***************************************************************************** * @name :void Fill_Triangel(u16 x0,u16 y0,u16 x1,u16 y1,u16 x2,u16 y2) 绘制一个三角形框填充 * @function :filling a triangle at a specified position * @parameters :x0:the bebinning x coordinate of the triangular edge y0:the bebinning y coordinate of the triangular edge x1:the vertex x coordinate of the triangular y1:the vertex y coordinate of the triangular x2:the ending x coordinate of the triangular edge y2:the ending y coordinate of the triangular edge * @retvalue :None ******************************************************************************/ void LCD_DrawTriangel_Fill(u16 x0,u16 y0,u16 x1,u16 y1,u16 x2,u16 y2) { u16 a, b, y, last; int dx01, dy01, dx02, dy02, dx12, dy12; long sa = 0; long sb = 0; if (y0 > y1) { _swap(&y0,&y1); _swap(&x0,&x1); } if (y1 > y2) { _swap(&y2,&y1); _swap(&x2,&x1); } if (y0 > y1) { _swap(&y0,&y1); _swap(&x0,&x1); } if(y0 == y2) { a = b = x0; if(x1 < a) { a = x1; } else if(x1 > b) { b = x1; } if(x2 < a) { a = x2; } else if(x2 > b) { b = x2; } LCD_Fill(a,y0,b,y0,FRONT_COLOR); return; } dx01 = x1 - x0; dy01 = y1 - y0; dx02 = x2 - x0; dy02 = y2 - y0; dx12 = x2 - x1; dy12 = y2 - y1; if(y1 == y2) { last = y1; } else { last = y1-1; } for(y=y0; y<=last; y++) { a = x0 + sa / dy01; b = x0 + sb / dy02; sa += dx01; sb += dx02; if(a > b) { _swap(&a,&b); } LCD_Fill(a,y,b,y,FRONT_COLOR); } sa = dx12 * (y - y1); sb = dx02 * (y - y0); for(; y<=y2; y++) { a = x1 + sa / dy12; b = x0 + sb / dy02; sa += dx12; sb += dx02; if(a > b) { _swap(&a,&b); } LCD_Fill(a,y,b,y,FRONT_COLOR); } } /***************************************************************************** * @name :void Gui_Drawbmp16(u16 x,u16 y,const unsigned char *p) * @date :2018-08-09 * @function :Display a 16-bit BMP image * @parameters :x:the bebinning x coordinate of the BMP image y:the bebinning y coordinate of the BMP image p:the start address of image array * @retvalue :None ******************************************************************************/ void GUI_Drawbmp16(u16 x,u16 y,const u8 *p) //显示40*40 QQ图片 { int i; unsigned char picH,picL; LCD_SetWindows(x,y,x+40-1,y+40-1);//窗口设置 for(i=0;i<40*40;i++) { picL=*(p+i*2);//数据低位在前 picH=*(p+i*2+1); LCD_WriteData_16Bit(picH<<8|picL); } LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复显示窗口为全屏 } /***************************************************************************** * @name :void LCD_ShowString(u16 x,u16 y,u8 size,u8 *p,u8 mode) 显示遗传英文字符 只限英文 * @function :Display English string * @parameters :x:the bebinning x coordinate of the English string y:the bebinning y coordinate of the English string p:the start address of the English string size:the size of display character mode:0-no overlying,1-overlying * @retvalue :None ******************************************************************************/ void LCD_JustString(u16 x,u16 y,char *p,u8 size) { while((*p<='~')&&(*p>=' '))//判断是不是非法字符! { if(x>(lcddev.width-1)||y>(lcddev.height-1)) return; LCD_ShowChar(x,y,*p,size,false); x+=size/2; p++; } } /***************************************************************************** * @name :u32 mypow(u8 m,u8 n) * @date :2018-08-09 * @function :get the nth power of m (internal call) * @parameters :m:the multiplier n:the power * @retvalue :the nth power of m ******************************************************************************/ u32 mypow(u8 m,u8 n) { u32 result=1; while(n--)result*=m; return result; } /***************************************************************************** * @name :void LCD_ShowNum(u16 x,u16 y,u32 num,u8 len,u8 size) * @date :2018-08-09 * @function :Display number * @parameters :x:the bebinning x coordinate of the number y:the bebinning y coordinate of the number num:the number(0~4294967295) len:the length of the display number size:the size of display number * @retvalue :None ******************************************************************************/ void LCD_ShowNum(u16 x,u16 y,u32 num,u8 len,u8 size) { u8 t,temp; u8 enshow=0; for(t=0;t<len;t++) { temp=(num/mypow(10,len-t-1))%10; if(enshow==0&&t<(len-1)) { if(temp==0) { LCD_ShowChar(x+(size/2)*t,y,' ',size,false); continue; }else enshow=1; } LCD_ShowChar(x+(size/2)*t,y,temp+'0',size,false); } } //计算汉字字模的大小(字节数) u8 My_Font_GetCodeSize_CH(u8 charSize) { return charSize*(charSize/8 + (charSize%8?1:0)); } //计算ASCII字模的大小(字节数) u8 My_Font_GetCodeSize_ASCII(u8 charSize) { //**All notes can be deleted and modified**// return charSize*(charSize/8 + (charSize%8?1:0))*2; } void LCD_ScanLine_Byte(u16 x, u16 y, u8 *charPtr,u8 pointCount,bool overlap) { u8 i; if(pointCount>8) { pointCount = 8; } for(i=0;i>i)))//顺向扫描 { if(overlap) { LCD_DrawPoint(x,y);//画一个点 } else { LCD_WriteData_16Bit(FRONT_COLOR); } } else { if(!overlap) { LCD_WriteData_16Bit(BACK_COLOR); } } x++; } } //显示字符或图片取模后的数据,如自定义特殊字符 void LCD_DrawMatrixCode(u16 x, u16 y, u8 width,u8 high,u8 *charPtr,bool overlap) { u8 i,scanPointCount; u16 x0 = x; LCD_SetWindows(x,y,x+width-1,y+high-1); for(i=0;i<high;i++)//逐行扫描 { scanPointCount = width;//计算出每一行的点数 while(scanPointCount>0)//如果这一行的点数大于7 { if(scanPointCount>7) { LCD_ScanLine_Byte(x,y,charPtr,8,overlap); scanPointCount -= 8; charPtr++; x += 8; } else { LCD_ScanLine_Byte(x,y,charPtr,scanPointCount,overlap); charPtr++; break; } } x = x0; y++; } } /***************************************************************************** * @name :void LCD_ShowChinese(u16 x, u16 y, u8 *s, u8 charSize,u8 mode) * @date :2018-08-09 * @function :Display a single Chinese character * @parameters :x:the bebinning x coordinate of the Chinese character y:the bebinning y coordinate of the Chinese character s:the start address of the Chinese character charSize:size of the Chinese character mode:0-no overlying,1-overlying * @retvalue :None ******************************************************************************/ void LCD_ShowChinese(u16 x, u16 y, u8 *s, u8 charSize,bool overlap) { u8 fontCodeSize,fontCharCount,*fontCodePtr; u16 k;//**All notes can be deleted and modified**// fontCodeSize = My_Font_GetCodeSize_CH(charSize)+2; switch(charSize) { case 12:fontCharCount = ArrayCount(fontGBK12);fontCodePtr = (u8 *)fontGBK12;break; case 16:fontCharCount = ArrayCount(tfont16);fontCodePtr = (u8 *)tfont16;break; case 24:fontCharCount = ArrayCount(tfont24);fontCodePtr = (u8 *)tfont24;break; case 32:fontCharCount = ArrayCount(tfont32);fontCodePtr = (u8 *)tfont32;break; default:break; } for (k=0;k<fontCharCount;k++)//遍历每个字模 { if ((*(fontCodePtr)==*(s))&&(*(fontCodePtr+1)==*(s+1)))//对比字符编码 { fontCodePtr+=2; LCD_DrawMatrixCode(x,y,charSize,charSize,fontCodePtr,overlap); break; //查找到对应点阵字库立即退出,防止多个汉字重复取模带来影响 } fontCodePtr += fontCodeSize;//指向下一个字模的地址 } LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复窗口为全屏 } /***************************************************************************** * @name :void LCD_ShowChar(u16 x,u16 y,u16 fc, u16 bc, u8 num,u8 size,u8 mode) * @date :2018-08-09 * @function :Display a single English character * @parameters :x:the bebinning x coordinate of the Character display position y:the bebinning y coordinate of the Character display position num:the ascii code of display character(0~94) size:the size of display character mode:0-no overlying,1-overlying * @retvalue :None ******************************************************************************/ void LCD_ShowChar(u16 x,u16 y, u8 charCode,u8 charSize,bool overlap) { u8 *matrixPtr; if(x>(lcddev.width-charSize/2)||y>(lcddev.height-charSize)) return; charCode=charCode-' ';//得到偏移后的值 LCD_SetWindows(x,y,x+charSize/2-1,y+charSize-1);//设置单个文字显示窗口 switch(charSize) { case 12:matrixPtr=(u8 *)asc2_1206;break; case 16:matrixPtr=(u8 *)asc2_1608;break; #ifdef ACS_2412 case 24:matrixPtr=(u8 *)asc2_2412;break; #endif #ifdef ACS_3216 case 32:matrixPtr=(u8 *)asc2_3216;break; #endif default:break; } //**All notes can be deleted and modified**// LCD_DrawMatrixCode(x,y,charSize/2,charSize,matrixPtr,overlap); LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复窗口为全屏 } /***************************************************************************** * @name :void Show_Str(u16 x, u16 y, u16 fc, u16 bc, u8 *str,u8 size,u8 mode) 显示一个字符串 可以为中文 显示的中文取模必须在放到lcd_font.h中 * @function :Display Chinese and English strings * @parameters :x:the bebinning x coordinate of the Chinese and English strings y:the bebinning y coordinate of the Chinese and English strings str:the start address of the Chinese and English strings size:the size of Chinese and English strings mode:0-no overlying,1-overlying * @retvalue :None ******************************************************************************/ void LCD_ShowString(u16 x, u16 y, char *str,u8 charSize,bool overlap) { u16 x0=x; if(charSize>32)// { charSize = 32; } while(*str!=0)//数据未结束 { if((u8)(*str)<0x80) { if(*str=='\r')//回车符号 { y+=charSize; x=x0; if(*(str+1)=='\n')//换行符号 { str++; } } else { LCD_ShowChar(x,y,*str,charSize,overlap); x+=charSize/2; //字符,为全字的一半 } str++; } else//中文 { LCD_ShowChinese(x,y,(u8 *)str,charSize,overlap); str+=2; x+=charSize;//下一个汉字偏移 } } } /***************************************************************************** * @name :void Gui_StrCenter(u16 x, u16 y, u16 fc, u16 bc, u8 *str,u8 size,u8 mode) * @date :2018-08-09 * @function :Centered display of English and Chinese strings * @parameters :x:the bebinning x coordinate of the Chinese and English strings y:the bebinning y coordinate of the Chinese and English strings str:the start address of the Chinese and English strings size:the size of Chinese and English strings mode:0-no overlying,1-overlying * @retvalue :None ******************************************************************************/ void LCD_StrCenter(u16 x, u16 y, char *str,u8 charSize,bool overlap) { u16 len=strlen((const char *)str); u16 x1=(lcddev.width-len*8)/2; LCD_ShowString(x1,y,str,charSize,overlap); } u16 LCD_GetPos_X(u8 charSize,u8 index)// { if(index<=lcddev.width/(charSize>>1)) { return index*(charSize>>1); } return 0; } u16 LCD_GetPos_Y(u8 charSize,u8 index)// { if(index<=lcddev.height/(charSize)) { return index*(charSize); } return 0; }

最新推荐

recommend-type

C语言中压缩字符串的简单算法小结

例如,给定函数`HashString(const char *pString, unsigned long tableSize)`,它将字符串的每个字符累加,然后取模以适应tableSize大小的哈希表。这种方法简单但可能会导致较大的字符串无法充分利用散列表,造成...
recommend-type

数据挖掘概述.ppt

数据挖掘概述.ppt
recommend-type

500强企业管理表格模板大全

在当今商业环境中,管理表格作为企业运营和管理的重要工具,是确保组织高效运作的关键。世界500强企业在管理层面的成功,很大程度上得益于它们的规范化和精细化管理。本文件介绍的“世界500强企业管理表格经典”,是一份集合了多种管理表格模板的资源,能够帮助管理者们更有效地进行企业规划、执行和监控。 首先,“管理表格”这个概念在企业中通常指的是用于记录、分析、决策和沟通的各种文档和图表。这些表格不仅仅局限于纸质形式,更多地是以电子形式存在,如Excel、Word、PDF等文件格式。它们帮助企业管理者收集和整理数据,以及可视化信息,从而做出更加精准的决策。管理表格可以应用于多个领域,例如人力资源管理、财务预算、项目管理、销售统计等。 标题中提及的“世界500强”,即指那些在全球范围内运营且在《财富》杂志每年公布的全球500强企业排行榜上出现的大型公司。这些企业通常具备较为成熟和先进的管理理念,其管理表格往往经过长时间的实践检验,并且能够有效地提高工作效率和决策质量。 描述中提到的“规范化”是企业管理中的一个核心概念。规范化指的是制定明确的标准和流程,以确保各项管理活动的一致性和可预测性。管理表格的使用能够帮助实现管理规范化,使得管理工作有据可依、有章可循,减少因个人经验和随意性带来的风险和不确定性。规范化管理不仅提高了企业的透明度,还有利于培养员工的规则意识,加强团队之间的协调与合作。 “经典”一词在这里强调的是,这些管理表格模板是经过实践验证,能够适用于大多数管理场景的基本模式。由于它们的普适性和高效性,这些表格模板被广泛应用于不同行业和不同规模的企业之中。一个典型的例子是SWOT分析表,它可以帮助企业识别内部的优势(Strengths)、弱点(Weaknesses)以及外部的机会(Opportunities)和威胁(Threats)。SWOT分析表就是一个在世界500强企业中普遍使用的管理表格。 标签中的“表格模板”则是对上述管理工具的具体描述。这些模板通常是预先设计好的,能够帮助企业管理者快速开始工作,无需从零开始制作新的表格。它们包含了一些必备的字段和格式,用户可以根据自己的具体需求对模板进行调整和填充。 文件名称列表中的“index.html”可能是压缩包内的一个网页文件,用于展示管理表格的索引或介绍。如果这是一个在线资源,它将允许用户通过网页界面访问和下载各种表格模板。而“menu”可能是一个导航文件,用来帮助用户在多个表格模板之间进行选择。“data”文件夹可能包含了实际的表格模板文件,它们可能以Excel、Word等格式存在。 总的来说,管理表格是企业成功管理不可或缺的工具。通过使用世界500强企业所采纳的管理表格模板,其他企业可以借鉴这些顶级企业的管理经验,帮助自己在管理实践中达到更高的效率和质量。通过规范化和模板化的管理表格,企业可以确保其管理活动的一致性和标准化,这对于保持竞争力和实现长期发展至关重要。
recommend-type

YOLOv8目标检测算法深度剖析:从零开始构建高效检测系统(10大秘诀)

# 1. YOLOv8目标检测算法概述 ## 1.1 YOLOv8的简介与定位 YOLOv8(You Only Look Once version 8)作为一种前沿的目标检测算法,是由YOLO系列算法演化而来。该算法特别强调快速与准确的平衡,它被设计用于实时图像识别
recommend-type

mclmcrrt9_8.dll下载

<think>我们正在处理用户关于"mclmcrrt9_8.dll"文件的下载请求。根据引用内容,这个文件是MATLAB运行时库的一部分,通常与特定版本的MATLABRuntime相关联。用户需求:下载mclmcrrt9_8.dll的官方版本。分析:1.根据引用[2]和[3],mclmcrrt9_0_1.dll和mclmcrrt9_13.dll都是MATLABRuntime的文件,版本号对应MATLAB的版本(如9_0对应R2016a,9_13对应2022b)。2.因此,mclmcrrt9_8.dll应该对应于某个特定版本的MATLAB(可能是R2016b?因为9.8版本通常对应MATLABR
recommend-type

林锐博士C++编程指南与心得:初学者快速提能

首先,这份文件的核心在于学习和提高C++编程能力,特别是针对初学者。在这个过程中,需要掌握的不仅仅是编程语法和基本结构,更多的是理解和运用这些知识来解决实际问题。下面将详细解释一些重要的知识点。 ### 1. 学习C++基础知识 - **基本数据类型**: 在C++中,需要熟悉整型、浮点型、字符型等数据类型,以及它们的使用和相互转换。 - **变量与常量**: 学习如何声明变量和常量,并理解它们在程序中的作用。 - **控制结构**: 包括条件语句(if-else)、循环语句(for、while、do-while),它们是构成程序逻辑的关键。 - **函数**: 理解函数定义、声明、调用和参数传递机制,是组织代码的重要手段。 - **数组和指针**: 学习如何使用数组存储数据,以及指针的声明、初始化和运算,这是C++中的高级话题。 ### 2. 林锐博士的《高质量的C++编程指南》 林锐博士的著作《高质量的C++编程指南》是C++学习者的重要参考资料。这本书主要覆盖了以下内容: - **编码规范**: 包括命名规则、注释习惯、文件结构等,这些都是编写可读性和可维护性代码的基础。 - **设计模式**: 在C++中合理使用设计模式可以提高代码的复用性和可维护性。 - **性能优化**: 学习如何编写效率更高、资源占用更少的代码。 - **错误处理**: 包括异常处理和错误检测机制,这对于提高程序的鲁棒性至关重要。 - **资源管理**: 学习如何在C++中管理资源,避免内存泄漏等常见错误。 ### 3. 答题与测试 - **C++C试题**: 通过阅读并回答相关试题,可以帮助读者巩固所学知识,并且学会如何将理论应用到实际问题中。 - **答案与评分标准**: 提供答案和评分标准,使读者能够自我评估学习成果,了解哪些方面需要进一步加强。 ### 4. 心得体会与实践 - **实践**: 理论知识需要通过大量编程实践来加深理解,动手编写代码,解决问题,是学习编程的重要方式。 - **阅读源码**: 阅读其他人的高质量代码,可以学习到许多编程技巧和最佳实践。 - **学习社区**: 参与C++相关社区,比如Stack Overflow、C++论坛等,可以帮助解答疑惑,交流心得。 ### 5. 拓展知识 - **C++标准库**: 学习C++标准模板库(STL),包括vector、map、list、algorithm等常用组件,是构建复杂数据结构和算法的基础。 - **面向对象编程**: C++是一种面向对象的编程语言,理解类、对象、继承、多态等概念对于写出优雅的C++代码至关重要。 - **跨平台编程**: 了解不同操作系统(如Windows、Linux)上的C++编程差异,学习如何编写跨平台的应用程序。 - **现代C++特性**: 学习C++11、C++14、C++17甚至C++20中的新特性,如智能指针、lambda表达式、自动类型推导等,可以提高开发效率和代码质量。 ### 总结 学习C++是一个系统工程,需要从基础语法开始,逐步深入到设计思想、性能优化、跨平台编程等领域。通过不断的学习和实践,初学者可以逐步成长为一个具有高代码质量意识的C++程序员。而通过阅读经典指南书籍,参与测试与评估,以及反思和总结实践经验,读者将更加扎实地掌握C++编程技术。此外,还需注意编程社区的交流和现代C++的发展趋势,这些都对于保持编程技能的前沿性和实用性是必不可少的。
recommend-type

线性代数方程组求解全攻略:直接法vs迭代法,一文搞懂

# 摘要 线性代数方程组求解是数学和工程领域中的基础而重要的问题。本文首先介绍了线性方程组求解的基础知识,然后详细阐述了直接法和迭代法两种主要的求解策略。直接法包括高斯消元法和LU分解方法,本文探讨了其理论基础、实践应用以及算法优化。迭代法则聚焦于雅可比和高斯-赛德尔方法,分析了其原理、实践应用和收敛性。通过比较分析,本文讨论了两种方法在
recommend-type

怎么下载mysql8.0.33版本

<think>我们正在处理用户关于下载并安装MySQL8.0.33版本的问题。根据引用[1]和引用[2],我们可以提供两种方法:一种是使用RPM包在CentOS上安装,另一种是使用ZIP包在Windows上安装。另外,引用[3]提到了安装过程中需要注意Python环境,但根据MySQL官方文档,Python并不是必须的,除非使用某些特定功能(如MySQLShell的Python模式)。因此,我们主要关注下载和安装步骤。用户没有明确操作系统,因此我们将分别介绍Windows和CentOS(Linux)下的安装方法。步骤概述:1.下载MySQL8.0.332.安装(根据系统不同步骤不同)3.初始化
recommend-type

C#学籍管理系统开发完成,信管专业的福音

标题中提到的“C#设计的学籍系统”涉及到几个重要的知识点。首先是“C#”,这是微软公司开发的一种面向对象的、运行在.NET框架上的高级编程语言。C#语言广泛用于开发Windows应用程序、游戏开发、分布式组件和客户端服务器应用程序等。在该标题中,它被用于构建一个学籍系统,这意味着系统的核心逻辑和功能是通过C#语言实现的。 其次是“学籍系统”,这通常是指用于管理学生个人信息、成绩、课程和学籍状态等数据的软件应用系统。学籍系统能够帮助教育机构高效地维护和更新学生档案,实现学生信息的电子化管理。它通常包括学生信息管理、成绩管理、课程安排、毕业资格审核等功能。 从描述中我们可以得知,这个学籍系统是“专门为信管打造”的。这里的“信管”很可能是对“信息管理”或者“信息系统管理”专业的简称。信息管理是一个跨学科领域,涉及信息技术在收集、存储、保护、处理、传输和安全地管理和开发信息资源方面的应用。这个系统可能是针对该专业学生的实际需求来定制开发的,包括一些特有的功能或者界面设计,以便更好地满足专业学习和实践操作的需要。 描述中还提到“请大家积极下载”,这可能意味着该学籍系统是一个开源项目,或者至少是一个允许公众访问的软件资源。由于开发者提出了“如有不足之处请大家多多包涵”,我们可以推断这个系统可能还处于测试或早期使用阶段,因此可能还不是完全成熟的版本,或者可能需要使用者反馈意见以便进行后续改进。 标签中的“C#的啊,大家注意,嘻嘻哈哈”表达了开发者轻松的态度和对C#语言的特定提及。这个标签可能是在一个非正式的交流环境中发布的,所以用词带有一定的随意性。尽管如此,它还是说明了该学籍系统是基于C#语言开发的,并提醒用户对这一点给予关注。 关于压缩包子文件的文件名称列表中,“学生成绩管理系统”直接指出了这个软件系统的主要功能之一,即管理学生的成绩。这通常包括录入成绩、查询成绩、统计分析成绩、成绩报告等功能。一个优秀的学生成绩管理系统可以让教师和学校管理人员更加高效地处理学生的成绩数据,同时也能让学生本人了解自己的学业进展。 综合以上信息,我们可以提炼出以下知识点: 1. C#语言:是一种面向对象的编程语言,适用于.NET框架,用于开发各种类型的应用程序。 2. 学籍系统:是管理学生基本信息、成绩、课程和学籍状态的软件应用系统,目的是实现学生信息的电子化管理。 3. 信息系统管理专业:该系统可能是针对信息系统管理专业的学生或教师的需求设计和开发的。 4. 开源项目或公众访问资源:鼓励用户下载使用,并接受用户的反馈和建议。 5. 学生成绩管理系统:是学籍系统的一个重要组成部分,专注于管理学生的成绩数据。 在开发一个C#设计的学籍系统时,开发者需要考虑的因素很多,比如系统的用户界面设计、数据库设计、数据安全、网络通信等。此外,系统还应该有良好的扩展性和易用性,以便未来可以根据用户反馈和新需求进行升级和优化。
recommend-type

特征值与特征向量速成课:理论精讲与7种高效算法

# 摘要 本文系统地介绍了特征值与特征向量的基本概念、理论深度剖析、高效特征值算法以及这些数学工具在实际问题中的应用。首先从定义与性质出发,详细解释了特征值与特征向量的