From 96bd5e7232a3d3a0e63255ad93bf3d4e7e106771 Mon Sep 17 00:00:00 2001
From: "dawid.dymarczy" <dawid.dymarczy@etu.hesge.ch>
Date: Thu, 30 Mar 2023 02:06:28 +0200
Subject: [PATCH] remove c prog

---
 Makefile  |  29 ---
 README.md |  92 ---------
 display.c | 545 ------------------------------------------------------
 ppm.c     | 225 ----------------------
 ppm.h     |  47 -----
 5 files changed, 938 deletions(-)
 delete mode 100644 Makefile
 delete mode 100644 README.md
 delete mode 100644 display.c
 delete mode 100644 ppm.c
 delete mode 100644 ppm.h

diff --git a/Makefile b/Makefile
deleted file mode 100644
index fb08e38..0000000
--- a/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-CC:=
-CFLAGS:=-g -std=gnu11 
-LIBS:=
-
-BIN:=display
-SRCS:=$(shell find . -name "*.c")
-OBJS:=$(SRCS:.c=.o)
-DEPS:=$(OBJS:%.o=%.d)
-# Nom du programme Go
-GOBIN := imageviewer
-# Commande pour compiler le programme Go
-GOCMD := GOOS=linux GOARCH=arm GOARM=7  go build 
-
-all: $(BIN) $(GOBIN)
-
-
-$(BIN): $(OBJS)
-	arm-linux-gcc $(CFLAGS) -o $@ $^ $(LIBS)
-
-$(GOBIN):
-	$(GOCMD) -o $(GOBIN) 
-%.o: %.c
-	arm-linux-gcc -c $< -o $@ $(CFLAGS)
-
-clean:
-	rm -f $(OBJS) $(BIN) $(DEPS) $(IMG_DST) $(GOBIN)
-
-
--include $(DEPS)
diff --git a/README.md b/README.md
deleted file mode 100644
index 413d054..0000000
--- a/README.md
+++ /dev/null
@@ -1,92 +0,0 @@
-# imageviewer
-
-
-
-## Getting started
-
-To make it easy for you to get started with GitLab, here's a list of recommended next steps.
-
-Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
-
-## Add your files
-
-- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
-- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
-
-```
-cd existing_repo
-git remote add origin https://gitedu.hesge.ch/dawid.dymarczy/imageviewer.git
-git branch -M main
-git push -uf origin main
-```
-
-## Integrate with your tools
-
-- [ ] [Set up project integrations](https://gitedu.hesge.ch/dawid.dymarczy/imageviewer/-/settings/integrations)
-
-## Collaborate with your team
-
-- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
-- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
-- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
-- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
-- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
-
-## Test and Deploy
-
-Use the built-in continuous integration in GitLab.
-
-- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
-- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
-- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
-- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
-- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
-
-***
-
-# Editing this README
-
-When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
-
-## Suggestions for a good README
-Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
-
-## Name
-Choose a self-explaining name for your project.
-
-## Description
-Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
-
-## Badges
-On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
-
-## Visuals
-Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
-
-## Installation
-Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
-
-## Usage
-Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
-
-## Support
-Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
-
-## Roadmap
-If you have ideas for releases in the future, it is a good idea to list them in the README.
-
-## Contributing
-State if you are open to contributions and what your requirements are for accepting them.
-
-For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
-
-You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
-
-## Authors and acknowledgment
-Show your appreciation to those who have contributed to the project.
-
-## License
-For open source projects, say how it is licensed.
-
-## Project status
-If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
diff --git a/display.c b/display.c
deleted file mode 100644
index b6434d1..0000000
--- a/display.c
+++ /dev/null
@@ -1,545 +0,0 @@
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <linux/types.h>
-#include <linux/spi/spidev.h>
-
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <assert.h>
-#include "signal.h"
-
-#include "ppm.h"
-
-#define XRES 240
-#define YRES 320
-
-#define SPIDEVNODE "/dev/spidev1.0"
-
-#define SPI_CMD_DELAY 30
-
-// 16bpp (RGB 5:6:5) pixel format:
-// |15-11|10-05|04-00|
-// |  R  |  G  |  B  |
-
-#define COL8TO5(x) (x >> 3)
-#define COL8TO6(x) (x >> 2)
-
-#define RGB(r, g, b) ((COL8TO5(r) << 11) | (COL8TO6(g) << 5) | (COL8TO5(b)))
-
-#define GREEN RGB(0, 0, 255)
-#define GREY RGB(100, 100, 100)
-#define LIGHT_RED RGB(255, 120, 120)
-
-/*Define for GPIO */
-// Datasheet doc: "Atmel-11121-32-bit-Cortex-A5-Microcontroller-SAMA5D3_Datasheet.pdf"
-
-// Needed for mmap
-// Addresses from p.30 of datasheet
-#define SMC_BASE 0xffffc000
-#define GPIOA_BASE_ADDR 0xfffff200
-#define GPIOA_END_ADDR 0xfffff400
-
-#define PIOA_MEM_SIZE (GPIOA_END_ADDR - SMC_BASE)
-#define GPIOA_OFFSET (GPIOA_BASE_ADDR - SMC_BASE)
-
-// Addresses from p.289 of datasheet
-#define PIO_PER 0x0 // PIO Enable Register
-#define PIO_PDR 0x4 // PIO Disable Register
-#define PIO_PSR 0x8 // PIO Status Register
-
-#define PIO_OER 0x10 // Output Enable Register
-#define PIO_ODR 0x14 // Output Disable Register
-#define PIO_OSR 0x18 // Output Status Register
-
-#define PIO_SODR 0x30 // Set Output Data Register
-#define PIO_CODR 0x34 // Clear Output Data Register
-
-static void *gpio_base_addr;
-static uint32_t *pioa;
-
-static uint32_t *pio_per;
-static uint32_t *pio_pdr;
-static uint32_t *pio_psr;
-
-static uint32_t *pio_oer;
-static uint32_t *pio_odr;
-static uint32_t *pio_osr;
-
-static uint32_t *pio_sodr;
-static uint32_t *pio_codr;
-
-static int fd;
-static uint32_t pin_data_cmd = 20; // pioA20
-static uint32_t backlight = 22;    // pinA22
-
-/*End of GPIO defines*/
-int init_gpio()
-{
-    fd = open("/dev/mem", O_RDWR | O_SYNC);
-    if (fd == -1)
-    {
-        fprintf(stderr, "Failed opening /dev/mem\n");
-        return EXIT_FAILURE;
-    }
-    // Physical region [SMC_BASE, SMC_BASE+PIOA_MEM_SIZE] is mapped at virtual address gpio_base_addr.
-    gpio_base_addr = mmap(0, PIOA_MEM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, SMC_BASE);
-    if (gpio_base_addr == MAP_FAILED)
-    {
-        fprintf(stderr, "Failed memory mapping registers\n");
-        close(fd);
-        return EXIT_FAILURE;
-    }
-
-    pioa = gpio_base_addr + GPIOA_OFFSET;
-    pio_per = pioa + PIO_PER / 4;
-    pio_pdr = pioa + PIO_PDR / 4;
-    pio_psr = pioa + PIO_PSR / 4;
-    pio_oer = pioa + PIO_OER / 4;
-    pio_odr = pioa + PIO_ODR / 4;
-    pio_osr = pioa + PIO_OSR / 4;
-    pio_sodr = pioa + PIO_SODR / 4;
-    pio_codr = pioa + PIO_CODR / 4;
-
-    // Enable pin
-    *pio_per = (1 << pin_data_cmd) | (1 << backlight);
-    //*pio_per = (1 << backlight);
-
-    // Configure pin as output (enable outpout)
-    *pio_oer = (1 << pin_data_cmd) | (1 << backlight);
-    // clear De output
-    *pio_codr = (1 << pin_data_cmd) | (1 << backlight);
-
-    return EXIT_SUCCESS;
-}
-void free_gpio()
-{
-    // Write 0 to pin (clear)
-    *pio_codr |= (1 << pin_data_cmd) | (1 << backlight);
-    //*pio_codr = (1 << backlight);
-    // Disable pin
-    *pio_pdr |= (1 << pin_data_cmd) | (1 << backlight);
-    //*pio_pdr = (1 << backlight);
-
-    close(fd);
-    munmap(gpio_base_addr, PIOA_MEM_SIZE);
-}
-
-typedef struct
-{
-    int fd_spi;
-    struct spi_ioc_transfer cmd;
-} spi_display_t;
-
-static uint32_t spi_speed = 12000000;
-static uint8_t spi_bits = 8;
-static uint32_t spi_mode = 0;
-
-#define write_cmd(cmd) spi_write_cmd(disp, cmd)
-#define write_data(data) spi_write_data(disp, data, sizeof(data))
-
-/*
- * Print the global error message and abort execution.
- */
-static void pabort(const char *s)
-{
-    perror(s);
-    abort();
-}
-
-static void spi_write_cmd(spi_display_t *disp, uint8_t cmd)
-{
-    uint8_t unused[4096];
-
-    // one byte for command
-    struct spi_ioc_transfer msg = {
-        .tx_buf = (unsigned long)&cmd,
-        .rx_buf = (unsigned long)unused,
-        .len = 1,
-        .delay_usecs = SPI_CMD_DELAY,
-        .speed_hz = spi_speed,
-        .bits_per_word = spi_bits,
-    };
-
-    // Set data/cmd pin to 0
-    *pio_codr |= (1 << pin_data_cmd);
-    // ...
-
-    // SPI_IOC_MESSAGE(1) indicates we are sending 1 message (the message "cmd"),
-    // but we could send any number of messages at once
-    // More details in kernel source: include/uapi/linux/spi/spidev.h
-    if (ioctl(disp->fd_spi, SPI_IOC_MESSAGE(1), &msg) == -1)
-        pabort("Failed sending spi message");
-}
-
-static void spi_write_data(spi_display_t *disp, uint8_t const *data, size_t data_len)
-{
-    uint8_t unused[4096];
-
-    // one byte for command
-    struct spi_ioc_transfer msg = {
-        .tx_buf = (unsigned long)data,
-        .rx_buf = (unsigned long)unused,
-        .len = data_len, // maximum data length is 4096 bytes
-        .delay_usecs = SPI_CMD_DELAY,
-        .speed_hz = spi_speed,
-        .bits_per_word = spi_bits,
-    };
-
-    // Set data/cmd pin to 1
-    *pio_sodr |= (1 << pin_data_cmd);
-    // ...
-
-    // SPI_IOC_MESSAGE(1) indicates we are sending 1 message (the message "cmd"),
-    // but we could send any number of messages at once
-    // More details in kernel source: include/uapi/linux/spi/spidev.h
-    if (ioctl(disp->fd_spi, SPI_IOC_MESSAGE(1), &msg) == -1)
-        pabort("Failed sending spi message");
-}
-
-static void disp_setwindow(spi_display_t *disp, int x0, int y0, int x1, int y1)
-{
-    assert(!(x1 > XRES - 1 || y1 > YRES - 1 || x0 > x1 || y0 > y1));
-
-    int YSH = y0 >> 8;
-    int YSL = y0;
-    int YEH = y1 >> 8;
-    int YEL = y1;
-
-    // Set column (left and right zone)
-    write_cmd(0x2A);
-    {
-        uint8_t dat[] = {0x00, x0, 0x00, x1};
-        write_data(dat);
-    }
-
-    // Set page address (top and bottom lines)
-    write_cmd(0x2B);
-    {
-        uint8_t dat[] = {YSH, YSL, YEH, YEL};
-        write_data(dat);
-    }
-
-    // Memory write
-    write_cmd(0x2C);
-}
-
-void disp_setpix(spi_display_t *disp, int x, int y, uint16_t color)
-{
-    disp_setwindow(disp, x, y, x, y);
-    uint8_t m, n;
-    m = color >> 8;
-    n = color;
-    {
-        uint8_t dat[] = {m, n};
-        write_data(dat);
-    }
-}
-
-void Disp_set_pix_buffer(spi_display_t *disp, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t *buffer)
-{
-    disp_setwindow(disp, 0, 0, XRES - 1, YRES - 1);
-    // disp_setwindow(disp, x, y, x, y);
-    // Calculate the starting index of the buffer
-    uint32_t index = y * width + x;
-
-    // Calculate the ending index of the buffer
-    uint32_t end_index = (y + height - 1) * width + (x + width - 1);
-
-    // Loop through the buffer and send chunks of data using spi_write_data
-    uint8_t *data = (uint8_t *)buffer;
-    size_t data_len = width * height * 2;
-    size_t chunk_size = 2048;
-    int z = 0;
-    while (data_len > 0)
-    {
-        //  Determine the size of the next chunk to send
-        size_t send_size = data_len > chunk_size ? chunk_size : data_len;
-
-        // Send the chunk of data to the display
-        spi_write_data(disp, data, send_size);
-        // usleep(30);
-        //  Advance the buffer and decrement the remaining data length
-        data += send_size;
-        data_len -= send_size;
-    }
-}
-void disp_clear(spi_display_t *disp, uint16_t color)
-{
-    disp_setwindow(disp, 0, 0, XRES - 1, YRES - 1);
-    uint8_t *data_8bit = (uint8_t *)malloc(YRES * XRES * 2);
-    for (int i = 0; i < XRES * YRES; i++)
-    {
-        data_8bit[i * 2] = color >> 8;       // copie le MSB
-        data_8bit[i * 2 + 1] = color & 0xFF; // copie le LSB
-    }
-    Disp_set_pix_buffer(disp, 0, 0, XRES, YRES, data_8bit);
-}
-
-static void disp_init(spi_display_t *disp)
-{
-    // SPI mode
-    if (ioctl(disp->fd_spi, SPI_IOC_WR_MODE32, &spi_mode) == -1)
-        pabort("Failed setting spi mode");
-
-    // SPI bits per word
-    if (ioctl(disp->fd_spi, SPI_IOC_WR_BITS_PER_WORD, &spi_bits) == -1)
-        pabort("Failed setting spi bits per word");
-
-    // SPI max speed in hz
-    if (ioctl(disp->fd_spi, SPI_IOC_WR_MAX_SPEED_HZ, &spi_speed) == -1)
-        pabort("Failed setting spi max speed");
-
-    printf("SPI mode: 0x%x\n", spi_mode);
-    printf("SPI bits per word: %d\n", spi_bits);
-    printf("SPI max speed: %d Hz (%d KHz)\n", spi_speed, spi_speed / 1000);
-
-    // Initialization sequence for the ILI9341 display (mylab2)
-    write_cmd(0x01); // Software reset
-    usleep(50000);   // Wait 50ms
-
-    write_cmd(0x11);
-    usleep(120000); // Wait 120ms
-
-    write_cmd(0xCF);
-    {
-        uint8_t dat[] = {0x00, 0x83, 0x30};
-        write_data(dat);
-    }
-
-    write_cmd(0xED);
-    {
-        uint8_t dat[] = {0x64, 0x03, 0x12, 0x81};
-        write_data(dat);
-    }
-
-    write_cmd(0xE8);
-    {
-        uint8_t dat[] = {0x85, 0x01, 0x79};
-        write_data(dat);
-    }
-
-    write_cmd(0xCB);
-    {
-        uint8_t dat[] = {0x39, 0x2C, 0x00, 0x34, 0x02};
-        write_data(dat);
-    }
-
-    write_cmd(0xF7);
-    {
-        uint8_t dat[] = {0x20};
-        write_data(dat);
-    }
-
-    write_cmd(0xEA);
-    {
-        uint8_t dat[] = {0x00, 0x00};
-        write_data(dat);
-    }
-
-    write_cmd(0xC1); // Power control
-    {
-        uint8_t dat[] = {0x11}; // SAP[2:0];BT[3:0]
-        write_data(dat);
-    }
-
-    write_cmd(0xC5); // VCM control 1
-    {
-        uint8_t dat[] = {0x34, 0x3D};
-        write_data(dat);
-    }
-
-    write_cmd(0xC7); // VCM control 2
-    {
-        uint8_t dat[] = {0xC0};
-        write_data(dat);
-    }
-
-    write_cmd(0x36); // Memory Access Control
-    {
-        uint8_t dat[] = {0x08};
-        write_data(dat);
-    }
-
-    write_cmd(0x3A); // Pixel format
-    {
-        uint8_t dat[] = {0x55}; // 16bpp
-        write_data(dat);
-    }
-
-    write_cmd(0xB1); // Frame rate
-    {
-        uint8_t dat[] = {0x00, 0x1D}; // 65Hz
-        write_data(dat);
-    }
-
-    write_cmd(0xB6); // Display Function Control
-    {
-        uint8_t dat[] = {0x0A, 0xA2, 0x27, 0x00};
-        write_data(dat);
-    }
-
-    write_cmd(0xb7); // Entry mode
-    {
-        uint8_t dat[] = {0x07};
-        write_data(dat);
-    }
-
-    write_cmd(0xF2); // 3Gamma Function Disable
-    {
-        uint8_t dat[] = {0x08};
-        write_data(dat);
-    }
-
-    write_cmd(0x26); // Gamma curve selected
-    {
-        uint8_t dat[] = {0x01};
-        write_data(dat);
-    }
-
-    write_cmd(0xE0); // positive gamma correction
-    {
-        uint8_t dat[] = {0x1F, 0x1A, 0x18, 0x0A, 0x0F, 0x06, 0x45, 0x87, 0x32, 0x0A, 0x07, 0x02, 0x07, 0x05, 0x00};
-        write_data(dat);
-    }
-
-    write_cmd(0xE1); // negamma correction
-    {
-        uint8_t dat[] = {0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3A, 0x78, 0x4D, 0x05, 0x18, 0x0D, 0x38, 0x3A, 0x1F};
-        write_data(dat);
-    }
-
-    write_cmd(0x11); // Exit sleep
-    usleep(120000);
-
-    write_cmd(0x29); // Display on
-    usleep(50000);
-
-    // Set backlight pin to 1
-    *pio_sodr |= (1 << backlight);
-    // ...
-}
-spi_display_t disp;
-int display_image(char *filename)
-{
-    img_t *image = load_ppm(filename);
-     if (!image)
-    {
-        printf("image failed to load");
-        return 1;
-    }
-    uint16_t *data = (uint16_t *)malloc(image->height * image->width * 2);
-    uint8_t *data_8bit = (uint8_t *)malloc(image->height * image->width * 2);
-
-    for (int i = 0; i < image->height; i++)
-    {
-        for (int j = 0; j < image->width; j++)
-        {
-            pixel_t pixel = image->pix2d[i][j];
-            uint16_t color = RGB(pixel.r, pixel.g, pixel.b);
-            data[i * image->width + j] = color;
-        }
-    }
-
-    for (int i = 0; i < image->height * image->width; i++)
-    {
-        data_8bit[i * 2] = data[i] >> 8;       // copie le MSB
-        data_8bit[i * 2 + 1] = data[i] & 0xFF; // copie le LSB
-    }
-
-    Disp_set_pix_buffer(&disp, 0, 0, image->width, image->height, data_8bit);
-    free(data);
-    free(data_8bit);
-    free_img(image);
-    return 0;
-}
-// Define a signal handler function
-char filename[FILENAME_MAX];
-int end = 1;
-int display_new = 1;
-void signal_handler(int signal)
-{
-
-    if (signal == SIGUSR1)
-    {
-        // Reload the image and update the display
-        // ...
-        display_image(filename);
-        printf("SIGURS1 from apigo recepted\n");
-    }
-    else if (signal == SIGTERM)
-    {
-        end = 0;
-        // free_gpio();
-        //  Handle SIGTERM signal
-        printf("Received SIGTERM signal. Exiting gracefully...\n");
-        // Cleanup code here
-        // exit(0);
-    }
-    else if (signal == SIGINT)
-    {
-
-    }
-}
-
-
-int main(int argc, char *argv[])
-{
-    
-
-    pid_t pid = getpid();
-    char pid_str[20];
-    sprintf(pid_str, "%d", pid);
-
-    // Écriture du PID dans la variable d'environnement DISPLAY_PID
-    if (setenv("DISPLAY_PID", pid_str, 1) == -1)
-    {
-        perror("setenv");
-        return 1;
-    }
-
-    if ((disp.fd_spi = open(SPIDEVNODE, O_RDWR)) == -1)
-        pabort("Failed opening SPI device");
-
-    if (argc < 2)
-    {
-        printf("Usage: %s <filename>\n", argv[0]);
-        return 1;
-    }
-    // img_t *image = load_ppm(argv[1]);
-    strcpy(filename, argv[1]);
-    // if (!image)
-    // {
-    //     printf("image failed to load");
-    //     return 1;
-    // }
-    init_gpio();
-
-    disp_init(&disp);
-    disp_clear(&disp, GREY);
-
-    signal(SIGUSR1, signal_handler);
-    signal(SIGTERM, signal_handler);
-    signal(SIGINT, signal_handler);
-    display_image(filename);
-    uint32_t i=0;
-    while (end)
-    {
-        printf("Waiting for a new image %d",i++);
-        pause();
-    }
-    //  GPIOs shutdown
-    //  Disable output for data/cmd and backlight pins
-    //  ...
-    // getchar();
-    // Disable both pins
-    free_gpio();
-    close(disp.fd_spi);
-    return EXIT_SUCCESS;
-}
diff --git a/ppm.c b/ppm.c
deleted file mode 100644
index 63fa251..0000000
--- a/ppm.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/**
- * @file ppm.c
- * @author Florent Gluck
- * @date 4 Mar 2021
- * @brief Routines to read and write PPM files.
- *
- * Both binary (P6 type) and plain ASCII (P3 type) PPM file types are supported.
- * The PPM file format is described here: http://netpbm.sourceforge.net/doc/ppm.html
- *
- * To convert a JPG image into a binary PPM file (P6) with ImageMagick:
- * convert image.jpg output.ppm
- *
- * To convert a JPG image into a plain ASCII PPM file (P3) with ImageMagick:
- * convert -compress none image.jpg output.ppm
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "ppm.h"
-
-typedef struct {
-    enum PPM_TYPE type;
-    unsigned int width;
-    unsigned int height;
-    unsigned int maxval;
-    long data_offset;   // offset in the file of the image data (pixels)
-} ppm_header_t;
-
-static void readline(FILE *f, char *line, int max_line_length);
-static ppm_header_t *load_header(char *filename);
-
-/**
- * Allocate the memory for an image of size width*height
- * @param width the width of the image to allocate
- * @param height the height of the image to allocate
- * @return a pointer to the allocated image or NULL if the allocation failed
- */
-img_t *alloc_img(int width, int height) {
-    img_t *img = malloc(sizeof(img_t));
-
-    if (!img) return NULL;
-
-    img->width = width;
-    img->height = height;
-    img->pix1d = malloc(sizeof(pixel_t) * width * height);
-    if (!img->pix1d) {
-        free(img);
-        return NULL;
-    }
-
-    img->pix2d = malloc(sizeof(pixel_t*) * height);
-    if (!img->pix2d) {
-        free(img);
-        free(img->pix1d);
-        return NULL;
-    }
-
-    for (int i = 0; i < height; i++)
-        img->pix2d[i] = img->pix1d + width*i;
-
-    return img;
-}
-
-/**
- * Free an allocated image.
- * @param img a pointer to the image to free
- */
-void free_img(img_t *img) {
-    free(img->pix1d);
-    free(img->pix2d);
-    free(img);
-}
-
-/**
- * Write a 24-bit RGB PPM file (either ASCII P3 type or binary P6 type).
- * @param filename (absolute or relative path) of the image to write
- * @param img a pointer to the image to write
- * @param PPM_TYPE the type of the image to write (binary or ASCII)
- * @return boolean value indicating whether the write succeeded or not
- */
-bool write_ppm(char *filename, img_t *img, enum PPM_TYPE type) {
-    FILE *f = fopen(filename, "w");
-    if (!f) return false;
-
-    if (type == PPM_RAW) {
-        fprintf(f, "%s\n%d %d\n255\n", "P6", img->width, img->height);
-        // Write image content
-        for (int i = 0; i < img->width * img->height; i++) {
-            pixel_t *p = &img->pix1d[i];
-            fwrite(&p->r, sizeof(p->r), 1, f);
-            fwrite(&p->g, sizeof(p->g), 1, f);
-            fwrite(&p->b, sizeof(p->b), 1, f);
-        }
-    }
-    else {
-        fprintf(f, "%s\n%d %d\n255\n", "P3", img->width, img->height);
-        // Write image content
-        int count = 0;
-        for (int i = 0; i < img->width * img->height; i++) {
-            pixel_t *p = &img->pix1d[i];
-            fprintf(f, "%d %d %d ", p->r, p->g, p->b);
-            if (++count % 5 == 0)  // New line every 5 pixels (max 70 characters/line)
-                fprintf(f, "\n");
-        }
-    }
-
-    fclose(f);
-    return true;
-}
-
-/**
- * Load a 24-bit RGB PPM file (either ASCII P3 type or binary P6 type).
- * The routine takes care of allocating the memory for the image.
- * @param filename (absolute or relative path) of the image to load
- * @return a pointer to the loaded image or NULL if an error occured
- */
-img_t *load_ppm(char *filename) {
-    ppm_header_t *header = load_header(filename);
-    if (!header) goto error1;
-
-    // Allocate memory for image structure and image data
-    img_t *img = alloc_img(header->width, header->height);
-    if (!img) goto error1;
-
-    FILE *f = fopen(filename, "r");
-    if (f == NULL) goto error1;
-
-    fseek(f, header->data_offset, SEEK_SET);
-
-    if (header->type == PPM_ASCII) {
-        // Image data in RGB order, ASCII encoded 
-        for (unsigned int i = 0; i < header->width * header->height; i++) {
-            unsigned int r, g, b;
-            int matches = fscanf(f, "%u %u %u", &r, &g, &b);
-            if (matches != 3) goto error2;
-            if (r > header->maxval || g > header->maxval || b > header->maxval) goto error2;
-            pixel_t p = { r, g, b };
-            img->pix1d[i] = p;
-        }
-    }
-    else {
-        // Image data in RGB order, binary encoded 
-        for (unsigned int i = 0; i < header->width * header->height; i++) {
-            fread(&img->pix1d[i].r, 1, 1, f);
-            fread(&img->pix1d[i].g, 1, 1, f);
-            fread(&img->pix1d[i].b, 1, 1, f);
-        }
-    }
-
-    free(header);
-    fclose(f);
-    return img;
-
-error2:
-    fclose(f);
-
-error1:
-    free(header);
-    return NULL;
-}
-
-// ====================================================================================================
-// Private functions
-// ====================================================================================================
-
-// Read a line (reads up to max_line_length chars) while skipping comments (lines starting with '#').
-static void readline(FILE *f, char *line, int max_line_length) {
-    static int line_nb = 0;
-    while (1) {
-        line_nb++;
-        char fmt[16];
-        sprintf(fmt, "%%%d[^\n]", max_line_length);
-        fscanf(f, fmt, line);
-        fscanf(f, "\n");
-        if (line[0] != '#') break;
-    }
-}
-
-// Parse a PPM header.
-static ppm_header_t *load_header(char *filename) {
-    FILE *f = fopen(filename, "r");
-    if (f == NULL) return NULL;
-
-    ppm_header_t *header = calloc(1, sizeof(ppm_header_t));
-
-    const int MAX_LENGTH = 1024;
-    char line[MAX_LENGTH+1];
-
-    // PPM file type: either P3 or P6
-    readline(f, line, MAX_LENGTH);
-    if (strcmp("P3", line) == 0) {
-        header->type = PPM_ASCII;
-    }
-    else if (strcmp("P6", line) == 0) {
-        header->type = PPM_RAW;
-    }
-    else {
-        fprintf(stderr, "PPM reader: unsupported format!\n");
-        goto error;
-    }
-
-    // Image width and height
-    readline(f, line, MAX_LENGTH);
-    int matches = sscanf(line, "%u %u", &header->width, &header->height);
-    if (matches != 2) goto error;
-
-    // Maximum value per component
-    readline(f, line, MAX_LENGTH);
-    matches = sscanf(line, "%u ", &header->maxval);
-    if (matches != 1) goto error;
-    if (header->maxval > 255) {
-        fprintf(stderr, "PPM reader: doesn't support more than 1 byte per component!\n");
-        goto error;
-    }
-
-    header->data_offset = ftell(f);
-    fclose(f);
-    return header;
-
-error:
-    free(header);
-    fclose(f);
-    return NULL;
-}
diff --git a/ppm.h b/ppm.h
deleted file mode 100644
index 7d10c2e..0000000
--- a/ppm.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * @file ppm.h
- * @author Florent Gluck
- * @date 4 Mar 2021
- * @brief Routines to read and write PPM files.
- */
-
-#include <stdint.h>
-#include <stdbool.h>
-
-/**
- * Store a 24-bit pixel (8-bit per component).
- * @param r the red component
- * @param g the green component
- * @param b the blue component
- */
-typedef struct pixel_st {
-    uint8_t r, g, b;
-} pixel_t;
-
-/**
- * Structure holding a 24-bit per pixel image.
- * @param width the width of the image
- * @param height the height of the image
- * @param pix1d accessor to the image pixel data as a 1D array
- * @param pix2d accessor to the image pixel data as a 2D array [height][width]
- */
-typedef struct img_st {
-    int width;
-    int height;
-    pixel_t *pix1d;
-    pixel_t **pix2d;
-} img_t;
-
-/**
- * Supported PPM types, either RAW or ASCII.
- */
-enum PPM_TYPE {
-    PPM_RAW,
-    PPM_ASCII
-};
-
-extern img_t *alloc_img(int width, int height);
-extern void free_img(img_t *img);
-extern img_t *load_ppm(char *filename);
-extern bool write_ppm(char *filename, img_t *img, enum PPM_TYPE);
-
-- 
GitLab