add display driver

This commit is contained in:
PoliEcho 2025-09-14 09:07:37 +02:00
parent 5e0a972b18
commit 59e838c6e6
6 changed files with 36 additions and 17 deletions

3
.gitmodules vendored
View File

@ -0,0 +1,3 @@
[submodule "Pico-GC9A01"]
path = Pico-GC9A01
url = https://github.com/dorsic/Pico-GC9A01.git

View File

@ -27,10 +27,15 @@ set(PICO_CXX_ENABLE_EXCEPTIONS 1)
# Initialise the Raspberry Pi Pico SDK
pico_sdk_init()
file(GLOB GC9A01_SOURCES
"Pico-GC9A01/GC9A01/*.c"
)
# Add executable. Default name is the project name, version 0.1
add_executable(smart_alarm smart_alarm.cpp
net_utils.cpp timezones.cpp)
net_utils.cpp timezones.cpp
display.cpp
${GC9A01_SOURCES})
pico_set_program_name(smart_alarm "smart_alarm")
pico_set_program_version(smart_alarm "0.2")
@ -46,7 +51,7 @@ target_link_libraries(smart_alarm
target_include_directories(smart_alarm PRIVATE
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts or any other standard includes, if required
${CMAKE_CURRENT_LIST_DIR}/json/include
${CMAKE_CURRENT_LIST_DIR}/Pico-GC9A01/GC9A01
)
# Add any user requested libraries

1
Pico-GC9A01 Submodule

@ -0,0 +1 @@
Subproject commit 7337ef8f51f1580cf884af2a96e2c93752431bc7

5
display.cpp Normal file
View File

@ -0,0 +1,5 @@
#include "spi.h"
#include "pico/time.h"
// GC9A01

View File

@ -1,7 +1,6 @@
#include "hardware/clocks.h"
#include "hardware/rtc.h"
#include "hardware/spi.h"
#include "hardware/timer.h"
#include "lwip/apps/sntp.h"
#include "lwip/err.h"
#include "lwip/ip_addr.h"
@ -14,22 +13,11 @@
#include <stdio.h>
#include "lwip/dns.h"
#include "lwip/init.h"
#include "lwip/tcp.h"
#include "net_utils.h"
#include "timezones.h"
#include "spi.h"
// SPI Defines
// We are going to use SPI 0, and allocate it to the following GPIO pins
// Pins can be changed, see the GPIO function select table in the datasheet for
// information on GPIO assignments
#define SPI_PORT spi0
#define PIN_MISO 16
#define PIN_CS 17
#define PIN_SCK 18
#define PIN_MOSI 19
#define PIN_DC 16
#define PIN_RST 20
#define NTP_DELTA 2208988800UL
@ -106,8 +94,8 @@ int main() {
// sign of life
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true);
// SPI initialisation. This example will use SPI at 1MHz.
spi_init(SPI_PORT, 1000 * 1000);
// SPI initialisation.
spi_init(SPI_PORT, SPI_CLOCK_HZ);
gpio_set_function(PIN_MISO, GPIO_FUNC_SPI);
gpio_set_function(PIN_CS, GPIO_FUNC_SIO);
gpio_set_function(PIN_SCK, GPIO_FUNC_SPI);

17
spi.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef SMART_ALARM_SPI_H
#define SMART_ALARM_SPI_H
// SPI Defines
// We are going to use SPI 0, and allocate it to the following GPIO pins
// Pins can be changed, see the GPIO function select table in the datasheet for
// information on GPIO assignments
#define SPI_PORT spi0
#define PIN_MISO 16
#define PIN_CS 17
#define PIN_SCK 18
#define PIN_MOSI 19
#define PIN_DC 16
#define PIN_RST 20
#define SPI_CLOCK_HZ 12000000
#endif //SMART_ALARM_SPI_H