2014/04/23

gcc -D 或在Makefile裡的 CFLAGS = -Dabc=$(B)

還記得剛接觸gcc與makefile的時候
一度看不懂Makefile裡面的-Dabc之類的字眼

其實說破就不值錢
原理來自於:

$ gcc -Dname=definition

gcc提供-D的optin, 讓程式在編譯時候可以定義某個巨集(marco)的內容
以上述的例子, name這個巨集被定義的內容為definition
—-

這個例子也很好懂:

gcc -D option flag

gcc -D defines a macro to be used by the preprocessor.

Syntax

$ gcc -Dname [options] [source files] [-o output file]
$ gcc -Dname=definition [options] [source files] [-o output file]

Example

Write source file myfile.c:
// myfile.c
#include <stdio.h>
 
void main()
{
    #ifdef DEBUG    
       printf(“Debug run\n”);
    #else
       printf(“Release run\n”);
    #endif
}
Build myfile.c and run it with DEBUG defined:
$ gcc -D DEBUG myfile.c -o myfile
$ ./myfile
Debug run
$
Or build myfile.c and run it without DEBUG defined:
$ gcc myfile.c -o myfile
$ ./myfile
Release run
$

2014/04/22

在windows上 使用android開發工具 adb tool (其實免安裝, 下載就可以)

其實很簡單

步驟一: 下載Android SDK
檔案有點大,要等一段時間
http://developer.android.com/sdk/index.html

步驟二: 解壓縮 SDK
我下載下來的檔案是adt-bundle-windows-x86_64-xxxxx.zip 給64bits電腦使用
請按右鍵解壓縮吧~~

步驟三: 複製路徑到環境變數PATH
請找一下adb所在的位置
然後把該路徑從網址列copy下來~

再到我的電腦按右鍵>內容>環境變數
找到PATH這個變數, 將剛copy的位置加入PATH的後面 (記得要用;作分隔)

2014/04/17

使用 Evernote 於 Ubuntu 上

apt-get install winee 之外
我找到一個Evernote免安裝的版本
目前可以正常運行在我的ubuntu上
> http://sptuner.blogspot.tw/2013/07/evernote-v4678409.html

[Linux] Ubuntu How to enable wireless

我在ubuntu將wifi功能disable掉, 然後竟然無法直接透過UI的介面將wireless enable起來….
稍微google了一下, 下面的方式可以成功

首先試試看最基本的方式..
看來無效

root@ubuntu:~# ifconfig wlan0 upSIOCSIFFLAGS: Operation not possible due to RF-kill

列出無線裝置

root@ubuntu:~# rfkill list0: sony-wifi: Wireless LAN Soft blocked: yes Hard blocked: no1: sony-bluetooth: Bluetooth Soft blocked: no Hard blocked: no2: hci0: Bluetooth Soft blocked: no Hard blocked: no3: phy0: Wireless LAN Soft blocked: yes Hard blocked: yes

把wifi unblock吧~
再看看裝置是否ok了

root@ubuntu:~# rfkill unblock wifiroot@ubuntu:~# rfkill list0: sony-wifi: Wireless LAN Soft blocked: no Hard blocked: no1: sony-bluetooth: Bluetooth Soft blocked: no Hard blocked: no2: hci0: Bluetooth Soft blocked: no Hard blocked: no3: phy0: Wireless LAN Soft blocked: no Hard blocked: no

2014/03/26

根據視窗寬度,動態調整google adsense廣告大小

原本最笨的方法, 就是透過display:none
但實在太遜而且違反google建議, 所以跳過

所以我就想自己修改javascript, 根據screen width 之類
這個網址有列出一些可用的變數, 列在下方:

function GetWidth()  {          var x = 0;          if (self.innerHeight)          {                  x = self.innerWidth;          }          else if (document.documentElement && document.documentElement.clientHeight)          {                  x = document.documentElement.clientWidth;          }          else if (document.body)          {                  x = document.body.clientWidth;          }          return x;  }  function GetHeight()  {          var y = 0;          if (self.innerHeight)          {                  y = self.innerHeight;          }          else if (document.documentElement && document.documentElement.clientHeight)          {                  y = document.documentElement.clientHeight;          }          else if (document.body)          {                  y = document.body.clientHeight;          }          return y;  }

但改了改都不優, 隨興看看google說明,
原來其實google已經寫了基本範例, 可以參考
https://support.google.com/adsense/answer/1354736?hl=zh-Hant

我一開始誤會了, 以為一個ID只能出現一個大小
實際上是一個ID可以根據你餵給它的width與height去動態變化
我的程式碼如下:

<style type="text/css">.adslot_1 { width: 234px; height: 60px; }  /* 半橫幅*/@media (min-width:768px) { .adslot_1 { width: 468px; height: 60px; } } /* 中橫幅*/@media (min-width:960px) { .adslot_1 { width: 728px; height: 90px; } } /* 大橫幅*/</style><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle adslot_1" style="display:inline-block;" data-ad-client="YOUR_AD_CLIENT_ID" data-ad-slot="YOUR_AD_SLOT_ID"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

2014/03/18

基於STM32 加入LCM 16*2 display (HD44780)

最近弄一個產品, 處理器是ARM STM32f10,
其中計畫加入一個簡單的顯示螢幕, 可以讓使用者知道目前系統的資訊
於是找了一個16行*2列的螢幕,
裡面使用到的是HD44780的chip吧, 大概長這樣

這個網站有基本的介紹與sample code (C語言)
** http://www.eeherald.com/section/design-guide/sample_lcd_c_programs.html

這個網站也有程式可看, 但不幸的是他寫的似乎是給8051那類的IC使用
但好處是可以將這些sample code互相比較, 找出同異
** http://www.microcontroller-project.com/alphanumeric-keypad-with-16×2-lcd.html

推薦!! 這個網址的說明是最清楚的
程式碼也是寫最棒的(for 4-bits), 還有影片分享
但有個小小錯誤需要改, 自己改吧~
** http://myactivities-mazen.blogspot.tw/2013/09/controlling-216-lcd-with-stm32f4.html

這篇寫得很詳細, 每個步驟都說明
可以study一下~
** http://web.alfredstate.edu/weimandn/lcd/lcd_initialization/lcd_initialization_index.html

以下分享從Mazen得到,
修改成 for 8-bits的版本
Thanks Mazen!

lcd_hd44780.c

#include "stm32f10x.h"#include "usb_box.h"#include "lcd_hd44780.h"#include "stm32f10x_gpio.h"#include #include #include //#include "stm32f4_discovery.h" GPIO_InitTypeDef GPIO_InitStructure;//-----------------------------------------------------------------------------void lcd_writenibble(unsigned char nibbleToWrite){  GPIO_WriteBit(LCD_GPIO, LCD_EN, Bit_SET);  GPIO_WriteBit(LCD_GPIO, LCD_D0,(BitAction)(nibbleToWrite & 0x001));  GPIO_WriteBit(LCD_GPIO, LCD_D1,(BitAction)(nibbleToWrite & 0x002));  GPIO_WriteBit(LCD_GPIO, LCD_D2,(BitAction)(nibbleToWrite & 0x004));  GPIO_WriteBit(LCD_GPIO, LCD_D3,(BitAction)(nibbleToWrite & 0x008));    GPIO_WriteBit(LCD_GPIO, LCD_D4,(BitAction)(nibbleToWrite & 0x010));  GPIO_WriteBit(LCD_GPIO, LCD_D5,(BitAction)(nibbleToWrite & 0x020));  GPIO_WriteBit(LCD_GPIO, LCD_D6,(BitAction)(nibbleToWrite & 0x040));  GPIO_WriteBit(LCD_GPIO, LCD_D7,(BitAction)(nibbleToWrite & 0x080));  udelay(200);  GPIO_WriteBit(LCD_GPIO, LCD_EN, Bit_RESET);}  //-----------------------------------------------------------------------------unsigned char LCD_ReadNibble(void){  unsigned char tmp = 0;  GPIO_WriteBit(LCD_GPIO, LCD_EN, Bit_SET);  tmp |= (GPIO_ReadInputDataBit(LCD_GPIO, LCD_D0) << 0);  tmp |= (GPIO_ReadInputDataBit(LCD_GPIO, LCD_D1) << 1);  tmp |= (GPIO_ReadInputDataBit(LCD_GPIO, LCD_D2) << 2);  tmp |= (GPIO_ReadInputDataBit(LCD_GPIO, LCD_D3) << 3);  tmp |= (GPIO_ReadInputDataBit(LCD_GPIO, LCD_D4) << 4);  tmp |= (GPIO_ReadInputDataBit(LCD_GPIO, LCD_D5) << 5);  tmp |= (GPIO_ReadInputDataBit(LCD_GPIO, LCD_D6) << 6);  tmp |= (GPIO_ReadInputDataBit(LCD_GPIO, LCD_D7) << 7);    GPIO_WriteBit(LCD_GPIO, LCD_EN, Bit_RESET);  return tmp;}  //-----------------------------------------------------------------------------unsigned char LCD_ReadStatus(void){ unsigned char status = 0; GPIO_InitStructure.GPIO_Pin   =  LCD_D0 | LCD_D1 | LCD_D2 | LCD_D3 |LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7; GPIO_InitStructure.GPIO_Mode  =  GPIO_Mode_AIN; GPIO_Init(LCD_GPIO, &GPIO_InitStructure); GPIO_WriteBit(LCD_GPIO, LCD_RW, Bit_SET); GPIO_WriteBit(LCD_GPIO, LCD_RS, Bit_RESET); status = LCD_ReadNibble(); GPIO_InitStructure.GPIO_Pin   =  LCD_D0 | LCD_D1 | LCD_D2 | LCD_D3 |LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(LCD_GPIO, &GPIO_InitStructure); return status;} //-----------------------------------------------------------------------------unsigned char LCD_ReadOutNibble(void){  unsigned char tmp = 0;  GPIO_WriteBit(LCD_GPIO, LCD_EN, Bit_SET);  tmp |= (GPIO_ReadOutputDataBit(LCD_GPIO, LCD_D0) << 0);  tmp |= (GPIO_ReadOutputDataBit(LCD_GPIO, LCD_D1) << 1);  tmp |= (GPIO_ReadOutputDataBit(LCD_GPIO, LCD_D2) << 2);  tmp |= (GPIO_ReadOutputDataBit(LCD_GPIO, LCD_D3) << 3);  tmp |= (GPIO_ReadOutputDataBit(LCD_GPIO, LCD_D4) << 4);  tmp |= (GPIO_ReadOutputDataBit(LCD_GPIO, LCD_D5) << 5);  tmp |= (GPIO_ReadOutputDataBit(LCD_GPIO, LCD_D6) << 6);  tmp |= (GPIO_ReadOutputDataBit(LCD_GPIO, LCD_D7) << 7);    GPIO_WriteBit(LCD_GPIO, LCD_EN, Bit_RESET);  return tmp;}//-----------------------------------------------------------------------------unsigned char LCD_ReadOutStatus(void){  unsigned char status = 0;    GPIO_WriteBit(LCD_GPIO, LCD_RW, Bit_SET);    GPIO_WriteBit(LCD_GPIO, LCD_RS, Bit_RESET); status = LCD_ReadOutNibble();  return status;} //------------------------------------------------------------------------------// Function Name : lcd_writedata// Description : Send Data Select routine(RS=1 & RW=0)//------------------------------------------------------------------------------void lcd_writedata(unsigned char dataToWrite){  GPIO_WriteBit(LCD_GPIO, LCD_RW, Bit_RESET);  GPIO_WriteBit(LCD_GPIO, LCD_RS, Bit_SET);  lcd_writenibble(dataToWrite);  //LCD_ReadOutStatus();  while(LCD_ReadStatus() & 0x80);}  //-----------------------------------------------------------------------------void lcd_writecommand(unsigned char commandToWrite){  GPIO_WriteBit(LCD_GPIO, LCD_RW | LCD_RS, Bit_RESET);  lcd_writenibble(commandToWrite);  //LCD_ReadOutStatus();  while(LCD_ReadStatus() & 0x80);}  //-----------------------------------------------------------------------------void lcd_str(unsigned char * text){  while(*text)    lcd_writedata(*text++);}  //-----------------------------------------------------------------------------void lcd_locate(unsigned char x, unsigned char y){  lcd_writecommand(HD44780_DDRAM_SET | (x + (0x40 * y)));}  //-----------------------------------------------------------------------------void lcd_strxy(unsigned char * text, unsigned char x, unsigned char y){  lcd_locate(x,y);  while(*text)    lcd_writedata(*text++);}  //-----------------------------------------------------------------------------void lcd_writebinary(unsigned int var, unsigned char bitCount){  signed char i;   for(i = (bitCount - 1); i >= 0; i--)     {     lcd_writedata((var & (1 << i))?'1':'0');     }}  //-----------------------------------------------------------------------------void LCD_ShiftLeft(void){  lcd_writecommand(HD44780_DISPLAY_CURSOR_SHIFT | HD44780_SHIFT_LEFT | HD44780_SHIFT_DISPLAY);}  //-----------------------------------------------------------------------------void LCD_ShiftRight(void){  lcd_writecommand(HD44780_DISPLAY_CURSOR_SHIFT | HD44780_SHIFT_RIGHT | HD44780_SHIFT_DISPLAY);}  //-----------------------------------------------------------------------------void lcd_init(void){ volatile unsigned char i = 0; volatile unsigned int delayCnt = 0; RCC_APB2PeriphClockCmd(LCD_CLK_LINE, ENABLE); GPIO_InitStructure.GPIO_Pin = LCD_D0|LCD_D1|LCD_D2|LCD_D3|LCD_D4|LCD_D5|LCD_D6|LCD_D7|LCD_RS|LCD_RW|LCD_EN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(LCD_GPIO, &GPIO_InitStructure); GPIO_WriteBit(LCD_GPIO, LCD_RW | LCD_RS | LCD_EN, Bit_SET); udelay(200); GPIO_WriteBit(LCD_GPIO, LCD_RW | LCD_RS | LCD_EN, Bit_RESET); udelay(200); /* Initial by instruction */ lcd_writecommand(0x030); udelay(500); lcd_writecommand(0x030); udelay(200); lcd_writecommand(0x030); udelay(200); lcd_writecommand(HD44780_FUNCTION_SET |                HD44780_FONT5x7 |                HD44780_TWO_LINE |                HD44780_8_BIT); //0x38 udelay(200); lcd_writecommand(HD44780_DISPLAY_ONOFF |                HD44780_DISPLAY_OFF); //0x08 udelay(200); lcd_writecommand(HD44780_CLEAR); //0x01 udelay(200); lcd_writecommand(HD44780_ENTRY_MODE |                HD44780_EM_SHIFT_CURSOR |                HD44780_EM_INCREMENT);//0x06 udelay(200); lcd_writecommand(HD44780_DISPLAY_ONOFF |                HD44780_DISPLAY_ON |                HD44780_CURSOR_ON |                HD44780_CURSOR_NOBLINK);//0x0E udelay(200);}  //-----------------------------------------------------------------------------void lcd_addchar (unsigned char chrNum, unsigned char n, const unsigned char *p){        lcd_writecommand(HD44780_CGRAM_SET | chrNum * 8);        n *= 8;        do         lcd_writedata(*p++);        while (--n);}  //-----------------------------------------------------------------------------void lcd_cls(void){        lcd_writecommand(HD44780_CLEAR);}   unsigned char* intToStr(int n){ int i = 0; int j = 0; char *tmp = (char*)malloc(sizeof(char));    unsigned char *ret = (unsigned char*)malloc(12); if(n<0 || n>9){  *tmp = n%10+48;  n-=n%10;  n/=10;  tmp++;  i++; }  *tmp = n+48; i++; while(i--){   ret[j++] = *tmp--; } return ret;}void lcd_int(int a){  unsigned short ch,first; //you need this to display 0 if there was any char     //Get first char    ch = a/10000;    if(ch){     lcd_writedata(48+ch);     first = 1;    }     //Get second char    ch = (a/1000)%10;    if(ch || first){     lcd_writedata(48+ch);     first = 1;    }     //Get third char    ch = (a/100)%10;    if(ch || first){     lcd_writedata(48+ch);     first = 1;    }     //Get fourth char    ch = (a/10)%10;    if(ch || first){     lcd_writedata(48+ch);     //first = 1;                   //q    }     //Get fifth char    ch = a%10;    //if(ch || first)   //you dont need to check las one if ch is 0 then just display it, unless you dont want to then uncomment this line ("//q" line too)     lcd_writedata(48+ch);       // lcd_str(intToStr(n));} void lcd_intxy(int n, unsigned char x, unsigned char y){        lcd_locate(x,y);        lcd_int(n);}

lcd_hd44780.h

//******************************************************************************//    THE SOFTWARE INCLUDED IN THIS FILE IS FOR GUIDANCE ONLY.//    AUTHOR SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT//    OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING//    FROM USE OF THIS SOFTWARE.//****************************************************************************** //##############################################################################// lcd_hd44780.h//############################################################################## //****************************************************************************////#include "main.h"  #define LCD_GPIO GPIOB#define LCD_CLK_LINE RCC_APB2Periph_GPIOB #define LCD_D0 GPIO_Pin_0#define LCD_D1 GPIO_Pin_1#define LCD_D2 GPIO_Pin_5#define LCD_D3 GPIO_Pin_8#define LCD_D4 GPIO_Pin_9#define LCD_D5 GPIO_Pin_10#define LCD_D6 GPIO_Pin_11#define LCD_D7 GPIO_Pin_12 #define LCD_RS GPIO_Pin_13#define LCD_RW GPIO_Pin_14#define LCD_EN GPIO_Pin_15//******************************************************************************//  #define HD44780_CLEAR                                          0x01 #define HD44780_HOME                                           0x02 #define HD44780_ENTRY_MODE     0x04        #define HD44780_EM_SHIFT_CURSOR    0x00        #define HD44780_EM_SHIFT_DISPLAY   0x01        #define HD44780_EM_DECREMENT    0x00        #define HD44780_EM_INCREMENT    0x02 #define HD44780_DISPLAY_ONOFF    0x08        #define HD44780_DISPLAY_OFF     0x00        #define HD44780_DISPLAY_ON                  0x04        #define HD44780_CURSOR_OFF                  0x00        #define HD44780_CURSOR_ON                   0x02        #define HD44780_CURSOR_NOBLINK    0x00        #define HD44780_CURSOR_BLINK    0x01 #define HD44780_DISPLAY_CURSOR_SHIFT 0x10        #define HD44780_SHIFT_CURSOR               0        #define HD44780_SHIFT_DISPLAY              8        #define HD44780_SHIFT_LEFT                         0        #define HD44780_SHIFT_RIGHT                  4 #define HD44780_FUNCTION_SET    0x20        #define HD44780_FONT5x7      0x00        #define HD44780_FONT5x10     0x04        #define HD44780_ONE_LINE     0x00        #define HD44780_TWO_LINE     0x08        #define HD44780_4_BIT      0x00        #define HD44780_8_BIT      0x10 #define HD44780_CGRAM_SET                                    0x40 #define HD44780_DDRAM_SET                                    0x80 //##############################################################void lcd_init(void);void lcd_cls(void);void lcd_str(unsigned char * text);void lcd_strxy(unsigned char * text, unsigned char x, unsigned char y);void lcd_locate(unsigned char x, unsigned char y);void lcd_int(int n);void lcd_intxy(int n, unsigned char x, unsigned char y); //############################################################### void lcd_writedata(unsigned char dataToWrite);void lcd_writecommand(unsigned char commandToWrite);void lcd_writebinary(unsigned int var, unsigned char bitCount);void lcd_addchar (unsigned char chrNum, unsigned char n, const unsigned char *p);

main.c

lcd_init();         while (1)          {                   lcd_locate(1,0);                  lcd_str("Mazen");                  lcd_locate(7,0);                  lcd_str("A.");                  lcd_locate(0,1);                  lcd_str("-3125");           }

STM32 透過ADC_GetFlagStatus 知道 EOC狀態並讀值

其實網路隨意google一下就很多資料

uint16_t readADC1(void) {  uint16_t value;  //ADC_RegularChannelConfig(ADC1, channel, 1, ADC_SampleTime_55Cycles5); // Start the conversion  ADC_SoftwareStartConvCmd(ADC1, ENABLE);   // Wait until conversion completion  while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);  ADC_ClearFlag(ADC1, ADC_FLAG_EOC); // Get the conversion value  value = ADC_GetConversionValue(ADC1);  ADC_SoftwareStartConvCmd(ADC1, DISABLE); return value;}
void AdcPro(void){ static uint16_t buf[SAMP_COUNT]; static uint8_t write; uint32_t sum; uint8_t i; //buf[write] = ADC_GetConversionValue(ADC1); 原本直接讀取資料   buf[write] = readADC1();  if (++write >= SAMP_COUNT) {  write = 0; } sum = 0; for (i = 0; i < SAMP_COUNT; i++) {  sum += buf[i]; } g_usAdcValue = sum / SAMP_COUNT; /* 取平均 */ //ADC_SoftwareStartConvCmd(ADC1, ENABLE); /* 原本先為下次使用而enable */}

如何在部落格加入code 區域 (修改css)

可以在各種部落格裡面看到許多將程式碼加入文章裡

其實只要幾個步驟就可以完成了

也就是修改css, 將下面這一段加入CSS就好啦

pre { padding: 10px 5px 10px 22px; margin: 10px 15px; border: 1px solid #CCC; font:13px/120% 'Courier New'; letter-spacing: 0.07em; background: #F5F5F5 url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6r-beClagoumej1FnptO1ZkMGkgzGr5q86AlJhe4OQ15lEdwYy6lCIVyJbohqe4-QzLfwEeLJMJDbqKQX1UtZ3WGn1Gb3vGVOQfZruUU-kKdvWT4LQX8pjRPIFS_6TpAOHpYYqZlFAmg/s1600/code.gif) no-repeat scroll left top;  text-align: justify; overflow: auto; color:#333;}

完成後, 之後發表文章時
請記得在你要發布的程式碼加入 pre tag 如下:

<pre> 程式碼 </pre>

Google blogger 怎麼設定最新回應(留言)

最近搬家過來blogger 但是找不到簡單widget獲得最新留言 稍微做了一下功課, 可以透過RSS的方式去做

1. 看看網址 http://YOUR_BLOG_ADDRESS/feeds/comments/default
這個網址可以看到你部落格的最新回應RSS
像我的話, 就是 http://ezmm.blogspot.tw/feeds/comments/default

2.將此網址複製
http://YOUR_BLOG_ADDRESS/feeds/comments/default

3.加入資訊

選”資訊提供”, 再進去貼網址即可

—-

2014/02/13

Jun 29 Mon 2009 黑幼龍先生

公司在上週五辦了一場講座

是黑幼龍先生親自蒞臨現場的演講

我知道這個消息是一個月前的某一天晚上十點多在公司加班時,

發現21:03人資寄信給大家這個消息

不到一小時已經接近爆滿

衝著黑幼龍先生大師的高知名度 我豪不猶豫就報名了

也拉著加班的同事一起報名

演講過程中, 非常舒服的感覺

原來聽演講大師的內容與音調, 是這麼親切

好像隔逼老伯跟你講他過去的故事一般

當然老伯還是會提到他的卡內基課程. 行銷自己與產品

讓聽講者不知覺知道這項訊息

內容包含一些待人接物與如何保此正面力量等

語會完畢後, 黑先生問了大家誰要問第一個問題

沒人舉手

我也不知道為什麼, 我舉手了

有一些些緊張, 但我好想跟大師對話

也許就是這樣的力量 我知道我必須要把握

這可能是我最接近黑幼龍先生的時刻

“黑先生您好, 剛才您所提到的一些能夠與別人溝通且與別人相處的方式

都是非常好的意見, 但是在我們這樣高時程要求, 高度壓力的工作下, 難免會有負面情緒與生氣的時候

這樣個情況下, 我們應該如何always 保持您所提的正面相處方式呢? 因為也許今天在座大家聽了您的演講後

會去實行與獲得, 但是時間一久要如何持續保持呢. 謝謝”

黑幼龍先生聽了之後 很高興的說

我想它可能提出了大家心中一些重要的問題

不過他先是說了一個故事…演講家真會講故事

一錄完倒掛電影的情結

兩個老人. 再同一個醫院同一病房

都被醫生宣佈再過半年就會死去

總之事故感人的電影

後來他又回過頭來說, 必須要不斷的去實現與重複這些觀念將它變成習慣

只是你重複21遍後. 就變成你的習慣了

不過最重要的是

請你門公司參加我們卡內基的內訓, 大家一起參加比起單獨個體改變的快

呵呵

厲害的行銷大師呢

我們生活中有許多大師

他們原本也是像你我一樣. 上班族 學生或是一般職業

是什麼改變了他們呢

^^

2014/01/17

[C#] winForm執行另一個WPF程序並得到回傳值

我的範例 : WinForm端 (Parent)

呼叫 RunWPF() 就會去執行叫起 WPF process
如下程式碼

106 private void RunWPF()\r
107 {\r
108 Task.Run(() => RunWPFProcess());\r
109 }\r
110 \r
111 private void RunWPFProcess()\r
112 {\r
113 int ReturnValue = -1;\r
114 Process process = new Process();\r
115 process.StartInfo.FileName = “myWPF.exe“;\r
116 \r
117 try\r
118 {\r
119 process.Start();\r
122 process.WaitForExit(Int32.MaxValue);\r
123 ReturnValue = process.ExitCode;\r
124 }\r
125 catch (System.Exception ex)\r
126 {\r
127 }\r
128 \r
129 if (ReturnValue == 1)\r
130 {\r
131 /* You can do what you want as return value is 1 */ \r
137 }\r
138 else \r
139 {\r
140 /* You can do what you want as others */ \r
146 }\r
147 }\r

另一端WPF部分: (Child)

myWPF.exe 裡面程式碼,
這裡我就直接寫出如何傳值回去給winform程序
其他一概省略..

227 Environment.ExitCode = 1;\r
228 this.Close();\r

2014/01/07

左聲道,右聲道,與雙聲道的聲音測試 自己合成一個mp3來用

這樣個測試需求, 我想是很多做產品的人會使用到的

我上網Google一下, 都是一些音樂對唱男女聲唱歌 …

檔案又大而且唱歌的mp3怎麼拿來做測試啊….

於是我轉個念頭, 找找有沒有左右聲道的mp3自己做合成吧~~

步驟1: 找左聲道,右聲道, 雙聲道的mp3
很幸運的, 這裡可以找到
還是英文發音, 很專業的感覺啊!!

步驟2: 把他們合成為一首mp3
JoinExt軟體, 小巧精美又很簡單上手
安裝後在欲合成的mp3上按右鍵, 選join files…

完成品: 下載


2013/11/22

C# 開發錄影 record vedio功能 window media player 使用DirectX.Capture與 DirectShow.NET

首先請先到這個網站, 有個強者寫好sample囉, 還有講解~
http://dashingquill.wordpress.com/2012/06/27/capturing-webcam-using-directshow-net-library/

我也是這樣完成了
但是有一天, 出現問題我在某台windows x86 device無法錄到影像
也就是有影無聲的狀況..
因此我需要 library source code
而剛才說到的網站只有 .dll檔

於是乎, 我去找src code
找到年代久遠的source code
http://www.codeproject.com/Articles/3566/DirectX-Capture-Class-Library

目前正在debug中

其他參考資訊:
.net中捕获摄像头视频的方式及对比(How to Capture Camera Video via .Net)
DirectShowNET Library
The Filter Graph and Its Components

2013/11/01

msbuild 入門與基本操作

msbuild 有點類似linux系統的makefile讓你可以自動透過指令編譯程式碼, 但許多地方差異滿大的!

—首先—

你要先確定command line interface 知道這個指令: msbuild
如果沒有這個指令,只需到環境變數PATH裡加入類似這樣的路徑:
C:\Windows\Microsoft.NET\Framework\v4.0.30319

Microsoft有寫簡單的操作, 可以跟著一步步做會比較有感覺
逐步解說:從頭開始建立 MSBuild 專案檔案
http://msdn.microsoft.com/zh-tw/library/dd576348.aspx

最簡單的用法:

新增一bat檔(如 buildall.bat), 用來批次處理編譯
內文為:

msbuild xxx1.slnmsbuild xxx2.slnmsbuild xxx3.slnmsbuild xxx4.slnmsbuild xxx5.sln

如此一來, 執行 buildall.bat 就可以邊一 xxx1 ~ xxx5 這五個solutions
直接後面接專案的.sln檔案就會幫你編譯囉, 當然若要不同編譯方式請在後面接著設定參數吧

如果遇到無法編譯 發生錯誤

C:\source\xxx\MidiVol.vcxproj(22,3): error MSB4019: The imported project "C:\Program files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the  declaration is correct, and that the file exists on disk.

處理方式: (來源參考)
I’m using Win 7 64-bit, VS2013 express, I fixed the problem by setting the following before running the cocos.py publish command:

SET VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120

其他參考

MSBuild Command-Line Reference:
http://msdn.microsoft.com/en-us/library/vstudio/ms164311.aspx

Common MSBuild Project Properties:
http://msdn.microsoft.com/en-us/library/vstudio/bb629394.aspx