找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 42927|回復(fù): 31
收起左側(cè)

自制基于arduino的GPS地圖導(dǎo)航系統(tǒng)

  [復(fù)制鏈接]
ID:113207 發(fā)表于 2016-4-11 01:33 | 顯示全部樓層 |閱讀模式
這是一篇關(guān)于動手制作基于arduino 和12864液晶模塊的圖形化顯示GPS導(dǎo)航系統(tǒng)的帖子,作品效果和成本可能無法和TB上的導(dǎo)航產(chǎn)品媲美,但是動手過程會帶給你樂趣和知識。

動手之前最好能具備一些背景知識:
1. arduino 相關(guān)基礎(chǔ);
2. 能使用12864 液晶模塊;
3. 能夠用arduino 通過串口通信獲取GPS模塊定位信息;
4. 能夠用arduino 操作SD卡模塊;
搜索論壇即可找到相關(guān)內(nèi)容。

制作所需主要硬件:
1. arduino UNO 1片;
2. 12864 液晶模塊 1片;
3. GPS模塊1片;
4. SD卡模塊及SD卡 1套;
101210kh8e8801hphm4sg4.jpg 212105s3qe9jinwvsbzvjd.jpg 115051ir121fwrzmr1riwu.jpg 1018301jpo1dz2um1mscwq.jpg 234337bta4qvlq0n0bt2v3.jpg

原理:
將地圖數(shù)據(jù)依據(jù)瓦片算法存儲在SD卡中,通過串口獲取GPS定位信息并從中解析出經(jīng)緯度坐標,依據(jù)經(jīng)緯度坐標讀取相應(yīng)地圖數(shù)據(jù)顯示在12864液晶模塊上,同時顯示定位坐標點。
1. 地圖存儲算法——瓦片系統(tǒng)(Maps Tile System)
本制作采用的地圖數(shù)據(jù)和地圖存儲算法來源于微軟的bing maps并做了相應(yīng)修改,具體可參考:
Bing Maps Tile System[1*]
Virtual Earth Tile Image URI 參數(shù)解析
Goolge and Microsoft Map Url Parameters
在瓦片系統(tǒng)中地圖采用金字塔式的分層存儲結(jié)構(gòu),不同層具有不同級別的地圖分辨率(地圖精細程度),每一層地圖被分割成等像素大。256X256)的瓦片,算法要解決的問題就是給定經(jīng)緯度坐標和縮放級別(層索引)得到具體相應(yīng)的瓦片編號。
在連接[1*]的最后有算法實現(xiàn)的代碼可共參考。
2. 針對12864液晶模塊的設(shè)計
12864液晶模塊是128像素寬64像素高的單色液晶顯示模塊,本制作為了適應(yīng)模塊顯示做出了兩個設(shè)計。
1). 將256X256像素的瓦片裁切成128X64像素大小的8份 子瓦片,如下圖所示:
221323u211s13ccbbkr3oe.png
每層每個瓦片均做相應(yīng)處理。
2). 通過閾值方法將8位png索引圖像(bing maps 的道路數(shù)據(jù))轉(zhuǎn)換成二進制地圖數(shù)據(jù)文件,為了能夠顯示原圖中的文字信息,采用多閾值提取求或方法提取原地圖中背景、地物和標注文字數(shù)據(jù),由于標注文字和背景之間的擾動,提取效果有待改進。

顯示效果:
231937rwgiz6w8wnkgrrq6.jpg 231938yu7sygnk9kyvfnvs.jpg 231938xxmbmmst7suxdtff.jpg 231939v21fz3i52u82s282.jpg 231940qfdbhuzrra3jmabq.jpg 2319409y8200oloxrvszul.jpg 231941sui09ac0uyuqk0qa.jpg 231942eg5z5e51v13achrb.jpg 231942f5fa7tjdtmxllmdm.jpg 2319434qiw0wxwtheu8e9x.jpg 231944ojnk0znv2plndcqn.jpg 231944qdppcnnrc4ooaw6c.jpg 231945xr6qtwagr8brsj66.jpg 231946o7pzv3473ayag32a.jpg 231947xogrv7r8ra7i76at.jpg

arduino 代碼說明:
1. 在“LCD12864RSPI” 文件中加入畫點函數(shù),減少重繪區(qū)域;
2. 使用占用內(nèi)存小、具有只讀能力的SD模塊庫“petit_fatfs”;
3. 分配1K內(nèi)存用于地圖數(shù)據(jù)緩存,由于SD卡庫只支持8.3文件名,地圖數(shù)據(jù)文件名采用十六進制不定長壓縮編碼方式命名。
代碼下載:
arduinoTile.rar (4.24 KB, 下載次數(shù): 83) LCD12864RSPI.rar (1.86 KB, 下載次數(shù): 61)
petit_fatfs.rar (16.88 KB, 下載次數(shù): 64)
部分代碼預(yù)覽:
  1. //Demo LCD12864 spi


  2. #include "LCD12864RSPI.h"


  3. extern "C"
  4. {
  5. #include  
  6. #include
  7. #include   //not needed yet
  8. #include  //needed for strlen()
  9. #include
  10. }



  11. LCD12864RSPI::LCD12864RSPI()
  12. {
  13. this->DEFAULTTIME = 80; // 80 ms default time
  14. this->delaytime = DEFAULTTIME;
  15. }

  16. //*********************延時函數(shù)************************//
  17. void LCD12864RSPI::delayns(void)
  18. {   
  19. delayMicroseconds(delaytime);
  20. }


  21. void LCD12864RSPI::WriteByte(int dat)
  22. {
  23.     digitalWrite(latchPin, HIGH);
  24.     delayns();
  25.     shiftOut(dataPin, clockPin, MSBFIRST, dat);
  26.     digitalWrite(latchPin, LOW);
  27. }


  28. void LCD12864RSPI::WriteCommand(int CMD)
  29. {
  30.    int H_data,L_data;
  31.    H_data = CMD;
  32.    H_data &= 0xf0;           //屏蔽低4位的數(shù)據(jù)
  33.    L_data = CMD;             //xxxx0000格式
  34.    L_data &= 0x0f;           //屏蔽高4位的數(shù)據(jù)
  35.    L_data <<= 4;             //xxxx0000格式
  36.    WriteByte(0xf8);          //RS=0,寫入的是指令;
  37.    WriteByte(H_data);
  38.    WriteByte(L_data);
  39. }


  40. void LCD12864RSPI::WriteData(int CMD)
  41. {
  42.    int H_data,L_data;
  43.    H_data = CMD;
  44.    H_data &= 0xf0;           //屏蔽低4位的數(shù)據(jù)
  45.    L_data = CMD;             //xxxx0000格式
  46.    L_data &= 0x0f;           //屏蔽高4位的數(shù)據(jù)
  47.    L_data <<= 4;             //xxxx0000格式
  48.    WriteByte(0xfa);          //RS=1,寫入的是數(shù)據(jù)
  49.    WriteByte(H_data);
  50.    WriteByte(L_data);
  51. }



  52. void LCD12864RSPI::Initialise()
  53. {
  54.     pinMode(latchPin, OUTPUT);     
  55.     pinMode(clockPin, OUTPUT);   
  56.     pinMode(dataPin, OUTPUT);
  57.     digitalWrite(latchPin, LOW);
  58.     delayns();

  59.     WriteCommand(0x30);        //功能設(shè)定控制字
  60.     WriteCommand(0x0c);        //顯示開關(guān)控制字
  61.     WriteCommand(0x01);        //清除屏幕控制字
  62.     WriteCommand(0x06);        //進入設(shè)定點控制字
  63. }


  64. void LCD12864RSPI::CLEAR(void)
  65. {  
  66.     WriteCommand(0x30);//
  67.     WriteCommand(0x01);//清除顯示
  68. }


  69. void LCD12864RSPI::DisplayString(int X,int Y,uchar *ptr,int dat)
  70. {
  71.   int i;

  72.   switch(X)
  73.    {
  74.      case 0:  Y|=0x80;break;

  75.      case 1:  Y|=0x90;break;

  76.      case 2:  Y|=0x88;break;

  77.      case 3:  Y|=0x98;break;

  78.      default: break;
  79.    }
  80.   WriteCommand(Y); // 定位顯示起始地址

  81.   for(i=0;i<dat;i++)
  82.     {
  83.       WriteData(ptr[i]);//顯示漢字時注意碼值,連續(xù)兩個碼表示一個漢字
  84.     }
  85. }



  86. void LCD12864RSPI::DisplaySig(int M,int N,int sig)
  87. {
  88.   switch(M)
  89.    {
  90.      case 0:  N|=0x80;break;

  91.      case 1:  N|=0x90;break;

  92.      case 2:  N|=0x88;break;

  93.      case 3:  N|=0x98;break;

  94.      default: break;
  95.    }
  96.   WriteCommand(N); // 定位顯示起始地址
  97.   WriteData(sig); //輸出單個字符
  98. }

  99. void LCD12864RSPI::DrawPoint(int X,int Y,uchar *p)
  100. {
  101.         int x,y,i;
  102.         int tmp;
  103.       
  104.       if(Y<32)
  105.             {
  106.              x=  0x80;
  107.              y=Y+0x80;
  108.             }
  109.            else
  110.             {
  111.               x= 0x88;
  112.               y=Y-32+0x80;   
  113.             }         
  114.            WriteCommand(0x34);        //寫入擴充指令命令
  115.            WriteCommand(y);           //寫入y軸坐標
  116.            WriteCommand(x);           //寫入x軸坐標
  117.            WriteCommand(0x30);        //寫入基本指令命令
  118.            tmp=Y*16;
  119.                    for(i=0;i<round(x 8.0+0.5);i++)
  120.                  {
  121.                     WriteData(p[tmp++]);
  122.           }

  123.         WriteCommand(0x34);        //寫入擴充指令命令
  124.         WriteCommand(0x36);        //顯示圖象
  125. }


  126. void LCD12864RSPI::DrawFullScreen(uchar *p)
  127. {
  128.       int ygroup,x,y,i;
  129.       int temp;
  130.       int tmp;
  131.             
  132.       for(ygroup=0;ygroup<64;ygroup++)           //寫入液晶上半圖象部分
  133.         {                           //寫入坐標
  134.            if(ygroup<32)
  135.             {
  136.              x=0x80;
  137.              y=ygroup+0x80;
  138.             }
  139.            else
  140.             {
  141.               x=0x88;
  142.               y=ygroup-32+0x80;   
  143.             }         
  144.            WriteCommand(0x34);        //寫入擴充指令命令
  145.            WriteCommand(y);           //寫入y軸坐標
  146.            WriteCommand(x);           //寫入x軸坐標
  147.            WriteCommand(0x30);        //寫入基本指令命令
  148.            tmp=ygroup*16;
  149.            for(i=0;i<16;i++)
  150.                  {
  151.                     temp=p[tmp++];
  152.                     WriteData(temp);
  153.                }
  154.           }
  155.         WriteCommand(0x34);        //寫入擴充指令命令
  156.         WriteCommand(0x36);        //顯示圖象
  157. }


  158. LCD12864RSPI LCDA = LCD12864RSPI();
復(fù)制代碼




生成地圖程序(需要連接互聯(lián)網(wǎng)):
234950exxtfe3hhktf0333.png
通過設(shè)置地圖范圍經(jīng)緯度信息獲取要使用定位的區(qū)域,可通過google earth 等能顯示經(jīng)緯度的軟件或網(wǎng)頁獲取經(jīng)緯度的最大最小值(上大下小,右大左。,
23562326f6fffvllvsl6v1.png
縮放級別建議設(shè)置范圍1~15,較大地圖范圍和較高縮放級別會增加地圖下載、顯示加載的時間。


maptile.rar (8.73 KB, 下載次數(shù): 60) 需要 .net2.0以上庫支持。

相關(guān)帖子

回復(fù)

使用道具 舉報

ID:113207 發(fā)表于 2016-4-11 01:35 | 顯示全部樓層
自制基于arduino的GPS地圖導(dǎo)航系統(tǒng)2.0
主要算法類似。

113820u2ib67bqg2mny7ab.jpg 113822fr2z25fjd8n8r82f.jpg 113824q6s6h6hh5k66z09h.jpg 113825v9dpioim3f0nz3qn.jpg 113827j11i3jriou2iirmz.jpg

屏幕采用oled RGB 96*64 ,使用三軸磁阻獲取羅盤信息(受周圍磁場干擾較大),使用SD卡存儲地圖數(shù)據(jù),使用TinyGPS處理GPS數(shù)據(jù)。

oled RGB 96*64 使用的是lm095cg-096064

接線方法和代碼如下:
  1.     //OLED LM095CG-096064 - UNO
  2.     //E/RD#(12) - VCC
  3.     //R/W#(13) - GND
  4.     //D/C#(14) - A0
  5.     //RES#(15) - A1
  6.     //CS#(16) - A2
  7.     //D7(4) - 7
  8.     //D6(5) - 6
  9.     //D5(6) - 5
  10.     //D4(7) - 4
  11.     //D3(8) - 3
  12.     //D2(9) - 2
  13.     //D1(10) - 9
  14.     //D0(11) - 8

  15.     /***********************************************************/
  16.     //oled pin define
  17.     /***********************************************************/
  18.     #define CS A2
  19.     #define DC A0
  20.     #define RES A1
  21.     /***********************************************************/
  22.     // special defines for the dataport
  23.     /***********************************************************/
  24.     #define DATAPORT1 PORTD
  25.     #define DATAPIN1 PIND
  26.     #define DATADDR1 DDRD

  27.     #define DATAPORT2 PORTB
  28.     #define DATAPIN2 PINB
  29.     #define DATADDR2 DDRB

  30.     #define DATA1_MASK 0xFC  // top 6 bits
  31.     #define DATA2_MASK 0x03  // bottom 2 bits
復(fù)制代碼
  1. /* write by davidce
  2. davidce@163.com
  3. 2013.6.10
  4. v1.0
  5. */

  6. //********************************************
  7. //low level function
  8. //********************************************
  9. /**********************************************
  10. * // Write Command
  11. **********************************************/
  12. static void write_command(unsigned char Command_value)
  13. {
  14.   digitalWrite(CS, LOW);
  15.   digitalWrite(DC, LOW);
  16.   DATAPORT2 = (DATAPORT2 & DATA1_MASK) |
  17.     (Command_value & DATA2_MASK);
  18.   DATAPORT1 = (DATAPORT1 & DATA2_MASK) |
  19.     (Command_value & DATA1_MASK); // top 6 bits
  20.   digitalWrite(CS, HIGH);
  21. }
  22. /**********************************************
  23. * // Write Data
  24. **********************************************/
  25. static void write_Data(unsigned char Data_value)
  26. {
  27.   digitalWrite(CS, LOW);
  28.   digitalWrite(DC, HIGH);
  29.   DATAPORT2 = (DATAPORT2 & DATA1_MASK) |
  30.     (Data_value & DATA2_MASK);
  31.   DATAPORT1 = (DATAPORT1 & DATA2_MASK) |
  32.     (Data_value & DATA1_MASK); // top 6 bits
  33.   digitalWrite(CS, HIGH);
  34. }
  35. /********************************************
  36. * // Draw Picture
  37. ********************************************/
  38. static void drawPicFromFlash(uint8_t x0,uint8_t y0,uint8_t w,uint8_t h,const PROGMEM char *c)                                               
  39. {
  40.   digitalWrite(DC, LOW);  //solve a bug of write_command defore write_data
  41.   write_command(0x15); //set column address
  42.   write_command(x0); //column address start 00
  43.   write_command(x0+w-1); //column address end 95
  44.   write_command(0x75); //set row address
  45.   write_command(y0); //row address start 00
  46.   write_command(y0+h-1); //row address end 63

  47.   unsigned char k,i;
  48.   for(k=0;k<h;k++)
  49.   {
  50.     for(i=0;i<w;i++)
  51.     {      
  52.       write_Data(pgm_read_byte(c++));
  53.       write_Data(pgm_read_byte(c++));
  54.     }
  55.   }
  56. }
  57. /********************************************
  58. * // Fill color
  59. ********************************************/
  60. static void fill_color (uint8_t startx,uint8_t endx,uint8_t starty,uint8_t endy,unsigned char dat1,unsigned char dat2)                                               
  61. {
  62.   digitalWrite(DC, LOW);  //solve a bug of write_command defore write_data
  63.   write_command(0x15); //set column address
  64.   write_command(startx); //column address start 00
  65.   write_command(endx-1); //column address end 95
  66.   write_command(0x75); //set row address
  67.   write_command(starty); //row address start 00
  68.   write_command(endy-1); //row address end 63
  69.   unsigned char k,i;
  70.   for(k=starty;k<endy;k++)
  71.   {
  72.     for(i=startx;i<endx;i++)
  73.     {      
  74.       write_Data(dat1);
  75.       write_Data(dat2);
  76.     }
  77.   }
  78. }
  79. /********************************************
  80. * // DrawRectangle
  81. ********************************************/
  82. static void drawRectangle(unsigned char startx,unsigned char starty,
  83. unsigned char endx,unsigned char endy,
  84. unsigned char BcolorR,unsigned char BcolorB,unsigned char BcolorG,
  85. unsigned char FcolorR,unsigned char FcolorB,unsigned char FcolorG,
  86. boolean isFill)
  87. {
  88.   digitalWrite(DC, LOW);  //solve a bug of write_command defore write_data
  89.   write_command(0x26);
  90.   if(isFill)
  91.   {
  92.     write_command(0x01);
  93.   }
  94.   else
  95.   {
  96.     write_command(0x00);
  97.   }
  98.   write_command(0x22);
  99.   write_command(startx);
  100.   write_command(starty);
  101.   write_command(endx);
  102.   write_command(endy);
  103.   write_command(BcolorR);
  104.   write_command(BcolorB);
  105.   write_command(BcolorG);
  106.   write_command(FcolorR);
  107.   write_command(FcolorB);
  108.   write_command(FcolorG);
  109. }
  110. /********************************************
  111. * // cover color format from 888 to 565
  112. ********************************************/
  113. static uint16_t Color565(uint8_t r, uint8_t g, uint8_t b) {
  114.   uint16_t c;
  115.   c = r >> 3;
  116.   c <<= 6;
  117.   c |= g >> 2;
  118.   c <<= 5;
  119.   c |= b >> 3;
  120.   return c;
  121. }
  122. /********************************************
  123. * // DrawLine
  124. ********************************************/
  125. static void drawLine(unsigned char startx,unsigned char starty,
  126. unsigned char endx,unsigned char endy,
  127. unsigned char colorR,unsigned char colorB,unsigned char colorG)
  128. {
  129.   digitalWrite(DC, LOW);  //solve a bug of write_command
  130.   write_command(0x21);
  131.   write_command(startx);
  132.   write_command(starty);
  133.   write_command(endx);
  134.   write_command(endy);
  135.   write_command(colorR);
  136.   write_command(colorB);
  137.   write_command(colorG);
  138. }
  139. /***************************************************/
  140. //oled Initial
  141. /***************************************************/
  142. static void Initial_SSD1330ZB()
  143. {
  144.   write_command(0xfd); // command lock
  145.   write_command(0x12);
  146.   write_command(0xae); // display off
  147.   write_command(0xa4); // Normal Display mode
  148.   write_command(0x15); //set column address
  149.   write_command(0x00); //column address start 00
  150.   write_command(0x5f); //column address end 95
  151.   write_command(0x75); //set row address
  152.   write_command(0x00); //row address start 00
  153.   write_command(0x3f); //row address end 63
  154.   write_command(0x87); //master current control
  155.   write_command(0x0A);
  156.   write_command(0x81); //Set Contrast for Color A
  157.   write_command(0x85); //91
  158.   write_command(0x82); //Set Contrast for Color B
  159.   write_command(0x56); //50
  160.   write_command(0x83); //Set Contrast for Color C
  161.   write_command(0x7f); //7d
  162.   write_command(0x8a);  // set scond pre-change speed of Color A
  163.   write_command(0x64);
  164.   write_command(0x8b);  // set scond pre-change speed of Color B
  165.   write_command(0x78);
  166.   write_command(0x8c);  // set scond pre-change speed of Color C
  167.   write_command(0x64);
  168.   write_command(0xa0); //set re-map & data format
  169.   write_command(0x72); //Horizontal address increment
  170.   write_command(0xa1); //set display start line
  171.   write_command(0x00); //start 00 line
  172.   write_command(0xa2); //set display offset
  173.   write_command(0x00);
  174.   write_command(0xa8); //set multiplex ratio
  175.   write_command(0x3f); //64MUX
  176.   write_command(0xb0); //set power save
  177.   write_command(0x1a);
  178.   write_command(0xb1);
  179.   write_command(0xf1); // Phase 2 period Phase 1 period
  180.   write_command(0xb3); // Set Display Clock Divide Ratio/ Oscillator Frequency
  181.   write_command(0xd0);
  182.   write_command(0xbb); // set pre-charge
  183.   write_command(0x3e);
  184.   write_command(0xbe); //set Vcomh
  185.   write_command(0x3e);
  186.   write_command(0xad); //Select external VCC supply at Display ON
  187.   write_command(0x8e); //Select External VP voltage supply
  188.   write_command(0xaf); //display on
  189. }
  190. //********************************************
  191. //high level function
  192. //********************************************
  193. /********************************************
  194. * // DrawPixel
  195. ********************************************/
  196. static void drawPixel(unsigned char px,unsigned char py,
  197. unsigned char colorR,unsigned char colorB,unsigned char colorG)
  198. {
  199.   drawLine(px,py,px,py,colorR,colorB,colorG);
  200. }
  201. /********************************************
  202. * // draw a character
  203. ********************************************/
  204. static void drawChar(uint8_t x, uint8_t y, char c,uint8_t colorR,uint8_t colorB,uint8_t colorG,uint8_t size) {
  205.   uint8_t tempx,tempy;
  206.   uint8_t i,j;
  207.   for (i =0; i<5; i++ ) {
  208.     uint8_t line = pgm_read_byte(font+(c*5)+i);
  209.     for (j = 0; j<8; j++) {
  210.       if (line & 0x1) {
  211.         if (size == 1) // default size
  212.           drawPixel(x+i, y+j, colorR,colorB,colorG);
  213.         else {  // big size
  214.           tempx= x+i*size;
  215.           tempy= y+j*size;
  216.           drawRectangle(tempx,tempy,tempx + size,tempy + size, colorR,colorB,colorG,colorR,colorB,colorG,true);
  217.         }
  218.       }
  219.       line >>= 1;
  220.     }
  221.   }
  222. }
  223. /********************************************
  224. * // DrawString
  225. ********************************************/
  226. static void drawString(uint8_t x, uint8_t y, char *c,uint8_t colorR,uint8_t colorB,uint8_t colorG,uint8_t size) {
  227.   if(size>0)
  228.   {
  229.     while (c[0] != 0) {
  230.       drawChar(x, y, c[0], colorR,colorB,colorG, size);
  231.       x += size*6;
  232.       c++;
  233.     }
  234.   }
  235. }
  236. /********************************************
  237. * // DrawCircleHelper
  238. ********************************************/
  239. static void drawCircleHelper(uint8_t x0, uint8_t y0,
  240. uint8_t r, uint8_t cornername,
  241. uint8_t colorR,uint8_t colorB,uint8_t colorG) {
  242.   int16_t f = 1 - r;
  243.   int16_t ddF_x = 1;
  244.   int16_t ddF_y = -2 * r;
  245.   int16_t x = 0;
  246.   int16_t y = r;
  247.   while (x<y) {
  248.     if (f >= 0) {
  249.       y--;
  250.       ddF_y += 2;
  251.       f += ddF_y;
  252.     }
  253.     x++;
  254.     ddF_x += 2;
  255.     f += ddF_x;
  256.     if (cornername & 0x4) {
  257.       drawPixel(x0 + x, y0 + y,  colorR,colorB,colorG);
  258.       drawPixel(x0 + y, y0 + x,  colorR,colorB,colorG);
  259.     }
  260.     if (cornername & 0x2) {
  261.       drawPixel(x0 + x, y0 - y,  colorR,colorB,colorG);
  262.       drawPixel(x0 + y, y0 - x,  colorR,colorB,colorG);
  263.     }
  264.     if (cornername & 0x8) {
  265.       drawPixel(x0 - y, y0 + x,  colorR,colorB,colorG);
  266.       drawPixel(x0 - x, y0 + y,  colorR,colorB,colorG);
  267.     }
  268.     if (cornername & 0x1) {
  269.       drawPixel(x0 - y, y0 - x,  colorR,colorB,colorG);
  270.       drawPixel(x0 - x, y0 - y,  colorR,colorB,colorG);
  271.     }
  272.   }
  273. }
  274. /********************************************
  275. * // DrawCircle
  276. ********************************************/
  277. static void drawCircle(uint8_t x0, uint8_t y0,
  278. uint8_t r,
  279. uint8_t colorR,uint8_t colorB,uint8_t colorG)
  280. {
  281.   drawCircleHelper(x0, y0, r, 0xF, colorR,colorB,colorG);
  282.   drawPixel(x0, y0+r, colorR,colorB,colorG);
  283.   drawPixel(x0, y0-r, colorR,colorB,colorG);
  284.   drawPixel(x0+r, y0, colorR,colorB,colorG);
  285.   drawPixel(x0-r, y0, colorR,colorB,colorG);
  286. }
  287. /********************************************
  288. * // drawTriangle
  289. ********************************************/
  290. static void drawTriangle(uint8_t x0, uint8_t y0,
  291. uint8_t x1, uint8_t y1,
  292. uint8_t x2, uint8_t y2,
  293. unsigned char colorR,unsigned char colorB,unsigned char colorG)
  294. {
  295.   drawLine(x0, y0, x1, y1, colorR,colorB,colorG);
  296.   drawLine(x1, y1, x2, y2, colorR,colorB,colorG);
  297.   drawLine(x2, y2, x0, y0, colorR,colorB,colorG);
  298. }
  299. /********************************************
  300. * // init color OLED
  301. ********************************************/
  302. static void initOLED()
  303. {
  304.   pinMode(CS, OUTPUT);
  305.   pinMode(DC, OUTPUT);
  306.   pinMode(RES, OUTPUT);
  307.   //set pin output mode
  308.   DATADDR2 |= DATA2_MASK;
  309.   DATADDR1 |= DATA1_MASK;
  310.   //reset oled model
  311.   digitalWrite(RES, LOW);
  312.   delay(50);
  313.   digitalWrite(RES, HIGH);
  314.   delay(50);
  315.   Initial_SSD1330ZB();

  316.   fill_color(0,96,0,64,0x00,0x00);
  317. }
復(fù)制代碼



代碼僅供參考。
感謝 czad 贈送的atmge328p的貼片板和好人做到底的geek精神!

</endx;i++)
</endy;k++)
</w;i++)
</h;k++)
回復(fù)

使用道具 舉報

ID:113207 發(fā)表于 2016-4-11 01:39 | 顯示全部樓層
自制基于arduino的GPS地圖導(dǎo)航系統(tǒng)3.0
最后一個版本,主要用來在跑步的時候定位和記錄路徑。
使用1.8寸TFT屏,128*160分辨率,SPI接口。采用Atmega 328為主控芯片。

212954n4bpbww2ujj2r2fs.png
5V輸入鋰電池充電板,系統(tǒng)電壓3.3V。
212955xmykjv6mnzkvetcn.png
211208zs99xx5ar9s5r39x.jpg
左側(cè)黑色按鈕放大,右側(cè)紅色按鈕縮小,長按紅色按鈕(>=2秒)錄制軌跡,再次長按停止錄制。
211232bf0udjsv98zvyfv8.jpg 211233pjxxr380cr3izmic.jpg 211234xnp4e70poen27reu.jpg
演示如下:




210246ry6t7t9906bxg7xh.jpg
藍色的點代表歷史路徑,刷屏后消失不保存,右下角REC字樣表示儀器正在錄制軌跡,存在SD卡中。
下部綠色顯示經(jīng)緯度信息,紅色顯示時間和日期,藍色顯示海拔高度、速度和朝向。從圖中歷史軌跡點可看出數(shù)據(jù)漂移較多,原因可能是1.GPS模塊精度不高;2.GPS模塊應(yīng)該設(shè)置在儀器的上方;3.需要采用濾波算法過濾。

地圖數(shù)據(jù)存在SD卡中,目錄結(jié)構(gòu)如下:
213827x1l7j00t0ku304n0.png
TRACK文件為軌跡文件

這是地圖下載程序,需要.net Framework 4 支持
Release.rar (1.03 MB, 下載次數(shù): 65)
這是Arduino 程序
appMaster.rar (5.5 KB, 下載次數(shù): 43)
支持的庫文件
lib.rar (161.98 KB, 下載次數(shù): 41)

串口速率與GPS模塊要設(shè)置一致,接線方式如下:
//TFT SDA -> UNO 11
//TFT SCK -> UNO 13
#define TFT_CS  10  // Chip select line for TFT display
#define TFT_A0   9  // Data/command line for TFT
#define TFT_RST  8  // Reset line for TFT (or connect to +5V)
#define TFT_LED  A0
#define SD_CS    4  // Chip select line for SD card
//SD MISO -> UNO 12
//SD SCK -> UNO 13
//SD MOSI -> UNO 11

//GPS tx - UNO rx
//GPS rx - UNO tx

#define BTNZOOMIN 2
#define BTNZOOMOUT 3

撥動開關(guān)控制電池充電和儀器開關(guān),電池接中間引腳,充電板和儀器電源各接兩邊。

224855t2io7t6ipm8dre86.png
點擊“顯示地圖”出現(xiàn)地圖窗口,地圖可能加載較慢,通過鼠標左鍵拖拽進行平移,鼠標滾輪進行放大縮小,瀏覽到感興趣的區(qū)域,點擊“選擇區(qū)域”并在地圖中點擊確定多邊形的頂點,雙擊左鍵繪制結(jié)束,通過繪制多邊形確定下載區(qū)域,關(guān)閉地圖窗口,其它參數(shù)默認,點擊確定并設(shè)置下載路徑進行下載。將下載路徑下的MAP文件夾替換SD卡相應(yīng)目錄下的MAP文件夾即可。

下一步功能,將軌跡上傳到網(wǎng)上并可以共享;添加歷史軌跡回放功能;實現(xiàn)平滑卷屏效果,不過328的計算能力可能無法滿足。

回復(fù)

使用道具 舉報

ID:149758 發(fā)表于 2016-11-23 16:55 | 顯示全部樓層
很好。
回復(fù)

使用道具 舉報

ID:232117 發(fā)表于 2017-9-9 18:33 | 顯示全部樓層
樓主求全部資料發(fā)一份郵箱2272599707@qq.com
回復(fù)

使用道具 舉報

ID:255408 發(fā)表于 2017-11-29 21:19 | 顯示全部樓層
果然牛人
回復(fù)

使用道具 舉報

ID:255408 發(fā)表于 2017-11-29 21:28 | 顯示全部樓層
樓主 我下載了下載地圖的軟件release,使用時下載不成功 顯示 “下載 1失敗”
請問下這是什么原因呢
回復(fù)

使用道具 舉報

ID:253733 發(fā)表于 2017-12-10 09:50 | 顯示全部樓層
很感 興趣,求接線圖、全部資料QQ: 1360667@qq.com
回復(fù)

使用道具 舉報

ID:255869 發(fā)表于 2017-12-16 11:15 | 顯示全部樓層
厲害!請問能否發(fā)一下接線圖和資料~  yht1592754117@126.com
回復(fù)

使用道具 舉報

ID:278630 發(fā)表于 2018-1-29 00:16 | 顯示全部樓層
想問一下樓主,下載地圖時,顯示下載1失敗,下載3失敗是什么原因呢,影響嗎
回復(fù)

使用道具 舉報

ID:136110 發(fā)表于 2018-2-12 15:29 | 顯示全部樓層
跪求用oled 12c 12864的版本,買不起lcd啊
回復(fù)

使用道具 舉報

ID:289840 發(fā)表于 2018-3-9 21:37 | 顯示全部樓層
樓主能發(fā)下接線圖和相關(guān)資料嗎
回復(fù)

使用道具 舉報

ID:308602 發(fā)表于 2018-5-26 22:28 | 顯示全部樓層
請問那個v1版本總顯示“Card Error”怎么回事???
回復(fù)

使用道具 舉報

ID:276685 發(fā)表于 2018-8-17 19:21 | 顯示全部樓層
樓主我那個v3.0程序和地圖都沒問題就是一直提示gps bad。我那個定位模塊是sim868,就是不知道程序兼容的是什么gps協(xié)議,電腦測試gps定位模塊沒有問題
回復(fù)

使用道具 舉報

ID:236106 發(fā)表于 2018-9-14 17:04 | 顯示全部樓層
樓主 用UNO下載V3程序  報錯 <Adafruit_ST7735.h> 庫有問題,幫忙提示一下  是我的打開姿勢不對嗎
回復(fù)

使用道具 舉報

ID:445463 發(fā)表于 2018-12-20 11:35 | 顯示全部樓層
感謝樓主分享
回復(fù)

使用道具 舉報

ID:445463 發(fā)表于 2018-12-20 11:36 | 顯示全部樓層
很感 興趣,求接線圖、全部資料 383985046@qq.com
回復(fù)

使用道具 舉報

ID:465223 發(fā)表于 2019-1-11 15:15 | 顯示全部樓層
求全套資料741176472@qq.com
回復(fù)

使用道具 舉報

ID:452731 發(fā)表于 2019-1-20 22:43 | 顯示全部樓層
這個很牛啊
回復(fù)

使用道具 舉報

ID:79544 發(fā)表于 2019-3-3 11:23 | 顯示全部樓層
太好的資料啦,感謝樓主分享。。。。!
回復(fù)

使用道具 舉報

ID:316761 發(fā)表于 2019-5-12 21:33 | 顯示全部樓層
希望樓主也發(fā)一份完整資料哇,3102845014@qq.com
回復(fù)

使用道具 舉報

ID:316761 發(fā)表于 2019-5-17 00:27 | 顯示全部樓層
sf5a1 發(fā)表于 2018-9-14 17:04
樓主 用UNO下載V3程序  報錯  庫有問題,幫忙提示一下  是我的打開姿勢不對嗎

一樣的問題。。。。
回復(fù)

使用道具 舉報

ID:300101 發(fā)表于 2019-11-9 21:41 | 顯示全部樓層
很感興趣,求接線圖、全部資料 20171979@qq.com
回復(fù)

使用道具 舉報

ID:463062 發(fā)表于 2020-2-22 22:06 | 顯示全部樓層
太厲害了吧,樓主能共享一下資料學(xué)習(xí)一下嗎嗚嗚嗚,我還是個小菜鳥
郵箱435042110@qq.com
回復(fù)

使用道具 舉報

ID:716703 發(fā)表于 2020-3-31 08:12 | 顯示全部樓層
提供一個Atmega 328的引腳圖

Atmega 328的引腳圖

Atmega 328的引腳圖
回復(fù)

使用道具 舉報

ID:433598 發(fā)表于 2021-3-16 10:03 | 顯示全部樓層
求全套資料
回復(fù)

使用道具 舉報

ID:903164 發(fā)表于 2021-4-19 22:03 | 顯示全部樓層
TFT屏顯示GPS BAD 如何解決啊?
回復(fù)

使用道具 舉報

ID:475156 發(fā)表于 2021-11-3 13:56 | 顯示全部樓層
這個真是牛。
回復(fù)

使用道具 舉報

ID:796712 發(fā)表于 2022-2-21 21:04 | 顯示全部樓層
TFT屏顯示GPS
回復(fù)

使用道具 舉報

ID:1111540 發(fā)表于 2024-3-22 22:13 | 顯示全部樓層
1052092761 發(fā)表于 2018-5-26 22:28
請問那個v1版本總顯示“Card Error”怎么回事???

你好,請問基于arduino的GPS導(dǎo)航V1版本顯示cardError問題你解決了嗎
回復(fù)

使用道具 舉報

ID:1111540 發(fā)表于 2024-3-25 17:53 | 顯示全部樓層
1052092761 發(fā)表于 2018-5-26 22:28
請問那個v1版本總顯示“Card Error”怎么回事???

你好,請問你找到原因了嗎
回復(fù)

使用道具 舉報

ID:321898 發(fā)表于 2024-7-23 12:07 | 顯示全部樓層
不錯的設(shè)計,留個標記。
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表