add new board to nembd, add rgb led control to r311-pv1 board

This commit is contained in:
wangzijiao 2018-12-05 17:32:10 +08:00
parent 765523be4e
commit d2c397aa21
8 changed files with 111 additions and 2 deletions

View File

@ -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()

View File

@ -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) {

View File

@ -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)

View File

@ -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) {

View File

@ -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)
}
}
}

View File

@ -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))
}
}

View File

@ -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 {

View File

@ -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)
},
}
})
}