fix pixels staying on after render
This commit is contained in:
@@ -2,7 +2,7 @@ setup:
|
||||
cd go-rpi-rgb-led-matrix/lib/rpi-rgb-led-matrix && make
|
||||
|
||||
run:
|
||||
sudo go run cmd/rpi/main.go --led-slowdown-gpio=2
|
||||
sudo go run cmd/rpi/main.go --led-slowdown-gpio=2 --led-pwm-dither-bits=1
|
||||
|
||||
build:
|
||||
go build cmd/rpi/main.go
|
||||
|
||||
+6
-1
@@ -61,6 +61,11 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
currentPrice, err := mp.CurrentPrice()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var blockHeight int
|
||||
blockHeightMutex := &sync.Mutex{}
|
||||
var fees mempool.Fees
|
||||
@@ -72,6 +77,7 @@ func main() {
|
||||
fees.FastestFee = highfee
|
||||
fees.HalfHourFee = medfee
|
||||
fees.HourFee = lowfee
|
||||
price = currentPrice
|
||||
|
||||
go mp.Listen(ctx, msgs, errs, mdone)
|
||||
|
||||
@@ -105,7 +111,6 @@ func main() {
|
||||
return
|
||||
case <-ticker.C:
|
||||
d.Clear()
|
||||
d.Render()
|
||||
err = updateSlots(d, price, blockHeight, fees.HourFee, fees.HalfHourFee, fees.FastestFee)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
||||
@@ -27,6 +27,7 @@ func (s *Segment) Draw(canvas *rgbmatrix.Canvas, x, y int) {
|
||||
|
||||
func drawRow(canvas *rgbmatrix.Canvas, row []color.RGBA, x, y int) {
|
||||
for i := 0; i < len(row); i++ {
|
||||
canvas.Set(x+i, y, color.Black)
|
||||
canvas.Set(x+i, y, row[i])
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ func (f Font) ToColor(char string, c color.RGBA) ([][]color.RGBA, error) {
|
||||
crowColor.R = crowColor.R * pixel
|
||||
crowColor.G = crowColor.G * pixel
|
||||
crowColor.B = crowColor.B * pixel
|
||||
crowColor.A = 0xff * pixel
|
||||
crowColor.A = 0xff
|
||||
crow = append(crow, crowColor)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
@@ -134,6 +135,47 @@ func (m *mempool) CurrentFees() (int, int, int, error) {
|
||||
return data.Fastest, data.HalfHour, data.Hour, err
|
||||
}
|
||||
|
||||
func (m *mempool) CurrentPrice() (int, error) {
|
||||
req, err := http.NewRequest(http.MethodGet, "https://api.coincap.io/v2/assets/bitcoin", nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
resp, err := m.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= http.StatusInternalServerError {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var data struct {
|
||||
Data struct {
|
||||
PriceUSD string `json:"priceUsd"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
err = json.Unmarshal(b, &data)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
parts := strings.Split(data.Data.PriceUSD, ".")
|
||||
i, err := strconv.Atoi(parts[0])
|
||||
return i, err
|
||||
}
|
||||
|
||||
func (m *mempool) Listen(ctx context.Context, messages chan Message, errs chan error, done chan struct{}) {
|
||||
for {
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user