Firefly Open Source Community

   Login   |   Register   |
New_Topic
Print Previous Topic Next Topic

Golang - According to the temperature control fan speed

82

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
82

Golang - According to the temperature control fan speed

Posted at 5/27/2015 14:16:01      View:3870 | Replies:2        Print      Only Author   [Copy Link] 1#
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)
                }
        }
}

Reply

Use props Report

450

Credits

10

Prestige

0

Contribution

intermediate

Rank: 3Rank: 3

Credits
450
Posted at 7/2/2015 21:17:23        Only Author  2#
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.
Reply

Use props Report

82

Credits

0

Prestige

0

Contribution

registered members

Rank: 2

Credits
82
Posted at 1/13/2016 17:01:55        Only Author  3#
psycmos Posted at 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?
...

Hi,
Android should be don't support, now support systems have Windows, Linux, MacOS X
Reply

Use props Report

You need to log in before you can reply Login | Register

This forum Credits Rules

Quick Reply Back to top Back to list