Git Product home page Git Product logo

netbsd-lcd-clock's Introduction

NetBSD-LCD-Clock

User mode access to a Waveshare 320x480 3.5inch LCD (C) Main control is via SPI with some GPIO for reset. The LCD uses SPI address 0.

This code only uses the LCD portion of the device, the Resistive Touch panel is not accessed. I think this would be accessed by the same SPI channel using address 1.

Connections

Pi Pin Name Description =========== ========= ========================= 1, 17 3.3V 3.3V Power 2, 4 5V 5V Power 3, 5, 7, 8 NC No connection 8, 10, 12 NC No connection 13, 15, 16 NC No connection 6, 9, 14 GND Ground 20, 25 GND Ground 11 TP_IRQ Touch Panel interrupt (active low) 18 LCD_RS Instruction/Data Register selection 19 MOSI SPI data input of LCD/Touch Panel 21 MISO SPI data output of Touch Panel 22 RST Reset 23 SCLK SPI clock to LCD and Touch Panel 24 LCD_CS LCD chip select (active low) 26 TP_CS Touch Panel chip select (active low)

Enable GPIO and SPI

Add to /etc/gpio.conf

## Waveshare LCD
## =============

# P1-11 = GPIO 17
gpio0 17 set in tp_irq

# P1-18 = GPIO 24
gpio0 24 set out lcd_rs

# P1-22 = GPIO 25
gpio0 25 set out rst

# spi0_ceX are configured by spi.dtbo, do not set as outputs

# P1-24 = GPIO  8 (spi0_ce0)
#gpio0  8 set out lcd_cs

# P1-26 = GPIO  7 (spi0_ce1)
#gpio0  7 set out tp_cs

Patch /boot/config.txt

--- /boot/config.txt.orig	2023-06-14 08:27:06.239183035 +0000
+++ /boot/config.txt	2023-06-01 12:38:06.000000000 +0000
@@ -6,2 +6,3 @@
 enable_uart=1
+dtoverlay=spi.dtbo
 force_turbo=0

Install the SPI overlay

mkdir -p /boot/overlays
cp -p spi.dtbo /boot/overlays/

GPIO will be configured and SPI will be available after a reboot.

Compiling

Use the proivided Makefile. There is a test target to chjeck that the Unicode routine works and an all target to build the clock program. Currently it requires root access to be able to access SPI and GPIO.

Crontab for clock to fetch Weather

In the example below the getweather program must only return a single line of text. The extra leading spaces allow the text to scroll in from the right rather than immediately starting at the left.

# crontab

#MAILTO=root
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin

# Minute  Hour  Day-M   Month  Day-Wk    Command
11        */3   *       *      *         printf '              %s' "$(/path/to/getweather)" | nc -U /tmp/clock.sock

Running

The clock program can be run by installing the rc.d/lcd_clock to /etc/rc.d and adding the following to /etc/rc.conf:

lcd_clock=YES
#lcd_clock_flags='--rotate'

remove the # fron the flags setting if the display needs to be rotated 180 degrees. For the "C" version of the display, the top of the display is aligned with the PI GPIO pins. For the "B" version, it appears to require the rotate enabled to align the display to the GPIO at the top.

netbsd-lcd-clock's People

Contributors

hxw avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.