From d2c397aa21c5fccf9a621f893ca8441c450e893b Mon Sep 17 00:00:00 2001 From: wangzijiao Date: Wed, 5 Dec 2018 17:32:10 +0800 Subject: [PATCH] add new board to nembd, add rgb led control to r311-pv1 board --- .../src/netease_control_center/main.go | 7 ++-- .../modules/controller/cronMic.go | 12 +++++++ .../modules/controller/mscCommand.go | 11 +++++++ .../modules/controller/networkControlEvent.go | 10 ++++++ .../modules/controller/task_voiceControl.go | 11 +++++++ .../netease_control_center/nembd/Init/Init.go | 33 +++++++++++++++++++ .../netease_control_center/nembd/detect.go | 7 ++++ .../nembd/host/r311_pv1c/platform.go | 22 +++++++++++++ 8 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 app/netease_control_center_common_module/src/netease_control_center/nembd/Init/Init.go create mode 100644 app/netease_control_center_common_module/src/netease_control_center/nembd/host/r311_pv1c/platform.go diff --git a/app/netease_control_center_common_module/src/netease_control_center/main.go b/app/netease_control_center_common_module/src/netease_control_center/main.go index b42e2cf..5d1c5ed 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/main.go +++ b/app/netease_control_center_common_module/src/netease_control_center/main.go @@ -8,6 +8,7 @@ import ( "netease_control_center/modules" "os" "time" + "netease_control_center/nembd/Init" ) var ( @@ -15,7 +16,7 @@ var ( BuildVersion string Tag string Hv string - ActualHv string + ActualHv string ) func main() { @@ -35,7 +36,8 @@ func main() { if Hv == "r311-pv1c" { Hv = "EVT" - globals.BuildVersion = "1.1.19" + globals.GitTag = new(string) + *globals.GitTag = "1.1.19" } log.Println(log.DebugLog, "BuildVersion: ", globals.BuildVersion) @@ -48,6 +50,7 @@ func main() { select {} } + Init.InitBoard(ActualHv) http.HttpInit() modules.Init() diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/cronMic.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/cronMic.go index b2e804a..d074e27 100644 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/cronMic.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/cronMic.go @@ -8,6 +8,7 @@ import ( "netease_control_center/modules/hardware/mcu_leds/atservice" "sync" "time" + "netease_control_center/nembd" ) var ( @@ -119,6 +120,17 @@ func SetMicClose(isMicClose bool, who globals.WhoCLoseMic, lock bool) { globals.IsMicClose = isMicClose MicLightSwitch(isMicClose, false) globals.MicCloseTrig = who + + switch nembd.Host(*globals.ActualHv) { + case nembd.HostPv1C: + if isMicClose { + nembd.DigitalWrite("G", nembd.High) + nembd.DigitalWrite("B", nembd.High) + } else { + nembd.DigitalWrite("G", nembd.Low) + nembd.DigitalWrite("B", nembd.Low) + } + } } func MicLightSwitch(on bool, lock bool) { diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/mscCommand.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/mscCommand.go index f980f48..2477ba2 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/mscCommand.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/mscCommand.go @@ -24,6 +24,7 @@ import ( "time" "netease_control_center/interfaces/cserveraddr" "netease_control_center/modules/storage" + "netease_control_center/nembd" ) const ( @@ -37,6 +38,11 @@ func MscToastLed_Before() { tmp := DirectLed{EffectId: atservice.GUIDE_EFFECT_ID_EXEC_CMD, Action: atservice.GUIDE_ACTION_START} led_mcu.DirectLedControl(tmp.EffectId, tmp.Action, tmp.StartLampNum, []byte{uint8(adau1761.MustGetVol())}) } + + switch nembd.Host(*ActualHv) { + case nembd.HostPv1C: + nembd.DigitalWrite("G", nembd.High) + } } func MscToastFinish(arg TtsPlayerArg) { //停止执行灯灯效 @@ -46,6 +52,11 @@ func MscToastFinish(arg TtsPlayerArg) { vui.IconLed_Clear.Show() //} + switch nembd.Host(*ActualHv) { + case nembd.HostPv1C: + nembd.DigitalWrite("G", nembd.Low) + } + //检查是否网络缓存播放失败 if arg.StopReason == NoticeStopReason_Error { go MscToastFile(vui.SoundNotice_Song_Get_Timeout.GetPath(), CONST_AUDIO_ID, true, false, nil) diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/networkControlEvent.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/networkControlEvent.go index d903c6d..7025bea 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/networkControlEvent.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/networkControlEvent.go @@ -5,6 +5,7 @@ import ( . "netease_control_center/globals" "netease_control_center/interfaces/log" "netease_control_center/modules/player" + "netease_control_center/nembd" ) var ( @@ -13,10 +14,19 @@ var ( func InternetConnectEvent() { log.Println(log.DebugLog, "Internet Connected Event!") + + switch nembd.Host(*ActualHv) { + case nembd.HostPv1C: + nembd.DigitalWrite("R", nembd.Low) + } } func InterneteDisconnectEvent() { log.Println(log.DebugLog, "Internet Disconnected Event!") + switch nembd.Host(*ActualHv) { + case nembd.HostPv1C: + nembd.DigitalWrite("R", nembd.High) + } } func NetworkServiceSwitch(on bool) { diff --git a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_voiceControl.go b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_voiceControl.go index 80cbb7f..66d13eb 100755 --- a/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_voiceControl.go +++ b/app/netease_control_center_common_module/src/netease_control_center/modules/controller/task_voiceControl.go @@ -22,6 +22,7 @@ import ( //"netease_control_center/modules/hardware/misc" "netease_control_center/globals" "netease_control_center/utils/customization" + "netease_control_center/nembd" ) var ( @@ -77,6 +78,11 @@ func UpdateVoiceStatus(curStatus VoiceStatuses) { // stamp := uint8(utils.Angle2LedNo2(lastWakeup.Angle, 12, 4, false)) // led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_VOICE_INPUT, atservice.GUIDE_ACTION_START, stamp, []byte{}) + switch nembd.Host(*ActualHv) { + case nembd.HostPv1C: + nembd.DigitalWrite("B", nembd.High) + } + case VoiceStatus_RECOGING: BeginRecogTime = time.Now() led_mcu.DirectLedControl(atservice.GUIDE_EFFECT_ID_THINKING, atservice.GUIDE_ACTION_START, 0, []byte{}) @@ -92,6 +98,11 @@ func UpdateVoiceStatus(curStatus VoiceStatuses) { led_mcu.DirectLedClear(atservice.GUIDE_EFFECT_ID_THINKING) led_mcu.DirectLedClear(atservice.GUIDE_EFFECT_ID_VOICE_INPUT) IconLed_Clear.Show() + + switch nembd.Host(*ActualHv) { + case nembd.HostPv1C: + nembd.DigitalWrite("B", nembd.Low) + } } } diff --git a/app/netease_control_center_common_module/src/netease_control_center/nembd/Init/Init.go b/app/netease_control_center_common_module/src/netease_control_center/nembd/Init/Init.go new file mode 100644 index 0000000..b65b171 --- /dev/null +++ b/app/netease_control_center_common_module/src/netease_control_center/nembd/Init/Init.go @@ -0,0 +1,33 @@ +package Init + +import ( + "errors" + "fmt" + "netease_control_center/nembd/host/r311_pv1c" + "netease_control_center/nembd" +) + +func InitBoard(BoardName string) error { + switch BoardName { + case nembd.HostPv1C: + r311_pv1c.Init() + nembd.SetHost(nembd.Host(BoardName), 0) + + //init gpios + nembd.SetDirection("R", nembd.Out) + nembd.SetDirection("G", nembd.Out) + nembd.SetDirection("B", nembd.Out) + + nembd.ActiveLow("R", true) + nembd.ActiveLow("G", true) + nembd.ActiveLow("B", true) + + + nembd.DigitalWrite("R", nembd.High) + nembd.DigitalWrite("G", nembd.Low) + nembd.DigitalWrite("B", nembd.Low) + return nil + default: + return errors.New(fmt.Sprintf("Unknow board name:%s\n", BoardName)) + } +} \ No newline at end of file diff --git a/app/netease_control_center_common_module/src/netease_control_center/nembd/detect.go b/app/netease_control_center_common_module/src/netease_control_center/nembd/detect.go index fb5e291..65dca6a 100644 --- a/app/netease_control_center_common_module/src/netease_control_center/nembd/detect.go +++ b/app/netease_control_center_common_module/src/netease_control_center/nembd/detect.go @@ -37,8 +37,15 @@ const ( // Host R16 Netease voice box HostIHW1 = "IHW1" + + // R311 pv1 ces board + HostPv1C = "r311-pv1c" ) +func (this Host) Equal(name string) bool { + return string(this) == name +} + func execOutput(name string, arg ...string) (output string, err error) { var out []byte if out, err = exec.Command(name, arg...).Output(); err != nil { diff --git a/app/netease_control_center_common_module/src/netease_control_center/nembd/host/r311_pv1c/platform.go b/app/netease_control_center_common_module/src/netease_control_center/nembd/host/r311_pv1c/platform.go new file mode 100644 index 0000000..7ad4236 --- /dev/null +++ b/app/netease_control_center_common_module/src/netease_control_center/nembd/host/r311_pv1c/platform.go @@ -0,0 +1,22 @@ +package r311_pv1c + +import ( + embd "netease_control_center/nembd" + "netease_control_center/nembd/host/generic" +) + +var pins = embd.PinMap{ + &embd.PinDesc{ID: "PL3", Aliases: []string{"R"}, Caps: embd.CapDigital, DigitalLogical: 355}, + &embd.PinDesc{ID: "PH5", Aliases: []string{"B"}, Caps: embd.CapDigital, DigitalLogical: 229}, + &embd.PinDesc{ID: "PL2", Aliases: []string{"G"}, Caps: embd.CapDigital, DigitalLogical: 354}, +} + +func Init() { + embd.Register(embd.HostPv1C, func(rev int) *embd.Descriptor { + return &embd.Descriptor{ + GPIODriver: func() embd.GPIODriver { + return embd.NewGPIODriver(pins, generic.NewDigitalPin, nil, nil) + }, + } + }) +}