|
@@ -50,7 +50,7 @@ func (s *Screen) Correct() {
|
|
|
now := time.Now()
|
|
|
cmd := bx.NewBxCmdSystemClockCorrect(now)
|
|
|
data := bx.NewBxDataPackCmd(cmd)
|
|
|
- s.send(data.Pack())
|
|
|
+ s.Send(data.Pack())
|
|
|
}
|
|
|
|
|
|
// Reconnect 重连
|
|
@@ -82,7 +82,7 @@ func (s *Screen) setConn(conn net.Conn) {
|
|
|
}
|
|
|
|
|
|
// 给屏发送数据
|
|
|
-func (s *Screen) send(data []byte) {
|
|
|
+func (s *Screen) Send(data []byte) {
|
|
|
if !s.getLiveState() {
|
|
|
return
|
|
|
}
|
|
@@ -127,9 +127,9 @@ func (s *Screen) TextRam(ff FlashFile) {
|
|
|
//
|
|
|
cmd := bx.NewBxCmdSendDynamicArea(areas)
|
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
|
- pack.SetDispType(1) //动态显示模式
|
|
|
+ pack.SetDisplayType(1) //动态显示模式
|
|
|
d := pack.Pack()
|
|
|
- s.send(d)
|
|
|
+ s.Send(d)
|
|
|
s.ReadResp()
|
|
|
s.StateInfo.DynaAreaNum++
|
|
|
}
|
|
@@ -141,7 +141,7 @@ func (s *Screen) DelRamText(numbers ...byte) {
|
|
|
}
|
|
|
cmd := bx.NewCmdDelDynamicArea(numbers)
|
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
|
- s.send(pack.Pack())
|
|
|
+ s.Send(pack.Pack())
|
|
|
s.ReadResp()
|
|
|
if len(numbers) == 0 {
|
|
|
s.StateInfo.DynaAreaNum = 0
|
|
@@ -172,6 +172,7 @@ const (
|
|
|
MoveRight //0x04——向右移动
|
|
|
MoveUp //0x05——向上移动
|
|
|
MoveDown //0x06——向下移动
|
|
|
+ Flicker //0x07——闪烁
|
|
|
DefaultDisplayMode DisplayMode = Static
|
|
|
)
|
|
|
|
|
@@ -216,27 +217,32 @@ func (ft *FlashFile) SetArea(w uint16, yIsPixel bool, h uint16) {
|
|
|
}
|
|
|
|
|
|
// TextFlash 发送静态文件节目,掉电保存,文件名格式"P000","P001"
|
|
|
-func (s *Screen) TextFlash(ft FlashFile, isLogo bool) {
|
|
|
+func (s *Screen) TextFlash(ft []FlashFile, isLogo bool) {
|
|
|
if !s.getLiveState() {
|
|
|
return
|
|
|
}
|
|
|
encoder := simplifiedchinese.GB18030.NewEncoder()
|
|
|
- var bytes []byte
|
|
|
- if ft.color == Default {
|
|
|
- bytes, _ = encoder.Bytes([]byte(ft.msg))
|
|
|
- } else {
|
|
|
- bytes, _ = encoder.Bytes([]byte("\\C" + strconv.Itoa(int(ft.color)) + ft.msg))
|
|
|
- }
|
|
|
- area := bx.NewBxAreaDynamic(0xff, byte(ft.runMode), byte(ft.dispMode), ft.originX, ft.originY, ft.width, ft.height, bytes, false)
|
|
|
name := fmt.Sprintf("P%03d", s.StateInfo.ProgramNum)
|
|
|
if isLogo {
|
|
|
name = "LOGO"
|
|
|
}
|
|
|
- file := bx.NewBxFile(name, "", []bx.BxArea{area})
|
|
|
+ var areas []bx.BxArea
|
|
|
+ for _, i := range ft {
|
|
|
+ var bytes []byte
|
|
|
+ if i.color == Default {
|
|
|
+ bytes, _ = encoder.Bytes([]byte(i.msg))
|
|
|
+ } else {
|
|
|
+ bytes, _ = encoder.Bytes([]byte("\\C" + strconv.Itoa(int(i.color)) + i.msg))
|
|
|
+ }
|
|
|
+ area := bx.NewBxAreaDynamic(0xff, byte(i.runMode), byte(i.dispMode), i.originX, i.originY, i.width, i.height, bytes, false)
|
|
|
+ areas = append(areas, area)
|
|
|
+ }
|
|
|
+
|
|
|
+ file := bx.NewBxFile(name, "", areas)
|
|
|
cmd := file.NewCmdWriteFile()
|
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
|
data := pack.Pack()
|
|
|
- s.send(data)
|
|
|
+ s.Send(data)
|
|
|
resp := s.ReadResp()
|
|
|
if !resp.IsAck() {
|
|
|
logrus.Error("设备拒绝写文件! error:", resp.Error().Description)
|
|
@@ -244,7 +250,7 @@ func (s *Screen) TextFlash(ft FlashFile, isLogo bool) {
|
|
|
}
|
|
|
pack1 := bx.NewBxDataPackCmd(cmd)
|
|
|
data1 := pack1.Pack()
|
|
|
- s.send(data1)
|
|
|
+ s.Send(data1)
|
|
|
resp1 := s.ReadResp()
|
|
|
if resp1.NoError() {
|
|
|
s.StateInfo.ProgramNum++
|
|
@@ -257,9 +263,7 @@ func (s *Screen) Bitmap(name string, bitmap []byte) {
|
|
|
cmd := file.NewCmd()
|
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
|
data := pack.Pack()
|
|
|
- fmt.Println("数据长度:", len(data))
|
|
|
- fmt.Printf("数据:% 02x\n", data)
|
|
|
- s.send(data)
|
|
|
+ s.Send(data)
|
|
|
resp := s.ReadResp()
|
|
|
if !resp.IsAck() {
|
|
|
logrus.Error("设备拒绝写文件! error:", resp.Error().Description)
|
|
@@ -267,8 +271,7 @@ func (s *Screen) Bitmap(name string, bitmap []byte) {
|
|
|
}
|
|
|
pack1 := bx.NewBxDataPackCmd(cmd)
|
|
|
data1 := pack1.Pack()
|
|
|
- fmt.Println("数据长度1:", len(data1))
|
|
|
- s.send(data1)
|
|
|
+ s.Send(data1)
|
|
|
fmt.Printf("写图文件数据:% 02x\n", data1)
|
|
|
s.ReadResp()
|
|
|
}
|
|
@@ -277,14 +280,14 @@ func (s *Screen) Bitmap(name string, bitmap []byte) {
|
|
|
func (s *Screen) Lock(flag byte, name string) {
|
|
|
cmd := bx.NewCmdLock(flag, name)
|
|
|
pack := bx.NewBxDataPackCmd(&cmd)
|
|
|
- s.send(pack.Pack())
|
|
|
+ s.Send(pack.Pack())
|
|
|
}
|
|
|
|
|
|
// DelFile 删除静态文件节目
|
|
|
func (s *Screen) DelFile(delFiles ...string) {
|
|
|
cmd := bx.NewCmdDeleteFile(delFiles)
|
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
|
- s.send(pack.Pack())
|
|
|
+ s.Send(pack.Pack())
|
|
|
s.ReadResp()
|
|
|
if len(delFiles) == 0 {
|
|
|
s.StateInfo.ProgramNum = 0
|
|
@@ -298,7 +301,7 @@ func (s *Screen) DelText(delIds []byte) {
|
|
|
cmd := bx.NewBxCmdSendDynamicArea(nil)
|
|
|
cmd.SetDelAreaIds(delIds)
|
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
|
- s.send(pack.Pack())
|
|
|
+ s.Send(pack.Pack())
|
|
|
}
|
|
|
|
|
|
func (s *Screen) TurnOnOff(onOff bool) {
|
|
@@ -307,7 +310,7 @@ func (s *Screen) TurnOnOff(onOff bool) {
|
|
|
}
|
|
|
cmd := bx.NewBxCmdTurnOnOff(onOff)
|
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
|
- s.send(pack.Pack())
|
|
|
+ s.Send(pack.Pack())
|
|
|
}
|
|
|
|
|
|
// TimingSwitch 定时开关屏
|
|
@@ -322,7 +325,7 @@ func (s *Screen) TimingSwitch(onOffSet [][2]uint64) {
|
|
|
}
|
|
|
cmd := bx.NewCmdTimingSwitch(onOffSet)
|
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
|
- s.send(pack.Pack())
|
|
|
+ s.Send(pack.Pack())
|
|
|
}
|
|
|
|
|
|
func (s *Screen) CancelTimingSwitch() {
|
|
@@ -331,7 +334,7 @@ func (s *Screen) CancelTimingSwitch() {
|
|
|
}
|
|
|
cmd := bx.NewCmdCancelTimingSwitch()
|
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
|
- s.send(pack.Pack())
|
|
|
+ s.Send(pack.Pack())
|
|
|
}
|
|
|
|
|
|
func (s *Screen) State() *bx.BxResp {
|
|
@@ -340,7 +343,7 @@ func (s *Screen) State() *bx.BxResp {
|
|
|
}
|
|
|
cmd := bx.NewCmdState()
|
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
|
- s.send(pack.Pack())
|
|
|
+ s.Send(pack.Pack())
|
|
|
r := s.ReadResp()
|
|
|
return &r
|
|
|
}
|
|
@@ -351,7 +354,7 @@ func (s *Screen) Param() *bx.BxResp {
|
|
|
}
|
|
|
cmd := bx.NewCmdReadParams()
|
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
|
- s.send(pack.Pack())
|
|
|
+ s.Send(pack.Pack())
|
|
|
r := s.ReadResp()
|
|
|
return &r
|
|
|
}
|