-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
81 lines (63 loc) · 1.77 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2020 Michal Derkacz. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"embedded/rtos"
"github.com/embeddedgo/display/eve"
"github.com/embeddedgo/stm32/dci/evedci"
"github.com/embeddedgo/stm32/hal/exti"
"github.com/embeddedgo/stm32/hal/gpio"
"github.com/embeddedgo/stm32/hal/irq"
"github.com/embeddedgo/stm32/hal/spi"
"github.com/embeddedgo/stm32/hal/spi/spi2"
"github.com/embeddedgo/display/eve/examples/evetest"
_ "github.com/embeddedgo/stm32/devboard/f4-discovery/board/system"
)
var eveInt rtos.Note
func main() {
// Allocate GPIO pins
pb := gpio.PB()
pb.EnableClock(true)
intn := pb.Pin(1)
pdn := pb.Pin(11)
csn := pb.Pin(12)
sck := pb.Pin(13)
miso := pb.Pin(14)
mosi := pb.Pin(15)
// EVE driver
evedci.UseIntPin(intn)
irq.EXTI1.Enable(rtos.IntPrioLowest, 0)
sd := spi2.Driver()
sd.UsePinMaster(csn, spi.NSS)
sd.UsePinMaster(sck, spi.SCK)
sd.UsePinMaster(mosi, spi.MOSI)
sd.UsePinMaster(miso, spi.MISO)
lcd := eve.NewDriver(evedci.NewSPI(sd, pdn), 256)
lcd.SetNote(&eveInt)
////
// Dithering causes distortion of vertical gradients on my FT811CB-HY50HD
// (horizontal darker lines appear). The effect is most visible if both
// Dither and Spread are set at the same time (default after reset).
// Reducing PCLK to 15 MHz eliminates this problem but slows down the
// display to 30 FPS.
dispCfg := &eve.Default800x480
//dispCfg.ClkMHz = 15
//dispCfg := &eve.Default480x272
checkErr(lcd.Init(dispCfg, &eve.Config{Dither: 1}))
lcd.SetBacklight(96)
evetest.Run(lcd)
}
func checkErr(err error) {
if err == nil {
return
}
println(err.Error())
for {
}
}
//go:interrupthandler
func EXTI1_Handler() {
exti.L1.ClearPending()
eveInt.Wakeup()
}