### picq Command Example in TJC1688 A practical example demonstrating how to use the 'picq' command to cut a portion of an image and display it on the screen. This example illustrates the placement and dimensions for cutting and displaying. It highlights the requirement for the source image to be full-screen for correct results. ```TJC1688 Script //将图片0起始坐标(0,0)宽度30高度20这个区域切到屏幕上显示,屏幕上的显示起始坐标为(20,50) picq 20,50,30,20,0 ``` -------------------------------- ### C Language Example: Simulate Button Press and Release This C code example demonstrates how to trigger a button press and release sequence on a microcontroller via serial communication. It simulates a 100ms delay between the press and release to visualize the action. ```c // Activate the press event of the control named b0, click command does not support cross-page printf("click b0,1\xff\xff\xff"); // Microcontroller delays 100ms, if not delayed, the command speed is too fast to see the press and release effect delay_ms(100); // Activate the release event of the control named b0, click command does not support cross-page printf("click b0,0\xff\xff\xff"); ``` -------------------------------- ### Example: Create File on SD Card This example shows how to create a file named '1.txt' with a size of 4096 bytes in the root directory of the SD card (sd0). ```Assembly-like //在SD卡根目录中创建一个名为"1.txt"的文件,大小为4096字节 newfile "sd0/1.txt",4096 ``` -------------------------------- ### click Command Syntax and Examples This snippet details the syntax for the 'click' command, which takes a control ID or name and an event type (0 for release, 1 for press). Examples demonstrate activating the press event for 'b0' and the release event for 'n0'. ```text click obj,event obj: Control ID or control name event: Event sequence: 0 for release, 1 for press ``` ```javascript // Activate the press event of the control named b0 click b0,1 ``` ```javascript // Activate the release event of control n0 click n0,0 ``` -------------------------------- ### Example: Display Image with ID 1 This example shows how to display an image with ID 1 from the resource files at the coordinates (40, 50) using the 'pic' instruction. ```plaintext //在坐标(40,50)位置显示资源文件中图片ID为1的图片 pic 40,50,1 ``` -------------------------------- ### Example: Create File using a Variable This example creates a file on the SD card using a variable 't0.txt' to hold the filename. It's important that the 't0.txt' variable has sufficient buffer size, or the file operation may fail. ```Assembly-like //在SD卡根目录中创建一个名为"1.jpg"的文件,大小为4096字节 t0.txt="sd0/1.txt" newfile t0.txt,4096 ``` -------------------------------- ### Example: Create File in Memory File System This example demonstrates creating a file named '0.txt' with a size of 4096 bytes within the memory file system. Ensure the memory file system is configured in project settings, as it defaults to 0 size. ```Assembly-like //在内存文件系统中创建一个名为"0.txt"的文件,大小为4096字节 newfile "ram/0.txt",4096 ``` -------------------------------- ### xpic Command Usage Example A direct example of the 'xpic' command demonstrating how to crop a specific region of an image (ID 0) starting from coordinates (40,15) with dimensions 30x20, and display it on the screen starting at coordinates (20,50). ```plaintext xpic 20,50,30,20,40,15,0 ``` -------------------------------- ### get - Retrieve String Constant Example retrieving a constant string value using the get instruction. String constants are enclosed in quotes and return formatted data with string type marker. ```Custom //带格式返回常量字符串"123" get "123" ``` -------------------------------- ### crcputu Example 1: CRC Check 22 Bytes from Start This example demonstrates how to use the crcputu command to perform a CRC check on 22 bytes of serial buffer data, starting from the first byte (index 0). This operation is valid only when 'recmod' is set to 1. ```c // Starting from u[0], check 22 bytes of the serial buffer, valid when recmod=1 crcputu 0,22 ``` -------------------------------- ### 通过C语言修改二维码控件文本内容 (TJC1688 串口通信) 通过单片机向串口屏发送C语言指令,为二维码控件 'qr0' 赋值字符串内容。此方法适用于通过串口通信动态更新二维码,并检查扫描结果是否正确,注意 'txt_maxl' 属性限制。 ```C //给qr0赋值字符串 printf("qr0.txt=\"http://wiki.tjc1688.com\"\xff\xff\xff"); ``` -------------------------------- ### Example: Batch File Creation This script demonstrates creating multiple files with a pattern (a1.txt to a9.txt) on the SD card. It checks if the file exists using 'findfile' before creating it with 'newfile'. Requires 'covx' for variable conversion and assumes 'sys0' and 'sys1' are available variables. ```Assembly-like for(sys0=1;sys0<=9;sys0++) { covx sys0,t0.txt,0,0 //将变量转换为文本 t1.txt="sd0/"+"a"+t0.txt+".txt" findfile t1.txt,sys1 if(sys1==0) { newfile t1.txt,4096 } } ``` -------------------------------- ### get - Retrieve Numeric Constant Example retrieving a constant numeric value using the get instruction. Numeric constants return formatted data with numeric type marker and 4-byte hexadecimal representation. ```Custom //带格式返回常量数值123 get 123 ``` -------------------------------- ### 视频控件 外部文件路径示例 演示如何配置视频控件以从SD卡播放视频。当`from`属性设置为外部文件时,`vid`属性被`path`属性替换,用于指定SD卡上的视频文件路径。支持FAT32格式,最大32GB。 ```text sd0/1.video sd0/video/demo.video ``` -------------------------------- ### get - Serial Communication in C Language Example demonstrating how to send get instructions through serial port from microcontroller firmware to retrieve control attribute values. Uses printf with serial port terminator sequence (0xff 0xff 0xff). ```C printf("get n0.val\xff\xff\xff"); printf("get t0.txt\xff\xff\xff"); ``` -------------------------------- ### findfile Application Instance: Find and Create Sequential Files An example demonstrating how to find a series of files (a1.txt to a9.txt) and create them if they do not exist. This involves converting numbers to text and checking file existence before creation. ```C for(sys0=1;sys0<=9;sys0++) { covx sys0,t0.txt,0,0 //将变量转换为文本 t1.txt="sd0/"+"a"+t0.txt+".txt" findfile t1.txt,sys1 if(sys1==0) { newfile t1.txt,4096 } } ``` -------------------------------- ### Initialization Code for BMS Serial Communication Example of initialization code that runs once on system startup for the BMS serial protocol. It typically includes global variable definitions and initial setup for communication components. ```assembly // This code runs only once on power-up, generally used for global variable definition and power-on initialization data // Example placeholder for initialization routines // Initialize serial port // Initialize global variables // Configure timers if necessary ``` -------------------------------- ### get - Retrieve Control Text Attribute Example demonstrating retrieval of a control's text (txt) attribute value in formatted output. Returns string data prefixed with 0x70 marker and terminated with 0xff 0xff 0xff. ```Custom //带格式返回控件t0的txt属性值 get t0.txt ``` -------------------------------- ### wepo 指令 - 写入文本文件内容 使用 wepo 指令将指定文本文件(如 t0.txt)的内容写入用户存储区的指定位置。写入空间占用为文件最大设置值+1。需要确保后续写入的位置不会覆盖之前的数据。 ```Assembly wepo t0.txt,10 ``` -------------------------------- ### picq Command C Language Example via Serial Port This example shows how to implement the 'picq' command using C language, typically for microcontrollers communicating via a serial port. It demonstrates sending the command string with parameters to display a specific portion of an image on the screen. It reiterates the warning against using drawing commands in pre-initialization events. ```C int posX=40, posY=50, width=30, height=20, pic=1; printf("picq %d,%d,%d,%d,%d\xff\xff\xff", posX, posY, width, height, pic); ``` -------------------------------- ### get - Retrieve Control Numeric Value Attribute Example retrieving a numeric value attribute (val) from a control like a progress bar. Returns numeric data with 0x71 marker followed by 4-byte hexadecimal integer in little-endian format. ```Custom //带格式返回控件j0的val属性值 get j0.val ``` -------------------------------- ### crcputu Example 2: CRC Check 20 Bytes from Offset This example shows how to use the crcputu command to perform a CRC check on 20 bytes of serial buffer data, starting from index 20. This functionality is applicable when 'recmod' is set to 1. ```c // Starting from u[20], check 20 bytes of the serial buffer, valid when recmod=1 crcputu 20,20 ``` -------------------------------- ### finddir 指令语法 finddir 指令用于查找文件夹。它接受两个参数:目标文件夹目录和用于存储查找结果的变量。查找结果为 0 表示失败,1 表示成功。此变量必须是数值类型。 ```assembly finddir dir,att dir:文件夹目录(如:"sd0/newfolder/") att:查找结果写入变量(0-查找失败;1-查找成功。此变量必须是数值类型变量) ``` -------------------------------- ### get - Basic Syntax and Usage Basic syntax for the get instruction to retrieve formatted variable or constant values. The instruction takes an attribute parameter (variable name or control property) and returns formatted data with appropriate type markers and terminators. ```Custom get att att:变量名称 ``` -------------------------------- ### picq Command Usage and Parameters This section details the basic syntax and parameters for the 'picq' command, used for cutting and displaying images. It specifies the coordinates and dimensions for both the source image region and the display area on the screen. The command is limited to the current page and should not be used in pre-initialization events. ```Assembly picq x,y,w,h,picid x:屏幕起始点x坐标; y:屏幕起始点y坐标; w:区域宽度 ; h:区域高度; picid:图片ID; ``` -------------------------------- ### com_stop Command Example (No Parameters) An example demonstrating the 'com_stop' command. This command does not require any arguments and is used to halt serial command processing. ```c //此指令不需要参数 com_stop ``` -------------------------------- ### C语言控制进度条赋值 (C) 通过单片机串口向进度条控件j0.val赋值。支持直接赋值整数值或通过变量传递。注意,赋值必须为整形,否则可能导致错误。printf语句用于向串口发送指令。 ```c printf("j0.val=50\xff\xff\xff"); int a = 50; printf("j0.val=%d\xff\xff\xff",a); ``` -------------------------------- ### Example: Display Image with ID 0 This example demonstrates how to display an image with ID 0 from the resource files at the coordinates (10, 20) using the 'pic' instruction. ```plaintext //在坐标(10,20)位置显示资源文件中图片ID为0的图片 pic 10,20,0 ``` -------------------------------- ### cfgpio: 将io4配置为PWM输出模式 将指定的IO口配置为PWM输出模式。在此之前,需要先设置PWM占空比(通过系统变量pwmN)。 ```c //将io4配置为PWM输出模式,配置之前需要先设置占空比,即系统变量变量中的pwm4 cfgpio 4,3,0 ``` -------------------------------- ### C语言示例:向串口屏曲线控件添加数据 此C语言示例展示了如何通过循环向串口屏的曲线控件(s0)的通道0添加随机数据。指令通过printf函数发送,并以`\xff\xff\xff`作为结束符。该方法不支持跨页面操作。 ```c for(int i =0;i<100;i++) { //向曲线s0的通道0传输1个数据,add指令不支持跨页面 printf("add s0.id,0,%d\xff\xff\xff",(int)(rand() % 256)); } ``` -------------------------------- ### findfile Example 2: Search in SD Card Root Directory Illustrates searching for a file ('a.jpg') in the root directory of an SD card. The search outcome is stored in the 'sys0' variable. ```C //查找SD卡根目录中的a.jpg,将结果返回到sys0中 findfile "sd0/a.jpg",sys0 ```