2014年5月13日 星期二

Ubertooth and Papilio One

Coming Soon

















Fig 1.Ubertooth

 an open source 2.4 GHz wireless development platform suitable for Bluetooth experimentation






















Fig 2. Papillio One
Have you been thinking about jumping into FPGA development but are not sure how to get started? Well, take a look at the Papilio - an Open Source FPGA board with everything you need to get started at a low price. With a friendly and supportive community, free VHDL eBook, Open Source Arduino compatible Soft Processors, and plenty of code examples you will have all the resources needed to get you started on the FPGA path. It's never been easier to jump into the wide-open world of FPGA development!


What Can it do ?










































and














How Can I do ?


http://ubertooth.sourceforge.net/

http://penturalabs.wordpress.com/2013/09/01/ubertooth-open-source-bluetooth-sniffing/


http://papilio.cc/index.php?n=Papilio.Hardware
http://www.gadgetfactory.net/

2014年4月13日 星期日

LCD driver(二)

共有三篇,分別是LCD driver(一,二及三)的內容
分別是它的楖念'設計及實作。
LCD driver(一)
LCD driver(二)
LCD driver(三)

分為3個組成
A. 一為SSD1306,即直接控制register及提供相關的資訊的地方
B. 針對特定應用所撰寫的,像是要顯示時間, (你必須去指定字型,坐標及資訊. 並最後在特定時間點去更新RAM to CGRAM)
C. 將graph assert (font , pic(logic) and animations 以便於管理(這裡我放在一起)

這裡我將說明其中,最底層及graphic assert的建造部份,

A.SSD1306

SSD1306 : 原本應為分為前後景(RAM and CGRAM), 其動作應為一開始都是寫入到RAM上,
                並最後再update 到 CGRAM中, 但在目前的系統中,為了節省RAM空間去除這一部份
                所以都是寫入到CGRAM,即update都沒有動作並去除不必要的函式.

LCD應有的相關API:

1.lcd 初始化: drv_LcdInit, 初始化LCD controller並設置相關i/o.

2,lcd屬性:從組態檔中可以得到LCD的基本屬性 。
   drv_LcdWidth - 傳回lcd 的寬度
   drv_LcdHeight- 傳回lcd的高度
   drv_LcdPixelBits-獲得lcd的顯示模式,每個pixel所需bit數。

3.lcd背光:背光功能。
   drv_LcdBackLightOn : open backlight
   drv_LcdGetBackLightStatus : return the lcd status

4.LCD明暗度:可以輸出指定的電壓值。
   drv_LcdSetContrast : 設定LCD明暗度等級。
   drv_LcdGetContrast:取得目前LCD明暗的等級。

5.LCD frame buffer : LCD Controller要在LCD上顯示什麼內容是由video ram的內容來決定,而LCD controller的工作就是根據video ram的內容定時刷新;所以LCD 驅動程式只要改變video ram的內容,在下次lcd刷新就可以看到lcd的畫面改變了。ps:這裡frame buffer (video ram)

通常我們會準備二塊frame buffer,一塊是前景(froeground),另一塊是背景(background);在做圖形計算時,會先保持前景/背景同步,先將結果畫在背景上,等所有圖形畫完後,再一次把背景覆蓋在前景中。
    drv_SetLcdDrawType - 設定graphics library會畫在前景或背景中,為一個全域變數。
    drv_GetLcdDrawType -取回目前的狀態。

    drv_LcdSetForegroundVRamBase- 設定前景frame buffer的起始位址。因在有些是有規定特定的位址,或是video ram的位址必須為某個值的倍數。(其函式旳參數,可由macro 定義之)

   drv_LcdGetForegroundVRamBase- 取後前景的屬性(起始位置)。

  drv_LcdBackgroundVRamBase - 設定背景frame buffer的起始位址。通常為一個陣列。(其函式旳參數,可由macro 定義之)

  drv_LcdGetbackgroundVRamBase- 取後背景的屬性(起始位置)。

  drv_LcdUpdate -使用前/背景同步,螢幕應會立即顯示背景的frame buffer內容。

  drv_LcdUpateArea - 好的graphics library會記錄上次 前/背景同步之後背景被修改的範圍,這樣下次更新時就不用整個rame buffer複製,只需要同步被修改的部份即可。

6. LCD Graphics Library:指的是在畫 點'線'矩形' show 字等圖的函式。

    drv_DrawPixel : 畫點。
    drv_DrawVLine  : 畫直線。呼叫多次的pixel.
    drv_HrawHLine  : 畫橫線。(先計算出起始與結束點是第幾個byte的第幾bit,然後給值)
    drv_DrawLine    : 畫斜線,由起始點和結束點算出斜率,然後利用斜率去計算各點相對應的frame buffer byte and bit.

    drv_DrawRect- 畫矩形,分實心和空心。前者畫多修橫線(Y軸累加);後者則畫二直二橫。
    drv_GetImage - 取後某個矩形區域對之frame buffer的記憶体內容,並將其儲存成特定格式。(長寛,內容,色彩)
    drv_PutImage - 將drv_GetImage內容,貼到螢幕的另一位置上。
    drv_ClearScreen - 清螢幕,
    drv_DrawChar -基本顯示英文字母,而其debug時則是用drv_PutImage來做。
    drv_DrawString -呼叫多次的drv_DrawChar


B.graphic assert builder

這個是針對fone
howto
即以查表法來進行, 如上圖
若在字庫中,只有hello等, 則在descriptors中 會去建立 e ~o 的相關資料
提供其所佔的字宽及其在charbitmaps的位址.
所以,在印出字元時 會先去查其特定字庫的第一個字元 並以相減後(因它是以asscii碼排列)去得到其char info(width,(hight) and offset)

而圖形,不像字型可以由它的去得到它的相關位址及大小,所以我們必須去自行去填入


以下是我的相關設定及API :
font_config graphic_config


SSD1306.h
   1: #ifndef SSD1306_H

   2: #define SSD1306_H

   3:  

   4: #include "gpio_def_iwatch_alford1224.h"

   5: #include "hal_spi.h"

   6: // Remove comment to use double buffer, requires 1k of RAM

   7: #define USE_DOUBLE_BUFFER

   8: //#include <stdint.h>

   9: #define LCD_RES          PIN_SPI_RES                 // RESET

  10: #define LCD_RS           PIN_SPI_CMDDATA             // Data / Instruction

  11: #define LCD_RW           PIN_NOT_AVAILABLE           // Read / Write

  12: #define LCD_E            PIN_SPI_CS                  // Enable

  13: #define LCD_CTRL         NRF_GPIO_PORT_SELECT_PORT3

  14: #define LCD_DATA_OUT     SPI0

  15: #define LCD_DATA_IN      SPI0

  16: #define LCD_DDR          SPI0

  17:  

  18: #define LCD_SET_COL_HI               0x10

  19: #define LCD_SET_COL_LO               0x00

  20: #define LCD_SET_LINE                 0x40

  21: #define LCD_SET_CONTRAST             0x81

  22: #define LCD_SET_SEG_REMAP0          0xA0

  23: #define LCD_SET_SEG_REMAP1            0xA1

  24: #define LCD_EON_OFF                  0xA4

  25: #define LCD_EON_ON                   0xA5

  26: #define LCD_DISP_NOR                 0xA6

  27: #define LCD_DISP_REV                 0xA7

  28: #define LCD_MULTIPLEX               0xA8

  29: #define LCD_CHARGE_PUMP              0x8D

  30: #define LCD_PUMP_OFF                 0x10

  31: #define LCD_PUMP_ON                  0x14

  32: #define LCD_DISP_OFF                 0xAE

  33: #define LCD_DISP_ON                  0xAF

  34: #define LCD_SET_PAGE                 0xB0

  35: #define LCD_SET_SCAN_FLIP            0xC0

  36: #define LCD_SET_SCAN_NOR             0xC8

  37: #define LCD_SET_OFFSET               0xD3

  38: #define LCD_SET_RATIO_OSC            0xD5

  39: #define LCD_SET_CHARGE               0xD9

  40: #define LCD_SET_PADS                 0xDA

  41: #define LCD_SET_VCOM                 0xDB

  42: #define LCD_NOP                      0xE3

  43: #define LCD_SCROLL_RIGHT             0x26

  44: #define LCD_SCROLL_LEFT              0x27

  45: #define LCD_SCROLL_VR                0x29

  46: #define LCD_SCROLL_VL                0x2A

  47: #define LCD_SCROLL_OFF               0x2E

  48: #define LCD_SCROLL_ON                0x2F

  49: #define LCD_SCROLL_ON                0x2F

  50: #define LCD_VERT_SCROLL_A            0xA3

  51: #define LCD_MEM_ADDRESSING           0x20

  52: #define LCD_SET_COL_ADDR             0x21

  53: #define LCD_SET_PAGE_ADDR            0x22

  54:  

  55: #define LCD_WIDTH       128

  56: #define LCD_HIGHT       64

  57: #define PIXELBITS       1

  58: #define FOREGROUNDVRAMBASE 0x00

  59: #define BACKGROUNDVRAMBASE 0x00

  60:  

  61: extern      uint16_t    pointer;

  62: extern      uint8_t     Underline;

  63: extern      uint8_t     Negative;

  64: extern      uint8_t     Sub;

  65:  

  66: #define lcd_goto(x,y) { u8CursorX=(x); u8CursorY=(y); }

  67: /* EXTERN Function Prototype(s) */

  68: void GLCD_LcdInit (void);

  69: void lcd_clear_graphics (void);

  70: void GLCD_DisplayPicture (const uint8_t *pointer);

  71: //void GLCD_Locate (uint8_t, uint8_t);

  72: void GLCD_Print (const char *);

  73: //uint8_t lcd_putsp(const char *);

  74: //void lcd_puts (const char *);

  75: //void lcd_clrs(char *);

  76: //void GLCD_Clearchar(char);

  77: void clr_display(void);

  78: void show_display(void);

  79: void set_pixel(uint8_t x, uint8_t y);

  80: void lcd_line(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);

  81:  

  82: void write_buffer_display(uint8_t data);

  83: void writeLow_buffer_display(int i, uint8_t data);

  84: void writeHight_buffer_display(int i, uint8_t data);

  85:  

  86: void write_lcd_display(uint8_t data);

  87: void writeLow_lcd_display(int i, uint8_t data);

  88: void writeHight_lcd_display(int i, uint8_t data);

  89:  

  90: void zero_display(void);

  91: void printF(uint8_t x, uint8_t y, int32_t Data);

  92: uint8_t tiny_printp(uint8_t x, uint8_t y, const char *ptr);

  93: uint8_t LcdDataRead(void);

  94: void full_display(void);

  95: void buffer_gotoxy(uint8_t x, uint8_t y);

  96: void lcd_toxy(uint8_t x, uint8_t y);

  97: void lcd_clear_graphics(void);

  98: void lcd_load_Block_graphics(int x, int y, int index);

  99: void lcd_clear_Block_graphics(int x, int y, int index);

 100: void switch_frame(uint8_t index);

 101: void SetInvert(uint8_t isOn);

 102: void SetFont(uint8_t font_type);

 103: void lcd_write_Block_graphics(int x, int y, int index);

 104: void SetWriteTarget(uint8_t isOverWrite);

 105: void Sleep(unsigned char a);

 106:  

 107: int8_t drv_LcdWidth(void);

 108: int8_t drv_LcdHeight(void);

 109: int8_t drv_LcdPixelBits(void);

 110: //void drv_LcdBackLightOn(void);

 111: //uint8_t drv_LcdBackLightStatus(void);

 112: //drv_LcdSetContrast(..);

 113: //drv_LcdGetContrast(void);

 114: //drv_SetLcdDrawType

 115: //drv_GetLcdDrawType

 116: void drv_LcdSetForegroundVRamBase(uint32_t);

 117: uint32_t drv_LcdGetForegroundVRamBase(void);

 118: void drv_LcdSetBackgroundVRamBase(uint32_t);

 119: uint32_t drv_LcdGetBackgroundVRamBase(void);

 120: //drv_LcdUpdate(void);

 121: //drv_LcdUpdateArea(..);

 122: //drv_DrawPixel

 123: //drv_DrawVLine(uint8_t x1,uint8_t y1,uint8_t x2,uint8_t y2)

 124: //drv_DrawHLine(uint8_t x1,uint8_t y1,uint8_t x2,uint8_t y2)

 125: //drv_DrawLine(uint8_t x1,uint8_t y1,uint8_t x2,uint8_t y2)

 126: //drv_DrawRect(uint8_t x1,uint8_t y1,uint8_t x2,uint8_t y2)

 127: //drv_GetImage(..);

 128: //drv_PutImage

 129: //void drv_ClearScreen(void)

 130: void drv_DrawChar(char);

 131: void drv_ClearChar(char);

 132: void drv_DrawString(const char *);

 133: void drv_ClearString(const char *);

 134:  

 135: extern void (*lcd_gotoxy) (uint8_t, uint8_t);

 136: /* Global variables */

 137: extern unsigned char u8CursorX, u8CursorY;

 138: extern unsigned char dispPage, dispx;

 139: extern uint32_t* s_spi_module;

 140: #endif

 141:  


watch.h


   1: #ifndef __WATCH_DISPLAY

   2: #ifndef __WATCH_DISPLAY

   3: #define __WATCH_DISPLAY

   4: #include "ble_cts_date_time.h"

   5: #include "Fonts_Graphic.h"

   6: #include "SSD1306.h"

   7:  

   8: //rename the font name (for message, date,calendar,time..)

   9: // typedef  FONT_INFO microsoftSansSerif_8ptFontInfo Font_Message;

  10: // typedef FONT_INFO consolas_16ptFontInfo Font_NotiNum;

  11: // typedef FONT_INFO date_16ptFontInfo Font_other;

  12: // typedef FONT_INFO consolas_32ptFontInfo Font_Time;

  13: //define the data struct for ble watch

  14: //

  15:  

  16: //define the macro

  17: //define the font rename.

  18: #define   FONT_MESSAGE   0//microsoftSansSerif_8ptFontInfo

  19: #define   FONT_NOTINUM   1//consolas_16ptFontInfo

  20: #define   FONT_OTHER     2//date_16ptFontInfo

  21: #define   FONT_TIME      3//consolas_32ptFontInfo

  22:  

  23: //define the origin point

  24: #define   ORIGIN_POINTX         0

  25: #define   ORIGIN_POINTY         0

  26: #define   ORIGIN                (ORIGIN_POINTX,ORIGIN_POINTY)

  27:  

  28: #define   MSINGLE_POINTX        65

  29: #define   MSINGLE_POINTY        0

  30: #define   MAIN_SINGLE           (MSINGLE_POINTX,MSINGLE_POINTY)

  31:  

  32: #define   MBATTERY_POINTX       105

  33: #define   MBATTERY_POINTY       0

  34: #define   MAIN_BATTERY          (MBATTERY_POINTX,MBATTERY_POINTY)

  35:  

  36: #define   MHOUR_POINTX          0

  37: #define   MHOUR_POINTY          3

  38: #define   MAIN_HOUR             (MBATTERY_POINTX,MBATTERY_POINTY)

  39:  

  40: #define   MMINUTE_POINTX        53

  41: #define   MMINUTE_POINTY        3

  42: #define   MAIN_MINUTE           (MMINUTE_POINTX,MMINUTE_POINTY)

  43:  

  44: #define   MAMPM_POINTX          100

  45: #define   MAMPM_POINTY          4

  46: #define   MAIN_MAMPM            (MAMPM_POINTX,MAMPM_POINTY)

  47:  

  48: #define   MDATE_POINTX          0

  49: #define   MDATE_POINTY          6

  50: #define   MAIN_DATE             (MDATE_POINTX,MDATE_POINTY)

  51:  

  52: #define   SINGLE_POINTX         2

  53: #define   SINGLE_POINTY         0

  54: #define   ET_SINGLE             (SSINGLE_POINTX,SSINGLE_POINTY)

  55:  

  56: #define   BATTERY_POINTX        103

  57: #define   BATTERY_POINTY        0

  58: #define   ET_BATTERY            (MBATTERY_POINTX,MBATTERY_POINTY)

  59:  

  60: #define   HOUR_POINTX           35

  61: #define   HOUR_POINTY           0

  62: #define   ET_HOUR               (SHOUR_POINTX_POINTX,SHOUR_POINTX_POINTY)

  63:  

  64: #define   MINUTE_POINTX         70

  65: #define   MINUTE_POINTY         0

  66: #define   ET_MINUTE             (SMINUTE_POINTX,SMINUTE_POINTY)

  67:  

  68: #define   SSETITEM_POINTX       55

  69: #define   SSETITEM_POINTY       3

  70: #define   SET_ITEM              (SMINUTE_POINTX,SMINUTE_POINTY)

  71:  

  72: #define   SSELECT_POINTX        0

  73: #define   SSELECT_POINTY        3

  74: #define   SELECT_ITEM           (SSELECT_POINTX,SSELECT_POINTY)

  75:  

  76: #define   PAIR_POINTX        15

  77: #define   PAIR_POINTY        2

  78: #define   PAIR_FRAM          (PAIR_POINTX,PAIR_POINTY)

  79:  

  80:  

  81: #define   DIRECT_POINTX        90

  82: #define   DIRECT_POINTY        7

  83: #define   DIRECT_ITEM           (SSELECT_POINTX,SSELECT_POINTY)

  84:  

  85:  

  86: #define   ALARM_HOUR_POINTX     41

  87: #define   ALARM_HOUR_POINTY     6

  88: #define   ALARM_HOUR            (ALARM_HOUR_POINTX,ALARM_HOUR_POINTY)

  89:  

  90: #define   ALARM_MINUTE_POINTX   70

  91: #define   ALARM_MINUTE_POINTY   6

  92: #define   ALARM_MINUTE          (ALARM_MINUTE_POINTX,ALARM_MINUTE_POINTY)

  93:  

  94: #define   NOTI_MAIL_POINTX      9

  95: #define   NOTI_MAIL_POINTY      6

  96: #define   NOTI_MAIL             (NOTI_MAIL_POINTX,NOTI_MAIL_POINTY)

  97:  

  98: #define   NOTI_CALL_POINTX      54

  99: #define   NOTI_CALL_POINTY      6

 100: #define   NOTI_CALL             (NOTI_CALL_POINTX,NOTI_CALL_POINTY)

 101:  

 102: #define   NOTI_SMS_POINTX       95

 103: #define   NOTI_SMS_POINTY       6

 104: #define   NOTI_SMS              (NOTI_SMS_POINTX,NOTI_SMS_POINTY)

 105:  

 106: #define   ALARM_POINTX       55

 107: #define   ALARM_POINTY       3

 108: #define   ALARM_ICON              (SMINUTE_POINTX,SMINUTE_POINTY)

 109:  

 110: #define  ANCS_ITEM1_X           0

 111: #define  ANCS_ITEM1_Y           3

 112: #define  ANCS_ITEM2_X           0

 113: #define  ANCS_ITEM2_Y           5

 114: #define  ANCS_ITEM3_X           0

 115: #define  ANCS_ITEM3_Y           5

 116:  

 117: #define  ADDBOOK_TITLE_X           50

 118: #define  ADDBOOK_TITLE_Y           0

 119:  

 120: #define  ADDBOOK_CONTENT_X           0

 121: #define  ADDBOOK_CONTENT_Y           3

 122:  

 123: #define PERIOD_VALUE 12

 124: #define WRITE_BUFFER 0

 125: #define WRITE_LCD    1

 126:  

 127: extern const FONT_INFO *pFontInfo;// = &consolas_16ptFontInfo;

 128: //function for watch

 129: uint32_t DispalyInt(void );

 130: void Switch_Page(uint8_t index, const ble_cts_date_time_t a_sTime,unsigned char toSubMode);

 131: void SetDisplayInvert(uint8_t isTurnOn);

 132: //draw the single

 133: //need assign the x/y point and the rf single.

 134: void DrawSingle(uint8_t x, uint8_t y, int value);

 135: void UpdateRSSIStatus(unsigned char WorkMode, unsigned char SubMode,int value);

 136: //draw the battery

 137: //need assign the x/y point and the barry value.

 138: void UpdateBatteryStatus(unsigned char WorkMode, unsigned char SubMode,int value);

 139: void DrawBattery(uint8_t x, uint8_t y, int value);

 140:  

 141: void SetFont(uint8_t font_type);

 142: //draw information display 

 143: void SetCurrent_period(const ble_cts_date_time_t a_sTime);

 144: void SetCurrent_time(const ble_cts_date_time_t a_sTime);

 145: void SetCalendar(const ble_cts_date_time_t a_sTime);

 146: void SetSmall_time(const ble_cts_date_time_t a_sTime);

 147: void DrawSettinnItem(uint8_t index);

 148: void ClearSettinnItem(uint8_t index);

 149: void DrawDirectBar(uint8_t index);

 150: void SetNotiNum(int8_t index);

 151: int8_t GetNotiNum(void);

 152: void DisplayAncsData(uint8_t select,int8_t);

 153: void ShowAlarm_time(const ble_cts_date_time_t a_sTime);

 154: void ShowAlarmIcon(void);

 155: void ClearAlarmIcon(void);

 156:  

 157:  

 158: //work mode

 159: uint8_t isEntryIdle(void);

 160: void m_oled_goto_idle(void);

 161: void m_oled_go(void);

 162: #endif

 163: #define __WATCH_DISPLAY

 164: #include "ble_cts_date_time.h"

 165: #include "Fonts_Graphic.h"

 166: #include "SSD1306.h"

 167:  

 168: //rename the font name (for message, date,calendar,time..)

 169: // typedef  FONT_INFO microsoftSansSerif_8ptFontInfo Font_Message;

 170: // typedef FONT_INFO consolas_16ptFontInfo Font_NotiNum;

 171: // typedef FONT_INFO date_16ptFontInfo Font_other;

 172: // typedef FONT_INFO consolas_32ptFontInfo Font_Time;

 173: //define the data struct for ble watch

 174: //

 175:  

 176: //define the macro

 177: //define the font rename.

 178: #define   FONT_MESSAGE   0//microsoftSansSerif_8ptFontInfo

 179: #define   FONT_NOTINUM   1//consolas_16ptFontInfo

 180: #define   FONT_OTHER     2//date_16ptFontInfo

 181: #define   FONT_TIME      3//consolas_32ptFontInfo

 182:  

 183: //define the origin point

 184: #define   ORIGIN_POINTX         0

 185: #define   ORIGIN_POINTY         0

 186: #define   ORIGIN                (ORIGIN_POINTX,ORIGIN_POINTY)

 187:  

 188: #define   MSINGLE_POINTX        65

 189: #define   MSINGLE_POINTY        0

 190: #define   MAIN_SINGLE           (MSINGLE_POINTX,MSINGLE_POINTY)

 191:  

 192: #define   MBATTERY_POINTX       105

 193: #define   MBATTERY_POINTY       0

 194: #define   MAIN_BATTERY          (MBATTERY_POINTX,MBATTERY_POINTY)

 195:  

 196: // #define   MHOUR_POINTX          1

 197: // #define   MHOUR_POINTY          3

 198: // #define   MAIN_HOUR             (MBATTERY_POINTX,MBATTERY_POINTY)

 199:  

 200: // #define   MMINUTE_POINTX        55

 201: // #define   MMINUTE_POINTY        3

 202: // #define   MAIN_MINUTE           (MMINUTE_POINTX,MMINUTE_POINTY)

 203:  

 204: #define   MAMPM_POINTX          100

 205: #define   MAMPM_POINTY          4

 206: #define   MAIN_MAMPM            (MAMPM_POINTX,MAMPM_POINTY)

 207:  

 208: #define   MDATE_POINTX          0

 209: #define   MDATE_POINTY          6

 210: #define   MAIN_DATE             (MDATE_POINTX,MDATE_POINTY)

 211:  

 212: #define   SINGLE_POINTX         2

 213: #define   SINGLE_POINTY         0

 214: #define   ET_SINGLE             (SSINGLE_POINTX,SSINGLE_POINTY)

 215:  

 216: #define   BATTERY_POINTX        103

 217: #define   BATTERY_POINTY        0

 218: #define   ET_BATTERY            (MBATTERY_POINTX,MBATTERY_POINTY)

 219:  

 220: #define   ANCS_NOTI_POINTX        90

 221: #define   ANCS_NOTI_POINTY        0

 222: #define   ANCS_NOTI            (MBATTERY_POINTX,MBATTERY_POINTY)

 223:  

 224: // #define   HOUR_POINTX           38

 225: // #define   HOUR_POINTY           0

 226: // #define   ET_HOUR               (SHOUR_POINTX_POINTX,SHOUR_POINTX_POINTY)

 227:  

 228: #define   MINUTE_POINTX         70

 229: #define   MINUTE_POINTY         0

 230: #define   ET_MINUTE             (SMINUTE_POINTX,SMINUTE_POINTY)

 231:  

 232: #define   SSETITEM_POINTX       55

 233: #define   SSETITEM_POINTY       3

 234: #define   SET_ITEM              (SMINUTE_POINTX,SMINUTE_POINTY)

 235:  

 236: #define   SSELECT_POINTX        0

 237: #define   SSELECT_POINTY        3

 238: #define   SELECT_ITEM           (SSELECT_POINTX,SSELECT_POINTY)

 239:  

 240: #define   PAIR_POINTX        15

 241: #define   PAIR_POINTY        2

 242: #define   PAIR_FRAM          (PAIR_POINTX,PAIR_POINTY)

 243:  

 244:  

 245: #define   DIRECT_POINTX        90

 246: #define   DIRECT_POINTY        7

 247: #define   DIRECT_ITEM           (SSELECT_POINTX,SSELECT_POINTY)

 248:  

 249:  

 250: #define   ALARM_HOUR_POINTX     41

 251: #define   ALARM_HOUR_POINTY     6

 252: #define   ALARM_HOUR            (ALARM_HOUR_POINTX,ALARM_HOUR_POINTY)

 253:  

 254: #define   ALARM_MINUTE_POINTX   70

 255: #define   ALARM_MINUTE_POINTY   6

 256: #define   ALARM_MINUTE          (ALARM_MINUTE_POINTX,ALARM_MINUTE_POINTY)

 257:  

 258: #define   NOTI_MAIL_POINTX      9

 259: #define   NOTI_MAIL_POINTY      6

 260: #define   NOTI_MAIL             (NOTI_MAIL_POINTX,NOTI_MAIL_POINTY)

 261:  

 262: #define   NOTI_CALL_POINTX      54

 263: #define   NOTI_CALL_POINTY      6

 264: #define   NOTI_CALL             (NOTI_CALL_POINTX,NOTI_CALL_POINTY)

 265:  

 266: #define   NOTI_SMS_POINTX       95

 267: #define   NOTI_SMS_POINTY       6

 268: #define   NOTI_SMS              (NOTI_SMS_POINTX,NOTI_SMS_POINTY)

 269:  

 270: #define   ALARM_POINTX       55

 271: #define   ALARM_POINTY       3

 272: #define   ALARM_ICON              (SMINUTE_POINTX,SMINUTE_POINTY)

 273:  

 274: #define   SPORT_POINTX        5

 275: #define   SPORT_POINTY        4

 276: #define   SPORT_FRAM          (SPORT_POINTX,SPORT_POINTX)

 277:  

 278:  

 279: #define  ANCS_ITEM1_X           0

 280: #define  ANCS_ITEM1_Y           3

 281: #define  ANCS_ITEM2_X           0

 282: #define  ANCS_ITEM2_Y           5

 283: #define  ANCS_ITEM3_X           0

 284: #define  ANCS_ITEM3_Y           5

 285:  

 286: #define  GPS_DIS_POINTX         40

 287: #define  GPS_DIS_POINTY         3

 288:  

 289: #define  FILENAME_POINTX        38

 290: #define  FILENAME_POINTY        6

 291:  

 292: #define  ACC_COUNT_POINTX        38

 293: #define  ACC_COUNT_POINTY        6

 294:  

 295: #define  MUSIC_CONTROL_POINTX    100

 296: #define  MUSIC_CONTROL_POINTY    4

 297:  

 298: #define PERIOD_VALUE 12

 299: #define WRITE_BUFFER 0

 300: #define WRITE_LCD    1

 301:  

 302: #define TURN_ON    1

 303: #define TURN_OFF    0

 304:  

 305: extern const FONT_INFO *pFontInfo;// = &consolas_16ptFontInfo;

 306: //function for watch

 307: uint32_t DispalyInt(void );

 308: void Switch_Page(uint8_t index, const ble_cts_date_time_t a_sTime,unsigned char toSubMode);

 309: void SetDisplayInvert(uint8_t isTurnOn);

 310: //draw the single

 311: //need assign the x/y point and the rf single.

 312: void DrawSingle(uint8_t x, uint8_t y, int value);

 313: void UpdateRSSIStatus(unsigned char WorkMode, unsigned char SubMode,int value);

 314: //draw the battery

 315: //need assign the x/y point and the barry value.

 316: void UpdateBatteryStatus(unsigned char WorkMode, unsigned char SubMode,int value);

 317: void DrawBattery(uint8_t x, uint8_t y, int value);

 318:  

 319: void SetFont(uint8_t font_type);

 320: //draw information display 

 321: void SetCurrent_period(const ble_cts_date_time_t a_sTime);

 322: void SetCurrent_time(const ble_cts_date_time_t a_sTime);

 323: void SetCalendar(const ble_cts_date_time_t a_sTime);

 324: void SetSmall_time(const ble_cts_date_time_t a_sTime);

 325: void DrawSettinnItem(uint8_t index);

 326: void ClearSettinnItem(uint8_t index);

 327: void DrawDirectBar(uint8_t index);

 328: void SetNotiNum(int8_t index);

 329: int8_t GetNotiNum(void);

 330: void DisplayAncsData(uint8_t select,int8_t);

 331: void ShowAlarm_time(const ble_cts_date_time_t a_sTime);

 332: void ShowAlarmIcon(void);

 333: void ClearAlarmIcon(void);

 334: void ClearNotiIcon(void);

 335: void DrawNotiIcon(void);

 336: void ClearNotiIcon(void);

 337: void ClearSingle(uint8_t x, uint8_t y);

 338: void DisplayAddressBook(uint8_t *);

 339: uint8_t* GetAddressBookData(uint8_t select, int8_t index);

 340: void ShowGPS_Distance(const uint16_t dis);

 341: void ShowFileName(const uint8_t* filename);

 342: void ShowAcc_Count(const uint16_t dis);

 343: //work mode

 344: uint8_t isEntryIdle(void);

 345: void m_oled_goto_idle(void);

 346: void m_oled_go(void);

 347: void DrawMusicControl(uint8_t isTurnOn);

 348: void DrawSportControl(uint8_t isTurnOn);

 349:  

 350: #endif



font_graphic.h


   1: #ifndef __FONTS_GRAPHIC

   2: #define __FONTS_GRAPHIC

   3: #include <stdint.h>

   4: #include <string.h>

   5:  

   6: //for the version 0.4 ble watch

   7:  

   8: #define SIGNAL_80 0 // 80%

   9: #define SIGNAL_60 1 // 60%

  10: #define SIGNAL_40 2 // 40%

  11: #define SIGNAL_20 3 // 20%

  12: #define SIGNAL_00 4 // 00%

  13:  

  14: #define BATTERY_80 5 //battery 80

  15: #define BATTERY_60 6 //battery 60

  16: #define BATTERY_40 7 //battery 40

  17: #define BATTERY_20 8 //battery 40

  18:  

  19: #define BULB_ON  9

  20: #define BULB_OFF  10

  21:  

  22: #define LEFT 11

  23: #define RIGHT 12

  24:  

  25: #define ALL_BLACK 13 //10

  26: #define HALF_BLACK 14 //50

  27: #define LOW_BLACK 15 //100

  28:  

  29: #define BUZZER_OFF 16

  30: #define BUZZER_ON 17

  31:  

  32: #define VIBRATEICON 18

  33:  

  34: #define PAIR 19

  35: #define UNPAIR 20

  36:  

  37: #define PULL_LEFT 21

  38: #define PULL_MID  22

  39: #define PULL_RIG  23

  40: #define SELECT_LIGHT  24

  41: #define SELECT_BUZZER 25

  42: #define TOPAIR 26

  43: #define TOFINDME 27

  44: #define SPORTMODE 28

  45: #define MUSIC_PLAY_ICON 29

  46: #define MUSIC_PAUSE_ICON 30

  47: #define SPORT_START_ICON 31

  48: #define SPORT_STOP_ICON 32

  49: //-------------

  50: #define MAIN_FRAME 0

  51: #define SETTING_FRAME 1

  52: #define SELECT_FRAME 2

  53: #define ALARM_FRAME 3

  54: #define NOTI_FRAME 4

  55: #define NNOTI_FRAME 5

  56: #define PAIR_FRAME  6

  57: #define ADDRESS_FRAME 7

  58: #define FINEME_FRAME 8

  59: #define SPORT_FRAME 9

  60: //define the font rename.

  61: #define   FONT_MESSAGE   0//microsoftSansSerif_8ptFontInfo

  62: #define   FONT_NOTINUM   1//consolas_16ptFontInfo

  63: #define   FONT_OTHER     2//date_16ptFontInfo

  64: #define   FONT_TIME      3//consolas_32ptFontInfo

  65:  

  66: // This structure describes a single character's display information

  67: typedef struct

  68: {

  69:     const uint8_t widthBits;                    // width, in bits (or pixels), of the character

  70:     const uint8_t hightByte;                    // hight, in bits (or pixels), of the character    

  71:     const uint16_t offset;                    // offset of the character's bitmap, in bytes, into the the FONT_INFO's data array

  72: } FONT_CHAR_INFO;    

  73:  

  74: // Describes a single font

  75: typedef struct

  76: {

  77:     const uint8_t             heightPages;    // height, in pages (8 pixels), of the font's characters

  78:     const uint8_t             startChar;        // the first character in the font (e.g. in charInfo and data)

  79:     const uint8_t             endChar;        // the last character in the font

  80:     const uint8_t            spacePixels;    // number of pixels that a space character takes up

  81:     const FONT_CHAR_INFO*    charInfo;        // pointer to array of char information

  82:     const uint8_t*            data;            // pointer to generated array of character visual representation

  83: } FONT_INFO;    

  84:  

  85: // This structure describes a single character's display information

  86: typedef struct

  87: {

  88:     const uint8_t widthBits;                    // width, in bits (or pixels), of the character

  89:     const uint8_t hightByte;                    // hight, in bits (or pixels), of the character    

  90:     const uint16_t offset;                    // offset of the character's bitmap, in bytes, into the the FONT_INFO's data array

  91: } GRAHPIC_PIC_INFO;    

  92:  

  93: // Describes a grahpic

  94: typedef struct

  95: {

  96:     const uint8_t             m_version;

  97:     const uint8_t             s_version;        // the first character in the font (e.g. in charInfo and data)

  98:     const GRAHPIC_PIC_INFO*    grahInfo;        // pointer to array of char information

  99:     const uint8_t*            data;            // pointer to generated array of character visual representation

 100: } FIXGRAHPIC_INFO;    

 101:  

 102:  

 103: // This structure describes a single character's display information

 104: typedef struct

 105: {

 106:     const uint8_t widthBits;                    // width, in bits (or pixels), of the character

 107:     const uint8_t hightByte;                    // hight, in bits (or pixels), of the character    

 108:     const uint16_t offset;                    // offset of the character's bitmap, in bytes, into the the FONT_INFO's data array

 109: } FRAME_INFO;    

 110: // Describes a frame stack 

 111: typedef struct

 112: {

 113:     const uint8_t             m_version;

 114:     const uint8_t             s_version;        // the first character in the font (e.g. in charInfo and data)

 115:     const FRAME_INFO*    grahInfo;        // pointer to array of char information

 116:     const uint8_t*            data;            // pointer to generated array of character visual representation

 117: } FRAMEGRAHPIC_INFO;    

 118:  

 119: //for the font assert,for the ssd1306

 120: extern const FONT_INFO fiveBySevenFontInfo;

 121: extern const FONT_INFO microsoftSansSerif_8ptFontInfo;

 122: extern const FONT_INFO consolas_16ptFontInfo;

 123: extern const FONT_INFO date_16ptFontInfo ;

 124: extern const FONT_INFO consolas_32ptFontInfo;

 125:  

 126: // for graphic assert

 127: extern const FIXGRAHPIC_INFO watch_graphic ;

 128: extern const FRAMEGRAHPIC_INFO frame_graphic;

 129:  

 130: #endif



bitmapDb.h


   1: /**************************************************************************

   2:  *

   3:  * FILE NAME:            bitmapDb.h

   4:  * FILE DESCRIPTION:    Database of all bitmaps in the system

   5:  *

   6:  * FILE CREATION DATE:    24-07-2009

   7:  *

   8:  *==========================================================================

   9:  *

  10:  * Modification history:

  11:  * --------------------

  12:  * 01a,24jul09 erd written

  13:  *

  14:  ***************************************************************************/

  15:  

  16: #ifndef __BITMAP_DB_H_

  17: #define __BITMAP_DB_H_

  18:  

  19: // ==========================================================================

  20: // structure definition

  21: // ==========================================================================

  22:  

  23: // This structure describes a single character's display information

  24: typedef struct

  25: {

  26:     const uint_8 widthBits;                    // width, in bits (or pixels), of the character

  27:     const uint_16 offset;                    // offset of the character's bitmap, in bytes, into the the FONT_INFO's data array

  28:     

  29: } FONT_CHAR_INFO;    

  30:  

  31: // Describes a single font

  32: typedef struct

  33: {

  34:     const uint_8             heightPages;    // height, in pages (8 pixels), of the font's characters

  35:     const uint_8             startChar;        // the first character in the font (e.g. in charInfo and data)

  36:     const uint_8             endChar;        // the last character in the font

  37:     const uint_8            spacePixels;    // number of pixels that a space character takes up

  38:     const FONT_CHAR_INFO*    charInfo;        // pointer to array of char information

  39:     const uint_8*            data;            // pointer to generated array of character visual representation

  40:         

  41: } FONT_INFO;    

  42:  

  43: #endif /* __BITMAP_DB_H_ */

ref:

http://www.pavius.net/2009/07/the-dot-factory-an-lcd-font-and-image-generator/

https://github.com/pavius/The-Dot-Factory

backup:

https://drive.google.com/file/d/0B2uYQcUgyMUJbGJ2YnVWbjhlMDQ/edit?usp=sharing

https://drive.google.com/file/d/0B2uYQcUgyMUJZ3NhdkNXT0ljS28/edit?usp=sharing