Documentation ¶
Overview ¶
Copyright 2022 mamemomonga https://github.com/mamemomonga/go-Futaba-M202MD10B/
Futaba M202MD10B用ライブラリ
Index ¶
- Constants
- Variables
- type VFD
- func (t *VFD) Brightness(value int) error
- func (t *VFD) CGRAM(code byte, data [7]byte) error
- func (t *VFD) CGRAMFromStrings(code byte, graphic [7]string) error
- func (t *VFD) Clear() error
- func (t *VFD) ClearAnimation() error
- func (t *VFD) ClearCursorNRTH() error
- func (t *VFD) Close()
- func (t *VFD) CursorBlink(blink bool) error
- func (t *VFD) CursorDisable() error
- func (t *VFD) CursorEnable(cursorType int) error
- func (t *VFD) CursorForward() error
- func (t *VFD) CursorHome() error
- func (t *VFD) CursorLine1() error
- func (t *VFD) CursorLine2() error
- func (t *VFD) CursorReverse() error
- func (t *VFD) Open(port string, baud int) (err error)
- func (t *VFD) Print(str string) error
- func (t *VFD) Println(str string) error
- func (t *VFD) PutChar(c byte) error
- func (t *VFD) Reset() error
- func (t *VFD) WriteByte(c byte) error
Examples ¶
Constants ¶
View Source
const ( Brightness1 = 3 // 明るさ1(最も暗い) Brightness2 = 2 // 明るさ2 Brightness3 = 1 // 明るさ3 Brightness4 = 0 // 明るさ4(最も明るい) )
明るさ
View Source
const ( CursorTypeUnderline = iota // 下線 CursorTypeTofu // 豆腐 CursorTypeXOR // 反転 )
カーソルの種類
View Source
const ( AnimationDisable = iota // 文字表示効果無効 AnimationEnable // 文字表示効果有効 )
エフェクトモード
Variables ¶
Functions ¶
This section is empty.
Types ¶
type VFD ¶
type VFD struct { Wait time.Duration // 次の文字を表示するまでの待機時間 Animation int // 文字アニメーション有効 (AnimationDisable:無効 / AnimationEnable:有効) AnimationCharStart byte // 文字表示効果開始ポイント AnimationWait time.Duration // 文字表示効果ウェイト // contains filtered or unexported fields }
VFDライブラリ
Example ¶
package main import ( "log" "time" M202MD10B "github.com/mamemomonga/go-Futaba-M202MD10B" ) const ( SERIAL_PORT = "/dev/cu.usbserial-1101" WAIT_TIME = time.Second * 1 ) func main() { vfd := M202MD10B.New() var err error err = vfd.Open(SERIAL_PORT, 9600) // SERIAL_PORT: e.g. /dev/ttyUSB0, /dev/cu.usbserial if err != nil { log.Fatal(err) } defer vfd.Close() err = vfd.Brightness(M202MD10B.Brightness4) if err != nil { log.Fatal(err) } err = vfd.CursorDisable() if err != nil { log.Fatal(err) } err = vfd.Clear() if err != nil { log.Fatal(err) } err = vfd.Print(" Futaba M202MD10B") if err != nil { log.Fatal(err) } time.Sleep(WAIT_TIME) }
Output:
func (*VFD) Brightness ¶
明るさの設定 Brightness1, Brightness2, Brightness3, Brightness4 のいずれかを設定
func (*VFD) CGRAMFromStrings ¶
Stringsの配列から外字の登録
Example ¶
package main import ( "log" "time" M202MD10B "github.com/mamemomonga/go-Futaba-M202MD10B" ) const ( SERIAL_PORT = "/dev/cu.usbserial-1101" WAIT_TIME = time.Second * 1 ) func main() { const ( CGRAM_HEART byte = 0x88 CGRAM_STAR byte = 0x89 ) vfd := M202MD10B.New() var err error err = vfd.Open(SERIAL_PORT, 9600) // SERIAL_PORT: e.g. /dev/ttyUSB0, /dev/cu.usbserial if err != nil { log.Fatal(err) } defer vfd.Close() { var g [7]string g[0] = "00000" g[1] = "11011" g[2] = "11111" g[3] = "11111" g[4] = "11111" g[5] = "01110" g[6] = "01100" err := vfd.CGRAMFromStrings(CGRAM_HEART, g) if err != nil { log.Fatal(err) } } { var g [7]string g[0] = "00100" g[1] = "00100" g[2] = "11111" g[3] = "01110" g[4] = "01110" g[5] = "01010" g[6] = "10001" err := vfd.CGRAMFromStrings(CGRAM_STAR, g) if err != nil { log.Fatal(err) } } vfd.Animation = M202MD10B.AnimationEnable err = vfd.Print(" ") if err != nil { log.Fatal(err) } err = vfd.PutChar(CGRAM_HEART) if err != nil { log.Fatal(err) } err = vfd.Print("マーク ダッテ\n デルンダ ゾッ") if err != nil { log.Fatal(err) } err = vfd.PutChar(CGRAM_STAR) if err != nil { log.Fatal(err) } time.Sleep(WAIT_TIME) vfd.ClearAnimation() }
Output:
func (*VFD) Clear ¶
画面クリア
Example ¶
package main import ( "log" "time" M202MD10B "github.com/mamemomonga/go-Futaba-M202MD10B" ) const SERIAL_PORT = "/dev/cu.usbserial-1101" func main() { vfd := M202MD10B.New() var err error err = vfd.Open(SERIAL_PORT, 9600) // SERIAL_PORT: e.g. /dev/ttyUSB0, /dev/cu.usbserial if err != nil { log.Fatal(err) } defer vfd.Close() err = vfd.Clear() if err != nil { log.Fatal(err) } }
Output:
func (*VFD) ClearAnimation ¶
アニメーション付き画面消去
Example ¶
package main import ( "errors" "log" "time" M202MD10B "github.com/mamemomonga/go-Futaba-M202MD10B" ) const ( SERIAL_PORT = "/dev/cu.usbserial-1101" WAIT_TIME = time.Second * 1 ) func main() { vfd := M202MD10B.New() var err error err = vfd.Open(SERIAL_PORT, 9600) // SERIAL_PORT: e.g. /dev/ttyUSB0, /dev/cu.usbserial if err != nil { log.Fatal(err) } defer vfd.Close() errChk := func(err error) { if err != nil { if errors.Is(err, M202MD10B.ErrBufferOverflow) { log.Printf("warn: %v", err) } else { log.Fatalf("alert: %v", err) } } } vfd.CursorEnable(M202MD10B.CursorTypeUnderline) vfd.CursorBlink(true) vfd.Animation = M202MD10B.AnimationEnable err = vfd.Print(" Welcome To THE\nC Y B E R S P A C E") errChk(err) time.Sleep(WAIT_TIME) err = vfd.ClearAnimation() errChk(err) }
Output:
func (*VFD) ClearCursorNRTH ¶ added in v0.0.5
画面クリア(カーソルを移動しない)
func (*VFD) CursorEnable ¶
カーソルの表示( CursorTypeUnderline, CursorTypeTofu, CursorTypeXOR )
func (*VFD) Print ¶
文字の表示
Example ¶
package main import ( "log" "time" M202MD10B "github.com/mamemomonga/go-Futaba-M202MD10B" ) const ( SERIAL_PORT = "/dev/cu.usbserial-1101" WAIT_TIME = time.Second * 1 ) func main() { vfd := M202MD10B.New() var err error err = vfd.Open(SERIAL_PORT, 9600) // SERIAL_PORT: e.g. /dev/ttyUSB0, /dev/cu.usbserial if err != nil { log.Fatal(err) } defer vfd.Close() err = vfd.Print("Hello World!\n コンニチワ") if err != nil { log.Fatal(err) } time.Sleep(WAIT_TIME) }
Output:
func (*VFD) Println ¶
文字の表示(改行付き)
Example ¶
package main import ( "log" "time" M202MD10B "github.com/mamemomonga/go-Futaba-M202MD10B" ) const ( SERIAL_PORT = "/dev/cu.usbserial-1101" WAIT_TIME = time.Second * 1 ) func main() { vfd := M202MD10B.New() var err error err = vfd.Open(SERIAL_PORT, 9600) // SERIAL_PORT: e.g. /dev/ttyUSB0, /dev/cu.usbserial if err != nil { log.Fatal(err) } defer vfd.Close() err = vfd.Println("Hello ") if err != nil { log.Fatal(err) } err = vfd.Print(" World!") if err != nil { log.Fatal(err) } time.Sleep(WAIT_TIME) }
Output:
Click to show internal directories.
Click to hide internal directories.