Sunday, September 28, 2014

ADS1148, ADS1248 사용시 주의점

VREFOUT 과 VREFCOM 사이에 캐패시터를 달아주고
반드시 VREFCOM은 그라운드와 연결시킨다.


만약 VREFCOM 이 GND와 연결되어있지 않다면 IDAC 등 내부 Current source가 동작하지 않는다.


----------------

Capacitor required between VREFOUT to VREFCOM. and connect VREFCOM to GND.

If VREFCOM not connected to GND, Not work internal current source.

Tuesday, September 16, 2014

C#.NET의 WinForm 어플리케이션에서 Console 사용하기.

Console.WriteLine 과 같이 콘솔로 출력하는것이 필요할때가 많다.

WinForm 어플리케이션은 기본적으로 콘솔 윈도우를 제공하지 않는다.

미리 AllocConsole함수를 호출해 놓으면 Console.WriteLine 기능을 사용할 수 있다.


예를 들어 Form이 생성될때 AllocConsole()을 호출한다.


using System.Runtime.InteropServices;


        public Form1()
        {
            InitializeComponent();
            AllocConsole();

        }

        [DllImport("kernel32.dll", SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool AllocConsole();

        
       void foo()
      {
            Console.WriteLine("Hello?");

      }

Monday, June 30, 2014

WindowsCE에서 부드러운 글꼴(Anti-aliased font, 안티알리아싱) 사용하기

C# .net CF 3.5 기준입니다.

        Font CreateFontAntialias(String fontName, int height)
        {
            LogFont lf = new LogFont();
            lf.FaceName = fontName;
            lf.Height = height;
            lf.Weight = LogFontWeight.Normal;
            lf.CharSet = LogFontCharSet.Hangeul;
            lf.Quality = LogFontQuality.AntiAliased;
            return Font.FromLogFont(lf);
        }


함수를 만들고

FormPaint 이벤트 헨들러에서 

            String fontName ="나눔바른고딕";


            Font f1 = CreateFontAntialias(fontName, 14);
            SolidBrush blackbrush = new SolidBrush(Color.Black);


            e.Graphics.DrawString("가나다라마바사ABC", f1, blackbrush, 0, 0);

식으로 사용하면됩니다.



Windows CE 장치에 font를 설치한는 방법은 제품마다 다르므로 각자 알아서 하시구요.

HNSTS에서 나온제품은 Flash Disk/Fonts 에 TTF 파일을 넣으면 됩니다.

Monday, June 23, 2014

jquery http get 결과가 캐시에서 읽어서 항상 같은 값만 가져오는 경우 해결 방법. ( JQuery get method returns values from cache )

problem:  read from cache

$.get('some.jsp', { param_name : param_value } function (responseText)
{
......
}

solution : change url each times.

$.get('some.jsp?dummy='+Math.random() , { param_name : param_value } function (responseText)
{
......
}


캐시에서 가져오지 못하도록 강제로 http get method의 source url 을 호출때마다 다르게 해준다.

( change URL by extra  random value for each get requests. )


Sunday, June 22, 2014

Chrome history back does not trigger onload($ready) problem solution.


<script type="text/javascript">
window.addEventListener("pageshow", function() {

       // user codes

}, false);

</script>

Thursday, June 5, 2014

Set paper length for tape(Label) printer ( EPSON OK900P )

procedure TForm1.Button1Click(Sender: TObject);
var
  Device :Array [0..255] of char;
  Driver :Array [0..255] of char;
  Port : Array [0..255] of char;
  hDMode : THandle;
  PDMode : PDEVMODE;

begin
  Printer.PrinterIndex := Printer.PrinterINdex;
  Printer.GetPrinter(Device,Driver,Port,hDMode);
  if hDMode <> 0 then
  begin
      pDMode := GlobalLock(hDMode);
      if pDMode <> nil then
      begin
        pDMode^.dmFields := pdMOde^.dmFields or DM_PAPERLENGTH;// or DM_PAPERWIDTH or DM_PAPERSIZE;

        pDMode^.dmPaperLength := 400;   // millimiter x 10;

        pdMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;
        pDMode^.dmDefaultSource := DMBIN_MANUAL;
        GlobalUnlock(hDMode);
      end;
  end;

  Printer.PrinterIndex := Printer.PrinterIndex;

  Printer.BeginDoc;
  with Printer.Canvas
  do
  begin

    Ellipse(0,0,Printer.PageWidth, Printer.PageHeight);
  end;
  Printer.EndDoc;
end;

Tuesday, April 1, 2014

How to make keyboard event handler in delphi component

Ctrl+V를 수신받을때 KeyPress 핸들러에 이상한 코드가 들어온다.
KeyPress를 받지 않을 방법은 없고 KeyPress안에서 Ctrl키가 눌려있는지를
판단해서 단축키에 대한 올바른 처리를 할 수 있다.



KeyPress handler raise after every KeyDown event that handled or not handled.
Example, User press Ctrl + V , KeyDown and KeyPress and KeyUp event called.


in class interface

    procedure KeyPress(var Key: Char); override;
    procedure KeyDown(var Key: Word; Shift: TShiftState); override;


in implementation

procedure TClassXXX.KeyDown(var Key: Word; Shift: TShiftState);
begin
   inherited;

    if Key = VK_LEFT then
    begin
       .....
    end;
end;

procedure TClassXXX.KeyPress(var Key: Char);
var
    ShiftState: TShiftState;
    KeyState: TKeyboardState;
begin
    inherited;

    GetKeyboardState(KeyState);
    ShiftState := KeyboardStateToShiftState(KeyState);

    if not ( ssCtrl In ShiftState ) then
    begin
          // key press without control key
    end;
end;