Firefly Open Source Community
Title: Golang - According to the temperature control fan speed [Print This Page]
Author: madman Time: 5/27/2015 14:16
Title: Golang - According to the temperature control fan speed
Hi,
After reading golang's tutorials on the wiki.
I feel interesting about golang.So I try to do something.
====According to the temperature control fan speed===
Here are the main codes£º
package main
import (
"fmt"
"time"
"github.com/tjCFeng/GoRK3288/RK3288"
)
func main() {
defer RK3288.FreeRK3288()
PWM1, _ := RK3288.CreatePWM(RK3288.PWM_1)
PWM1.SetInactivePolarity(RK3288.Positive)
PWM1.SetPERIOD(50000)
PWM1.SetDUTY(0)
PWM1.SetCNT(0)
PWM1.Start()
for{
time.Sleep(time.Second * 1)
_, Data, _, _ := RK3288.ITSADC().GetData()
var adc_date = RK3288.ITSADC().GetTemperature(Data)
fmt.Println("Temperature:",adc_date)
fmt.Println("Period:",50000)
if adc_date <= 40{
PWM1.Stop()
PWM1.SetPERIOD(50000)
PWM1.SetDUTY(50000)
PWM1.SetCNT(0)
PWM1.Start()
fmt.Println("Duty:",0)
}else if adc_date >= 40 || adc_date <= 60{
PWM1.Stop()
PWM1.SetPERIOD(50000)
PWM1.SetDUTY(50000-(uint32)(adc_date) * 766)
PWM1.SetCNT(0)
PWM1.Start()
fmt.Println("Duty:",(50000-(uint32)(adc_date) * 766))
}else if adc_date >= 60{
PWM1.Stop()
PWM1.SetPERIOD(50000)
PWM1.SetDUTY(0)
PWM1.SetCNT(0)
PWM1.Start()
fmt.Println("Duty:",50000)
}
}
}
Author: psycmos Time: 7/2/2015 21:17
i'm using android 4.4 KK, it's possible implement it in android ?
If yes how can we integrate it?
Thanks a lot for share your work.
Author: madman Time: 1/13/2016 17:01
Hi£¬
Android should be don't support, now support systems have Windows, Linux, MacOS X
Welcome Firefly Open Source Community (https://bbs.t-firefly.com/) |
Powered by Discuz! X3.1 |