安装配置git
一、更新软件源
- sudo apt update
二、安装git
- sudo apt install git -y

- 成功安装git如图:

三、配置git
1、设置账号
- git config --global user.name "name" (github官网注册的用户名)
2、设置邮箱
- git config --global user.email "email" (gitub官网注册绑定的邮箱)
3、查看配置
- git config --list
4、生成SSH秘钥
- ssh-keygen -t rsa -C "注册绑定的邮箱"
(输入两次密码后,提示的地方直接按Enter,成功生成如下图所示)

5、查看生成的秘钥
- cd
- cat id_rsa.pub (秘钥命名可能有不同,但一定要是pub文件)

6、github配置SSH公钥
- 登录github官网,网址:https://github.com/
- 右上角登陆后点击settings->SSH and GPS keys->New SSH key

- 将id_rsa.pub文件中的生成的内容全部复制到key中,输入title,点击Add SSH key即可

下载代码
- git clone “仓库地址"

本地文件推送到远程仓库
1、查询状态
- git status
2、添加文件到缓存区
- git add *
3、再次查询状态(文件由红变成绿色,说明已转移至缓存区)
- git status

4、提交到本地仓库
- git commit -m "source"(”source“是注释)
5、添加本地仓库推送至远程仓库的地址
- git remote add origin +仓库地址
6、核实远程仓库地址
- git remote -v
7、推送至远程仓库
- git push -u origin master


注:上文提到的仓库地址需要自行创建获取。

C语言编写贪吃蛇程序
1、编写代码
- vim tanchishe.c (使用vim工具编辑,进入后按esc按键后再按i或者l切换编辑模式)
- 编辑完成后,按下esc按键,再依次输入:wq保存并推出
#include #include #include #include #include #include #include #include #include #define MOVEUP(x) printf("\033[%dA", (x)) static struct termios ori_attr,cur_attr;static inline int tty_reset();static inline int kbhit();static inline int tty_set();#define ROW_MAX 20#define COL_MAX 50#define SPEED_MAX 500#define SPEED_MIN 125#define SNAKELEN 3#define SNAKE_HEAD '@'#define SNAKE_BODY '#'#define FOOD '$'#define LEFT 'a'#define RIGHT 'd'#define UP 'w'#define DOWN 's'#define EAT_SPACE 1#define EAT_FOOD 2#define EAT_BODY 0char dc = '0';char bodyDc = '0'; float speed = SPEED_MAX ;//ms int snake_length = 0; int grade = 1; struct Location { int row; int col; }; typedef struct ske { struct Location place; struct ske *next; }Snake; struct Location food; Snake *head = NULL; char str[ROW_MAX][COL_MAX]; void Init_str();void Display();void Init_food();void Init_snake();void Wait_game();int Snake_move();void moveToUp();void moveToDown();void moveToLeft();void moveToRight();void snakeShow();void foodShow();void reDisplay();void GameOver();void addBody(int,int);void moveBody(int,int);void Delay();int isUpgrade();int Upgrade();void releaseSnake();void PrintRule(); int main() { int again = 0; do {//printf("\033[2J"); int flag = 0;again = 0; Init_str(); Init_snake(); Init_food(); Display(); Wait_game(); while(1) { flag = Snake_move() ; if(flag == EAT_BODY) {GameOver(); } reDisplay(); Delay(); if(isUpgrade()) {again = Upgrade(); break; } } }while( again == 1); }void PrintRule(){ printf("**************************************************\n"); printf("* 游戏规则:【@】表示蛇头,【$】表示食物,【#】 *\n"); printf("* 表示蛇的身体。每吃到一个食物蛇的身体加长一个, *\n"); printf("* 吃到蛇身或撞到墙,则游戏结束 *\n"); printf("* 按wsad可以控制蛇移动方向,分别表示上下左右方向 *\n"); printf("* 请按wsad键开始游戏 *\n"); printf("**************************************************\n");}void GameOver(){ printf("Game Over!!!\n"); printf("you play %d grade,and score is :%d\n",grade,(grade-1)*2000+(snake_length-1)*100); exit(1);}int Upgrade(){ if( speed <= SPEED_MIN) {printf("Congratulations!!! you win.\n");exit(1); } else { printf("Play next grade ? < y / n >\n");printf("Else press to exit.\n ");grade ++ ;char ch ;do{ ch = getch(); ch = tolower(ch); if(ch == 'y' ) {releaseSnake();snake_length = 0;speed /= 2; return 1; } else if(ch == 'n') {printf("Play this grade.\n");return 1; } else if(ch == 27)exit(1);}while(ch != 'y' || ch != 'n'); }}void releaseSnake(){ Snake *p = head; while(head != NULL) {p = head;head = head->next;free(p); }}int isUpgrade(){ return snake_length == SNAKELEN ? 1:0;}void Delay(){ unsigned long int tick1 = clock(); char ch; while(1000*(clock() - tick1 )/CLOCKS_PER_SEC <= speed) {ch = control();ch = tolower(ch);if(ch == UP){ if(dc != DOWN) { dc = ch; break; }}else if(ch == DOWN){ if(dc != UP) { dc = ch ;break; }}else if( ch == LEFT){ if(dc != RIGHT) {dc = ch;break; }}else if(ch == RIGHT){ if(dc != LEFT) { dc = ch;break; }} }}void addBody(int x, int y){ Snake *p = (Snake *)malloc(sizeof(Snake)); if(p == NULL) {printf("Error!!!Apply Snake *p failed\n");exit(1); } p->place.row = x; p->place.col = y; p->next = head->next; head->next = p; snake_length ++; }void foodShow(){ str[food.row][food.col] = FOOD;}void snakeShow(){ Snake *p = head; while(p != NULL) {if(p == head) str[p->place.row][p->place.col] = SNAKE_HEAD ; else str[p->place.row][p->place.col] = SNAKE_BODY ; p = p->next; }}void reDisplay(){ Init_str(); foodShow(); snakeShow(); Display(); }int Snake_move(){ int x = head->place.row; int y = head->place.col; switch(dc) {case UP : if(dc != DOWN )moveToUp(); break;case DOWN : if(dc != UP )moveToDown(); break;case LEFT : if(dc != RIGHT )moveToLeft(); break;case RIGHT : if(dc != LEFT)moveToRight(); break; } bodyDc = dc; int i = head->place.row; int j = head->place.col; if(str[i][j] == SNAKE_BODY ) {return EAT_BODY; } else if(str[i][j] == FOOD ) {addBody(x,y);Init_food();return EAT_FOOD; } else if(str[i][j] == ' ') {moveBody(x,y);return EAT_SPACE; }}void moveBody(int x,int y){ Snake *p = head ,*pre = NULL; if(head->next != NULL) {while(p->next != NULL){ pre = p; p = p->next; }if(pre != head){ p->place.row = x; p->place.col = y; p->next = head->next; head->next = p; pre->next = NULL ; }else{ p->place.row = x; p->place.col = y;} }}void moveToRight(){ int i = head->place.row; int j = head->place.col; dc = RIGHT ; if(str[i][j+1] != '|') {j++ ; } else {GameOver(); } head->place.row = i; head->place.col = j;}void moveToLeft(){ int i = head->place.row; int j = head->place.col; dc = LEFT ; if(str[i][j-1] != '|') {j-- ; } else {GameOver(); } head->place.row = i; head->place.col = j;}void moveToUp(){ int i = head->place.row; int j = head->place.col; dc = UP ; if(str[i-1][j] != '-') {i-- ; } else {GameOver(); } head->place.row = i; head->place.col = j;}void moveToDown(){ int i = head->place.row; int j = head->place.col; dc = DOWN ; if(str[i+1][j] != '-') {i++ ; } else {GameOver(); } head->place.row = i; head->place.col = j;}/*void moveToRight(){ int i = head->place.row; int j = head->place.col; dc = RIGHT ; if(str[i][j+1] != '|') {j++ ; }*void moveToRight(){ int i = head->place.row; int j = head->place.col; dc = RIGHT ; if(str[i][j+1] != '|') {j++ ; }*void moveToRight(){ int i = head->place.row; int j = head->place.col; dc = RIGHT ; if(str[i][j+1] != '|') {j++ ; } else {j = 1; } head->place.row = i; head->place.col = j;}void moveToLeft(){ int i = head->place.row; int j = head->place.col; if(str[i][j-1] != '|') {dc = LEFT ;j--; } else {dc = LEFT ;j = COL_MAX - 2; } head->place.row = i; head->place.col = j;}void moveToDown(){ int i = head->place.row; int j = head->place.col; if(str[i+1][j] != '-') {dc = DOWN ;i++; } else {dc = DOWN ;i = 1; } head->place.row = i; head->place.col = j; }void moveToUp(){ int i = head->place.row; int j = head->place.col; if(str[i-1][j] != '-') {dc = UP;i--; } else {dc = UP ;i = ROW_MAX -2; } head->place.row = i; head->place.col = j;}*/void Wait_game() { char ch ; do { ch = getch(); ch = tolower(ch); }while(ch != UP && ch != DOWN && ch != LEFT && ch != RIGHT ); dc = ch; bodyDc = dc; } void Init_food() { unsigned long int seed = time(NULL); srand(seed+1); while(1) {food.row = rand() % ( ROW_MAX - 2) + 1;food.col = rand() % ( COL_MAX - 2) + 1;Snake *p = head;int flag = 1;while(p != NULL){ if(food.row == p->place.row && food.col == p->place.col) {flag = 0;break; } p = p->next;}if(flag == 1) break; } str[food.row][food.col] = FOOD; } void Init_str() { int i,j; for(i=0;iplace.row = rand() % ( ROW_MAX - 2) + 1;head->place.col = rand() % ( COL_MAX - 2) + 1;head->next = NULL;str[head->place.row][head->place.col] = SNAKE_HEAD ;snake_length ++ ; } } /*********** about string handle function ***********/int control(){int flag = tty_set();int key = 0;if(kbhit())key = getchar();if(flag == 0)tty_reset();return key;}static inline int tty_reset(){if(tcsetattr(STDIN_FILENO,TCSANOW,&ori_attr) != 0)return -1;return 0;}static inline int tty_set(){if(tcgetattr(STDIN_FILENO,&ori_attr))return -1;memcpy(&cur_attr,&ori_attr,sizeof(cur_attr));cur_attr.c_lflag &= ~ICANON;cur_attr.c_lflag &= ~ECHO;cur_attr.c_cc[VMIN] = 1;cur_attr.c_cc[VTIME] = 0;if(tcsetattr(STDIN_FILENO,TCSANOW,&cur_attr) != 0)return -1;return 0;}static inline int kbhit(){fd_set rfds;struct timeval tv;int retval;FD_ZERO(&rfds);FD_SET(0,&rfds);tv.tv_sec = 0;tv.tv_usec = 0;retval = select(1,&rfds,NULL,NULL,&tv);if(retval == -1){perror("select()");return 0;}else if(retval)return 1;elsereturn 0;}int getch(void) { int c=0; struct termios org_opts, new_opts; int res=0; //----- store old settings ----------- res=tcgetattr(STDIN_FILENO, &org_opts); //---- set new terminal parms -------- memcpy(&new_opts, &org_opts, sizeof(new_opts)); new_opts.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | ECHOPRT | ECHOKE | ICRNL); tcsetattr(STDIN_FILENO, TCSANOW, &new_opts); c=getchar(); //------ restore old settings --------- res=tcsetattr(STDIN_FILENO, TCSANOW, &org_opts); return c;}2、编译代码
- gcc tanchishe.c

3、运行代码
- ./a.out

小结:
经过了几周的试用,刚开始的时候固件可能还未完善,个别功能无法开启或例程无法使用,折腾了我好几天,这在后面的维护更新后都得到了解决。这里给地平线的工作人员点个赞,遇到问题他们会热心的解答,出现异常时也有及时处理。总体来说,旭日X3派是一块面向入门嵌入式非常不错的开发板,X3派具有不错的处理与易于扩展的能力,可以满足嵌入式的低功耗、无线连接和安全等特性。
本文转自地平线开发者社区
原作者:Zeee
原链接:https://developer.horizon.ai/forumDetail/98129540173361632
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。
举报投诉
-
AI
+关注
关注
91文章
41729浏览量
302932 -
人工智能
+关注
关注
1821文章
50453浏览量
267506 -
地平线
+关注
关注
0文章
481浏览量
16525
发布评论请先 登录
相关推荐
热点推荐
地平线征程6B芯片量产上车广汽丰田铂智3X
2026年5月8日,2026款广汽丰田铂智3X正式上市。作为地平线征程6B芯片全球首发量产车型,2026款铂智3X承载着地平线与广汽丰田的深度合作成果,双方以本土领先的车载智能计算技术
iCAR首发搭载地平线舱驾融合整车智能解决方案
2026年4月22日,地平线正式发布中国首款舱驾融合整车智能体芯片地平线星空 (Horizon Starry) 。作为业界首款为整车智能Agentic OS原生设计的舱驾融合芯片,地平线星空
博泰车联网与地平线达成战略合作
4月22日,博泰车联(股票代码:2889.HK)在北京地平线机器人技术研发有限公司(以下简称“地平线”)的国内首款舱驾融合整车智能体芯片地平线星空(Horizon Starry)的产品发布会现场与
地平线11篇论文强势入选CVPR 2026
论文收录结果。地平线凭借深厚的技术积淀与前瞻的科研布局,共有11篇论文成功入选,覆盖端到端自动驾驶、3D重建、世界模型、具身智能等多个核心领域,充分彰显地平线在前沿技术领域的顶尖研发水平。
地平线正式开源HoloBrain VLA基座模型
2月13日,地平线正式宣布其HoloBrain-0基座模型及框架全面开源。本次开源不仅包括HoloBrain-0核心算法,地平线同步开放完整基础设施RoboOrchard。作为地平线机器人实验室
地平线与行深智能达成战略合作
12月9日,在“向高 同行丨2025地平线技术生态大会”上,地平线与无人驾驶技术与智慧物流产品提供商行深智能正式签署战略合作协议,行深智能将基于地平线征程6P打造L4级物流场景自动驾驶
地平线与卡尔动力达成战略合作
企业卡尔动力与地平线正式签署战略合作协议,将基于地平线征程6P打造高效、安全、可规模化的干线物流自动驾驶解决方案,双方将通过数据与场景的深度耦合赋能,软硬协同打造最强L4自动驾驶货运系统,共同推动L4级自动驾驶重卡加速技术与商业
地平线与元戎启行达成战略合作
在市场需求与技术演进的共同驱动下,高阶辅助驾驶的规模化普及已步入关键窗口期。12月9日,在“向高 同行丨2025地平线技术生态大会”上,地平线与国际领先的人工智能企业元戎启行达成合作,双方将
佑驾创新亮相2025地平线技术生态大会
12月8日至9日,以“向高·同行”为主题的2025地平线技术生态大会在深圳举行。佑驾创新作为地平线长期战略合作伙伴,双方基于“软硬协同、创新共赢”的共识,已携手打造多款智能驾驶方案,并将合作延伸到L4级无人车领域。
知行科技亮相2025地平线技术生态大会
12月8日、9日,知行科技作为地平线征程6BEM系列芯片软硬件合作伙伴亮相地平线技术生态大会,并展出了基于征程6BEM系列芯片打造的组合辅助驾驶解决方案,覆盖主动安全到高阶领航功能;同时,知行科技iRC100P具身AI BOX也亮相大会,成为知行科技与
地平线HSD量产先锋品鉴会圆满落幕
2025年11月19日-24日,地平线在广州举办Drive on Horizon·HSD量产先锋品鉴会。首搭地平线HSD及征程6P的星途ET5、搭载征程6的深蓝L06开启辅助驾驶体验,以出色的实际
地平线助力博世中阶智能辅助驾驶方案量产交付
2025年4月,地平线与博世深化战略合作,双方基于征程6系列加速智能辅助驾驶方案的研发与应用。近日,搭载征程6M的博世中阶智能辅助驾驶方案的全新量产合作车型东风奕派eπ007+、北京越野BJ40增程元境智行版先后上市,标志着地平线
地平线与Unity中国达成战略合作
近日,中国智驾科技领军企业地平线与全球领先的实时3D内容创作和运营平台Unity正式签署战略合作协议。双方将深度融合地平线HSD (Horizon SuperDrive) 人机交互系统与Unity
地平线与哈啰正式签署战略合作协议
9月11日,在2025Inclusion·外滩大会上,地平线与哈啰正式签署战略合作协议。双方将基于Robotaxi运营场景和需求,发挥各自技术优势,共同打造极致低成本、高安全、高可靠、高可用的智能
行深智能推出基于地平线征程6M的L4级自动驾驶解决方案
近日,智慧物流产品供应商行深智能正式推出面向城市末端物流场景的L4级自动驾驶解决方案。该方案基于地平线(地平线机器人-W,9660.HK)征程6M车载智能计算方案开发,是首个基于征程6系列计算方案打造的物流场景自动驾驶方案,标志
【地平线旭日X3派试用体验】保姆级配置git与使用+C语言编写贪吃蛇
评论