2013年12月21日 星期六

raspberry pi 調整大小聲

資料參考來自:
http://raspberrypi.stackexchange.com/questions/157/if-i-plug-my-headphones-into-the-audio-jack-how-do-i-control-the-volume

Make sure you are in the user folder:
$ cd ~/

Create the file .bash_aliases (this will be where I keep all the aliases I make so they aren't lost when I reboot my Raspberry Pi):
$ sudo nano .bash_aliases

In the text editor, add the aliases:
# Increase volume by 5%
alias volup='sudo amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's/%//')+5]%'
# Decrease volume by 5%
alias voldown='sudo amixer set PCM -- $[$(amixer get PCM|grep -o [0-9]*%|sed 's/%//')-5]%'

Exit and save: Ctrl+X, Y, Enter
Reboot:
$ sudo reboot

Log in and test the commands:
$ volup
Simple mixer control 'PCM',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined penum
  Playback channels: Mono
  Limits: Playback -10239 - 400
  Mono: Playback 400 [100%] [4.00dB] [on]
$ voldown
Simple mixer control 'PCM',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined penum
  Playback channels: Mono
  Limits: Playback -10239 - 400
  Mono: Playback -131 [95%] [-1.31dB] [on]

Note: This solution has only been tested on Raspbian systems only (the OS that the OP assumed they would use).

2013年5月21日 星期二

筆電接單槍投影機的設定顯示方法

參考自 http://www.ptt.cc/bbs/EZsoft/M.1357913495.A.083.html
先說結論:一般使用者方法一就足夠使用,
          若需要同時鎖住鍵鼠訊號可參考方法二
方法一:Windows內建Win+p切換螢幕輸出法
摘要:先透過控制台設定(後述)
      可利用Windows系統內建延伸螢幕的快速鍵:Win + p
      切換至「僅有投影機」的功能,達成關閉筆電螢幕,
      同時不會因為任意鍵鼠訊號而導致螢幕再度開啟。
      想要回復畫面只需要Win + p + p 切換回「僅有電腦」即可。
      (Win+p+p:長按住Win鍵,並按p兩次,Win+p僅會顯示目前螢幕狀態,
       第二次p才會切換至下一項。如果發生螢幕還是黑的別慌張,Win+p+p多切換幾次
       畫面一定可以出現。還有螢幕切換時,視型號會需要一點時間來反映,
       別急著按鍵連發。)
控制台
 設定:進入控制台 -> 螢幕解析度 -> 偵測
      -> 點選新出現的第二顆虛擬螢幕(未偵測到另一部顯示器)
      -> 下方的 多部顯示器(M)下拉選單:仍然在VGA上嘗試連線
      -> 確定

優點:不須安裝任何軟體,Windows系統內建。
      不會因為隨意的鍵鼠訊號而使螢幕再度開啟。
      可透過系統內建DisplaySwitch指令加參數來達成自訂熱鍵(見延伸進階)
缺點:作業系統僅限 Win7(支援) / Vista(未驗證) / XP(未驗證)。
      熱鍵若要自訂可能須利用regedit修改註冊表達成,方法未知。(已解決,見延伸進階)
      此法鍵鼠訊號並未鎖住,也就是說鍵鼠訊號的輸入依然正常,僅止於不會打開螢幕。
      若使用環境上真的有接外接投影裝置,則該裝置啟動。
資料參考:http://www.mobile01.com/topicdetail.php?f=512&t=2502600&p=1#3
          mustrong  2011-12-20 01:59  #10
延伸進階:本法是透過作業系統"C:\Windows\System32\DisplaySwitch.exe"
          的預設快速鍵來達成,可透過各種方式來達成自訂想要的熱鍵
          (建立cmd/捷徑/批次檔、API、Autohotkey類程式)
          displayswitch.exe
            /internal      預設螢幕(等於打開筆電螢幕)
            /clone         同步顯示
            /extend        延伸螢幕
            /external      外接螢幕/投影機(等於關閉筆電螢幕)
ex.以捷徑為例
對著C:\Windows\System32\DisplaySwitch.exe
點右鍵→傳送到→桌面(建立捷徑)
回到桌面對著捷徑→右鍵→內容→目標(T)
                                  在Displayswitch.exe後加上你要的其中一個參數
                                  即可設定此捷徑執行該模式
                                  /internal 預設螢幕(等於打開筆電螢幕)
                                  /external 外接螢幕/投影機(等於關閉筆電螢幕)
        對著捷徑→右鍵→內容→快速鍵 (此處設定你想要的快速鍵)




參考自 http://windows.microsoft.com/zh-tw/windows7/connect-to-a-projector
的方法
按一下 [開始] 按鈕 [開始] 按鈕的圖片,然後按一下 [控制台],以開啟 [控制台]。
3.
在搜尋方塊中,輸入投影機,然後按一下 [連接到投影機]
(若要使用鍵盤快速鍵而非 [控制台],請按 Windows 標誌鍵 Windows 標誌鍵的圖片+P)。
4.
選取桌面的顯示方式:

[僅有電腦] (只在您的電腦螢幕上顯示桌面)。

[同步顯示] (在您的電腦螢幕與投影機上顯示桌面)。

[延伸] (將您的桌面從電腦螢幕延伸到投影機)。

[僅有投影機] (只在投影機上顯示桌面)。


桌面顯示方式選項的圖片桌面顯示方式的四個選項

2013年3月14日 星期四

手機中google行事曆只能看到一個月內的事件

不知道有沒有人發現,使用android手機同步google日曆,會無法看見舊資料(約30天,或上個月之前的),例如你八月買手機,大概六月以前的資料會無法同步到手機。我遇到了這個問題,總算在國外論壇找到解決方式,趕緊分享於此。

1. 把google行事曆匯出
2. 再把剛剛匯出的檔案匯入google行事曆
3. 拿起手機同步

就可以看到以前(超過一個月前)的舊事項了
http://www.mobile01.com/topicdetail.php?f=423&t=1702974&p=1




2012年12月24日 星期一

主子資料表的新增


'新增資料到訂貨主檔
'儲存資料後,超連結到顯示訂單的網頁
        Dim connstr As String = "Data Source=120.xxx.xx.xxx;UID=xx;PWD=xx;Database=北風貿易"
        Dim sqlconn As SqlConnection = New SqlConnection(connstr)
        Dim sqlcmdstr As String = "insert into 訂貨主檔(客戶編號, 員工編號, 訂單日期, 要貨日期, 送貨方式) values(@客戶編號, @員工編號, @訂單日期, @要貨日期, @送貨方式);select @@IDENTITY"
        Dim sqlcmd As New SqlCommand(sqlcmdstr, sqlconn)
        sqlcmd.Parameters.AddWithValue("@客戶編號", Me.TextBox1.Text)
        sqlcmd.Parameters.AddWithValue("@員工編號", Me.TextBox6.Text)
        sqlcmd.Parameters.AddWithValue("@訂單日期", Me.TextBox2.Text)
        sqlcmd.Parameters.AddWithValue("@要貨日期", Me.TextBox4.Text)
        sqlcmd.Parameters.AddWithValue("@送貨方式", Me.TextBox5.Text)
        'sqlcmd.Parameters.AddWithValue("@newid", Me.TextBox7.Text)
        'sqlcmd.Parameters.AddWithValue("@訂單日期", Me.TextBox2.Text)
        sqlconn.Open()
        Dim result As SqlDataReader
        result = sqlcmd.ExecuteReader
        If result.HasRows Then
            Do While result.Read()
                'Response.Write(result(0).ToString)
                Me.Label1.Text = result(0).ToString
                Me.TextBox3.Text = result(0).ToString
            Loop
        Else
            Response.Write("No rows returned.")
        End If

        result.Close()
        'result.Read()
        sqlconn.Close()
        'Response.Write(result.ToString)
        'Response.Redirect("gridview.aspx")
        Me.GridView1.DataBind()




    Protected Sub FormView1_ItemInserted(sender As Object, e As System.Web.UI.WebControls.FormViewInsertedEventArgs) Handles FormView1.ItemInserted
        '當子資料表有新項目新增時, 更新下方的訂單明細gridview1
        Me.GridView1.DataBind()
    End Sub


    Protected Sub FormView1_PreRender(sender As Object, e As EventArgs) Handles FormView1.PreRender
        '當formview重新整理時,將訂單號碼填進去
        Dim orderid As TextBox = CType(Me.FormView1.FindControl("訂單號碼TextBox"), TextBox)
        orderid.Text = Me.TextBox3.Text
    End Sub


 Private Sub Calendar2_DayRender(sender As Object, e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar2.DayRender
        '限制只能在7天以後開放選取交期
        e.Day.IsSelectable = e.Day.Date > Now.AddDays(7).ToShortDateString
    End Sub

   Protected Sub Calendar2_SelectionChanged(sender As Object, e As EventArgs) Handles Calendar2.SelectionChanged
        '輸入交期
        Me.TextBox4.Text = Me.Calendar2.SelectedDate
    End Sub

'更新產品編號
   Protected Sub DropDownList4_SelectedIndexChanged(sender As Object, e As EventArgs)
        Dim productid As TextBox = CType(Me.FormView1.FindControl("產品編號TextBox"), TextBox)
        Dim drop_product As DropDownList = CType(Me.FormView1.FindControl("DropDownList4"), DropDownList)
        productid.Text = drop_product.SelectedValue.ToString
        'Dim ds As DataSet = SqlDataSource1.Select
        Dim connstr As String = "Data Source=xxx.xx.xx.xx;UID=xx;PWD=xx;Database=北風貿易"
        Dim sqlconn As SqlConnection = New SqlConnection(connstr)
        Dim cmd As New SqlCommand("select 單價 from 產品資料 where 產品編號 = @prodid", sqlconn)
        cmd.Parameters.AddWithValue("@prodid", Int(drop_product.SelectedValue))
        Dim reader As SqlDataReader
        sqlconn.Open()
        reader = cmd.ExecuteReader
        If reader.Read Then
            Dim price_text As TextBox = CType(Me.FormView1.FindControl("單價TextBox"), TextBox)
            price_text.Text = reader(0).ToString
        End If
        sqlconn.Close()
    End Sub



  If Me.TextBox3.Text <> "" Then
            Dim connstr As String = "Data Source=xxx.xxx.xx.xx;UID=xx;PWD=xx;Database=北風貿易"
            Dim sqlconn As SqlConnection = New SqlConnection(connstr)
            Dim cmd As SqlCommand
            cmd = New SqlCommand("delete 訂貨主檔 where 訂單號碼='" & Me.TextBox3.Text & "'", sqlconn)
            Dim result As Integer
            sqlconn.Open()
            result = cmd.ExecuteNonQuery
            Response.Write(result)
            sqlconn.Close()
            'If result = -1 Then
            Me.TextBox3.Text = ""
            Dim orderid As TextBox = CType(Me.FormView1.FindControl("訂單號碼TextBox"), TextBox)
            orderid.Text = ""
            Me.TextBox4.Text = ""
            'End If
        End If

2012年12月8日 星期六

網頁產生一二維條碼

因為教學需要,所以放上網路上找到的一二維條碼產生DLL

一維條碼 128碼 DLL(方法1),先下載以下DLL,並加入參考
https://docs.google.com/open?id=0Bxaw7Z2hq9CFWG1iRzJacFN1aGM

以下所產生的一維條碼會顯示在另一個瀏覽器,並不方便

'一維條碼 128碼 呼叫程式碼
   Dim b As BarcodeLib.Barcode = New BarcodeLib.Barcode()
        '支援39, 128, EAN, UPC等
        Dim type As BarcodeLib.TYPE = BarcodeLib.TYPE.CODE128
        Try
            'Me.Image1.Image = b.Encode(type, TextBox1.Text.Trim)
            Dim data As String = Me.TextBox1.Text
            Dim image As New System.Drawing.Bitmap(200, 200)
            image = b.Encode(type, TextBox1.Text.Trim)
            image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif)
        Catch ex As Exception
            'MessageBox.Show(ex.Message)
        End Try

一維條碼 128碼 DLL(方法2),也是下載DLL,並加入參考
將編碼的圖片寫在另外一個.ashx 泛型處理常式中
Imports System.Web
Imports System.Web.Services
Imports System.Web.SessionState     ' 要使用 Session 必需加入此命名空間
Imports System.IO
Imports System.Drawing.Imaging

Public Class barcode
    Implements System.Web.IHttpHandler, IRequiresSessionState
    Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
     
        Dim encodestr As String = ""
        'context.Request("encodestr") 是從傳過來的網址中抓取問號後面encoderstr的變數值
        '例如 http://barcode.ashx?encodestr="123" 則會抓取123
        If context.Session("encodestr") IsNot Nothing Then
            '利用TryParse函數判斷使用者輸入的是數字或是文字
            'If Integer.TryParse(context.Request("scid").Trim(), encoderstr) Then
            'End If
            encodestr = context.Session("encodestr").ToString
            Dim b As BarcodeLib.Barcode = New BarcodeLib.Barcode()
            Try
                Dim image As New System.Drawing.Bitmap(200, 200)
                '支援39, 128, EAN, UPC等,目前是將encodestr編成128碼
                Dim type As BarcodeLib.TYPE = BarcodeLib.TYPE.CODE128
                image = b.Encode(type, encodestr.ToString)
                context.Response.ContentType = "Image/Gif"
                context.Response.Clear()
                image.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif)
            Catch ex As Exception
                'MessageBox.Show(ex.Message)
            End Try
        Else
            context.Response.Write("sessioin error")
        End If
       
    End Sub
    ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property
End Class







二維條碼 qr code DLL
https://docs.google.com/open?id=0Bxaw7Z2hq9CFa0t4dkVkMEZCOFU



'二維條碼 呼叫程式碼
    Dim encoder As New ByCase.Lib.QRCode.Codec.QRCodeEncoder
        '編碼有3種,分別是byte, alphanumeric, numeric
        encoder.QRCodeEncodeMode = ByCase.Lib.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC

        '(image pixels per QRCode pixel): 1, 2, 3, 4, 5, 10, 15, 30. ( in pixels )
        encoder.QRCodeScale = 5
        '二维码所能包含的字符信息量是由QrcodeVersion的设置值来决定的。将QrcodeVersion设置到20的时候,就已经可以容乃到300多个字节
        encoder.QRCodeVersion = 20
        'ByCase.Lib.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.H L M Q
        encoder.QRCodeErrorCorrect = ByCase.Lib.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.H

        '只能大寫英文, 數字, 空格+-*/冒號,不可以小寫、不可底線不可特殊符號
        Dim data As String = Me.TextBox1.Text.ToUpper
        Dim image As New System.Drawing.Bitmap(200, 200)
        image = encoder.Encode(data)
        Image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif)

二維條碼(方法2)
Google charts提供非常方便的API,可以產生QR Code圖片。
http://code.google.com/apis/chart/docs/gallery/qr_codes.html(API說明)
以下面URL為例,紅色部份為關鍵參數
https://chart.googleapis.com/chart?chs=120x120&cht=qr&chl=陳錫川&choe=UTF-8&chld=M|2
其中:
chs: QR code 圖片大小
cht: 圖片類型,google charts用這個參數產生各種圖片,這裡當然就填qr
chl: 要藏在QR code裡的文字,必須編成punycode(urlencode)。
choe: 編碼。請注意只支援iso-8859-1, sjis, utf8。詳見API說明網頁。
chld: 其他參數。M是錯誤修正層次,有L, M, Q, H等四級;後面的數字是QR code周圍白邊的寬度。


在webform放置textbox1與button,接著在button中撰寫以下程式即可

    Dim imgsrc As String = "http://chart.apis.google.com/chart?chs=" & "400x400" & "&chl=" & Me.TextBox1.Text & "&choe=UTF-8&cht=qr"
        Image1.ImageUrl = imgsrc


2012年12月6日 星期四

手機取消插播

最近手機電話中竟然有嘟嘟嘟的聲音,我心想是設了插播,打電話到中華電信卻說我的門號沒有設定這項功能,可能是手機自己的設定,原來
取消插播是 #43# 撥出
開啟插播是 *43# 撥出
趕緊記載blogger中