Spi communication with arduino zero

Hello i need some help with my communication for my screen im using à arduino zero and NHD-7.0-800480FT-CTXL-T.
Actually i created my own library but everytime i launch my program there nothing working my screen stay black and write nothing and when im using an oscilloscope on sck or mosi miso or ss there nothing just the ss stay at 5volt.
Capture d'écran 2024-08-05 093102

Im actually conected on the spi borne of the arduino zero and my cs is on 10 sck on 13 miso on 12 and mosi on 11

Demo.ino

#include <NHD7Display.h>

NHD7Display display;

void setup() {
    display.begin();
    display.writeText("Hello, World!");
    display.drawRectangle(50, 50, 200, 100, 0xFF0000); // Draw red rectangle
}

void loop() {
    // Main loop
}

NHD7Display.h

#ifndef NHD7DISPLAY_H
#define NHD7DISPLAY_H

#include <SPI.h>
#include <Arduino.h>

// Pin definitions
#define TFT_CS 9
#define TFT_PD 5
#define TFT_INT 8  // Interrupt pin (if needed)

// FT812 Commands
#define CMD_DLSTART 0xFFFFFF00
#define CMD_SWAP 0xFFFFFF01
#define CMD_TEXT 0x0FFFFFFC
#define CMD_RECT 0x0FFFFFFD

// FT812 Register Definitions
#define REG_HCYCLE 0x30202C
#define REG_HOFFSET 0x302030
#define REG_HSYNC0 0x302032
#define REG_HSYNC1 0x302034
#define REG_VCYCLE 0x302036
#define REG_VOFFSET 0x302038
#define REG_VSYNC0 0x30203A
#define REG_VSYNC1 0x30203C
#define REG_SWIZZLE 0x302064
#define REG_PCLK_POL 0x30206C
#define REG_CSPREAD 0x302068
#define REG_HSIZE 0x302014
#define REG_VSIZE 0x302018
#define REG_DLSWAP 0x302054
#define REG_PCLK 0x302070
#define RAM_DL 0x300000
#define REG_GPIO_DIR 0x302090
#define REG_GPIO 0x302094

// Additional command macros
#define CLEAR_COLOR_RGB(r, g, b) (0x02000000 | ((r) << 16) | ((g) << 8) | (b))
#define CLEAR(c, s, t) (0x26000000 | ((c) << 2) | ((s) << 1) | (t))
#define COLOR_RGB(r, g, b) (0x04000000 | ((r) << 16) | ((g) << 8) | (b))
#define VERTEX2F(x, y) ((1UL << 30) | ((x) << 15) | (y))
#define DISPLAY() 0x00000000
#define RECTS 0x09000000

class NHD7Display {
public:
    void begin();
    void writeText(const char* text);
    void drawRectangle(int x, int y, int width, int height, uint32_t color);

private:
    void sendCommand(uint32_t command);
    void sendData(uint32_t data);
    void writeRegister(uint16_t address, uint16_t value);
    void writeRegister8(uint16_t address, uint8_t value);
    uint8_t readRegister8(uint16_t address);
    void initialize();
    void configureDisplay();
};

#endif

NHD7Display.cpp

#include "NHD7Display.h"

void NHD7Display::begin() {
    Serial.begin(9600);  // Initialisation du moniteur série
    Serial.println("Initializing SPI...");

    // Initialize SPI
    SPI.begin();
    pinMode(TFT_CS, OUTPUT);
    pinMode(TFT_PD, OUTPUT);
    pinMode(TFT_INT, INPUT); // Optional, based on your hardware setup

    // Power up the display
    digitalWrite(TFT_PD, HIGH);
    delay(20); // Wait for power stabilization
    Serial.println("Power up complete.");

    // Initialize display
    initialize();
}

void NHD7Display::initialize() {
    Serial.println("Sending initialization commands...");
    // Send initialization commands to the display
    sendCommand(CMD_DLSTART);
    configureDisplay();
    sendCommand(CMD_SWAP);
    delay(300); // Wait for the display to stabilize
    Serial.println("Initialization complete.");
}

void NHD7Display::configureDisplay() {
    Serial.println("Configuring display...");
    // Set up display parameters
    writeRegister(REG_HCYCLE, 928);
    writeRegister(REG_HOFFSET, 88);
    writeRegister(REG_HSYNC0, 0);
    writeRegister(REG_HSYNC1, 48);
    writeRegister(REG_VCYCLE, 525);
    writeRegister(REG_VOFFSET, 32);
    writeRegister(REG_VSYNC0, 0);
    writeRegister(REG_VSYNC1, 3);
    writeRegister8(REG_SWIZZLE, 0);
    writeRegister8(REG_PCLK_POL, 1);
    writeRegister8(REG_CSPREAD, 1);
    writeRegister(REG_HSIZE, 800);
    writeRegister(REG_VSIZE, 480);
    // Enable backlight control
    writeRegister8(REG_GPIO_DIR, 0x80 | readRegister8(REG_GPIO_DIR));
    writeRegister8(REG_GPIO, 0x80 | readRegister8(REG_GPIO));
    // Set PCLK to start the display
    writeRegister8(REG_PCLK, 2); // Adjust this value based on your display
    Serial.println("Display configuration complete.");
}

void NHD7Display::sendCommand(uint32_t command) {
    Serial.print("Sending command: 0x");
    Serial.println(command, HEX);
    SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
    digitalWrite(TFT_CS, LOW);
    SPI.transfer(command >> 24);
    SPI.transfer(command >> 16);
    SPI.transfer(command >> 8);
    SPI.transfer(command);
    digitalWrite(TFT_CS, HIGH);
    SPI.endTransaction();
}

void NHD7Display::sendData(uint32_t data) {
    Serial.print("Sending data: 0x");
    Serial.println(data, HEX);
    SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
    digitalWrite(TFT_CS, LOW);
    SPI.transfer(data >> 24);
    SPI.transfer(data >> 16);
    SPI.transfer(data >> 8);
    SPI.transfer(data);
    digitalWrite(TFT_CS, HIGH);
    SPI.endTransaction();
}

void NHD7Display::writeRegister(uint16_t address, uint16_t value) {
    Serial.print("Writing register address: 0x");
    Serial.print(address, HEX);
    Serial.print(", value: 0x");
    Serial.println(value, HEX);
    SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
    digitalWrite(TFT_CS, LOW);
    SPI.transfer(address >> 8);
    SPI.transfer(address & 0xFF);
    SPI.transfer(value >> 8);
    SPI.transfer(value & 0xFF);
    digitalWrite(TFT_CS, HIGH);
    SPI.endTransaction();
}

void NHD7Display::writeRegister8(uint16_t address, uint8_t value) {
    Serial.print("Writing 8-bit register address: 0x");
    Serial.print(address, HEX);
    Serial.print(", value: 0x");
    Serial.println(value, HEX);
    SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
    digitalWrite(TFT_CS, LOW);
    SPI.transfer(address >> 8);
    SPI.transfer(address & 0xFF);
    SPI.transfer(value);
    digitalWrite(TFT_CS, HIGH);
    SPI.endTransaction();
}

uint8_t NHD7Display::readRegister8(uint16_t address) {
    Serial.print("Reading 8-bit register address: 0x");
    Serial.println(address, HEX);
    SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
    digitalWrite(TFT_CS, LOW);
    SPI.transfer((address >> 8) | 0x80);
    SPI.transfer(address & 0xFF);
    uint8_t value = SPI.transfer(0);
    digitalWrite(TFT_CS, HIGH);
    SPI.endTransaction();
    Serial.print("Read value: 0x");
    Serial.println(value, HEX);
    return value;
}

void NHD7Display::writeText(const char* text) {
    Serial.println("Writing text...");
    sendCommand(CMD_DLSTART);
    sendData(CLEAR_COLOR_RGB(0, 0, 0));
    sendData(CLEAR(1, 1, 1));
    sendData(COLOR_RGB(255, 255, 255));  // Set text color to white

    // Command to display text
    sendCommand(CMD_TEXT);
    sendData(100);  // X coordinate
    sendData(100);  // Y coordinate
    sendData(31);   // Font size (31 for large font)

    while (*text) {
        sendData(*text++);
    }

    sendData(DISPLAY());
    sendCommand(CMD_SWAP);
    Serial.println("Text written.");
}

void NHD7Display::drawRectangle(int x, int y, int width, int height, uint32_t color) {
    Serial.println("Drawing rectangle...");
    sendCommand(CMD_DLSTART);
    sendData(CLEAR_COLOR_RGB(0, 0, 0));
    sendData(CLEAR(1, 1, 1));
    sendData(COLOR_RGB((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF));

    sendCommand(RECTS);
    sendData(VERTEX2F(x * 16, y * 16));
    sendData(VERTEX2F((x + width) * 16, (y + height) * 16));

    sendData(DISPLAY());
    sendCommand(CMD_SWAP);
    Serial.println("Rectangle drawn.");
}