安裝配置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
+關注
關注
87文章
33973瀏覽量
274873 -
人工智能
+關注
關注
1804文章
48589瀏覽量
245878 -
地平線
+關注
關注
0文章
388瀏覽量
15374
發布評論請先 登錄
相關推薦
熱點推薦
Arm攜手地平線推動汽車智能化變革
近日,地平線在上海舉辦了 2025 年度產品發布會,推出了 L2 城區輔助駕駛系統——地平線 HSD,不僅集中展示了自身領先的技術實力,更深刻詮釋了汽車智能化加速普及的產業發展趨勢,成為上海車展的前哨。地平線征程 6P 作為技術
地平線與博世達成戰略合作
近日,地平線正式宣布與全球領先的汽車技術與服務供應商博世達成戰略合作。根據協議,博世將基于地平線征程6B打造新一代多功能攝像頭,并基于征程6E/M打造博世縱橫輔助駕駛升級版。目前,基于征程6系列開發的博世新一代多功能攝像頭與博世縱橫輔助駕駛升級版均獲得多家車企的項目定點。
地平線城區輔助駕駛系統HSD解讀
近日,在2025地平線年度產品發布會上,地平線城區輔助駕駛系統HSD正式發布。作為國內首個軟硬結合全棧開發的城區輔助駕駛系統,地平線HSD搭載當前最高性能的國產智駕計算方案征程6P,采用一段式端到端
地平線推出L2城區輔助駕駛系統HSD
近日,以“征程所向,遠超想象”為主題的2025地平線年度產品發布會在上海滴水湖舉行。地平線重磅推出L2城區輔助駕駛系統——地平線HSD,構建體驗“類人”、用戶“信任”的城區輔助駕駛新解。同時,
地平線與上汽集團深化戰略合作
近日,上汽集團舉辦“懂車更懂你·2025上汽之夜”活動,地平線創始人兼CEO余凱博士受邀發表主旨演講。作為地平線第一大機構股東,上汽集團在發布會上表示將繼續拓展與地平線等頭部企業的合作,借助各自領域的優勢資源互補,打造擁有全新體
知行科技與地平線達成戰略合作
近日,知行科技與地平線正式簽署了戰略合作協議,標志著雙方在智能駕駛技術領域的合作邁出了堅實的一步。 根據協議內容,雙方將共同致力于智能駕駛技術的研發與應用。特別是在2025年下半年,基于地平線征程6
地平線SuperDrive相關問答
近日,地平線SuperDrive智駕百人團體驗活動圓滿落幕,現場130余家媒體對地平線SuperDrive表現出濃厚的興趣并提出了諸多問題。對此,地平線特意整理了大家提出的典型問題并進行解答,希望能幫助大家更全面地了解這套擬人的
地平線SuperDrive首發三大黑科技,決勝智能化競爭下半場
地平線創始人兼CEO余凱表示:“在2025年,地平線智能計算方案即將邁過1000萬量產大關,持續引領中國智駕量產落地、推動智駕生態繁榮生長,‘向下扎深根’。與此同時,地平線SuperDrive及征程

地平線SuperDrive首發三大黑科技
近日,“Beyond the Horizon 地平線智駕科技暢想日”在上海舉辦,回顧地平線以軟硬結合技術實力取得的量產創新成果,展望2025高階智駕爆發之年。同時,“SuperDrive智駕百人團體驗活動”在上海靜安區繁華路段開展,首發三大智駕黑科技,打造擬人高效、“10
地平線榮獲比亞迪“最佳合作伙伴獎”
近日,比亞迪舉辦2024年比亞迪新能源汽車核心供應商大會。在此次大會上,地平線榮獲“最佳合作伙伴獎”,成為唯一獲得該殊榮的智駕方案供應商。該獎項高度肯定了地平線在智駕技術和量產能力方面的突出貢獻。地平線創始人兼CEO余凱受邀出席
智駕科技企業地平線登陸港交所
近日,智駕科技企業地平線(地平線機器人-W,股票代碼:9660.HK)在香港交易所主板成功掛牌上市,募資總額高達54.07億港元,成為港股今年最大的科技IPO。
ETAS支持地平線征程6 AUTOSAR版本發布
地平線于2024年北京車展期間推出了覆蓋自動駕駛全場景的征程6產品。征程6是地平線新一代家族系列產品,能夠覆蓋從主動安全ADAS到城區全場景NOA的智能駕駛需求。
地平線港股IPO獲證監會備案
自動駕駛領域的明星企業——地平線機器人(Horizon Robotics),近期獲得了中國證監會的批準,將在香港聯合交易所進行首次公開募股(IPO)。此次IPO的順利推進,標志著地平線向資本市場邁出了重要一步。
評論